mutation.go 1.8 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998479994800048001480024800348004480054800648007480084800948010480114801248013480144801548016480174801848019480204802148022480234802448025480264802748028480294803048031480324803348034480354803648037480384803948040480414804248043480444804548046480474804848049480504805148052480534805448055480564805748058480594806048061480624806348064480654806648067480684806948070480714807248073480744807548076480774807848079480804808148082480834808448085480864808748088480894809048091480924809348094480954809648097480984809948100481014810248103481044810548106481074810848109481104811148112481134811448115481164811748118481194812048121481224812348124481254812648127481284812948130481314813248133481344813548136481374813848139481404814148142481434814448145481464814748148481494815048151481524815348154481554815648157481584815948160481614816248163481644816548166481674816848169481704817148172481734817448175481764817748178481794818048181481824818348184481854818648187481884818948190481914819248193481944819548196481974819848199482004820148202482034820448205482064820748208482094821048211482124821348214482154821648217482184821948220482214822248223482244822548226482274822848229482304823148232482334823448235482364823748238482394824048241482424824348244482454824648247482484824948250482514825248253482544825548256482574825848259482604826148262482634826448265482664826748268482694827048271482724827348274482754827648277482784827948280482814828248283482844828548286482874828848289482904829148292482934829448295482964829748298482994830048301483024830348304483054830648307483084830948310483114831248313483144831548316483174831848319483204832148322483234832448325483264832748328483294833048331483324833348334483354833648337483384833948340483414834248343483444834548346483474834848349483504835148352483534835448355483564835748358483594836048361483624836348364483654836648367483684836948370483714837248373483744837548376483774837848379483804838148382483834838448385483864838748388483894839048391483924839348394483954839648397483984839948400484014840248403484044840548406484074840848409484104841148412484134841448415484164841748418484194842048421484224842348424484254842648427484284842948430484314843248433484344843548436484374843848439484404844148442484434844448445484464844748448484494845048451484524845348454484554845648457484584845948460484614846248463484644846548466484674846848469484704847148472484734847448475484764847748478484794848048481484824848348484484854848648487484884848948490484914849248493484944849548496484974849848499485004850148502485034850448505485064850748508485094851048511485124851348514485154851648517485184851948520485214852248523485244852548526485274852848529485304853148532485334853448535485364853748538485394854048541485424854348544485454854648547485484854948550485514855248553485544855548556485574855848559485604856148562485634856448565485664856748568485694857048571485724857348574485754857648577485784857948580485814858248583485844858548586485874858848589485904859148592485934859448595485964859748598485994860048601486024860348604486054860648607486084860948610486114861248613486144861548616486174861848619486204862148622486234862448625486264862748628486294863048631486324863348634486354863648637486384863948640486414864248643486444864548646486474864848649486504865148652486534865448655486564865748658486594866048661486624866348664486654866648667486684866948670486714867248673486744867548676486774867848679486804868148682486834868448685486864868748688486894869048691486924869348694486954869648697486984869948700487014870248703487044870548706487074870848709487104871148712487134871448715487164871748718487194872048721487224872348724487254872648727487284872948730487314873248733487344873548736487374873848739487404874148742487434874448745487464874748748487494875048751487524875348754487554875648757487584875948760487614876248763487644876548766487674876848769487704877148772487734877448775487764877748778487794878048781487824878348784487854878648787487884878948790487914879248793487944879548796487974879848799488004880148802488034880448805488064880748808488094881048811488124881348814488154881648817488184881948820488214882248823488244882548826488274882848829488304883148832488334883448835488364883748838488394884048841488424884348844488454884648847488484884948850488514885248853488544885548856488574885848859488604886148862488634886448865488664886748868488694887048871488724887348874488754887648877488784887948880488814888248883488844888548886488874888848889488904889148892488934889448895488964889748898488994890048901489024890348904489054890648907489084890948910489114891248913489144891548916489174891848919489204892148922489234892448925489264892748928489294893048931489324893348934489354893648937489384893948940489414894248943489444894548946489474894848949489504895148952489534895448955489564895748958489594896048961489624896348964489654896648967489684896948970489714897248973489744897548976489774897848979489804898148982489834898448985489864898748988489894899048991489924899348994489954899648997489984899949000490014900249003490044900549006490074900849009490104901149012490134901449015490164901749018490194902049021490224902349024490254902649027490284902949030490314903249033490344903549036490374903849039490404904149042490434904449045490464904749048490494905049051490524905349054490554905649057490584905949060490614906249063490644906549066490674906849069490704907149072490734907449075490764907749078490794908049081490824908349084490854908649087490884908949090490914909249093490944909549096490974909849099491004910149102491034910449105491064910749108491094911049111491124911349114491154911649117491184911949120491214912249123491244912549126491274912849129491304913149132491334913449135491364913749138491394914049141491424914349144491454914649147491484914949150491514915249153491544915549156491574915849159491604916149162491634916449165491664916749168491694917049171491724917349174491754917649177491784917949180491814918249183491844918549186491874918849189491904919149192491934919449195491964919749198491994920049201492024920349204492054920649207492084920949210492114921249213492144921549216492174921849219492204922149222492234922449225492264922749228492294923049231492324923349234492354923649237492384923949240492414924249243492444924549246492474924849249492504925149252492534925449255492564925749258492594926049261492624926349264492654926649267492684926949270492714927249273492744927549276492774927849279492804928149282492834928449285492864928749288492894929049291492924929349294492954929649297492984929949300493014930249303493044930549306493074930849309493104931149312493134931449315493164931749318493194932049321493224932349324493254932649327493284932949330493314933249333493344933549336493374933849339493404934149342493434934449345493464934749348493494935049351493524935349354493554935649357493584935949360493614936249363493644936549366493674936849369493704937149372493734937449375493764937749378493794938049381493824938349384493854938649387493884938949390493914939249393493944939549396493974939849399494004940149402494034940449405494064940749408494094941049411494124941349414494154941649417494184941949420494214942249423494244942549426494274942849429494304943149432494334943449435494364943749438494394944049441494424944349444494454944649447494484944949450494514945249453494544945549456494574945849459494604946149462494634946449465494664946749468494694947049471494724947349474494754947649477494784947949480494814948249483494844948549486494874948849489494904949149492494934949449495494964949749498494994950049501495024950349504495054950649507495084950949510495114951249513495144951549516495174951849519495204952149522495234952449525495264952749528495294953049531495324953349534495354953649537495384953949540495414954249543495444954549546495474954849549495504955149552495534955449555495564955749558495594956049561495624956349564495654956649567495684956949570495714957249573495744957549576495774957849579495804958149582495834958449585495864958749588495894959049591495924959349594495954959649597495984959949600496014960249603496044960549606496074960849609496104961149612496134961449615496164961749618496194962049621496224962349624496254962649627496284962949630496314963249633496344963549636496374963849639496404964149642496434964449645496464964749648496494965049651496524965349654496554965649657496584965949660496614966249663496644966549666496674966849669496704967149672496734967449675496764967749678496794968049681496824968349684496854968649687496884968949690496914969249693496944969549696496974969849699497004970149702497034970449705497064970749708497094971049711497124971349714497154971649717497184971949720497214972249723497244972549726497274972849729497304973149732497334973449735497364973749738497394974049741497424974349744497454974649747497484974949750497514975249753497544975549756497574975849759497604976149762497634976449765497664976749768497694977049771497724977349774497754977649777497784977949780497814978249783497844978549786497874978849789497904979149792497934979449795497964979749798497994980049801498024980349804498054980649807498084980949810498114981249813498144981549816498174981849819498204982149822498234982449825498264982749828498294983049831498324983349834498354983649837498384983949840498414984249843498444984549846498474984849849498504985149852498534985449855498564985749858498594986049861498624986349864498654986649867498684986949870498714987249873498744987549876498774987849879498804988149882498834988449885498864988749888498894989049891498924989349894498954989649897498984989949900499014990249903499044990549906499074990849909499104991149912499134991449915499164991749918499194992049921499224992349924499254992649927499284992949930499314993249933499344993549936499374993849939499404994149942499434994449945499464994749948499494995049951499524995349954499554995649957499584995949960499614996249963499644996549966499674996849969499704997149972499734997449975499764997749978499794998049981499824998349984499854998649987499884998949990499914999249993499944999549996499974999849999500005000150002500035000450005500065000750008500095001050011500125001350014500155001650017500185001950020500215002250023500245002550026500275002850029500305003150032500335003450035500365003750038500395004050041500425004350044500455004650047500485004950050500515005250053500545005550056500575005850059500605006150062500635006450065500665006750068500695007050071500725007350074500755007650077500785007950080500815008250083500845008550086500875008850089500905009150092500935009450095500965009750098500995010050101501025010350104501055010650107501085010950110501115011250113501145011550116501175011850119501205012150122501235012450125501265012750128501295013050131501325013350134501355013650137501385013950140501415014250143501445014550146501475014850149501505015150152501535015450155501565015750158501595016050161501625016350164501655016650167501685016950170501715017250173501745017550176501775017850179501805018150182501835018450185501865018750188501895019050191501925019350194501955019650197501985019950200502015020250203502045020550206502075020850209502105021150212502135021450215502165021750218502195022050221502225022350224502255022650227502285022950230502315023250233502345023550236502375023850239502405024150242502435024450245502465024750248502495025050251502525025350254502555025650257502585025950260502615026250263502645026550266502675026850269502705027150272502735027450275502765027750278502795028050281502825028350284502855028650287502885028950290502915029250293502945029550296502975029850299503005030150302503035030450305503065030750308503095031050311503125031350314503155031650317503185031950320503215032250323503245032550326503275032850329503305033150332503335033450335503365033750338503395034050341503425034350344503455034650347503485034950350503515035250353503545035550356503575035850359503605036150362503635036450365503665036750368503695037050371503725037350374503755037650377503785037950380503815038250383503845038550386503875038850389503905039150392503935039450395503965039750398503995040050401504025040350404504055040650407504085040950410504115041250413504145041550416504175041850419504205042150422504235042450425504265042750428504295043050431504325043350434504355043650437504385043950440504415044250443504445044550446504475044850449504505045150452504535045450455504565045750458504595046050461504625046350464504655046650467504685046950470504715047250473504745047550476504775047850479504805048150482504835048450485504865048750488504895049050491504925049350494504955049650497504985049950500505015050250503505045050550506505075050850509505105051150512505135051450515505165051750518505195052050521505225052350524505255052650527505285052950530505315053250533505345053550536505375053850539505405054150542505435054450545505465054750548505495055050551505525055350554505555055650557505585055950560505615056250563505645056550566505675056850569505705057150572505735057450575505765057750578505795058050581505825058350584505855058650587505885058950590505915059250593505945059550596505975059850599506005060150602506035060450605506065060750608506095061050611506125061350614506155061650617506185061950620506215062250623506245062550626506275062850629506305063150632506335063450635506365063750638506395064050641506425064350644506455064650647506485064950650506515065250653506545065550656506575065850659506605066150662506635066450665506665066750668506695067050671506725067350674506755067650677506785067950680506815068250683506845068550686506875068850689506905069150692506935069450695506965069750698506995070050701507025070350704507055070650707507085070950710507115071250713507145071550716507175071850719507205072150722507235072450725507265072750728507295073050731507325073350734507355073650737507385073950740507415074250743507445074550746507475074850749507505075150752507535075450755507565075750758507595076050761507625076350764507655076650767507685076950770507715077250773507745077550776507775077850779507805078150782507835078450785507865078750788507895079050791507925079350794507955079650797507985079950800508015080250803508045080550806508075080850809508105081150812508135081450815508165081750818508195082050821508225082350824508255082650827508285082950830508315083250833508345083550836508375083850839508405084150842508435084450845508465084750848508495085050851508525085350854508555085650857508585085950860508615086250863508645086550866508675086850869508705087150872508735087450875508765087750878508795088050881508825088350884508855088650887508885088950890508915089250893508945089550896508975089850899509005090150902509035090450905509065090750908509095091050911509125091350914509155091650917509185091950920509215092250923509245092550926509275092850929509305093150932509335093450935509365093750938509395094050941509425094350944509455094650947509485094950950509515095250953509545095550956509575095850959509605096150962509635096450965509665096750968509695097050971509725097350974509755097650977509785097950980509815098250983509845098550986509875098850989509905099150992509935099450995509965099750998509995100051001510025100351004510055100651007510085100951010510115101251013510145101551016510175101851019510205102151022510235102451025510265102751028510295103051031510325103351034510355103651037510385103951040510415104251043510445104551046510475104851049510505105151052510535105451055510565105751058510595106051061510625106351064510655106651067510685106951070510715107251073510745107551076510775107851079510805108151082510835108451085510865108751088510895109051091510925109351094510955109651097510985109951100511015110251103511045110551106511075110851109511105111151112511135111451115511165111751118511195112051121511225112351124511255112651127511285112951130511315113251133511345113551136511375113851139511405114151142511435114451145511465114751148511495115051151511525115351154511555115651157511585115951160511615116251163511645116551166511675116851169511705117151172511735117451175511765117751178511795118051181511825118351184511855118651187511885118951190511915119251193511945119551196511975119851199512005120151202512035120451205512065120751208512095121051211512125121351214512155121651217512185121951220512215122251223512245122551226512275122851229512305123151232512335123451235512365123751238512395124051241512425124351244512455124651247512485124951250512515125251253512545125551256512575125851259512605126151262512635126451265512665126751268512695127051271512725127351274512755127651277512785127951280512815128251283512845128551286512875128851289512905129151292512935129451295512965129751298512995130051301513025130351304513055130651307513085130951310513115131251313513145131551316513175131851319513205132151322513235132451325513265132751328513295133051331513325133351334513355133651337513385133951340513415134251343513445134551346513475134851349513505135151352513535135451355513565135751358513595136051361513625136351364513655136651367513685136951370513715137251373513745137551376513775137851379513805138151382513835138451385513865138751388513895139051391513925139351394513955139651397513985139951400514015140251403514045140551406514075140851409514105141151412514135141451415514165141751418514195142051421514225142351424514255142651427514285142951430514315143251433514345143551436514375143851439514405144151442514435144451445514465144751448514495145051451514525145351454514555145651457514585145951460514615146251463514645146551466514675146851469514705147151472514735147451475514765147751478514795148051481514825148351484514855148651487514885148951490514915149251493514945149551496514975149851499515005150151502515035150451505515065150751508515095151051511515125151351514515155151651517515185151951520515215152251523515245152551526515275152851529515305153151532515335153451535515365153751538515395154051541515425154351544515455154651547515485154951550515515155251553515545155551556515575155851559515605156151562515635156451565515665156751568515695157051571515725157351574515755157651577515785157951580515815158251583515845158551586515875158851589515905159151592515935159451595515965159751598515995160051601516025160351604516055160651607516085160951610516115161251613516145161551616516175161851619516205162151622516235162451625516265162751628516295163051631516325163351634516355163651637516385163951640516415164251643516445164551646516475164851649516505165151652516535165451655516565165751658516595166051661516625166351664516655166651667516685166951670516715167251673516745167551676516775167851679516805168151682516835168451685516865168751688516895169051691516925169351694516955169651697516985169951700517015170251703517045170551706517075170851709517105171151712517135171451715517165171751718517195172051721517225172351724517255172651727517285172951730517315173251733517345173551736517375173851739517405174151742517435174451745517465174751748517495175051751517525175351754517555175651757517585175951760517615176251763517645176551766517675176851769517705177151772517735177451775517765177751778517795178051781517825178351784517855178651787517885178951790517915179251793517945179551796517975179851799518005180151802518035180451805518065180751808518095181051811518125181351814518155181651817518185181951820518215182251823518245182551826518275182851829518305183151832518335183451835518365183751838518395184051841518425184351844518455184651847518485184951850518515185251853518545185551856518575185851859518605186151862518635186451865518665186751868518695187051871518725187351874518755187651877518785187951880518815188251883518845188551886518875188851889518905189151892518935189451895518965189751898518995190051901519025190351904519055190651907519085190951910519115191251913519145191551916519175191851919519205192151922519235192451925519265192751928519295193051931519325193351934519355193651937519385193951940519415194251943519445194551946519475194851949519505195151952519535195451955519565195751958519595196051961519625196351964519655196651967519685196951970519715197251973519745197551976519775197851979519805198151982519835198451985519865198751988519895199051991519925199351994519955199651997519985199952000520015200252003520045200552006520075200852009520105201152012520135201452015520165201752018520195202052021520225202352024520255202652027520285202952030520315203252033520345203552036520375203852039520405204152042520435204452045520465204752048520495205052051520525205352054520555205652057520585205952060520615206252063520645206552066520675206852069520705207152072520735207452075520765207752078520795208052081520825208352084520855208652087520885208952090520915209252093520945209552096520975209852099521005210152102521035210452105521065210752108521095211052111521125211352114521155211652117521185211952120521215212252123521245212552126521275212852129521305213152132521335213452135521365213752138521395214052141521425214352144521455214652147521485214952150521515215252153521545215552156521575215852159521605216152162521635216452165521665216752168521695217052171521725217352174521755217652177521785217952180521815218252183521845218552186521875218852189521905219152192521935219452195521965219752198521995220052201522025220352204522055220652207522085220952210522115221252213522145221552216522175221852219522205222152222522235222452225522265222752228522295223052231522325223352234522355223652237522385223952240522415224252243522445224552246522475224852249522505225152252522535225452255522565225752258522595226052261522625226352264522655226652267522685226952270522715227252273522745227552276522775227852279522805228152282522835228452285522865228752288522895229052291522925229352294522955229652297522985229952300523015230252303523045230552306523075230852309523105231152312523135231452315523165231752318523195232052321523225232352324523255232652327523285232952330523315233252333523345233552336523375233852339523405234152342523435234452345523465234752348523495235052351523525235352354523555235652357523585235952360523615236252363523645236552366523675236852369523705237152372523735237452375523765237752378523795238052381523825238352384523855238652387523885238952390523915239252393523945239552396523975239852399524005240152402524035240452405524065240752408524095241052411524125241352414524155241652417524185241952420524215242252423524245242552426524275242852429524305243152432524335243452435524365243752438524395244052441524425244352444524455244652447524485244952450524515245252453524545245552456524575245852459524605246152462524635246452465524665246752468524695247052471524725247352474524755247652477524785247952480524815248252483524845248552486524875248852489524905249152492524935249452495524965249752498524995250052501525025250352504525055250652507525085250952510525115251252513525145251552516525175251852519525205252152522525235252452525525265252752528525295253052531525325253352534525355253652537525385253952540525415254252543525445254552546525475254852549525505255152552525535255452555525565255752558525595256052561525625256352564525655256652567525685256952570525715257252573525745257552576525775257852579525805258152582525835258452585525865258752588525895259052591525925259352594525955259652597525985259952600526015260252603526045260552606526075260852609526105261152612526135261452615526165261752618526195262052621526225262352624526255262652627526285262952630526315263252633526345263552636526375263852639526405264152642526435264452645526465264752648526495265052651526525265352654526555265652657526585265952660526615266252663526645266552666526675266852669526705267152672526735267452675526765267752678526795268052681526825268352684526855268652687526885268952690526915269252693526945269552696526975269852699527005270152702527035270452705527065270752708527095271052711527125271352714527155271652717527185271952720527215272252723527245272552726527275272852729527305273152732527335273452735527365273752738527395274052741527425274352744527455274652747527485274952750527515275252753527545275552756527575275852759527605276152762527635276452765527665276752768527695277052771527725277352774527755277652777527785277952780527815278252783527845278552786527875278852789527905279152792527935279452795527965279752798527995280052801528025280352804528055280652807528085280952810528115281252813528145281552816528175281852819528205282152822528235282452825528265282752828528295283052831528325283352834528355283652837528385283952840528415284252843528445284552846528475284852849528505285152852528535285452855528565285752858528595286052861528625286352864528655286652867528685286952870528715287252873528745287552876528775287852879528805288152882528835288452885528865288752888528895289052891528925289352894528955289652897528985289952900529015290252903529045290552906529075290852909529105291152912529135291452915529165291752918529195292052921529225292352924529255292652927529285292952930529315293252933529345293552936529375293852939529405294152942529435294452945529465294752948529495295052951529525295352954529555295652957529585295952960529615296252963529645296552966529675296852969529705297152972529735297452975529765297752978529795298052981529825298352984529855298652987529885298952990529915299252993529945299552996529975299852999530005300153002530035300453005530065300753008530095301053011530125301353014530155301653017530185301953020530215302253023530245302553026530275302853029530305303153032530335303453035530365303753038530395304053041530425304353044530455304653047530485304953050530515305253053530545305553056530575305853059530605306153062530635306453065530665306753068530695307053071530725307353074530755307653077530785307953080530815308253083530845308553086530875308853089530905309153092530935309453095530965309753098530995310053101531025310353104531055310653107531085310953110531115311253113531145311553116531175311853119531205312153122531235312453125531265312753128531295313053131531325313353134531355313653137531385313953140531415314253143531445314553146531475314853149531505315153152531535315453155531565315753158531595316053161531625316353164531655316653167531685316953170531715317253173531745317553176531775317853179531805318153182531835318453185531865318753188531895319053191531925319353194531955319653197531985319953200532015320253203532045320553206532075320853209532105321153212532135321453215532165321753218532195322053221532225322353224532255322653227532285322953230532315323253233532345323553236532375323853239532405324153242532435324453245532465324753248532495325053251532525325353254532555325653257532585325953260532615326253263532645326553266532675326853269532705327153272532735327453275532765327753278532795328053281532825328353284532855328653287532885328953290532915329253293532945329553296532975329853299533005330153302533035330453305533065330753308533095331053311533125331353314533155331653317533185331953320533215332253323533245332553326533275332853329533305333153332533335333453335533365333753338533395334053341533425334353344533455334653347533485334953350533515335253353533545335553356533575335853359533605336153362533635336453365533665336753368533695337053371533725337353374533755337653377533785337953380533815338253383533845338553386533875338853389533905339153392533935339453395533965339753398533995340053401534025340353404534055340653407534085340953410534115341253413534145341553416534175341853419534205342153422534235342453425534265342753428534295343053431534325343353434534355343653437534385343953440534415344253443534445344553446534475344853449534505345153452534535345453455534565345753458534595346053461534625346353464534655346653467534685346953470534715347253473534745347553476534775347853479534805348153482534835348453485534865348753488534895349053491534925349353494534955349653497534985349953500535015350253503535045350553506535075350853509535105351153512535135351453515535165351753518535195352053521535225352353524535255352653527535285352953530535315353253533535345353553536535375353853539535405354153542535435354453545535465354753548535495355053551535525355353554535555355653557535585355953560535615356253563535645356553566535675356853569535705357153572535735357453575535765357753578535795358053581535825358353584535855358653587535885358953590535915359253593535945359553596535975359853599536005360153602536035360453605536065360753608536095361053611536125361353614536155361653617536185361953620536215362253623536245362553626536275362853629536305363153632536335363453635536365363753638536395364053641536425364353644536455364653647536485364953650536515365253653536545365553656536575365853659536605366153662536635366453665536665366753668536695367053671536725367353674536755367653677536785367953680536815368253683536845368553686536875368853689536905369153692536935369453695536965369753698536995370053701537025370353704537055370653707537085370953710537115371253713537145371553716537175371853719537205372153722537235372453725537265372753728537295373053731537325373353734537355373653737537385373953740537415374253743537445374553746537475374853749537505375153752537535375453755537565375753758537595376053761537625376353764537655376653767537685376953770537715377253773537745377553776537775377853779537805378153782537835378453785537865378753788537895379053791537925379353794537955379653797537985379953800538015380253803538045380553806538075380853809538105381153812538135381453815538165381753818538195382053821538225382353824538255382653827538285382953830538315383253833538345383553836538375383853839538405384153842538435384453845538465384753848538495385053851538525385353854538555385653857538585385953860538615386253863538645386553866538675386853869538705387153872538735387453875538765387753878538795388053881538825388353884538855388653887538885388953890538915389253893538945389553896538975389853899539005390153902539035390453905539065390753908539095391053911539125391353914539155391653917539185391953920539215392253923539245392553926539275392853929539305393153932539335393453935539365393753938539395394053941539425394353944539455394653947539485394953950539515395253953539545395553956539575395853959539605396153962539635396453965539665396753968539695397053971539725397353974539755397653977539785397953980539815398253983539845398553986539875398853989539905399153992539935399453995539965399753998539995400054001540025400354004540055400654007540085400954010540115401254013540145401554016540175401854019540205402154022540235402454025540265402754028540295403054031540325403354034540355403654037540385403954040540415404254043540445404554046540475404854049540505405154052540535405454055540565405754058540595406054061540625406354064540655406654067540685406954070540715407254073540745407554076540775407854079540805408154082540835408454085540865408754088540895409054091540925409354094540955409654097540985409954100541015410254103541045410554106541075410854109541105411154112541135411454115541165411754118541195412054121541225412354124541255412654127541285412954130541315413254133541345413554136541375413854139541405414154142541435414454145541465414754148541495415054151541525415354154541555415654157541585415954160541615416254163541645416554166541675416854169541705417154172541735417454175541765417754178541795418054181541825418354184541855418654187541885418954190541915419254193541945419554196541975419854199542005420154202542035420454205542065420754208542095421054211542125421354214542155421654217542185421954220542215422254223542245422554226542275422854229542305423154232542335423454235542365423754238542395424054241542425424354244542455424654247542485424954250542515425254253542545425554256542575425854259542605426154262542635426454265542665426754268542695427054271542725427354274542755427654277542785427954280542815428254283542845428554286542875428854289542905429154292542935429454295542965429754298542995430054301543025430354304543055430654307543085430954310543115431254313543145431554316543175431854319543205432154322543235432454325543265432754328543295433054331543325433354334543355433654337543385433954340543415434254343543445434554346543475434854349543505435154352543535435454355543565435754358543595436054361543625436354364543655436654367543685436954370543715437254373543745437554376543775437854379543805438154382543835438454385543865438754388543895439054391543925439354394543955439654397543985439954400544015440254403544045440554406544075440854409544105441154412544135441454415544165441754418544195442054421544225442354424544255442654427544285442954430544315443254433544345443554436544375443854439544405444154442544435444454445544465444754448544495445054451544525445354454544555445654457544585445954460544615446254463544645446554466544675446854469544705447154472544735447454475544765447754478544795448054481544825448354484544855448654487544885448954490544915449254493544945449554496544975449854499545005450154502545035450454505545065450754508545095451054511545125451354514545155451654517545185451954520545215452254523545245452554526545275452854529545305453154532545335453454535545365453754538545395454054541545425454354544545455454654547545485454954550545515455254553545545455554556545575455854559545605456154562545635456454565545665456754568545695457054571545725457354574545755457654577545785457954580545815458254583545845458554586545875458854589545905459154592545935459454595545965459754598545995460054601546025460354604546055460654607546085460954610546115461254613546145461554616546175461854619546205462154622546235462454625546265462754628546295463054631546325463354634546355463654637546385463954640546415464254643546445464554646546475464854649546505465154652546535465454655546565465754658546595466054661546625466354664546655466654667546685466954670546715467254673546745467554676546775467854679546805468154682546835468454685546865468754688546895469054691546925469354694546955469654697546985469954700547015470254703547045470554706547075470854709547105471154712547135471454715547165471754718547195472054721547225472354724547255472654727547285472954730547315473254733547345473554736547375473854739547405474154742547435474454745547465474754748547495475054751547525475354754547555475654757547585475954760547615476254763547645476554766547675476854769547705477154772547735477454775547765477754778547795478054781547825478354784547855478654787547885478954790547915479254793547945479554796547975479854799548005480154802548035480454805548065480754808548095481054811548125481354814548155481654817548185481954820548215482254823548245482554826548275482854829548305483154832548335483454835548365483754838548395484054841548425484354844548455484654847548485484954850548515485254853548545485554856548575485854859548605486154862548635486454865548665486754868548695487054871548725487354874548755487654877548785487954880548815488254883548845488554886548875488854889548905489154892548935489454895548965489754898548995490054901549025490354904549055490654907549085490954910549115491254913549145491554916549175491854919549205492154922549235492454925549265492754928549295493054931549325493354934549355493654937549385493954940549415494254943549445494554946549475494854949549505495154952549535495454955549565495754958549595496054961549625496354964549655496654967549685496954970549715497254973549745497554976549775497854979549805498154982549835498454985549865498754988549895499054991549925499354994549955499654997549985499955000550015500255003550045500555006550075500855009550105501155012550135501455015550165501755018550195502055021550225502355024550255502655027550285502955030550315503255033550345503555036550375503855039550405504155042550435504455045550465504755048550495505055051550525505355054550555505655057550585505955060550615506255063550645506555066550675506855069550705507155072550735507455075550765507755078550795508055081550825508355084550855508655087550885508955090550915509255093550945509555096550975509855099551005510155102551035510455105551065510755108551095511055111551125511355114551155511655117551185511955120551215512255123551245512555126551275512855129551305513155132551335513455135551365513755138551395514055141551425514355144551455514655147551485514955150551515515255153551545515555156551575515855159551605516155162551635516455165551665516755168551695517055171551725517355174551755517655177551785517955180551815518255183551845518555186551875518855189551905519155192551935519455195551965519755198551995520055201552025520355204552055520655207552085520955210552115521255213552145521555216552175521855219552205522155222552235522455225552265522755228552295523055231552325523355234552355523655237552385523955240552415524255243552445524555246552475524855249552505525155252552535525455255552565525755258552595526055261552625526355264552655526655267552685526955270552715527255273552745527555276552775527855279552805528155282552835528455285552865528755288552895529055291552925529355294552955529655297552985529955300553015530255303553045530555306553075530855309553105531155312553135531455315553165531755318553195532055321553225532355324553255532655327553285532955330553315533255333553345533555336553375533855339553405534155342553435534455345553465534755348553495535055351553525535355354553555535655357553585535955360553615536255363553645536555366553675536855369553705537155372553735537455375553765537755378553795538055381553825538355384553855538655387553885538955390553915539255393553945539555396553975539855399554005540155402554035540455405554065540755408554095541055411554125541355414554155541655417554185541955420554215542255423554245542555426554275542855429554305543155432554335543455435554365543755438554395544055441554425544355444554455544655447554485544955450554515545255453554545545555456554575545855459554605546155462554635546455465554665546755468554695547055471554725547355474554755547655477554785547955480554815548255483554845548555486554875548855489554905549155492554935549455495554965549755498554995550055501555025550355504555055550655507555085550955510555115551255513555145551555516555175551855519555205552155522555235552455525555265552755528555295553055531555325553355534555355553655537555385553955540555415554255543555445554555546555475554855549555505555155552555535555455555555565555755558555595556055561555625556355564555655556655567555685556955570555715557255573555745557555576555775557855579555805558155582555835558455585555865558755588555895559055591555925559355594555955559655597555985559955600556015560255603556045560555606556075560855609556105561155612556135561455615556165561755618556195562055621556225562355624556255562655627556285562955630556315563255633556345563555636556375563855639556405564155642556435564455645556465564755648556495565055651556525565355654556555565655657556585565955660556615566255663556645566555666556675566855669556705567155672556735567455675556765567755678556795568055681556825568355684556855568655687556885568955690556915569255693556945569555696556975569855699557005570155702557035570455705557065570755708557095571055711557125571355714557155571655717557185571955720557215572255723557245572555726557275572855729557305573155732557335573455735557365573755738557395574055741557425574355744557455574655747557485574955750557515575255753557545575555756557575575855759557605576155762557635576455765557665576755768557695577055771557725577355774557755577655777557785577955780557815578255783557845578555786557875578855789557905579155792557935579455795557965579755798557995580055801558025580355804558055580655807558085580955810558115581255813558145581555816558175581855819558205582155822558235582455825558265582755828558295583055831558325583355834558355583655837558385583955840558415584255843558445584555846558475584855849558505585155852558535585455855558565585755858558595586055861558625586355864558655586655867558685586955870558715587255873558745587555876558775587855879558805588155882558835588455885558865588755888558895589055891558925589355894558955589655897558985589955900559015590255903559045590555906559075590855909559105591155912559135591455915559165591755918559195592055921559225592355924559255592655927559285592955930559315593255933559345593555936559375593855939559405594155942559435594455945559465594755948559495595055951559525595355954559555595655957559585595955960559615596255963559645596555966559675596855969559705597155972559735597455975559765597755978559795598055981559825598355984559855598655987559885598955990559915599255993559945599555996559975599855999560005600156002560035600456005560065600756008560095601056011560125601356014560155601656017560185601956020560215602256023560245602556026560275602856029560305603156032560335603456035560365603756038560395604056041560425604356044560455604656047560485604956050560515605256053560545605556056560575605856059560605606156062560635606456065560665606756068560695607056071560725607356074560755607656077560785607956080560815608256083560845608556086560875608856089560905609156092560935609456095560965609756098560995610056101561025610356104561055610656107561085610956110561115611256113561145611556116561175611856119561205612156122561235612456125561265612756128561295613056131561325613356134561355613656137561385613956140561415614256143561445614556146561475614856149561505615156152561535615456155561565615756158561595616056161561625616356164561655616656167561685616956170561715617256173561745617556176561775617856179561805618156182561835618456185561865618756188561895619056191561925619356194561955619656197561985619956200562015620256203562045620556206562075620856209562105621156212562135621456215562165621756218562195622056221562225622356224562255622656227562285622956230562315623256233562345623556236562375623856239562405624156242562435624456245562465624756248562495625056251562525625356254562555625656257562585625956260562615626256263562645626556266562675626856269562705627156272562735627456275562765627756278562795628056281562825628356284562855628656287562885628956290562915629256293562945629556296562975629856299563005630156302563035630456305563065630756308563095631056311563125631356314563155631656317563185631956320563215632256323563245632556326563275632856329563305633156332563335633456335563365633756338563395634056341563425634356344563455634656347563485634956350563515635256353563545635556356563575635856359563605636156362563635636456365563665636756368563695637056371563725637356374563755637656377563785637956380563815638256383563845638556386563875638856389563905639156392563935639456395563965639756398563995640056401564025640356404564055640656407564085640956410564115641256413564145641556416564175641856419564205642156422564235642456425564265642756428564295643056431564325643356434564355643656437564385643956440564415644256443564445644556446564475644856449564505645156452564535645456455564565645756458564595646056461564625646356464564655646656467564685646956470564715647256473564745647556476564775647856479564805648156482564835648456485564865648756488564895649056491564925649356494564955649656497564985649956500565015650256503565045650556506565075650856509565105651156512565135651456515565165651756518565195652056521565225652356524565255652656527565285652956530565315653256533565345653556536565375653856539565405654156542565435654456545565465654756548565495655056551565525655356554565555655656557565585655956560565615656256563565645656556566565675656856569565705657156572565735657456575565765657756578565795658056581565825658356584565855658656587565885658956590565915659256593565945659556596565975659856599566005660156602566035660456605566065660756608566095661056611566125661356614566155661656617566185661956620566215662256623566245662556626566275662856629566305663156632566335663456635566365663756638566395664056641566425664356644566455664656647566485664956650566515665256653566545665556656566575665856659566605666156662566635666456665566665666756668566695667056671566725667356674566755667656677566785667956680566815668256683566845668556686566875668856689566905669156692566935669456695566965669756698566995670056701567025670356704567055670656707567085670956710567115671256713567145671556716567175671856719567205672156722567235672456725567265672756728567295673056731567325673356734567355673656737567385673956740567415674256743567445674556746567475674856749567505675156752567535675456755567565675756758567595676056761567625676356764567655676656767567685676956770567715677256773567745677556776567775677856779567805678156782567835678456785567865678756788567895679056791567925679356794567955679656797567985679956800568015680256803568045680556806568075680856809568105681156812568135681456815568165681756818568195682056821568225682356824568255682656827568285682956830568315683256833568345683556836568375683856839568405684156842568435684456845568465684756848568495685056851568525685356854568555685656857568585685956860568615686256863568645686556866568675686856869568705687156872568735687456875568765687756878568795688056881568825688356884568855688656887568885688956890568915689256893568945689556896568975689856899569005690156902569035690456905569065690756908569095691056911569125691356914569155691656917569185691956920569215692256923569245692556926569275692856929569305693156932569335693456935569365693756938569395694056941569425694356944569455694656947569485694956950569515695256953569545695556956569575695856959569605696156962569635696456965569665696756968569695697056971569725697356974569755697656977569785697956980569815698256983569845698556986569875698856989569905699156992569935699456995569965699756998569995700057001570025700357004570055700657007570085700957010570115701257013570145701557016570175701857019570205702157022570235702457025570265702757028570295703057031570325703357034570355703657037570385703957040570415704257043570445704557046570475704857049570505705157052570535705457055570565705757058570595706057061570625706357064570655706657067570685706957070570715707257073570745707557076570775707857079570805708157082570835708457085570865708757088570895709057091570925709357094570955709657097570985709957100571015710257103571045710557106571075710857109571105711157112571135711457115571165711757118571195712057121571225712357124571255712657127571285712957130571315713257133571345713557136571375713857139571405714157142571435714457145571465714757148571495715057151571525715357154571555715657157571585715957160571615716257163571645716557166571675716857169571705717157172571735717457175571765717757178571795718057181571825718357184571855718657187571885718957190571915719257193571945719557196571975719857199572005720157202572035720457205572065720757208572095721057211572125721357214572155721657217572185721957220572215722257223572245722557226572275722857229572305723157232572335723457235572365723757238572395724057241572425724357244572455724657247572485724957250572515725257253572545725557256572575725857259572605726157262572635726457265572665726757268572695727057271572725727357274572755727657277572785727957280572815728257283572845728557286572875728857289572905729157292572935729457295572965729757298572995730057301573025730357304573055730657307573085730957310573115731257313573145731557316573175731857319573205732157322573235732457325573265732757328573295733057331573325733357334573355733657337573385733957340573415734257343573445734557346573475734857349573505735157352573535735457355573565735757358573595736057361573625736357364573655736657367573685736957370573715737257373573745737557376573775737857379573805738157382573835738457385573865738757388573895739057391573925739357394573955739657397573985739957400574015740257403574045740557406574075740857409574105741157412574135741457415574165741757418574195742057421574225742357424574255742657427574285742957430574315743257433574345743557436574375743857439574405744157442574435744457445574465744757448574495745057451574525745357454574555745657457574585745957460574615746257463574645746557466574675746857469574705747157472574735747457475574765747757478574795748057481574825748357484574855748657487574885748957490574915749257493574945749557496574975749857499575005750157502575035750457505575065750757508575095751057511575125751357514575155751657517575185751957520575215752257523575245752557526575275752857529575305753157532575335753457535575365753757538575395754057541575425754357544575455754657547575485754957550575515755257553575545755557556575575755857559575605756157562575635756457565575665756757568575695757057571575725757357574575755757657577575785757957580575815758257583575845758557586575875758857589575905759157592575935759457595575965759757598575995760057601576025760357604576055760657607576085760957610576115761257613576145761557616576175761857619576205762157622576235762457625576265762757628576295763057631576325763357634576355763657637576385763957640576415764257643576445764557646576475764857649576505765157652576535765457655576565765757658576595766057661576625766357664576655766657667576685766957670576715767257673576745767557676576775767857679576805768157682576835768457685576865768757688576895769057691576925769357694576955769657697576985769957700577015770257703577045770557706577075770857709577105771157712577135771457715577165771757718577195772057721577225772357724577255772657727577285772957730577315773257733577345773557736577375773857739577405774157742577435774457745577465774757748577495775057751577525775357754577555775657757577585775957760577615776257763577645776557766577675776857769577705777157772577735777457775577765777757778577795778057781577825778357784577855778657787577885778957790577915779257793577945779557796577975779857799578005780157802578035780457805578065780757808578095781057811578125781357814578155781657817578185781957820578215782257823578245782557826578275782857829578305783157832578335783457835578365783757838578395784057841578425784357844578455784657847578485784957850578515785257853578545785557856578575785857859578605786157862578635786457865578665786757868578695787057871578725787357874578755787657877578785787957880578815788257883578845788557886578875788857889578905789157892578935789457895578965789757898578995790057901579025790357904579055790657907579085790957910579115791257913579145791557916579175791857919579205792157922579235792457925579265792757928579295793057931579325793357934579355793657937579385793957940579415794257943579445794557946579475794857949579505795157952579535795457955579565795757958579595796057961579625796357964579655796657967579685796957970579715797257973579745797557976579775797857979579805798157982579835798457985579865798757988579895799057991579925799357994579955799657997579985799958000580015800258003580045800558006580075800858009580105801158012580135801458015580165801758018580195802058021580225802358024580255802658027580285802958030580315803258033580345803558036580375803858039580405804158042580435804458045580465804758048580495805058051580525805358054580555805658057580585805958060580615806258063580645806558066580675806858069580705807158072580735807458075580765807758078580795808058081580825808358084580855808658087580885808958090580915809258093
  1. // Code generated by ent, DO NOT EDIT.
  2. package ent
  3. import (
  4. "context"
  5. "encoding/json/jsontext"
  6. "errors"
  7. "fmt"
  8. "sync"
  9. "time"
  10. "entgo.io/ent"
  11. "entgo.io/ent/dialect/sql"
  12. "github.com/Wei-Shaw/sub2api/ent/account"
  13. "github.com/Wei-Shaw/sub2api/ent/accountgroup"
  14. "github.com/Wei-Shaw/sub2api/ent/announcement"
  15. "github.com/Wei-Shaw/sub2api/ent/announcementread"
  16. "github.com/Wei-Shaw/sub2api/ent/apikey"
  17. "github.com/Wei-Shaw/sub2api/ent/authidentity"
  18. "github.com/Wei-Shaw/sub2api/ent/authidentitychannel"
  19. "github.com/Wei-Shaw/sub2api/ent/batchimageevent"
  20. "github.com/Wei-Shaw/sub2api/ent/batchimageitem"
  21. "github.com/Wei-Shaw/sub2api/ent/batchimagejob"
  22. "github.com/Wei-Shaw/sub2api/ent/channelmonitor"
  23. "github.com/Wei-Shaw/sub2api/ent/channelmonitordailyrollup"
  24. "github.com/Wei-Shaw/sub2api/ent/channelmonitorhistory"
  25. "github.com/Wei-Shaw/sub2api/ent/channelmonitorrequesttemplate"
  26. "github.com/Wei-Shaw/sub2api/ent/compositemodelroute"
  27. "github.com/Wei-Shaw/sub2api/ent/errorpassthroughrule"
  28. "github.com/Wei-Shaw/sub2api/ent/group"
  29. "github.com/Wei-Shaw/sub2api/ent/idempotencyrecord"
  30. "github.com/Wei-Shaw/sub2api/ent/identityadoptiondecision"
  31. "github.com/Wei-Shaw/sub2api/ent/paymentauditlog"
  32. "github.com/Wei-Shaw/sub2api/ent/paymentorder"
  33. "github.com/Wei-Shaw/sub2api/ent/paymentproviderinstance"
  34. "github.com/Wei-Shaw/sub2api/ent/pendingauthsession"
  35. "github.com/Wei-Shaw/sub2api/ent/predicate"
  36. "github.com/Wei-Shaw/sub2api/ent/promocode"
  37. "github.com/Wei-Shaw/sub2api/ent/promocodeusage"
  38. "github.com/Wei-Shaw/sub2api/ent/proxy"
  39. "github.com/Wei-Shaw/sub2api/ent/redeemcode"
  40. "github.com/Wei-Shaw/sub2api/ent/securitypolicykeyword"
  41. "github.com/Wei-Shaw/sub2api/ent/securitysecret"
  42. "github.com/Wei-Shaw/sub2api/ent/setting"
  43. "github.com/Wei-Shaw/sub2api/ent/subscriptionplan"
  44. "github.com/Wei-Shaw/sub2api/ent/tlsfingerprintprofile"
  45. "github.com/Wei-Shaw/sub2api/ent/usagecleanuptask"
  46. "github.com/Wei-Shaw/sub2api/ent/usagelog"
  47. "github.com/Wei-Shaw/sub2api/ent/user"
  48. "github.com/Wei-Shaw/sub2api/ent/userallowedgroup"
  49. "github.com/Wei-Shaw/sub2api/ent/userattributedefinition"
  50. "github.com/Wei-Shaw/sub2api/ent/userattributevalue"
  51. "github.com/Wei-Shaw/sub2api/ent/userplatformquota"
  52. "github.com/Wei-Shaw/sub2api/ent/usersubscription"
  53. "github.com/Wei-Shaw/sub2api/internal/domain"
  54. )
  55. const (
  56. // Operation types.
  57. OpCreate = ent.OpCreate
  58. OpDelete = ent.OpDelete
  59. OpDeleteOne = ent.OpDeleteOne
  60. OpUpdate = ent.OpUpdate
  61. OpUpdateOne = ent.OpUpdateOne
  62. // Node types.
  63. TypeAPIKey = "APIKey"
  64. TypeAccount = "Account"
  65. TypeAccountGroup = "AccountGroup"
  66. TypeAnnouncement = "Announcement"
  67. TypeAnnouncementRead = "AnnouncementRead"
  68. TypeAuthIdentity = "AuthIdentity"
  69. TypeAuthIdentityChannel = "AuthIdentityChannel"
  70. TypeBatchImageEvent = "BatchImageEvent"
  71. TypeBatchImageItem = "BatchImageItem"
  72. TypeBatchImageJob = "BatchImageJob"
  73. TypeChannelMonitor = "ChannelMonitor"
  74. TypeChannelMonitorDailyRollup = "ChannelMonitorDailyRollup"
  75. TypeChannelMonitorHistory = "ChannelMonitorHistory"
  76. TypeChannelMonitorRequestTemplate = "ChannelMonitorRequestTemplate"
  77. TypeCompositeModelRoute = "CompositeModelRoute"
  78. TypeErrorPassthroughRule = "ErrorPassthroughRule"
  79. TypeGroup = "Group"
  80. TypeIdempotencyRecord = "IdempotencyRecord"
  81. TypeIdentityAdoptionDecision = "IdentityAdoptionDecision"
  82. TypePaymentAuditLog = "PaymentAuditLog"
  83. TypePaymentOrder = "PaymentOrder"
  84. TypePaymentProviderInstance = "PaymentProviderInstance"
  85. TypePendingAuthSession = "PendingAuthSession"
  86. TypePromoCode = "PromoCode"
  87. TypePromoCodeUsage = "PromoCodeUsage"
  88. TypeProxy = "Proxy"
  89. TypeRedeemCode = "RedeemCode"
  90. TypeSecurityPolicyKeyword = "SecurityPolicyKeyword"
  91. TypeSecuritySecret = "SecuritySecret"
  92. TypeSetting = "Setting"
  93. TypeSubscriptionPlan = "SubscriptionPlan"
  94. TypeTLSFingerprintProfile = "TLSFingerprintProfile"
  95. TypeUsageCleanupTask = "UsageCleanupTask"
  96. TypeUsageLog = "UsageLog"
  97. TypeUser = "User"
  98. TypeUserAllowedGroup = "UserAllowedGroup"
  99. TypeUserAttributeDefinition = "UserAttributeDefinition"
  100. TypeUserAttributeValue = "UserAttributeValue"
  101. TypeUserPlatformQuota = "UserPlatformQuota"
  102. TypeUserSubscription = "UserSubscription"
  103. )
  104. // APIKeyMutation represents an operation that mutates the APIKey nodes in the graph.
  105. type APIKeyMutation struct {
  106. config
  107. op Op
  108. typ string
  109. id *int64
  110. created_at *time.Time
  111. updated_at *time.Time
  112. deleted_at *time.Time
  113. key *string
  114. key_hash *string
  115. key_prefix *string
  116. name *string
  117. status *string
  118. last_used_at *time.Time
  119. ip_whitelist *[]string
  120. appendip_whitelist []string
  121. ip_blacklist *[]string
  122. appendip_blacklist []string
  123. quota *float64
  124. addquota *float64
  125. quota_used *float64
  126. addquota_used *float64
  127. expires_at *time.Time
  128. rate_limit_5h *float64
  129. addrate_limit_5h *float64
  130. rate_limit_1d *float64
  131. addrate_limit_1d *float64
  132. rate_limit_7d *float64
  133. addrate_limit_7d *float64
  134. usage_5h *float64
  135. addusage_5h *float64
  136. usage_1d *float64
  137. addusage_1d *float64
  138. usage_7d *float64
  139. addusage_7d *float64
  140. window_5h_start *time.Time
  141. window_1d_start *time.Time
  142. window_7d_start *time.Time
  143. clearedFields map[string]struct{}
  144. user *int64
  145. cleareduser bool
  146. group *int64
  147. clearedgroup bool
  148. usage_logs map[int64]struct{}
  149. removedusage_logs map[int64]struct{}
  150. clearedusage_logs bool
  151. done bool
  152. oldValue func(context.Context) (*APIKey, error)
  153. predicates []predicate.APIKey
  154. }
  155. var _ ent.Mutation = (*APIKeyMutation)(nil)
  156. // apikeyOption allows management of the mutation configuration using functional options.
  157. type apikeyOption func(*APIKeyMutation)
  158. // newAPIKeyMutation creates new mutation for the APIKey entity.
  159. func newAPIKeyMutation(c config, op Op, opts ...apikeyOption) *APIKeyMutation {
  160. m := &APIKeyMutation{
  161. config: c,
  162. op: op,
  163. typ: TypeAPIKey,
  164. clearedFields: make(map[string]struct{}),
  165. }
  166. for _, opt := range opts {
  167. opt(m)
  168. }
  169. return m
  170. }
  171. // withAPIKeyID sets the ID field of the mutation.
  172. func withAPIKeyID(id int64) apikeyOption {
  173. return func(m *APIKeyMutation) {
  174. var (
  175. err error
  176. once sync.Once
  177. value *APIKey
  178. )
  179. m.oldValue = func(ctx context.Context) (*APIKey, error) {
  180. once.Do(func() {
  181. if m.done {
  182. err = errors.New("querying old values post mutation is not allowed")
  183. } else {
  184. value, err = m.Client().APIKey.Get(ctx, id)
  185. }
  186. })
  187. return value, err
  188. }
  189. m.id = &id
  190. }
  191. }
  192. // withAPIKey sets the old APIKey of the mutation.
  193. func withAPIKey(node *APIKey) apikeyOption {
  194. return func(m *APIKeyMutation) {
  195. m.oldValue = func(context.Context) (*APIKey, error) {
  196. return node, nil
  197. }
  198. m.id = &node.ID
  199. }
  200. }
  201. // Client returns a new `ent.Client` from the mutation. If the mutation was
  202. // executed in a transaction (ent.Tx), a transactional client is returned.
  203. func (m APIKeyMutation) Client() *Client {
  204. client := &Client{config: m.config}
  205. client.init()
  206. return client
  207. }
  208. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  209. // it returns an error otherwise.
  210. func (m APIKeyMutation) Tx() (*Tx, error) {
  211. if _, ok := m.driver.(*txDriver); !ok {
  212. return nil, errors.New("ent: mutation is not running in a transaction")
  213. }
  214. tx := &Tx{config: m.config}
  215. tx.init()
  216. return tx, nil
  217. }
  218. // ID returns the ID value in the mutation. Note that the ID is only available
  219. // if it was provided to the builder or after it was returned from the database.
  220. func (m *APIKeyMutation) ID() (id int64, exists bool) {
  221. if m.id == nil {
  222. return
  223. }
  224. return *m.id, true
  225. }
  226. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  227. // That means, if the mutation is applied within a transaction with an isolation level such
  228. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  229. // or updated by the mutation.
  230. func (m *APIKeyMutation) IDs(ctx context.Context) ([]int64, error) {
  231. switch {
  232. case m.op.Is(OpUpdateOne | OpDeleteOne):
  233. id, exists := m.ID()
  234. if exists {
  235. return []int64{id}, nil
  236. }
  237. fallthrough
  238. case m.op.Is(OpUpdate | OpDelete):
  239. return m.Client().APIKey.Query().Where(m.predicates...).IDs(ctx)
  240. default:
  241. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  242. }
  243. }
  244. // SetCreatedAt sets the "created_at" field.
  245. func (m *APIKeyMutation) SetCreatedAt(t time.Time) {
  246. m.created_at = &t
  247. }
  248. // CreatedAt returns the value of the "created_at" field in the mutation.
  249. func (m *APIKeyMutation) CreatedAt() (r time.Time, exists bool) {
  250. v := m.created_at
  251. if v == nil {
  252. return
  253. }
  254. return *v, true
  255. }
  256. // OldCreatedAt returns the old "created_at" field's value of the APIKey entity.
  257. // If the APIKey object wasn't provided to the builder, the object is fetched from the database.
  258. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  259. func (m *APIKeyMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  260. if !m.op.Is(OpUpdateOne) {
  261. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  262. }
  263. if m.id == nil || m.oldValue == nil {
  264. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  265. }
  266. oldValue, err := m.oldValue(ctx)
  267. if err != nil {
  268. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  269. }
  270. return oldValue.CreatedAt, nil
  271. }
  272. // ResetCreatedAt resets all changes to the "created_at" field.
  273. func (m *APIKeyMutation) ResetCreatedAt() {
  274. m.created_at = nil
  275. }
  276. // SetUpdatedAt sets the "updated_at" field.
  277. func (m *APIKeyMutation) SetUpdatedAt(t time.Time) {
  278. m.updated_at = &t
  279. }
  280. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  281. func (m *APIKeyMutation) UpdatedAt() (r time.Time, exists bool) {
  282. v := m.updated_at
  283. if v == nil {
  284. return
  285. }
  286. return *v, true
  287. }
  288. // OldUpdatedAt returns the old "updated_at" field's value of the APIKey entity.
  289. // If the APIKey object wasn't provided to the builder, the object is fetched from the database.
  290. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  291. func (m *APIKeyMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  292. if !m.op.Is(OpUpdateOne) {
  293. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  294. }
  295. if m.id == nil || m.oldValue == nil {
  296. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  297. }
  298. oldValue, err := m.oldValue(ctx)
  299. if err != nil {
  300. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  301. }
  302. return oldValue.UpdatedAt, nil
  303. }
  304. // ResetUpdatedAt resets all changes to the "updated_at" field.
  305. func (m *APIKeyMutation) ResetUpdatedAt() {
  306. m.updated_at = nil
  307. }
  308. // SetDeletedAt sets the "deleted_at" field.
  309. func (m *APIKeyMutation) SetDeletedAt(t time.Time) {
  310. m.deleted_at = &t
  311. }
  312. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  313. func (m *APIKeyMutation) DeletedAt() (r time.Time, exists bool) {
  314. v := m.deleted_at
  315. if v == nil {
  316. return
  317. }
  318. return *v, true
  319. }
  320. // OldDeletedAt returns the old "deleted_at" field's value of the APIKey entity.
  321. // If the APIKey object wasn't provided to the builder, the object is fetched from the database.
  322. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  323. func (m *APIKeyMutation) OldDeletedAt(ctx context.Context) (v *time.Time, err error) {
  324. if !m.op.Is(OpUpdateOne) {
  325. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  326. }
  327. if m.id == nil || m.oldValue == nil {
  328. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  329. }
  330. oldValue, err := m.oldValue(ctx)
  331. if err != nil {
  332. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  333. }
  334. return oldValue.DeletedAt, nil
  335. }
  336. // ClearDeletedAt clears the value of the "deleted_at" field.
  337. func (m *APIKeyMutation) ClearDeletedAt() {
  338. m.deleted_at = nil
  339. m.clearedFields[apikey.FieldDeletedAt] = struct{}{}
  340. }
  341. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  342. func (m *APIKeyMutation) DeletedAtCleared() bool {
  343. _, ok := m.clearedFields[apikey.FieldDeletedAt]
  344. return ok
  345. }
  346. // ResetDeletedAt resets all changes to the "deleted_at" field.
  347. func (m *APIKeyMutation) ResetDeletedAt() {
  348. m.deleted_at = nil
  349. delete(m.clearedFields, apikey.FieldDeletedAt)
  350. }
  351. // SetUserID sets the "user_id" field.
  352. func (m *APIKeyMutation) SetUserID(i int64) {
  353. m.user = &i
  354. }
  355. // UserID returns the value of the "user_id" field in the mutation.
  356. func (m *APIKeyMutation) UserID() (r int64, exists bool) {
  357. v := m.user
  358. if v == nil {
  359. return
  360. }
  361. return *v, true
  362. }
  363. // OldUserID returns the old "user_id" field's value of the APIKey entity.
  364. // If the APIKey object wasn't provided to the builder, the object is fetched from the database.
  365. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  366. func (m *APIKeyMutation) OldUserID(ctx context.Context) (v int64, err error) {
  367. if !m.op.Is(OpUpdateOne) {
  368. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  369. }
  370. if m.id == nil || m.oldValue == nil {
  371. return v, errors.New("OldUserID requires an ID field in the mutation")
  372. }
  373. oldValue, err := m.oldValue(ctx)
  374. if err != nil {
  375. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  376. }
  377. return oldValue.UserID, nil
  378. }
  379. // ResetUserID resets all changes to the "user_id" field.
  380. func (m *APIKeyMutation) ResetUserID() {
  381. m.user = nil
  382. }
  383. // SetKey sets the "key" field.
  384. func (m *APIKeyMutation) SetKey(s string) {
  385. m.key = &s
  386. }
  387. // Key returns the value of the "key" field in the mutation.
  388. func (m *APIKeyMutation) Key() (r string, exists bool) {
  389. v := m.key
  390. if v == nil {
  391. return
  392. }
  393. return *v, true
  394. }
  395. // OldKey returns the old "key" field's value of the APIKey entity.
  396. // If the APIKey object wasn't provided to the builder, the object is fetched from the database.
  397. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  398. func (m *APIKeyMutation) OldKey(ctx context.Context) (v string, err error) {
  399. if !m.op.Is(OpUpdateOne) {
  400. return v, errors.New("OldKey is only allowed on UpdateOne operations")
  401. }
  402. if m.id == nil || m.oldValue == nil {
  403. return v, errors.New("OldKey requires an ID field in the mutation")
  404. }
  405. oldValue, err := m.oldValue(ctx)
  406. if err != nil {
  407. return v, fmt.Errorf("querying old value for OldKey: %w", err)
  408. }
  409. return oldValue.Key, nil
  410. }
  411. // ClearKey clears the value of the "key" field.
  412. func (m *APIKeyMutation) ClearKey() {
  413. m.key = nil
  414. m.clearedFields[apikey.FieldKey] = struct{}{}
  415. }
  416. // KeyCleared returns if the "key" field was cleared in this mutation.
  417. func (m *APIKeyMutation) KeyCleared() bool {
  418. _, ok := m.clearedFields[apikey.FieldKey]
  419. return ok
  420. }
  421. // ResetKey resets all changes to the "key" field.
  422. func (m *APIKeyMutation) ResetKey() {
  423. m.key = nil
  424. delete(m.clearedFields, apikey.FieldKey)
  425. }
  426. // SetKeyHash sets the "key_hash" field.
  427. func (m *APIKeyMutation) SetKeyHash(s string) {
  428. m.key_hash = &s
  429. }
  430. // KeyHash returns the value of the "key_hash" field in the mutation.
  431. func (m *APIKeyMutation) KeyHash() (r string, exists bool) {
  432. v := m.key_hash
  433. if v == nil {
  434. return
  435. }
  436. return *v, true
  437. }
  438. // OldKeyHash returns the old "key_hash" field's value of the APIKey entity.
  439. // If the APIKey object wasn't provided to the builder, the object is fetched from the database.
  440. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  441. func (m *APIKeyMutation) OldKeyHash(ctx context.Context) (v string, err error) {
  442. if !m.op.Is(OpUpdateOne) {
  443. return v, errors.New("OldKeyHash is only allowed on UpdateOne operations")
  444. }
  445. if m.id == nil || m.oldValue == nil {
  446. return v, errors.New("OldKeyHash requires an ID field in the mutation")
  447. }
  448. oldValue, err := m.oldValue(ctx)
  449. if err != nil {
  450. return v, fmt.Errorf("querying old value for OldKeyHash: %w", err)
  451. }
  452. return oldValue.KeyHash, nil
  453. }
  454. // ClearKeyHash clears the value of the "key_hash" field.
  455. func (m *APIKeyMutation) ClearKeyHash() {
  456. m.key_hash = nil
  457. m.clearedFields[apikey.FieldKeyHash] = struct{}{}
  458. }
  459. // KeyHashCleared returns if the "key_hash" field was cleared in this mutation.
  460. func (m *APIKeyMutation) KeyHashCleared() bool {
  461. _, ok := m.clearedFields[apikey.FieldKeyHash]
  462. return ok
  463. }
  464. // ResetKeyHash resets all changes to the "key_hash" field.
  465. func (m *APIKeyMutation) ResetKeyHash() {
  466. m.key_hash = nil
  467. delete(m.clearedFields, apikey.FieldKeyHash)
  468. }
  469. // SetKeyPrefix sets the "key_prefix" field.
  470. func (m *APIKeyMutation) SetKeyPrefix(s string) {
  471. m.key_prefix = &s
  472. }
  473. // KeyPrefix returns the value of the "key_prefix" field in the mutation.
  474. func (m *APIKeyMutation) KeyPrefix() (r string, exists bool) {
  475. v := m.key_prefix
  476. if v == nil {
  477. return
  478. }
  479. return *v, true
  480. }
  481. // OldKeyPrefix returns the old "key_prefix" field's value of the APIKey entity.
  482. // If the APIKey object wasn't provided to the builder, the object is fetched from the database.
  483. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  484. func (m *APIKeyMutation) OldKeyPrefix(ctx context.Context) (v string, err error) {
  485. if !m.op.Is(OpUpdateOne) {
  486. return v, errors.New("OldKeyPrefix is only allowed on UpdateOne operations")
  487. }
  488. if m.id == nil || m.oldValue == nil {
  489. return v, errors.New("OldKeyPrefix requires an ID field in the mutation")
  490. }
  491. oldValue, err := m.oldValue(ctx)
  492. if err != nil {
  493. return v, fmt.Errorf("querying old value for OldKeyPrefix: %w", err)
  494. }
  495. return oldValue.KeyPrefix, nil
  496. }
  497. // ClearKeyPrefix clears the value of the "key_prefix" field.
  498. func (m *APIKeyMutation) ClearKeyPrefix() {
  499. m.key_prefix = nil
  500. m.clearedFields[apikey.FieldKeyPrefix] = struct{}{}
  501. }
  502. // KeyPrefixCleared returns if the "key_prefix" field was cleared in this mutation.
  503. func (m *APIKeyMutation) KeyPrefixCleared() bool {
  504. _, ok := m.clearedFields[apikey.FieldKeyPrefix]
  505. return ok
  506. }
  507. // ResetKeyPrefix resets all changes to the "key_prefix" field.
  508. func (m *APIKeyMutation) ResetKeyPrefix() {
  509. m.key_prefix = nil
  510. delete(m.clearedFields, apikey.FieldKeyPrefix)
  511. }
  512. // SetName sets the "name" field.
  513. func (m *APIKeyMutation) SetName(s string) {
  514. m.name = &s
  515. }
  516. // Name returns the value of the "name" field in the mutation.
  517. func (m *APIKeyMutation) Name() (r string, exists bool) {
  518. v := m.name
  519. if v == nil {
  520. return
  521. }
  522. return *v, true
  523. }
  524. // OldName returns the old "name" field's value of the APIKey entity.
  525. // If the APIKey object wasn't provided to the builder, the object is fetched from the database.
  526. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  527. func (m *APIKeyMutation) OldName(ctx context.Context) (v string, err error) {
  528. if !m.op.Is(OpUpdateOne) {
  529. return v, errors.New("OldName is only allowed on UpdateOne operations")
  530. }
  531. if m.id == nil || m.oldValue == nil {
  532. return v, errors.New("OldName requires an ID field in the mutation")
  533. }
  534. oldValue, err := m.oldValue(ctx)
  535. if err != nil {
  536. return v, fmt.Errorf("querying old value for OldName: %w", err)
  537. }
  538. return oldValue.Name, nil
  539. }
  540. // ResetName resets all changes to the "name" field.
  541. func (m *APIKeyMutation) ResetName() {
  542. m.name = nil
  543. }
  544. // SetGroupID sets the "group_id" field.
  545. func (m *APIKeyMutation) SetGroupID(i int64) {
  546. m.group = &i
  547. }
  548. // GroupID returns the value of the "group_id" field in the mutation.
  549. func (m *APIKeyMutation) GroupID() (r int64, exists bool) {
  550. v := m.group
  551. if v == nil {
  552. return
  553. }
  554. return *v, true
  555. }
  556. // OldGroupID returns the old "group_id" field's value of the APIKey entity.
  557. // If the APIKey object wasn't provided to the builder, the object is fetched from the database.
  558. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  559. func (m *APIKeyMutation) OldGroupID(ctx context.Context) (v *int64, err error) {
  560. if !m.op.Is(OpUpdateOne) {
  561. return v, errors.New("OldGroupID is only allowed on UpdateOne operations")
  562. }
  563. if m.id == nil || m.oldValue == nil {
  564. return v, errors.New("OldGroupID requires an ID field in the mutation")
  565. }
  566. oldValue, err := m.oldValue(ctx)
  567. if err != nil {
  568. return v, fmt.Errorf("querying old value for OldGroupID: %w", err)
  569. }
  570. return oldValue.GroupID, nil
  571. }
  572. // ClearGroupID clears the value of the "group_id" field.
  573. func (m *APIKeyMutation) ClearGroupID() {
  574. m.group = nil
  575. m.clearedFields[apikey.FieldGroupID] = struct{}{}
  576. }
  577. // GroupIDCleared returns if the "group_id" field was cleared in this mutation.
  578. func (m *APIKeyMutation) GroupIDCleared() bool {
  579. _, ok := m.clearedFields[apikey.FieldGroupID]
  580. return ok
  581. }
  582. // ResetGroupID resets all changes to the "group_id" field.
  583. func (m *APIKeyMutation) ResetGroupID() {
  584. m.group = nil
  585. delete(m.clearedFields, apikey.FieldGroupID)
  586. }
  587. // SetStatus sets the "status" field.
  588. func (m *APIKeyMutation) SetStatus(s string) {
  589. m.status = &s
  590. }
  591. // Status returns the value of the "status" field in the mutation.
  592. func (m *APIKeyMutation) Status() (r string, exists bool) {
  593. v := m.status
  594. if v == nil {
  595. return
  596. }
  597. return *v, true
  598. }
  599. // OldStatus returns the old "status" field's value of the APIKey entity.
  600. // If the APIKey object wasn't provided to the builder, the object is fetched from the database.
  601. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  602. func (m *APIKeyMutation) OldStatus(ctx context.Context) (v string, err error) {
  603. if !m.op.Is(OpUpdateOne) {
  604. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  605. }
  606. if m.id == nil || m.oldValue == nil {
  607. return v, errors.New("OldStatus requires an ID field in the mutation")
  608. }
  609. oldValue, err := m.oldValue(ctx)
  610. if err != nil {
  611. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  612. }
  613. return oldValue.Status, nil
  614. }
  615. // ResetStatus resets all changes to the "status" field.
  616. func (m *APIKeyMutation) ResetStatus() {
  617. m.status = nil
  618. }
  619. // SetLastUsedAt sets the "last_used_at" field.
  620. func (m *APIKeyMutation) SetLastUsedAt(t time.Time) {
  621. m.last_used_at = &t
  622. }
  623. // LastUsedAt returns the value of the "last_used_at" field in the mutation.
  624. func (m *APIKeyMutation) LastUsedAt() (r time.Time, exists bool) {
  625. v := m.last_used_at
  626. if v == nil {
  627. return
  628. }
  629. return *v, true
  630. }
  631. // OldLastUsedAt returns the old "last_used_at" field's value of the APIKey entity.
  632. // If the APIKey object wasn't provided to the builder, the object is fetched from the database.
  633. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  634. func (m *APIKeyMutation) OldLastUsedAt(ctx context.Context) (v *time.Time, err error) {
  635. if !m.op.Is(OpUpdateOne) {
  636. return v, errors.New("OldLastUsedAt is only allowed on UpdateOne operations")
  637. }
  638. if m.id == nil || m.oldValue == nil {
  639. return v, errors.New("OldLastUsedAt requires an ID field in the mutation")
  640. }
  641. oldValue, err := m.oldValue(ctx)
  642. if err != nil {
  643. return v, fmt.Errorf("querying old value for OldLastUsedAt: %w", err)
  644. }
  645. return oldValue.LastUsedAt, nil
  646. }
  647. // ClearLastUsedAt clears the value of the "last_used_at" field.
  648. func (m *APIKeyMutation) ClearLastUsedAt() {
  649. m.last_used_at = nil
  650. m.clearedFields[apikey.FieldLastUsedAt] = struct{}{}
  651. }
  652. // LastUsedAtCleared returns if the "last_used_at" field was cleared in this mutation.
  653. func (m *APIKeyMutation) LastUsedAtCleared() bool {
  654. _, ok := m.clearedFields[apikey.FieldLastUsedAt]
  655. return ok
  656. }
  657. // ResetLastUsedAt resets all changes to the "last_used_at" field.
  658. func (m *APIKeyMutation) ResetLastUsedAt() {
  659. m.last_used_at = nil
  660. delete(m.clearedFields, apikey.FieldLastUsedAt)
  661. }
  662. // SetIPWhitelist sets the "ip_whitelist" field.
  663. func (m *APIKeyMutation) SetIPWhitelist(s []string) {
  664. m.ip_whitelist = &s
  665. m.appendip_whitelist = nil
  666. }
  667. // IPWhitelist returns the value of the "ip_whitelist" field in the mutation.
  668. func (m *APIKeyMutation) IPWhitelist() (r []string, exists bool) {
  669. v := m.ip_whitelist
  670. if v == nil {
  671. return
  672. }
  673. return *v, true
  674. }
  675. // OldIPWhitelist returns the old "ip_whitelist" field's value of the APIKey entity.
  676. // If the APIKey object wasn't provided to the builder, the object is fetched from the database.
  677. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  678. func (m *APIKeyMutation) OldIPWhitelist(ctx context.Context) (v []string, err error) {
  679. if !m.op.Is(OpUpdateOne) {
  680. return v, errors.New("OldIPWhitelist is only allowed on UpdateOne operations")
  681. }
  682. if m.id == nil || m.oldValue == nil {
  683. return v, errors.New("OldIPWhitelist requires an ID field in the mutation")
  684. }
  685. oldValue, err := m.oldValue(ctx)
  686. if err != nil {
  687. return v, fmt.Errorf("querying old value for OldIPWhitelist: %w", err)
  688. }
  689. return oldValue.IPWhitelist, nil
  690. }
  691. // AppendIPWhitelist adds s to the "ip_whitelist" field.
  692. func (m *APIKeyMutation) AppendIPWhitelist(s []string) {
  693. m.appendip_whitelist = append(m.appendip_whitelist, s...)
  694. }
  695. // AppendedIPWhitelist returns the list of values that were appended to the "ip_whitelist" field in this mutation.
  696. func (m *APIKeyMutation) AppendedIPWhitelist() ([]string, bool) {
  697. if len(m.appendip_whitelist) == 0 {
  698. return nil, false
  699. }
  700. return m.appendip_whitelist, true
  701. }
  702. // ClearIPWhitelist clears the value of the "ip_whitelist" field.
  703. func (m *APIKeyMutation) ClearIPWhitelist() {
  704. m.ip_whitelist = nil
  705. m.appendip_whitelist = nil
  706. m.clearedFields[apikey.FieldIPWhitelist] = struct{}{}
  707. }
  708. // IPWhitelistCleared returns if the "ip_whitelist" field was cleared in this mutation.
  709. func (m *APIKeyMutation) IPWhitelistCleared() bool {
  710. _, ok := m.clearedFields[apikey.FieldIPWhitelist]
  711. return ok
  712. }
  713. // ResetIPWhitelist resets all changes to the "ip_whitelist" field.
  714. func (m *APIKeyMutation) ResetIPWhitelist() {
  715. m.ip_whitelist = nil
  716. m.appendip_whitelist = nil
  717. delete(m.clearedFields, apikey.FieldIPWhitelist)
  718. }
  719. // SetIPBlacklist sets the "ip_blacklist" field.
  720. func (m *APIKeyMutation) SetIPBlacklist(s []string) {
  721. m.ip_blacklist = &s
  722. m.appendip_blacklist = nil
  723. }
  724. // IPBlacklist returns the value of the "ip_blacklist" field in the mutation.
  725. func (m *APIKeyMutation) IPBlacklist() (r []string, exists bool) {
  726. v := m.ip_blacklist
  727. if v == nil {
  728. return
  729. }
  730. return *v, true
  731. }
  732. // OldIPBlacklist returns the old "ip_blacklist" field's value of the APIKey entity.
  733. // If the APIKey object wasn't provided to the builder, the object is fetched from the database.
  734. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  735. func (m *APIKeyMutation) OldIPBlacklist(ctx context.Context) (v []string, err error) {
  736. if !m.op.Is(OpUpdateOne) {
  737. return v, errors.New("OldIPBlacklist is only allowed on UpdateOne operations")
  738. }
  739. if m.id == nil || m.oldValue == nil {
  740. return v, errors.New("OldIPBlacklist requires an ID field in the mutation")
  741. }
  742. oldValue, err := m.oldValue(ctx)
  743. if err != nil {
  744. return v, fmt.Errorf("querying old value for OldIPBlacklist: %w", err)
  745. }
  746. return oldValue.IPBlacklist, nil
  747. }
  748. // AppendIPBlacklist adds s to the "ip_blacklist" field.
  749. func (m *APIKeyMutation) AppendIPBlacklist(s []string) {
  750. m.appendip_blacklist = append(m.appendip_blacklist, s...)
  751. }
  752. // AppendedIPBlacklist returns the list of values that were appended to the "ip_blacklist" field in this mutation.
  753. func (m *APIKeyMutation) AppendedIPBlacklist() ([]string, bool) {
  754. if len(m.appendip_blacklist) == 0 {
  755. return nil, false
  756. }
  757. return m.appendip_blacklist, true
  758. }
  759. // ClearIPBlacklist clears the value of the "ip_blacklist" field.
  760. func (m *APIKeyMutation) ClearIPBlacklist() {
  761. m.ip_blacklist = nil
  762. m.appendip_blacklist = nil
  763. m.clearedFields[apikey.FieldIPBlacklist] = struct{}{}
  764. }
  765. // IPBlacklistCleared returns if the "ip_blacklist" field was cleared in this mutation.
  766. func (m *APIKeyMutation) IPBlacklistCleared() bool {
  767. _, ok := m.clearedFields[apikey.FieldIPBlacklist]
  768. return ok
  769. }
  770. // ResetIPBlacklist resets all changes to the "ip_blacklist" field.
  771. func (m *APIKeyMutation) ResetIPBlacklist() {
  772. m.ip_blacklist = nil
  773. m.appendip_blacklist = nil
  774. delete(m.clearedFields, apikey.FieldIPBlacklist)
  775. }
  776. // SetQuota sets the "quota" field.
  777. func (m *APIKeyMutation) SetQuota(f float64) {
  778. m.quota = &f
  779. m.addquota = nil
  780. }
  781. // Quota returns the value of the "quota" field in the mutation.
  782. func (m *APIKeyMutation) Quota() (r float64, exists bool) {
  783. v := m.quota
  784. if v == nil {
  785. return
  786. }
  787. return *v, true
  788. }
  789. // OldQuota returns the old "quota" field's value of the APIKey entity.
  790. // If the APIKey object wasn't provided to the builder, the object is fetched from the database.
  791. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  792. func (m *APIKeyMutation) OldQuota(ctx context.Context) (v float64, err error) {
  793. if !m.op.Is(OpUpdateOne) {
  794. return v, errors.New("OldQuota is only allowed on UpdateOne operations")
  795. }
  796. if m.id == nil || m.oldValue == nil {
  797. return v, errors.New("OldQuota requires an ID field in the mutation")
  798. }
  799. oldValue, err := m.oldValue(ctx)
  800. if err != nil {
  801. return v, fmt.Errorf("querying old value for OldQuota: %w", err)
  802. }
  803. return oldValue.Quota, nil
  804. }
  805. // AddQuota adds f to the "quota" field.
  806. func (m *APIKeyMutation) AddQuota(f float64) {
  807. if m.addquota != nil {
  808. *m.addquota += f
  809. } else {
  810. m.addquota = &f
  811. }
  812. }
  813. // AddedQuota returns the value that was added to the "quota" field in this mutation.
  814. func (m *APIKeyMutation) AddedQuota() (r float64, exists bool) {
  815. v := m.addquota
  816. if v == nil {
  817. return
  818. }
  819. return *v, true
  820. }
  821. // ResetQuota resets all changes to the "quota" field.
  822. func (m *APIKeyMutation) ResetQuota() {
  823. m.quota = nil
  824. m.addquota = nil
  825. }
  826. // SetQuotaUsed sets the "quota_used" field.
  827. func (m *APIKeyMutation) SetQuotaUsed(f float64) {
  828. m.quota_used = &f
  829. m.addquota_used = nil
  830. }
  831. // QuotaUsed returns the value of the "quota_used" field in the mutation.
  832. func (m *APIKeyMutation) QuotaUsed() (r float64, exists bool) {
  833. v := m.quota_used
  834. if v == nil {
  835. return
  836. }
  837. return *v, true
  838. }
  839. // OldQuotaUsed returns the old "quota_used" field's value of the APIKey entity.
  840. // If the APIKey object wasn't provided to the builder, the object is fetched from the database.
  841. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  842. func (m *APIKeyMutation) OldQuotaUsed(ctx context.Context) (v float64, err error) {
  843. if !m.op.Is(OpUpdateOne) {
  844. return v, errors.New("OldQuotaUsed is only allowed on UpdateOne operations")
  845. }
  846. if m.id == nil || m.oldValue == nil {
  847. return v, errors.New("OldQuotaUsed requires an ID field in the mutation")
  848. }
  849. oldValue, err := m.oldValue(ctx)
  850. if err != nil {
  851. return v, fmt.Errorf("querying old value for OldQuotaUsed: %w", err)
  852. }
  853. return oldValue.QuotaUsed, nil
  854. }
  855. // AddQuotaUsed adds f to the "quota_used" field.
  856. func (m *APIKeyMutation) AddQuotaUsed(f float64) {
  857. if m.addquota_used != nil {
  858. *m.addquota_used += f
  859. } else {
  860. m.addquota_used = &f
  861. }
  862. }
  863. // AddedQuotaUsed returns the value that was added to the "quota_used" field in this mutation.
  864. func (m *APIKeyMutation) AddedQuotaUsed() (r float64, exists bool) {
  865. v := m.addquota_used
  866. if v == nil {
  867. return
  868. }
  869. return *v, true
  870. }
  871. // ResetQuotaUsed resets all changes to the "quota_used" field.
  872. func (m *APIKeyMutation) ResetQuotaUsed() {
  873. m.quota_used = nil
  874. m.addquota_used = nil
  875. }
  876. // SetExpiresAt sets the "expires_at" field.
  877. func (m *APIKeyMutation) SetExpiresAt(t time.Time) {
  878. m.expires_at = &t
  879. }
  880. // ExpiresAt returns the value of the "expires_at" field in the mutation.
  881. func (m *APIKeyMutation) ExpiresAt() (r time.Time, exists bool) {
  882. v := m.expires_at
  883. if v == nil {
  884. return
  885. }
  886. return *v, true
  887. }
  888. // OldExpiresAt returns the old "expires_at" field's value of the APIKey entity.
  889. // If the APIKey object wasn't provided to the builder, the object is fetched from the database.
  890. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  891. func (m *APIKeyMutation) OldExpiresAt(ctx context.Context) (v *time.Time, err error) {
  892. if !m.op.Is(OpUpdateOne) {
  893. return v, errors.New("OldExpiresAt is only allowed on UpdateOne operations")
  894. }
  895. if m.id == nil || m.oldValue == nil {
  896. return v, errors.New("OldExpiresAt requires an ID field in the mutation")
  897. }
  898. oldValue, err := m.oldValue(ctx)
  899. if err != nil {
  900. return v, fmt.Errorf("querying old value for OldExpiresAt: %w", err)
  901. }
  902. return oldValue.ExpiresAt, nil
  903. }
  904. // ClearExpiresAt clears the value of the "expires_at" field.
  905. func (m *APIKeyMutation) ClearExpiresAt() {
  906. m.expires_at = nil
  907. m.clearedFields[apikey.FieldExpiresAt] = struct{}{}
  908. }
  909. // ExpiresAtCleared returns if the "expires_at" field was cleared in this mutation.
  910. func (m *APIKeyMutation) ExpiresAtCleared() bool {
  911. _, ok := m.clearedFields[apikey.FieldExpiresAt]
  912. return ok
  913. }
  914. // ResetExpiresAt resets all changes to the "expires_at" field.
  915. func (m *APIKeyMutation) ResetExpiresAt() {
  916. m.expires_at = nil
  917. delete(m.clearedFields, apikey.FieldExpiresAt)
  918. }
  919. // SetRateLimit5h sets the "rate_limit_5h" field.
  920. func (m *APIKeyMutation) SetRateLimit5h(f float64) {
  921. m.rate_limit_5h = &f
  922. m.addrate_limit_5h = nil
  923. }
  924. // RateLimit5h returns the value of the "rate_limit_5h" field in the mutation.
  925. func (m *APIKeyMutation) RateLimit5h() (r float64, exists bool) {
  926. v := m.rate_limit_5h
  927. if v == nil {
  928. return
  929. }
  930. return *v, true
  931. }
  932. // OldRateLimit5h returns the old "rate_limit_5h" field's value of the APIKey entity.
  933. // If the APIKey object wasn't provided to the builder, the object is fetched from the database.
  934. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  935. func (m *APIKeyMutation) OldRateLimit5h(ctx context.Context) (v float64, err error) {
  936. if !m.op.Is(OpUpdateOne) {
  937. return v, errors.New("OldRateLimit5h is only allowed on UpdateOne operations")
  938. }
  939. if m.id == nil || m.oldValue == nil {
  940. return v, errors.New("OldRateLimit5h requires an ID field in the mutation")
  941. }
  942. oldValue, err := m.oldValue(ctx)
  943. if err != nil {
  944. return v, fmt.Errorf("querying old value for OldRateLimit5h: %w", err)
  945. }
  946. return oldValue.RateLimit5h, nil
  947. }
  948. // AddRateLimit5h adds f to the "rate_limit_5h" field.
  949. func (m *APIKeyMutation) AddRateLimit5h(f float64) {
  950. if m.addrate_limit_5h != nil {
  951. *m.addrate_limit_5h += f
  952. } else {
  953. m.addrate_limit_5h = &f
  954. }
  955. }
  956. // AddedRateLimit5h returns the value that was added to the "rate_limit_5h" field in this mutation.
  957. func (m *APIKeyMutation) AddedRateLimit5h() (r float64, exists bool) {
  958. v := m.addrate_limit_5h
  959. if v == nil {
  960. return
  961. }
  962. return *v, true
  963. }
  964. // ResetRateLimit5h resets all changes to the "rate_limit_5h" field.
  965. func (m *APIKeyMutation) ResetRateLimit5h() {
  966. m.rate_limit_5h = nil
  967. m.addrate_limit_5h = nil
  968. }
  969. // SetRateLimit1d sets the "rate_limit_1d" field.
  970. func (m *APIKeyMutation) SetRateLimit1d(f float64) {
  971. m.rate_limit_1d = &f
  972. m.addrate_limit_1d = nil
  973. }
  974. // RateLimit1d returns the value of the "rate_limit_1d" field in the mutation.
  975. func (m *APIKeyMutation) RateLimit1d() (r float64, exists bool) {
  976. v := m.rate_limit_1d
  977. if v == nil {
  978. return
  979. }
  980. return *v, true
  981. }
  982. // OldRateLimit1d returns the old "rate_limit_1d" field's value of the APIKey entity.
  983. // If the APIKey object wasn't provided to the builder, the object is fetched from the database.
  984. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  985. func (m *APIKeyMutation) OldRateLimit1d(ctx context.Context) (v float64, err error) {
  986. if !m.op.Is(OpUpdateOne) {
  987. return v, errors.New("OldRateLimit1d is only allowed on UpdateOne operations")
  988. }
  989. if m.id == nil || m.oldValue == nil {
  990. return v, errors.New("OldRateLimit1d requires an ID field in the mutation")
  991. }
  992. oldValue, err := m.oldValue(ctx)
  993. if err != nil {
  994. return v, fmt.Errorf("querying old value for OldRateLimit1d: %w", err)
  995. }
  996. return oldValue.RateLimit1d, nil
  997. }
  998. // AddRateLimit1d adds f to the "rate_limit_1d" field.
  999. func (m *APIKeyMutation) AddRateLimit1d(f float64) {
  1000. if m.addrate_limit_1d != nil {
  1001. *m.addrate_limit_1d += f
  1002. } else {
  1003. m.addrate_limit_1d = &f
  1004. }
  1005. }
  1006. // AddedRateLimit1d returns the value that was added to the "rate_limit_1d" field in this mutation.
  1007. func (m *APIKeyMutation) AddedRateLimit1d() (r float64, exists bool) {
  1008. v := m.addrate_limit_1d
  1009. if v == nil {
  1010. return
  1011. }
  1012. return *v, true
  1013. }
  1014. // ResetRateLimit1d resets all changes to the "rate_limit_1d" field.
  1015. func (m *APIKeyMutation) ResetRateLimit1d() {
  1016. m.rate_limit_1d = nil
  1017. m.addrate_limit_1d = nil
  1018. }
  1019. // SetRateLimit7d sets the "rate_limit_7d" field.
  1020. func (m *APIKeyMutation) SetRateLimit7d(f float64) {
  1021. m.rate_limit_7d = &f
  1022. m.addrate_limit_7d = nil
  1023. }
  1024. // RateLimit7d returns the value of the "rate_limit_7d" field in the mutation.
  1025. func (m *APIKeyMutation) RateLimit7d() (r float64, exists bool) {
  1026. v := m.rate_limit_7d
  1027. if v == nil {
  1028. return
  1029. }
  1030. return *v, true
  1031. }
  1032. // OldRateLimit7d returns the old "rate_limit_7d" field's value of the APIKey entity.
  1033. // If the APIKey object wasn't provided to the builder, the object is fetched from the database.
  1034. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1035. func (m *APIKeyMutation) OldRateLimit7d(ctx context.Context) (v float64, err error) {
  1036. if !m.op.Is(OpUpdateOne) {
  1037. return v, errors.New("OldRateLimit7d is only allowed on UpdateOne operations")
  1038. }
  1039. if m.id == nil || m.oldValue == nil {
  1040. return v, errors.New("OldRateLimit7d requires an ID field in the mutation")
  1041. }
  1042. oldValue, err := m.oldValue(ctx)
  1043. if err != nil {
  1044. return v, fmt.Errorf("querying old value for OldRateLimit7d: %w", err)
  1045. }
  1046. return oldValue.RateLimit7d, nil
  1047. }
  1048. // AddRateLimit7d adds f to the "rate_limit_7d" field.
  1049. func (m *APIKeyMutation) AddRateLimit7d(f float64) {
  1050. if m.addrate_limit_7d != nil {
  1051. *m.addrate_limit_7d += f
  1052. } else {
  1053. m.addrate_limit_7d = &f
  1054. }
  1055. }
  1056. // AddedRateLimit7d returns the value that was added to the "rate_limit_7d" field in this mutation.
  1057. func (m *APIKeyMutation) AddedRateLimit7d() (r float64, exists bool) {
  1058. v := m.addrate_limit_7d
  1059. if v == nil {
  1060. return
  1061. }
  1062. return *v, true
  1063. }
  1064. // ResetRateLimit7d resets all changes to the "rate_limit_7d" field.
  1065. func (m *APIKeyMutation) ResetRateLimit7d() {
  1066. m.rate_limit_7d = nil
  1067. m.addrate_limit_7d = nil
  1068. }
  1069. // SetUsage5h sets the "usage_5h" field.
  1070. func (m *APIKeyMutation) SetUsage5h(f float64) {
  1071. m.usage_5h = &f
  1072. m.addusage_5h = nil
  1073. }
  1074. // Usage5h returns the value of the "usage_5h" field in the mutation.
  1075. func (m *APIKeyMutation) Usage5h() (r float64, exists bool) {
  1076. v := m.usage_5h
  1077. if v == nil {
  1078. return
  1079. }
  1080. return *v, true
  1081. }
  1082. // OldUsage5h returns the old "usage_5h" field's value of the APIKey entity.
  1083. // If the APIKey object wasn't provided to the builder, the object is fetched from the database.
  1084. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1085. func (m *APIKeyMutation) OldUsage5h(ctx context.Context) (v float64, err error) {
  1086. if !m.op.Is(OpUpdateOne) {
  1087. return v, errors.New("OldUsage5h is only allowed on UpdateOne operations")
  1088. }
  1089. if m.id == nil || m.oldValue == nil {
  1090. return v, errors.New("OldUsage5h requires an ID field in the mutation")
  1091. }
  1092. oldValue, err := m.oldValue(ctx)
  1093. if err != nil {
  1094. return v, fmt.Errorf("querying old value for OldUsage5h: %w", err)
  1095. }
  1096. return oldValue.Usage5h, nil
  1097. }
  1098. // AddUsage5h adds f to the "usage_5h" field.
  1099. func (m *APIKeyMutation) AddUsage5h(f float64) {
  1100. if m.addusage_5h != nil {
  1101. *m.addusage_5h += f
  1102. } else {
  1103. m.addusage_5h = &f
  1104. }
  1105. }
  1106. // AddedUsage5h returns the value that was added to the "usage_5h" field in this mutation.
  1107. func (m *APIKeyMutation) AddedUsage5h() (r float64, exists bool) {
  1108. v := m.addusage_5h
  1109. if v == nil {
  1110. return
  1111. }
  1112. return *v, true
  1113. }
  1114. // ResetUsage5h resets all changes to the "usage_5h" field.
  1115. func (m *APIKeyMutation) ResetUsage5h() {
  1116. m.usage_5h = nil
  1117. m.addusage_5h = nil
  1118. }
  1119. // SetUsage1d sets the "usage_1d" field.
  1120. func (m *APIKeyMutation) SetUsage1d(f float64) {
  1121. m.usage_1d = &f
  1122. m.addusage_1d = nil
  1123. }
  1124. // Usage1d returns the value of the "usage_1d" field in the mutation.
  1125. func (m *APIKeyMutation) Usage1d() (r float64, exists bool) {
  1126. v := m.usage_1d
  1127. if v == nil {
  1128. return
  1129. }
  1130. return *v, true
  1131. }
  1132. // OldUsage1d returns the old "usage_1d" field's value of the APIKey entity.
  1133. // If the APIKey object wasn't provided to the builder, the object is fetched from the database.
  1134. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1135. func (m *APIKeyMutation) OldUsage1d(ctx context.Context) (v float64, err error) {
  1136. if !m.op.Is(OpUpdateOne) {
  1137. return v, errors.New("OldUsage1d is only allowed on UpdateOne operations")
  1138. }
  1139. if m.id == nil || m.oldValue == nil {
  1140. return v, errors.New("OldUsage1d requires an ID field in the mutation")
  1141. }
  1142. oldValue, err := m.oldValue(ctx)
  1143. if err != nil {
  1144. return v, fmt.Errorf("querying old value for OldUsage1d: %w", err)
  1145. }
  1146. return oldValue.Usage1d, nil
  1147. }
  1148. // AddUsage1d adds f to the "usage_1d" field.
  1149. func (m *APIKeyMutation) AddUsage1d(f float64) {
  1150. if m.addusage_1d != nil {
  1151. *m.addusage_1d += f
  1152. } else {
  1153. m.addusage_1d = &f
  1154. }
  1155. }
  1156. // AddedUsage1d returns the value that was added to the "usage_1d" field in this mutation.
  1157. func (m *APIKeyMutation) AddedUsage1d() (r float64, exists bool) {
  1158. v := m.addusage_1d
  1159. if v == nil {
  1160. return
  1161. }
  1162. return *v, true
  1163. }
  1164. // ResetUsage1d resets all changes to the "usage_1d" field.
  1165. func (m *APIKeyMutation) ResetUsage1d() {
  1166. m.usage_1d = nil
  1167. m.addusage_1d = nil
  1168. }
  1169. // SetUsage7d sets the "usage_7d" field.
  1170. func (m *APIKeyMutation) SetUsage7d(f float64) {
  1171. m.usage_7d = &f
  1172. m.addusage_7d = nil
  1173. }
  1174. // Usage7d returns the value of the "usage_7d" field in the mutation.
  1175. func (m *APIKeyMutation) Usage7d() (r float64, exists bool) {
  1176. v := m.usage_7d
  1177. if v == nil {
  1178. return
  1179. }
  1180. return *v, true
  1181. }
  1182. // OldUsage7d returns the old "usage_7d" field's value of the APIKey entity.
  1183. // If the APIKey object wasn't provided to the builder, the object is fetched from the database.
  1184. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1185. func (m *APIKeyMutation) OldUsage7d(ctx context.Context) (v float64, err error) {
  1186. if !m.op.Is(OpUpdateOne) {
  1187. return v, errors.New("OldUsage7d is only allowed on UpdateOne operations")
  1188. }
  1189. if m.id == nil || m.oldValue == nil {
  1190. return v, errors.New("OldUsage7d requires an ID field in the mutation")
  1191. }
  1192. oldValue, err := m.oldValue(ctx)
  1193. if err != nil {
  1194. return v, fmt.Errorf("querying old value for OldUsage7d: %w", err)
  1195. }
  1196. return oldValue.Usage7d, nil
  1197. }
  1198. // AddUsage7d adds f to the "usage_7d" field.
  1199. func (m *APIKeyMutation) AddUsage7d(f float64) {
  1200. if m.addusage_7d != nil {
  1201. *m.addusage_7d += f
  1202. } else {
  1203. m.addusage_7d = &f
  1204. }
  1205. }
  1206. // AddedUsage7d returns the value that was added to the "usage_7d" field in this mutation.
  1207. func (m *APIKeyMutation) AddedUsage7d() (r float64, exists bool) {
  1208. v := m.addusage_7d
  1209. if v == nil {
  1210. return
  1211. }
  1212. return *v, true
  1213. }
  1214. // ResetUsage7d resets all changes to the "usage_7d" field.
  1215. func (m *APIKeyMutation) ResetUsage7d() {
  1216. m.usage_7d = nil
  1217. m.addusage_7d = nil
  1218. }
  1219. // SetWindow5hStart sets the "window_5h_start" field.
  1220. func (m *APIKeyMutation) SetWindow5hStart(t time.Time) {
  1221. m.window_5h_start = &t
  1222. }
  1223. // Window5hStart returns the value of the "window_5h_start" field in the mutation.
  1224. func (m *APIKeyMutation) Window5hStart() (r time.Time, exists bool) {
  1225. v := m.window_5h_start
  1226. if v == nil {
  1227. return
  1228. }
  1229. return *v, true
  1230. }
  1231. // OldWindow5hStart returns the old "window_5h_start" field's value of the APIKey entity.
  1232. // If the APIKey object wasn't provided to the builder, the object is fetched from the database.
  1233. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1234. func (m *APIKeyMutation) OldWindow5hStart(ctx context.Context) (v *time.Time, err error) {
  1235. if !m.op.Is(OpUpdateOne) {
  1236. return v, errors.New("OldWindow5hStart is only allowed on UpdateOne operations")
  1237. }
  1238. if m.id == nil || m.oldValue == nil {
  1239. return v, errors.New("OldWindow5hStart requires an ID field in the mutation")
  1240. }
  1241. oldValue, err := m.oldValue(ctx)
  1242. if err != nil {
  1243. return v, fmt.Errorf("querying old value for OldWindow5hStart: %w", err)
  1244. }
  1245. return oldValue.Window5hStart, nil
  1246. }
  1247. // ClearWindow5hStart clears the value of the "window_5h_start" field.
  1248. func (m *APIKeyMutation) ClearWindow5hStart() {
  1249. m.window_5h_start = nil
  1250. m.clearedFields[apikey.FieldWindow5hStart] = struct{}{}
  1251. }
  1252. // Window5hStartCleared returns if the "window_5h_start" field was cleared in this mutation.
  1253. func (m *APIKeyMutation) Window5hStartCleared() bool {
  1254. _, ok := m.clearedFields[apikey.FieldWindow5hStart]
  1255. return ok
  1256. }
  1257. // ResetWindow5hStart resets all changes to the "window_5h_start" field.
  1258. func (m *APIKeyMutation) ResetWindow5hStart() {
  1259. m.window_5h_start = nil
  1260. delete(m.clearedFields, apikey.FieldWindow5hStart)
  1261. }
  1262. // SetWindow1dStart sets the "window_1d_start" field.
  1263. func (m *APIKeyMutation) SetWindow1dStart(t time.Time) {
  1264. m.window_1d_start = &t
  1265. }
  1266. // Window1dStart returns the value of the "window_1d_start" field in the mutation.
  1267. func (m *APIKeyMutation) Window1dStart() (r time.Time, exists bool) {
  1268. v := m.window_1d_start
  1269. if v == nil {
  1270. return
  1271. }
  1272. return *v, true
  1273. }
  1274. // OldWindow1dStart returns the old "window_1d_start" field's value of the APIKey entity.
  1275. // If the APIKey object wasn't provided to the builder, the object is fetched from the database.
  1276. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1277. func (m *APIKeyMutation) OldWindow1dStart(ctx context.Context) (v *time.Time, err error) {
  1278. if !m.op.Is(OpUpdateOne) {
  1279. return v, errors.New("OldWindow1dStart is only allowed on UpdateOne operations")
  1280. }
  1281. if m.id == nil || m.oldValue == nil {
  1282. return v, errors.New("OldWindow1dStart requires an ID field in the mutation")
  1283. }
  1284. oldValue, err := m.oldValue(ctx)
  1285. if err != nil {
  1286. return v, fmt.Errorf("querying old value for OldWindow1dStart: %w", err)
  1287. }
  1288. return oldValue.Window1dStart, nil
  1289. }
  1290. // ClearWindow1dStart clears the value of the "window_1d_start" field.
  1291. func (m *APIKeyMutation) ClearWindow1dStart() {
  1292. m.window_1d_start = nil
  1293. m.clearedFields[apikey.FieldWindow1dStart] = struct{}{}
  1294. }
  1295. // Window1dStartCleared returns if the "window_1d_start" field was cleared in this mutation.
  1296. func (m *APIKeyMutation) Window1dStartCleared() bool {
  1297. _, ok := m.clearedFields[apikey.FieldWindow1dStart]
  1298. return ok
  1299. }
  1300. // ResetWindow1dStart resets all changes to the "window_1d_start" field.
  1301. func (m *APIKeyMutation) ResetWindow1dStart() {
  1302. m.window_1d_start = nil
  1303. delete(m.clearedFields, apikey.FieldWindow1dStart)
  1304. }
  1305. // SetWindow7dStart sets the "window_7d_start" field.
  1306. func (m *APIKeyMutation) SetWindow7dStart(t time.Time) {
  1307. m.window_7d_start = &t
  1308. }
  1309. // Window7dStart returns the value of the "window_7d_start" field in the mutation.
  1310. func (m *APIKeyMutation) Window7dStart() (r time.Time, exists bool) {
  1311. v := m.window_7d_start
  1312. if v == nil {
  1313. return
  1314. }
  1315. return *v, true
  1316. }
  1317. // OldWindow7dStart returns the old "window_7d_start" field's value of the APIKey entity.
  1318. // If the APIKey object wasn't provided to the builder, the object is fetched from the database.
  1319. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1320. func (m *APIKeyMutation) OldWindow7dStart(ctx context.Context) (v *time.Time, err error) {
  1321. if !m.op.Is(OpUpdateOne) {
  1322. return v, errors.New("OldWindow7dStart is only allowed on UpdateOne operations")
  1323. }
  1324. if m.id == nil || m.oldValue == nil {
  1325. return v, errors.New("OldWindow7dStart requires an ID field in the mutation")
  1326. }
  1327. oldValue, err := m.oldValue(ctx)
  1328. if err != nil {
  1329. return v, fmt.Errorf("querying old value for OldWindow7dStart: %w", err)
  1330. }
  1331. return oldValue.Window7dStart, nil
  1332. }
  1333. // ClearWindow7dStart clears the value of the "window_7d_start" field.
  1334. func (m *APIKeyMutation) ClearWindow7dStart() {
  1335. m.window_7d_start = nil
  1336. m.clearedFields[apikey.FieldWindow7dStart] = struct{}{}
  1337. }
  1338. // Window7dStartCleared returns if the "window_7d_start" field was cleared in this mutation.
  1339. func (m *APIKeyMutation) Window7dStartCleared() bool {
  1340. _, ok := m.clearedFields[apikey.FieldWindow7dStart]
  1341. return ok
  1342. }
  1343. // ResetWindow7dStart resets all changes to the "window_7d_start" field.
  1344. func (m *APIKeyMutation) ResetWindow7dStart() {
  1345. m.window_7d_start = nil
  1346. delete(m.clearedFields, apikey.FieldWindow7dStart)
  1347. }
  1348. // ClearUser clears the "user" edge to the User entity.
  1349. func (m *APIKeyMutation) ClearUser() {
  1350. m.cleareduser = true
  1351. m.clearedFields[apikey.FieldUserID] = struct{}{}
  1352. }
  1353. // UserCleared reports if the "user" edge to the User entity was cleared.
  1354. func (m *APIKeyMutation) UserCleared() bool {
  1355. return m.cleareduser
  1356. }
  1357. // UserIDs returns the "user" edge IDs in the mutation.
  1358. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  1359. // UserID instead. It exists only for internal usage by the builders.
  1360. func (m *APIKeyMutation) UserIDs() (ids []int64) {
  1361. if id := m.user; id != nil {
  1362. ids = append(ids, *id)
  1363. }
  1364. return
  1365. }
  1366. // ResetUser resets all changes to the "user" edge.
  1367. func (m *APIKeyMutation) ResetUser() {
  1368. m.user = nil
  1369. m.cleareduser = false
  1370. }
  1371. // ClearGroup clears the "group" edge to the Group entity.
  1372. func (m *APIKeyMutation) ClearGroup() {
  1373. m.clearedgroup = true
  1374. m.clearedFields[apikey.FieldGroupID] = struct{}{}
  1375. }
  1376. // GroupCleared reports if the "group" edge to the Group entity was cleared.
  1377. func (m *APIKeyMutation) GroupCleared() bool {
  1378. return m.GroupIDCleared() || m.clearedgroup
  1379. }
  1380. // GroupIDs returns the "group" edge IDs in the mutation.
  1381. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  1382. // GroupID instead. It exists only for internal usage by the builders.
  1383. func (m *APIKeyMutation) GroupIDs() (ids []int64) {
  1384. if id := m.group; id != nil {
  1385. ids = append(ids, *id)
  1386. }
  1387. return
  1388. }
  1389. // ResetGroup resets all changes to the "group" edge.
  1390. func (m *APIKeyMutation) ResetGroup() {
  1391. m.group = nil
  1392. m.clearedgroup = false
  1393. }
  1394. // AddUsageLogIDs adds the "usage_logs" edge to the UsageLog entity by ids.
  1395. func (m *APIKeyMutation) AddUsageLogIDs(ids ...int64) {
  1396. if m.usage_logs == nil {
  1397. m.usage_logs = make(map[int64]struct{})
  1398. }
  1399. for i := range ids {
  1400. m.usage_logs[ids[i]] = struct{}{}
  1401. }
  1402. }
  1403. // ClearUsageLogs clears the "usage_logs" edge to the UsageLog entity.
  1404. func (m *APIKeyMutation) ClearUsageLogs() {
  1405. m.clearedusage_logs = true
  1406. }
  1407. // UsageLogsCleared reports if the "usage_logs" edge to the UsageLog entity was cleared.
  1408. func (m *APIKeyMutation) UsageLogsCleared() bool {
  1409. return m.clearedusage_logs
  1410. }
  1411. // RemoveUsageLogIDs removes the "usage_logs" edge to the UsageLog entity by IDs.
  1412. func (m *APIKeyMutation) RemoveUsageLogIDs(ids ...int64) {
  1413. if m.removedusage_logs == nil {
  1414. m.removedusage_logs = make(map[int64]struct{})
  1415. }
  1416. for i := range ids {
  1417. delete(m.usage_logs, ids[i])
  1418. m.removedusage_logs[ids[i]] = struct{}{}
  1419. }
  1420. }
  1421. // RemovedUsageLogs returns the removed IDs of the "usage_logs" edge to the UsageLog entity.
  1422. func (m *APIKeyMutation) RemovedUsageLogsIDs() (ids []int64) {
  1423. for id := range m.removedusage_logs {
  1424. ids = append(ids, id)
  1425. }
  1426. return
  1427. }
  1428. // UsageLogsIDs returns the "usage_logs" edge IDs in the mutation.
  1429. func (m *APIKeyMutation) UsageLogsIDs() (ids []int64) {
  1430. for id := range m.usage_logs {
  1431. ids = append(ids, id)
  1432. }
  1433. return
  1434. }
  1435. // ResetUsageLogs resets all changes to the "usage_logs" edge.
  1436. func (m *APIKeyMutation) ResetUsageLogs() {
  1437. m.usage_logs = nil
  1438. m.clearedusage_logs = false
  1439. m.removedusage_logs = nil
  1440. }
  1441. // Where appends a list predicates to the APIKeyMutation builder.
  1442. func (m *APIKeyMutation) Where(ps ...predicate.APIKey) {
  1443. m.predicates = append(m.predicates, ps...)
  1444. }
  1445. // WhereP appends storage-level predicates to the APIKeyMutation builder. Using this method,
  1446. // users can use type-assertion to append predicates that do not depend on any generated package.
  1447. func (m *APIKeyMutation) WhereP(ps ...func(*sql.Selector)) {
  1448. p := make([]predicate.APIKey, len(ps))
  1449. for i := range ps {
  1450. p[i] = ps[i]
  1451. }
  1452. m.Where(p...)
  1453. }
  1454. // Op returns the operation name.
  1455. func (m *APIKeyMutation) Op() Op {
  1456. return m.op
  1457. }
  1458. // SetOp allows setting the mutation operation.
  1459. func (m *APIKeyMutation) SetOp(op Op) {
  1460. m.op = op
  1461. }
  1462. // Type returns the node type of this mutation (APIKey).
  1463. func (m *APIKeyMutation) Type() string {
  1464. return m.typ
  1465. }
  1466. // Fields returns all fields that were changed during this mutation. Note that in
  1467. // order to get all numeric fields that were incremented/decremented, call
  1468. // AddedFields().
  1469. func (m *APIKeyMutation) Fields() []string {
  1470. fields := make([]string, 0, 25)
  1471. if m.created_at != nil {
  1472. fields = append(fields, apikey.FieldCreatedAt)
  1473. }
  1474. if m.updated_at != nil {
  1475. fields = append(fields, apikey.FieldUpdatedAt)
  1476. }
  1477. if m.deleted_at != nil {
  1478. fields = append(fields, apikey.FieldDeletedAt)
  1479. }
  1480. if m.user != nil {
  1481. fields = append(fields, apikey.FieldUserID)
  1482. }
  1483. if m.key != nil {
  1484. fields = append(fields, apikey.FieldKey)
  1485. }
  1486. if m.key_hash != nil {
  1487. fields = append(fields, apikey.FieldKeyHash)
  1488. }
  1489. if m.key_prefix != nil {
  1490. fields = append(fields, apikey.FieldKeyPrefix)
  1491. }
  1492. if m.name != nil {
  1493. fields = append(fields, apikey.FieldName)
  1494. }
  1495. if m.group != nil {
  1496. fields = append(fields, apikey.FieldGroupID)
  1497. }
  1498. if m.status != nil {
  1499. fields = append(fields, apikey.FieldStatus)
  1500. }
  1501. if m.last_used_at != nil {
  1502. fields = append(fields, apikey.FieldLastUsedAt)
  1503. }
  1504. if m.ip_whitelist != nil {
  1505. fields = append(fields, apikey.FieldIPWhitelist)
  1506. }
  1507. if m.ip_blacklist != nil {
  1508. fields = append(fields, apikey.FieldIPBlacklist)
  1509. }
  1510. if m.quota != nil {
  1511. fields = append(fields, apikey.FieldQuota)
  1512. }
  1513. if m.quota_used != nil {
  1514. fields = append(fields, apikey.FieldQuotaUsed)
  1515. }
  1516. if m.expires_at != nil {
  1517. fields = append(fields, apikey.FieldExpiresAt)
  1518. }
  1519. if m.rate_limit_5h != nil {
  1520. fields = append(fields, apikey.FieldRateLimit5h)
  1521. }
  1522. if m.rate_limit_1d != nil {
  1523. fields = append(fields, apikey.FieldRateLimit1d)
  1524. }
  1525. if m.rate_limit_7d != nil {
  1526. fields = append(fields, apikey.FieldRateLimit7d)
  1527. }
  1528. if m.usage_5h != nil {
  1529. fields = append(fields, apikey.FieldUsage5h)
  1530. }
  1531. if m.usage_1d != nil {
  1532. fields = append(fields, apikey.FieldUsage1d)
  1533. }
  1534. if m.usage_7d != nil {
  1535. fields = append(fields, apikey.FieldUsage7d)
  1536. }
  1537. if m.window_5h_start != nil {
  1538. fields = append(fields, apikey.FieldWindow5hStart)
  1539. }
  1540. if m.window_1d_start != nil {
  1541. fields = append(fields, apikey.FieldWindow1dStart)
  1542. }
  1543. if m.window_7d_start != nil {
  1544. fields = append(fields, apikey.FieldWindow7dStart)
  1545. }
  1546. return fields
  1547. }
  1548. // Field returns the value of a field with the given name. The second boolean
  1549. // return value indicates that this field was not set, or was not defined in the
  1550. // schema.
  1551. func (m *APIKeyMutation) Field(name string) (ent.Value, bool) {
  1552. switch name {
  1553. case apikey.FieldCreatedAt:
  1554. return m.CreatedAt()
  1555. case apikey.FieldUpdatedAt:
  1556. return m.UpdatedAt()
  1557. case apikey.FieldDeletedAt:
  1558. return m.DeletedAt()
  1559. case apikey.FieldUserID:
  1560. return m.UserID()
  1561. case apikey.FieldKey:
  1562. return m.Key()
  1563. case apikey.FieldKeyHash:
  1564. return m.KeyHash()
  1565. case apikey.FieldKeyPrefix:
  1566. return m.KeyPrefix()
  1567. case apikey.FieldName:
  1568. return m.Name()
  1569. case apikey.FieldGroupID:
  1570. return m.GroupID()
  1571. case apikey.FieldStatus:
  1572. return m.Status()
  1573. case apikey.FieldLastUsedAt:
  1574. return m.LastUsedAt()
  1575. case apikey.FieldIPWhitelist:
  1576. return m.IPWhitelist()
  1577. case apikey.FieldIPBlacklist:
  1578. return m.IPBlacklist()
  1579. case apikey.FieldQuota:
  1580. return m.Quota()
  1581. case apikey.FieldQuotaUsed:
  1582. return m.QuotaUsed()
  1583. case apikey.FieldExpiresAt:
  1584. return m.ExpiresAt()
  1585. case apikey.FieldRateLimit5h:
  1586. return m.RateLimit5h()
  1587. case apikey.FieldRateLimit1d:
  1588. return m.RateLimit1d()
  1589. case apikey.FieldRateLimit7d:
  1590. return m.RateLimit7d()
  1591. case apikey.FieldUsage5h:
  1592. return m.Usage5h()
  1593. case apikey.FieldUsage1d:
  1594. return m.Usage1d()
  1595. case apikey.FieldUsage7d:
  1596. return m.Usage7d()
  1597. case apikey.FieldWindow5hStart:
  1598. return m.Window5hStart()
  1599. case apikey.FieldWindow1dStart:
  1600. return m.Window1dStart()
  1601. case apikey.FieldWindow7dStart:
  1602. return m.Window7dStart()
  1603. }
  1604. return nil, false
  1605. }
  1606. // OldField returns the old value of the field from the database. An error is
  1607. // returned if the mutation operation is not UpdateOne, or the query to the
  1608. // database failed.
  1609. func (m *APIKeyMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  1610. switch name {
  1611. case apikey.FieldCreatedAt:
  1612. return m.OldCreatedAt(ctx)
  1613. case apikey.FieldUpdatedAt:
  1614. return m.OldUpdatedAt(ctx)
  1615. case apikey.FieldDeletedAt:
  1616. return m.OldDeletedAt(ctx)
  1617. case apikey.FieldUserID:
  1618. return m.OldUserID(ctx)
  1619. case apikey.FieldKey:
  1620. return m.OldKey(ctx)
  1621. case apikey.FieldKeyHash:
  1622. return m.OldKeyHash(ctx)
  1623. case apikey.FieldKeyPrefix:
  1624. return m.OldKeyPrefix(ctx)
  1625. case apikey.FieldName:
  1626. return m.OldName(ctx)
  1627. case apikey.FieldGroupID:
  1628. return m.OldGroupID(ctx)
  1629. case apikey.FieldStatus:
  1630. return m.OldStatus(ctx)
  1631. case apikey.FieldLastUsedAt:
  1632. return m.OldLastUsedAt(ctx)
  1633. case apikey.FieldIPWhitelist:
  1634. return m.OldIPWhitelist(ctx)
  1635. case apikey.FieldIPBlacklist:
  1636. return m.OldIPBlacklist(ctx)
  1637. case apikey.FieldQuota:
  1638. return m.OldQuota(ctx)
  1639. case apikey.FieldQuotaUsed:
  1640. return m.OldQuotaUsed(ctx)
  1641. case apikey.FieldExpiresAt:
  1642. return m.OldExpiresAt(ctx)
  1643. case apikey.FieldRateLimit5h:
  1644. return m.OldRateLimit5h(ctx)
  1645. case apikey.FieldRateLimit1d:
  1646. return m.OldRateLimit1d(ctx)
  1647. case apikey.FieldRateLimit7d:
  1648. return m.OldRateLimit7d(ctx)
  1649. case apikey.FieldUsage5h:
  1650. return m.OldUsage5h(ctx)
  1651. case apikey.FieldUsage1d:
  1652. return m.OldUsage1d(ctx)
  1653. case apikey.FieldUsage7d:
  1654. return m.OldUsage7d(ctx)
  1655. case apikey.FieldWindow5hStart:
  1656. return m.OldWindow5hStart(ctx)
  1657. case apikey.FieldWindow1dStart:
  1658. return m.OldWindow1dStart(ctx)
  1659. case apikey.FieldWindow7dStart:
  1660. return m.OldWindow7dStart(ctx)
  1661. }
  1662. return nil, fmt.Errorf("unknown APIKey field %s", name)
  1663. }
  1664. // SetField sets the value of a field with the given name. It returns an error if
  1665. // the field is not defined in the schema, or if the type mismatched the field
  1666. // type.
  1667. func (m *APIKeyMutation) SetField(name string, value ent.Value) error {
  1668. switch name {
  1669. case apikey.FieldCreatedAt:
  1670. v, ok := value.(time.Time)
  1671. if !ok {
  1672. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1673. }
  1674. m.SetCreatedAt(v)
  1675. return nil
  1676. case apikey.FieldUpdatedAt:
  1677. v, ok := value.(time.Time)
  1678. if !ok {
  1679. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1680. }
  1681. m.SetUpdatedAt(v)
  1682. return nil
  1683. case apikey.FieldDeletedAt:
  1684. v, ok := value.(time.Time)
  1685. if !ok {
  1686. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1687. }
  1688. m.SetDeletedAt(v)
  1689. return nil
  1690. case apikey.FieldUserID:
  1691. v, ok := value.(int64)
  1692. if !ok {
  1693. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1694. }
  1695. m.SetUserID(v)
  1696. return nil
  1697. case apikey.FieldKey:
  1698. v, ok := value.(string)
  1699. if !ok {
  1700. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1701. }
  1702. m.SetKey(v)
  1703. return nil
  1704. case apikey.FieldKeyHash:
  1705. v, ok := value.(string)
  1706. if !ok {
  1707. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1708. }
  1709. m.SetKeyHash(v)
  1710. return nil
  1711. case apikey.FieldKeyPrefix:
  1712. v, ok := value.(string)
  1713. if !ok {
  1714. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1715. }
  1716. m.SetKeyPrefix(v)
  1717. return nil
  1718. case apikey.FieldName:
  1719. v, ok := value.(string)
  1720. if !ok {
  1721. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1722. }
  1723. m.SetName(v)
  1724. return nil
  1725. case apikey.FieldGroupID:
  1726. v, ok := value.(int64)
  1727. if !ok {
  1728. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1729. }
  1730. m.SetGroupID(v)
  1731. return nil
  1732. case apikey.FieldStatus:
  1733. v, ok := value.(string)
  1734. if !ok {
  1735. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1736. }
  1737. m.SetStatus(v)
  1738. return nil
  1739. case apikey.FieldLastUsedAt:
  1740. v, ok := value.(time.Time)
  1741. if !ok {
  1742. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1743. }
  1744. m.SetLastUsedAt(v)
  1745. return nil
  1746. case apikey.FieldIPWhitelist:
  1747. v, ok := value.([]string)
  1748. if !ok {
  1749. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1750. }
  1751. m.SetIPWhitelist(v)
  1752. return nil
  1753. case apikey.FieldIPBlacklist:
  1754. v, ok := value.([]string)
  1755. if !ok {
  1756. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1757. }
  1758. m.SetIPBlacklist(v)
  1759. return nil
  1760. case apikey.FieldQuota:
  1761. v, ok := value.(float64)
  1762. if !ok {
  1763. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1764. }
  1765. m.SetQuota(v)
  1766. return nil
  1767. case apikey.FieldQuotaUsed:
  1768. v, ok := value.(float64)
  1769. if !ok {
  1770. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1771. }
  1772. m.SetQuotaUsed(v)
  1773. return nil
  1774. case apikey.FieldExpiresAt:
  1775. v, ok := value.(time.Time)
  1776. if !ok {
  1777. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1778. }
  1779. m.SetExpiresAt(v)
  1780. return nil
  1781. case apikey.FieldRateLimit5h:
  1782. v, ok := value.(float64)
  1783. if !ok {
  1784. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1785. }
  1786. m.SetRateLimit5h(v)
  1787. return nil
  1788. case apikey.FieldRateLimit1d:
  1789. v, ok := value.(float64)
  1790. if !ok {
  1791. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1792. }
  1793. m.SetRateLimit1d(v)
  1794. return nil
  1795. case apikey.FieldRateLimit7d:
  1796. v, ok := value.(float64)
  1797. if !ok {
  1798. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1799. }
  1800. m.SetRateLimit7d(v)
  1801. return nil
  1802. case apikey.FieldUsage5h:
  1803. v, ok := value.(float64)
  1804. if !ok {
  1805. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1806. }
  1807. m.SetUsage5h(v)
  1808. return nil
  1809. case apikey.FieldUsage1d:
  1810. v, ok := value.(float64)
  1811. if !ok {
  1812. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1813. }
  1814. m.SetUsage1d(v)
  1815. return nil
  1816. case apikey.FieldUsage7d:
  1817. v, ok := value.(float64)
  1818. if !ok {
  1819. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1820. }
  1821. m.SetUsage7d(v)
  1822. return nil
  1823. case apikey.FieldWindow5hStart:
  1824. v, ok := value.(time.Time)
  1825. if !ok {
  1826. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1827. }
  1828. m.SetWindow5hStart(v)
  1829. return nil
  1830. case apikey.FieldWindow1dStart:
  1831. v, ok := value.(time.Time)
  1832. if !ok {
  1833. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1834. }
  1835. m.SetWindow1dStart(v)
  1836. return nil
  1837. case apikey.FieldWindow7dStart:
  1838. v, ok := value.(time.Time)
  1839. if !ok {
  1840. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1841. }
  1842. m.SetWindow7dStart(v)
  1843. return nil
  1844. }
  1845. return fmt.Errorf("unknown APIKey field %s", name)
  1846. }
  1847. // AddedFields returns all numeric fields that were incremented/decremented during
  1848. // this mutation.
  1849. func (m *APIKeyMutation) AddedFields() []string {
  1850. var fields []string
  1851. if m.addquota != nil {
  1852. fields = append(fields, apikey.FieldQuota)
  1853. }
  1854. if m.addquota_used != nil {
  1855. fields = append(fields, apikey.FieldQuotaUsed)
  1856. }
  1857. if m.addrate_limit_5h != nil {
  1858. fields = append(fields, apikey.FieldRateLimit5h)
  1859. }
  1860. if m.addrate_limit_1d != nil {
  1861. fields = append(fields, apikey.FieldRateLimit1d)
  1862. }
  1863. if m.addrate_limit_7d != nil {
  1864. fields = append(fields, apikey.FieldRateLimit7d)
  1865. }
  1866. if m.addusage_5h != nil {
  1867. fields = append(fields, apikey.FieldUsage5h)
  1868. }
  1869. if m.addusage_1d != nil {
  1870. fields = append(fields, apikey.FieldUsage1d)
  1871. }
  1872. if m.addusage_7d != nil {
  1873. fields = append(fields, apikey.FieldUsage7d)
  1874. }
  1875. return fields
  1876. }
  1877. // AddedField returns the numeric value that was incremented/decremented on a field
  1878. // with the given name. The second boolean return value indicates that this field
  1879. // was not set, or was not defined in the schema.
  1880. func (m *APIKeyMutation) AddedField(name string) (ent.Value, bool) {
  1881. switch name {
  1882. case apikey.FieldQuota:
  1883. return m.AddedQuota()
  1884. case apikey.FieldQuotaUsed:
  1885. return m.AddedQuotaUsed()
  1886. case apikey.FieldRateLimit5h:
  1887. return m.AddedRateLimit5h()
  1888. case apikey.FieldRateLimit1d:
  1889. return m.AddedRateLimit1d()
  1890. case apikey.FieldRateLimit7d:
  1891. return m.AddedRateLimit7d()
  1892. case apikey.FieldUsage5h:
  1893. return m.AddedUsage5h()
  1894. case apikey.FieldUsage1d:
  1895. return m.AddedUsage1d()
  1896. case apikey.FieldUsage7d:
  1897. return m.AddedUsage7d()
  1898. }
  1899. return nil, false
  1900. }
  1901. // AddField adds the value to the field with the given name. It returns an error if
  1902. // the field is not defined in the schema, or if the type mismatched the field
  1903. // type.
  1904. func (m *APIKeyMutation) AddField(name string, value ent.Value) error {
  1905. switch name {
  1906. case apikey.FieldQuota:
  1907. v, ok := value.(float64)
  1908. if !ok {
  1909. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1910. }
  1911. m.AddQuota(v)
  1912. return nil
  1913. case apikey.FieldQuotaUsed:
  1914. v, ok := value.(float64)
  1915. if !ok {
  1916. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1917. }
  1918. m.AddQuotaUsed(v)
  1919. return nil
  1920. case apikey.FieldRateLimit5h:
  1921. v, ok := value.(float64)
  1922. if !ok {
  1923. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1924. }
  1925. m.AddRateLimit5h(v)
  1926. return nil
  1927. case apikey.FieldRateLimit1d:
  1928. v, ok := value.(float64)
  1929. if !ok {
  1930. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1931. }
  1932. m.AddRateLimit1d(v)
  1933. return nil
  1934. case apikey.FieldRateLimit7d:
  1935. v, ok := value.(float64)
  1936. if !ok {
  1937. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1938. }
  1939. m.AddRateLimit7d(v)
  1940. return nil
  1941. case apikey.FieldUsage5h:
  1942. v, ok := value.(float64)
  1943. if !ok {
  1944. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1945. }
  1946. m.AddUsage5h(v)
  1947. return nil
  1948. case apikey.FieldUsage1d:
  1949. v, ok := value.(float64)
  1950. if !ok {
  1951. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1952. }
  1953. m.AddUsage1d(v)
  1954. return nil
  1955. case apikey.FieldUsage7d:
  1956. v, ok := value.(float64)
  1957. if !ok {
  1958. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1959. }
  1960. m.AddUsage7d(v)
  1961. return nil
  1962. }
  1963. return fmt.Errorf("unknown APIKey numeric field %s", name)
  1964. }
  1965. // ClearedFields returns all nullable fields that were cleared during this
  1966. // mutation.
  1967. func (m *APIKeyMutation) ClearedFields() []string {
  1968. var fields []string
  1969. if m.FieldCleared(apikey.FieldDeletedAt) {
  1970. fields = append(fields, apikey.FieldDeletedAt)
  1971. }
  1972. if m.FieldCleared(apikey.FieldKey) {
  1973. fields = append(fields, apikey.FieldKey)
  1974. }
  1975. if m.FieldCleared(apikey.FieldKeyHash) {
  1976. fields = append(fields, apikey.FieldKeyHash)
  1977. }
  1978. if m.FieldCleared(apikey.FieldKeyPrefix) {
  1979. fields = append(fields, apikey.FieldKeyPrefix)
  1980. }
  1981. if m.FieldCleared(apikey.FieldGroupID) {
  1982. fields = append(fields, apikey.FieldGroupID)
  1983. }
  1984. if m.FieldCleared(apikey.FieldLastUsedAt) {
  1985. fields = append(fields, apikey.FieldLastUsedAt)
  1986. }
  1987. if m.FieldCleared(apikey.FieldIPWhitelist) {
  1988. fields = append(fields, apikey.FieldIPWhitelist)
  1989. }
  1990. if m.FieldCleared(apikey.FieldIPBlacklist) {
  1991. fields = append(fields, apikey.FieldIPBlacklist)
  1992. }
  1993. if m.FieldCleared(apikey.FieldExpiresAt) {
  1994. fields = append(fields, apikey.FieldExpiresAt)
  1995. }
  1996. if m.FieldCleared(apikey.FieldWindow5hStart) {
  1997. fields = append(fields, apikey.FieldWindow5hStart)
  1998. }
  1999. if m.FieldCleared(apikey.FieldWindow1dStart) {
  2000. fields = append(fields, apikey.FieldWindow1dStart)
  2001. }
  2002. if m.FieldCleared(apikey.FieldWindow7dStart) {
  2003. fields = append(fields, apikey.FieldWindow7dStart)
  2004. }
  2005. return fields
  2006. }
  2007. // FieldCleared returns a boolean indicating if a field with the given name was
  2008. // cleared in this mutation.
  2009. func (m *APIKeyMutation) FieldCleared(name string) bool {
  2010. _, ok := m.clearedFields[name]
  2011. return ok
  2012. }
  2013. // ClearField clears the value of the field with the given name. It returns an
  2014. // error if the field is not defined in the schema.
  2015. func (m *APIKeyMutation) ClearField(name string) error {
  2016. switch name {
  2017. case apikey.FieldDeletedAt:
  2018. m.ClearDeletedAt()
  2019. return nil
  2020. case apikey.FieldKey:
  2021. m.ClearKey()
  2022. return nil
  2023. case apikey.FieldKeyHash:
  2024. m.ClearKeyHash()
  2025. return nil
  2026. case apikey.FieldKeyPrefix:
  2027. m.ClearKeyPrefix()
  2028. return nil
  2029. case apikey.FieldGroupID:
  2030. m.ClearGroupID()
  2031. return nil
  2032. case apikey.FieldLastUsedAt:
  2033. m.ClearLastUsedAt()
  2034. return nil
  2035. case apikey.FieldIPWhitelist:
  2036. m.ClearIPWhitelist()
  2037. return nil
  2038. case apikey.FieldIPBlacklist:
  2039. m.ClearIPBlacklist()
  2040. return nil
  2041. case apikey.FieldExpiresAt:
  2042. m.ClearExpiresAt()
  2043. return nil
  2044. case apikey.FieldWindow5hStart:
  2045. m.ClearWindow5hStart()
  2046. return nil
  2047. case apikey.FieldWindow1dStart:
  2048. m.ClearWindow1dStart()
  2049. return nil
  2050. case apikey.FieldWindow7dStart:
  2051. m.ClearWindow7dStart()
  2052. return nil
  2053. }
  2054. return fmt.Errorf("unknown APIKey nullable field %s", name)
  2055. }
  2056. // ResetField resets all changes in the mutation for the field with the given name.
  2057. // It returns an error if the field is not defined in the schema.
  2058. func (m *APIKeyMutation) ResetField(name string) error {
  2059. switch name {
  2060. case apikey.FieldCreatedAt:
  2061. m.ResetCreatedAt()
  2062. return nil
  2063. case apikey.FieldUpdatedAt:
  2064. m.ResetUpdatedAt()
  2065. return nil
  2066. case apikey.FieldDeletedAt:
  2067. m.ResetDeletedAt()
  2068. return nil
  2069. case apikey.FieldUserID:
  2070. m.ResetUserID()
  2071. return nil
  2072. case apikey.FieldKey:
  2073. m.ResetKey()
  2074. return nil
  2075. case apikey.FieldKeyHash:
  2076. m.ResetKeyHash()
  2077. return nil
  2078. case apikey.FieldKeyPrefix:
  2079. m.ResetKeyPrefix()
  2080. return nil
  2081. case apikey.FieldName:
  2082. m.ResetName()
  2083. return nil
  2084. case apikey.FieldGroupID:
  2085. m.ResetGroupID()
  2086. return nil
  2087. case apikey.FieldStatus:
  2088. m.ResetStatus()
  2089. return nil
  2090. case apikey.FieldLastUsedAt:
  2091. m.ResetLastUsedAt()
  2092. return nil
  2093. case apikey.FieldIPWhitelist:
  2094. m.ResetIPWhitelist()
  2095. return nil
  2096. case apikey.FieldIPBlacklist:
  2097. m.ResetIPBlacklist()
  2098. return nil
  2099. case apikey.FieldQuota:
  2100. m.ResetQuota()
  2101. return nil
  2102. case apikey.FieldQuotaUsed:
  2103. m.ResetQuotaUsed()
  2104. return nil
  2105. case apikey.FieldExpiresAt:
  2106. m.ResetExpiresAt()
  2107. return nil
  2108. case apikey.FieldRateLimit5h:
  2109. m.ResetRateLimit5h()
  2110. return nil
  2111. case apikey.FieldRateLimit1d:
  2112. m.ResetRateLimit1d()
  2113. return nil
  2114. case apikey.FieldRateLimit7d:
  2115. m.ResetRateLimit7d()
  2116. return nil
  2117. case apikey.FieldUsage5h:
  2118. m.ResetUsage5h()
  2119. return nil
  2120. case apikey.FieldUsage1d:
  2121. m.ResetUsage1d()
  2122. return nil
  2123. case apikey.FieldUsage7d:
  2124. m.ResetUsage7d()
  2125. return nil
  2126. case apikey.FieldWindow5hStart:
  2127. m.ResetWindow5hStart()
  2128. return nil
  2129. case apikey.FieldWindow1dStart:
  2130. m.ResetWindow1dStart()
  2131. return nil
  2132. case apikey.FieldWindow7dStart:
  2133. m.ResetWindow7dStart()
  2134. return nil
  2135. }
  2136. return fmt.Errorf("unknown APIKey field %s", name)
  2137. }
  2138. // AddedEdges returns all edge names that were set/added in this mutation.
  2139. func (m *APIKeyMutation) AddedEdges() []string {
  2140. edges := make([]string, 0, 3)
  2141. if m.user != nil {
  2142. edges = append(edges, apikey.EdgeUser)
  2143. }
  2144. if m.group != nil {
  2145. edges = append(edges, apikey.EdgeGroup)
  2146. }
  2147. if m.usage_logs != nil {
  2148. edges = append(edges, apikey.EdgeUsageLogs)
  2149. }
  2150. return edges
  2151. }
  2152. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  2153. // name in this mutation.
  2154. func (m *APIKeyMutation) AddedIDs(name string) []ent.Value {
  2155. switch name {
  2156. case apikey.EdgeUser:
  2157. if id := m.user; id != nil {
  2158. return []ent.Value{*id}
  2159. }
  2160. case apikey.EdgeGroup:
  2161. if id := m.group; id != nil {
  2162. return []ent.Value{*id}
  2163. }
  2164. case apikey.EdgeUsageLogs:
  2165. ids := make([]ent.Value, 0, len(m.usage_logs))
  2166. for id := range m.usage_logs {
  2167. ids = append(ids, id)
  2168. }
  2169. return ids
  2170. }
  2171. return nil
  2172. }
  2173. // RemovedEdges returns all edge names that were removed in this mutation.
  2174. func (m *APIKeyMutation) RemovedEdges() []string {
  2175. edges := make([]string, 0, 3)
  2176. if m.removedusage_logs != nil {
  2177. edges = append(edges, apikey.EdgeUsageLogs)
  2178. }
  2179. return edges
  2180. }
  2181. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  2182. // the given name in this mutation.
  2183. func (m *APIKeyMutation) RemovedIDs(name string) []ent.Value {
  2184. switch name {
  2185. case apikey.EdgeUsageLogs:
  2186. ids := make([]ent.Value, 0, len(m.removedusage_logs))
  2187. for id := range m.removedusage_logs {
  2188. ids = append(ids, id)
  2189. }
  2190. return ids
  2191. }
  2192. return nil
  2193. }
  2194. // ClearedEdges returns all edge names that were cleared in this mutation.
  2195. func (m *APIKeyMutation) ClearedEdges() []string {
  2196. edges := make([]string, 0, 3)
  2197. if m.cleareduser {
  2198. edges = append(edges, apikey.EdgeUser)
  2199. }
  2200. if m.clearedgroup {
  2201. edges = append(edges, apikey.EdgeGroup)
  2202. }
  2203. if m.clearedusage_logs {
  2204. edges = append(edges, apikey.EdgeUsageLogs)
  2205. }
  2206. return edges
  2207. }
  2208. // EdgeCleared returns a boolean which indicates if the edge with the given name
  2209. // was cleared in this mutation.
  2210. func (m *APIKeyMutation) EdgeCleared(name string) bool {
  2211. switch name {
  2212. case apikey.EdgeUser:
  2213. return m.cleareduser
  2214. case apikey.EdgeGroup:
  2215. return m.clearedgroup
  2216. case apikey.EdgeUsageLogs:
  2217. return m.clearedusage_logs
  2218. }
  2219. return false
  2220. }
  2221. // ClearEdge clears the value of the edge with the given name. It returns an error
  2222. // if that edge is not defined in the schema.
  2223. func (m *APIKeyMutation) ClearEdge(name string) error {
  2224. switch name {
  2225. case apikey.EdgeUser:
  2226. m.ClearUser()
  2227. return nil
  2228. case apikey.EdgeGroup:
  2229. m.ClearGroup()
  2230. return nil
  2231. }
  2232. return fmt.Errorf("unknown APIKey unique edge %s", name)
  2233. }
  2234. // ResetEdge resets all changes to the edge with the given name in this mutation.
  2235. // It returns an error if the edge is not defined in the schema.
  2236. func (m *APIKeyMutation) ResetEdge(name string) error {
  2237. switch name {
  2238. case apikey.EdgeUser:
  2239. m.ResetUser()
  2240. return nil
  2241. case apikey.EdgeGroup:
  2242. m.ResetGroup()
  2243. return nil
  2244. case apikey.EdgeUsageLogs:
  2245. m.ResetUsageLogs()
  2246. return nil
  2247. }
  2248. return fmt.Errorf("unknown APIKey edge %s", name)
  2249. }
  2250. // AccountMutation represents an operation that mutates the Account nodes in the graph.
  2251. type AccountMutation struct {
  2252. config
  2253. op Op
  2254. typ string
  2255. id *int64
  2256. created_at *time.Time
  2257. updated_at *time.Time
  2258. deleted_at *time.Time
  2259. name *string
  2260. notes *string
  2261. platform *string
  2262. _type *string
  2263. credentials *map[string]interface{}
  2264. extra *map[string]interface{}
  2265. proxy_fallback_origin_id *int64
  2266. addproxy_fallback_origin_id *int64
  2267. concurrency *int
  2268. addconcurrency *int
  2269. load_factor *int
  2270. addload_factor *int
  2271. priority *int
  2272. addpriority *int
  2273. rate_multiplier *float64
  2274. addrate_multiplier *float64
  2275. status *string
  2276. error_message *string
  2277. last_used_at *time.Time
  2278. expires_at *time.Time
  2279. auto_pause_on_expired *bool
  2280. schedulable *bool
  2281. rate_limited_at *time.Time
  2282. rate_limit_reset_at *time.Time
  2283. overload_until *time.Time
  2284. temp_unschedulable_until *time.Time
  2285. temp_unschedulable_reason *string
  2286. session_window_start *time.Time
  2287. session_window_end *time.Time
  2288. session_window_status *string
  2289. quota_dimension *account.QuotaDimension
  2290. clearedFields map[string]struct{}
  2291. groups map[int64]struct{}
  2292. removedgroups map[int64]struct{}
  2293. clearedgroups bool
  2294. proxy *int64
  2295. clearedproxy bool
  2296. parent *int64
  2297. clearedparent bool
  2298. children map[int64]struct{}
  2299. removedchildren map[int64]struct{}
  2300. clearedchildren bool
  2301. usage_logs map[int64]struct{}
  2302. removedusage_logs map[int64]struct{}
  2303. clearedusage_logs bool
  2304. done bool
  2305. oldValue func(context.Context) (*Account, error)
  2306. predicates []predicate.Account
  2307. }
  2308. var _ ent.Mutation = (*AccountMutation)(nil)
  2309. // accountOption allows management of the mutation configuration using functional options.
  2310. type accountOption func(*AccountMutation)
  2311. // newAccountMutation creates new mutation for the Account entity.
  2312. func newAccountMutation(c config, op Op, opts ...accountOption) *AccountMutation {
  2313. m := &AccountMutation{
  2314. config: c,
  2315. op: op,
  2316. typ: TypeAccount,
  2317. clearedFields: make(map[string]struct{}),
  2318. }
  2319. for _, opt := range opts {
  2320. opt(m)
  2321. }
  2322. return m
  2323. }
  2324. // withAccountID sets the ID field of the mutation.
  2325. func withAccountID(id int64) accountOption {
  2326. return func(m *AccountMutation) {
  2327. var (
  2328. err error
  2329. once sync.Once
  2330. value *Account
  2331. )
  2332. m.oldValue = func(ctx context.Context) (*Account, error) {
  2333. once.Do(func() {
  2334. if m.done {
  2335. err = errors.New("querying old values post mutation is not allowed")
  2336. } else {
  2337. value, err = m.Client().Account.Get(ctx, id)
  2338. }
  2339. })
  2340. return value, err
  2341. }
  2342. m.id = &id
  2343. }
  2344. }
  2345. // withAccount sets the old Account of the mutation.
  2346. func withAccount(node *Account) accountOption {
  2347. return func(m *AccountMutation) {
  2348. m.oldValue = func(context.Context) (*Account, error) {
  2349. return node, nil
  2350. }
  2351. m.id = &node.ID
  2352. }
  2353. }
  2354. // Client returns a new `ent.Client` from the mutation. If the mutation was
  2355. // executed in a transaction (ent.Tx), a transactional client is returned.
  2356. func (m AccountMutation) Client() *Client {
  2357. client := &Client{config: m.config}
  2358. client.init()
  2359. return client
  2360. }
  2361. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  2362. // it returns an error otherwise.
  2363. func (m AccountMutation) Tx() (*Tx, error) {
  2364. if _, ok := m.driver.(*txDriver); !ok {
  2365. return nil, errors.New("ent: mutation is not running in a transaction")
  2366. }
  2367. tx := &Tx{config: m.config}
  2368. tx.init()
  2369. return tx, nil
  2370. }
  2371. // ID returns the ID value in the mutation. Note that the ID is only available
  2372. // if it was provided to the builder or after it was returned from the database.
  2373. func (m *AccountMutation) ID() (id int64, exists bool) {
  2374. if m.id == nil {
  2375. return
  2376. }
  2377. return *m.id, true
  2378. }
  2379. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  2380. // That means, if the mutation is applied within a transaction with an isolation level such
  2381. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  2382. // or updated by the mutation.
  2383. func (m *AccountMutation) IDs(ctx context.Context) ([]int64, error) {
  2384. switch {
  2385. case m.op.Is(OpUpdateOne | OpDeleteOne):
  2386. id, exists := m.ID()
  2387. if exists {
  2388. return []int64{id}, nil
  2389. }
  2390. fallthrough
  2391. case m.op.Is(OpUpdate | OpDelete):
  2392. return m.Client().Account.Query().Where(m.predicates...).IDs(ctx)
  2393. default:
  2394. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  2395. }
  2396. }
  2397. // SetCreatedAt sets the "created_at" field.
  2398. func (m *AccountMutation) SetCreatedAt(t time.Time) {
  2399. m.created_at = &t
  2400. }
  2401. // CreatedAt returns the value of the "created_at" field in the mutation.
  2402. func (m *AccountMutation) CreatedAt() (r time.Time, exists bool) {
  2403. v := m.created_at
  2404. if v == nil {
  2405. return
  2406. }
  2407. return *v, true
  2408. }
  2409. // OldCreatedAt returns the old "created_at" field's value of the Account entity.
  2410. // If the Account object wasn't provided to the builder, the object is fetched from the database.
  2411. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2412. func (m *AccountMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  2413. if !m.op.Is(OpUpdateOne) {
  2414. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  2415. }
  2416. if m.id == nil || m.oldValue == nil {
  2417. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  2418. }
  2419. oldValue, err := m.oldValue(ctx)
  2420. if err != nil {
  2421. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  2422. }
  2423. return oldValue.CreatedAt, nil
  2424. }
  2425. // ResetCreatedAt resets all changes to the "created_at" field.
  2426. func (m *AccountMutation) ResetCreatedAt() {
  2427. m.created_at = nil
  2428. }
  2429. // SetUpdatedAt sets the "updated_at" field.
  2430. func (m *AccountMutation) SetUpdatedAt(t time.Time) {
  2431. m.updated_at = &t
  2432. }
  2433. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  2434. func (m *AccountMutation) UpdatedAt() (r time.Time, exists bool) {
  2435. v := m.updated_at
  2436. if v == nil {
  2437. return
  2438. }
  2439. return *v, true
  2440. }
  2441. // OldUpdatedAt returns the old "updated_at" field's value of the Account entity.
  2442. // If the Account object wasn't provided to the builder, the object is fetched from the database.
  2443. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2444. func (m *AccountMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  2445. if !m.op.Is(OpUpdateOne) {
  2446. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  2447. }
  2448. if m.id == nil || m.oldValue == nil {
  2449. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  2450. }
  2451. oldValue, err := m.oldValue(ctx)
  2452. if err != nil {
  2453. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  2454. }
  2455. return oldValue.UpdatedAt, nil
  2456. }
  2457. // ResetUpdatedAt resets all changes to the "updated_at" field.
  2458. func (m *AccountMutation) ResetUpdatedAt() {
  2459. m.updated_at = nil
  2460. }
  2461. // SetDeletedAt sets the "deleted_at" field.
  2462. func (m *AccountMutation) SetDeletedAt(t time.Time) {
  2463. m.deleted_at = &t
  2464. }
  2465. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  2466. func (m *AccountMutation) DeletedAt() (r time.Time, exists bool) {
  2467. v := m.deleted_at
  2468. if v == nil {
  2469. return
  2470. }
  2471. return *v, true
  2472. }
  2473. // OldDeletedAt returns the old "deleted_at" field's value of the Account entity.
  2474. // If the Account object wasn't provided to the builder, the object is fetched from the database.
  2475. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2476. func (m *AccountMutation) OldDeletedAt(ctx context.Context) (v *time.Time, err error) {
  2477. if !m.op.Is(OpUpdateOne) {
  2478. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  2479. }
  2480. if m.id == nil || m.oldValue == nil {
  2481. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  2482. }
  2483. oldValue, err := m.oldValue(ctx)
  2484. if err != nil {
  2485. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  2486. }
  2487. return oldValue.DeletedAt, nil
  2488. }
  2489. // ClearDeletedAt clears the value of the "deleted_at" field.
  2490. func (m *AccountMutation) ClearDeletedAt() {
  2491. m.deleted_at = nil
  2492. m.clearedFields[account.FieldDeletedAt] = struct{}{}
  2493. }
  2494. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  2495. func (m *AccountMutation) DeletedAtCleared() bool {
  2496. _, ok := m.clearedFields[account.FieldDeletedAt]
  2497. return ok
  2498. }
  2499. // ResetDeletedAt resets all changes to the "deleted_at" field.
  2500. func (m *AccountMutation) ResetDeletedAt() {
  2501. m.deleted_at = nil
  2502. delete(m.clearedFields, account.FieldDeletedAt)
  2503. }
  2504. // SetName sets the "name" field.
  2505. func (m *AccountMutation) SetName(s string) {
  2506. m.name = &s
  2507. }
  2508. // Name returns the value of the "name" field in the mutation.
  2509. func (m *AccountMutation) Name() (r string, exists bool) {
  2510. v := m.name
  2511. if v == nil {
  2512. return
  2513. }
  2514. return *v, true
  2515. }
  2516. // OldName returns the old "name" field's value of the Account entity.
  2517. // If the Account object wasn't provided to the builder, the object is fetched from the database.
  2518. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2519. func (m *AccountMutation) OldName(ctx context.Context) (v string, err error) {
  2520. if !m.op.Is(OpUpdateOne) {
  2521. return v, errors.New("OldName is only allowed on UpdateOne operations")
  2522. }
  2523. if m.id == nil || m.oldValue == nil {
  2524. return v, errors.New("OldName requires an ID field in the mutation")
  2525. }
  2526. oldValue, err := m.oldValue(ctx)
  2527. if err != nil {
  2528. return v, fmt.Errorf("querying old value for OldName: %w", err)
  2529. }
  2530. return oldValue.Name, nil
  2531. }
  2532. // ResetName resets all changes to the "name" field.
  2533. func (m *AccountMutation) ResetName() {
  2534. m.name = nil
  2535. }
  2536. // SetNotes sets the "notes" field.
  2537. func (m *AccountMutation) SetNotes(s string) {
  2538. m.notes = &s
  2539. }
  2540. // Notes returns the value of the "notes" field in the mutation.
  2541. func (m *AccountMutation) Notes() (r string, exists bool) {
  2542. v := m.notes
  2543. if v == nil {
  2544. return
  2545. }
  2546. return *v, true
  2547. }
  2548. // OldNotes returns the old "notes" field's value of the Account entity.
  2549. // If the Account object wasn't provided to the builder, the object is fetched from the database.
  2550. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2551. func (m *AccountMutation) OldNotes(ctx context.Context) (v *string, err error) {
  2552. if !m.op.Is(OpUpdateOne) {
  2553. return v, errors.New("OldNotes is only allowed on UpdateOne operations")
  2554. }
  2555. if m.id == nil || m.oldValue == nil {
  2556. return v, errors.New("OldNotes requires an ID field in the mutation")
  2557. }
  2558. oldValue, err := m.oldValue(ctx)
  2559. if err != nil {
  2560. return v, fmt.Errorf("querying old value for OldNotes: %w", err)
  2561. }
  2562. return oldValue.Notes, nil
  2563. }
  2564. // ClearNotes clears the value of the "notes" field.
  2565. func (m *AccountMutation) ClearNotes() {
  2566. m.notes = nil
  2567. m.clearedFields[account.FieldNotes] = struct{}{}
  2568. }
  2569. // NotesCleared returns if the "notes" field was cleared in this mutation.
  2570. func (m *AccountMutation) NotesCleared() bool {
  2571. _, ok := m.clearedFields[account.FieldNotes]
  2572. return ok
  2573. }
  2574. // ResetNotes resets all changes to the "notes" field.
  2575. func (m *AccountMutation) ResetNotes() {
  2576. m.notes = nil
  2577. delete(m.clearedFields, account.FieldNotes)
  2578. }
  2579. // SetPlatform sets the "platform" field.
  2580. func (m *AccountMutation) SetPlatform(s string) {
  2581. m.platform = &s
  2582. }
  2583. // Platform returns the value of the "platform" field in the mutation.
  2584. func (m *AccountMutation) Platform() (r string, exists bool) {
  2585. v := m.platform
  2586. if v == nil {
  2587. return
  2588. }
  2589. return *v, true
  2590. }
  2591. // OldPlatform returns the old "platform" field's value of the Account entity.
  2592. // If the Account object wasn't provided to the builder, the object is fetched from the database.
  2593. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2594. func (m *AccountMutation) OldPlatform(ctx context.Context) (v string, err error) {
  2595. if !m.op.Is(OpUpdateOne) {
  2596. return v, errors.New("OldPlatform is only allowed on UpdateOne operations")
  2597. }
  2598. if m.id == nil || m.oldValue == nil {
  2599. return v, errors.New("OldPlatform requires an ID field in the mutation")
  2600. }
  2601. oldValue, err := m.oldValue(ctx)
  2602. if err != nil {
  2603. return v, fmt.Errorf("querying old value for OldPlatform: %w", err)
  2604. }
  2605. return oldValue.Platform, nil
  2606. }
  2607. // ResetPlatform resets all changes to the "platform" field.
  2608. func (m *AccountMutation) ResetPlatform() {
  2609. m.platform = nil
  2610. }
  2611. // SetType sets the "type" field.
  2612. func (m *AccountMutation) SetType(s string) {
  2613. m._type = &s
  2614. }
  2615. // GetType returns the value of the "type" field in the mutation.
  2616. func (m *AccountMutation) GetType() (r string, exists bool) {
  2617. v := m._type
  2618. if v == nil {
  2619. return
  2620. }
  2621. return *v, true
  2622. }
  2623. // OldType returns the old "type" field's value of the Account entity.
  2624. // If the Account object wasn't provided to the builder, the object is fetched from the database.
  2625. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2626. func (m *AccountMutation) OldType(ctx context.Context) (v string, err error) {
  2627. if !m.op.Is(OpUpdateOne) {
  2628. return v, errors.New("OldType is only allowed on UpdateOne operations")
  2629. }
  2630. if m.id == nil || m.oldValue == nil {
  2631. return v, errors.New("OldType requires an ID field in the mutation")
  2632. }
  2633. oldValue, err := m.oldValue(ctx)
  2634. if err != nil {
  2635. return v, fmt.Errorf("querying old value for OldType: %w", err)
  2636. }
  2637. return oldValue.Type, nil
  2638. }
  2639. // ResetType resets all changes to the "type" field.
  2640. func (m *AccountMutation) ResetType() {
  2641. m._type = nil
  2642. }
  2643. // SetCredentials sets the "credentials" field.
  2644. func (m *AccountMutation) SetCredentials(value map[string]interface{}) {
  2645. m.credentials = &value
  2646. }
  2647. // Credentials returns the value of the "credentials" field in the mutation.
  2648. func (m *AccountMutation) Credentials() (r map[string]interface{}, exists bool) {
  2649. v := m.credentials
  2650. if v == nil {
  2651. return
  2652. }
  2653. return *v, true
  2654. }
  2655. // OldCredentials returns the old "credentials" field's value of the Account entity.
  2656. // If the Account object wasn't provided to the builder, the object is fetched from the database.
  2657. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2658. func (m *AccountMutation) OldCredentials(ctx context.Context) (v map[string]interface{}, err error) {
  2659. if !m.op.Is(OpUpdateOne) {
  2660. return v, errors.New("OldCredentials is only allowed on UpdateOne operations")
  2661. }
  2662. if m.id == nil || m.oldValue == nil {
  2663. return v, errors.New("OldCredentials requires an ID field in the mutation")
  2664. }
  2665. oldValue, err := m.oldValue(ctx)
  2666. if err != nil {
  2667. return v, fmt.Errorf("querying old value for OldCredentials: %w", err)
  2668. }
  2669. return oldValue.Credentials, nil
  2670. }
  2671. // ResetCredentials resets all changes to the "credentials" field.
  2672. func (m *AccountMutation) ResetCredentials() {
  2673. m.credentials = nil
  2674. }
  2675. // SetExtra sets the "extra" field.
  2676. func (m *AccountMutation) SetExtra(value map[string]interface{}) {
  2677. m.extra = &value
  2678. }
  2679. // Extra returns the value of the "extra" field in the mutation.
  2680. func (m *AccountMutation) Extra() (r map[string]interface{}, exists bool) {
  2681. v := m.extra
  2682. if v == nil {
  2683. return
  2684. }
  2685. return *v, true
  2686. }
  2687. // OldExtra returns the old "extra" field's value of the Account entity.
  2688. // If the Account object wasn't provided to the builder, the object is fetched from the database.
  2689. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2690. func (m *AccountMutation) OldExtra(ctx context.Context) (v map[string]interface{}, err error) {
  2691. if !m.op.Is(OpUpdateOne) {
  2692. return v, errors.New("OldExtra is only allowed on UpdateOne operations")
  2693. }
  2694. if m.id == nil || m.oldValue == nil {
  2695. return v, errors.New("OldExtra requires an ID field in the mutation")
  2696. }
  2697. oldValue, err := m.oldValue(ctx)
  2698. if err != nil {
  2699. return v, fmt.Errorf("querying old value for OldExtra: %w", err)
  2700. }
  2701. return oldValue.Extra, nil
  2702. }
  2703. // ResetExtra resets all changes to the "extra" field.
  2704. func (m *AccountMutation) ResetExtra() {
  2705. m.extra = nil
  2706. }
  2707. // SetProxyID sets the "proxy_id" field.
  2708. func (m *AccountMutation) SetProxyID(i int64) {
  2709. m.proxy = &i
  2710. }
  2711. // ProxyID returns the value of the "proxy_id" field in the mutation.
  2712. func (m *AccountMutation) ProxyID() (r int64, exists bool) {
  2713. v := m.proxy
  2714. if v == nil {
  2715. return
  2716. }
  2717. return *v, true
  2718. }
  2719. // OldProxyID returns the old "proxy_id" field's value of the Account entity.
  2720. // If the Account object wasn't provided to the builder, the object is fetched from the database.
  2721. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2722. func (m *AccountMutation) OldProxyID(ctx context.Context) (v *int64, err error) {
  2723. if !m.op.Is(OpUpdateOne) {
  2724. return v, errors.New("OldProxyID is only allowed on UpdateOne operations")
  2725. }
  2726. if m.id == nil || m.oldValue == nil {
  2727. return v, errors.New("OldProxyID requires an ID field in the mutation")
  2728. }
  2729. oldValue, err := m.oldValue(ctx)
  2730. if err != nil {
  2731. return v, fmt.Errorf("querying old value for OldProxyID: %w", err)
  2732. }
  2733. return oldValue.ProxyID, nil
  2734. }
  2735. // ClearProxyID clears the value of the "proxy_id" field.
  2736. func (m *AccountMutation) ClearProxyID() {
  2737. m.proxy = nil
  2738. m.clearedFields[account.FieldProxyID] = struct{}{}
  2739. }
  2740. // ProxyIDCleared returns if the "proxy_id" field was cleared in this mutation.
  2741. func (m *AccountMutation) ProxyIDCleared() bool {
  2742. _, ok := m.clearedFields[account.FieldProxyID]
  2743. return ok
  2744. }
  2745. // ResetProxyID resets all changes to the "proxy_id" field.
  2746. func (m *AccountMutation) ResetProxyID() {
  2747. m.proxy = nil
  2748. delete(m.clearedFields, account.FieldProxyID)
  2749. }
  2750. // SetProxyFallbackOriginID sets the "proxy_fallback_origin_id" field.
  2751. func (m *AccountMutation) SetProxyFallbackOriginID(i int64) {
  2752. m.proxy_fallback_origin_id = &i
  2753. m.addproxy_fallback_origin_id = nil
  2754. }
  2755. // ProxyFallbackOriginID returns the value of the "proxy_fallback_origin_id" field in the mutation.
  2756. func (m *AccountMutation) ProxyFallbackOriginID() (r int64, exists bool) {
  2757. v := m.proxy_fallback_origin_id
  2758. if v == nil {
  2759. return
  2760. }
  2761. return *v, true
  2762. }
  2763. // OldProxyFallbackOriginID returns the old "proxy_fallback_origin_id" field's value of the Account entity.
  2764. // If the Account object wasn't provided to the builder, the object is fetched from the database.
  2765. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2766. func (m *AccountMutation) OldProxyFallbackOriginID(ctx context.Context) (v *int64, err error) {
  2767. if !m.op.Is(OpUpdateOne) {
  2768. return v, errors.New("OldProxyFallbackOriginID is only allowed on UpdateOne operations")
  2769. }
  2770. if m.id == nil || m.oldValue == nil {
  2771. return v, errors.New("OldProxyFallbackOriginID requires an ID field in the mutation")
  2772. }
  2773. oldValue, err := m.oldValue(ctx)
  2774. if err != nil {
  2775. return v, fmt.Errorf("querying old value for OldProxyFallbackOriginID: %w", err)
  2776. }
  2777. return oldValue.ProxyFallbackOriginID, nil
  2778. }
  2779. // AddProxyFallbackOriginID adds i to the "proxy_fallback_origin_id" field.
  2780. func (m *AccountMutation) AddProxyFallbackOriginID(i int64) {
  2781. if m.addproxy_fallback_origin_id != nil {
  2782. *m.addproxy_fallback_origin_id += i
  2783. } else {
  2784. m.addproxy_fallback_origin_id = &i
  2785. }
  2786. }
  2787. // AddedProxyFallbackOriginID returns the value that was added to the "proxy_fallback_origin_id" field in this mutation.
  2788. func (m *AccountMutation) AddedProxyFallbackOriginID() (r int64, exists bool) {
  2789. v := m.addproxy_fallback_origin_id
  2790. if v == nil {
  2791. return
  2792. }
  2793. return *v, true
  2794. }
  2795. // ClearProxyFallbackOriginID clears the value of the "proxy_fallback_origin_id" field.
  2796. func (m *AccountMutation) ClearProxyFallbackOriginID() {
  2797. m.proxy_fallback_origin_id = nil
  2798. m.addproxy_fallback_origin_id = nil
  2799. m.clearedFields[account.FieldProxyFallbackOriginID] = struct{}{}
  2800. }
  2801. // ProxyFallbackOriginIDCleared returns if the "proxy_fallback_origin_id" field was cleared in this mutation.
  2802. func (m *AccountMutation) ProxyFallbackOriginIDCleared() bool {
  2803. _, ok := m.clearedFields[account.FieldProxyFallbackOriginID]
  2804. return ok
  2805. }
  2806. // ResetProxyFallbackOriginID resets all changes to the "proxy_fallback_origin_id" field.
  2807. func (m *AccountMutation) ResetProxyFallbackOriginID() {
  2808. m.proxy_fallback_origin_id = nil
  2809. m.addproxy_fallback_origin_id = nil
  2810. delete(m.clearedFields, account.FieldProxyFallbackOriginID)
  2811. }
  2812. // SetConcurrency sets the "concurrency" field.
  2813. func (m *AccountMutation) SetConcurrency(i int) {
  2814. m.concurrency = &i
  2815. m.addconcurrency = nil
  2816. }
  2817. // Concurrency returns the value of the "concurrency" field in the mutation.
  2818. func (m *AccountMutation) Concurrency() (r int, exists bool) {
  2819. v := m.concurrency
  2820. if v == nil {
  2821. return
  2822. }
  2823. return *v, true
  2824. }
  2825. // OldConcurrency returns the old "concurrency" field's value of the Account entity.
  2826. // If the Account object wasn't provided to the builder, the object is fetched from the database.
  2827. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2828. func (m *AccountMutation) OldConcurrency(ctx context.Context) (v int, err error) {
  2829. if !m.op.Is(OpUpdateOne) {
  2830. return v, errors.New("OldConcurrency is only allowed on UpdateOne operations")
  2831. }
  2832. if m.id == nil || m.oldValue == nil {
  2833. return v, errors.New("OldConcurrency requires an ID field in the mutation")
  2834. }
  2835. oldValue, err := m.oldValue(ctx)
  2836. if err != nil {
  2837. return v, fmt.Errorf("querying old value for OldConcurrency: %w", err)
  2838. }
  2839. return oldValue.Concurrency, nil
  2840. }
  2841. // AddConcurrency adds i to the "concurrency" field.
  2842. func (m *AccountMutation) AddConcurrency(i int) {
  2843. if m.addconcurrency != nil {
  2844. *m.addconcurrency += i
  2845. } else {
  2846. m.addconcurrency = &i
  2847. }
  2848. }
  2849. // AddedConcurrency returns the value that was added to the "concurrency" field in this mutation.
  2850. func (m *AccountMutation) AddedConcurrency() (r int, exists bool) {
  2851. v := m.addconcurrency
  2852. if v == nil {
  2853. return
  2854. }
  2855. return *v, true
  2856. }
  2857. // ResetConcurrency resets all changes to the "concurrency" field.
  2858. func (m *AccountMutation) ResetConcurrency() {
  2859. m.concurrency = nil
  2860. m.addconcurrency = nil
  2861. }
  2862. // SetLoadFactor sets the "load_factor" field.
  2863. func (m *AccountMutation) SetLoadFactor(i int) {
  2864. m.load_factor = &i
  2865. m.addload_factor = nil
  2866. }
  2867. // LoadFactor returns the value of the "load_factor" field in the mutation.
  2868. func (m *AccountMutation) LoadFactor() (r int, exists bool) {
  2869. v := m.load_factor
  2870. if v == nil {
  2871. return
  2872. }
  2873. return *v, true
  2874. }
  2875. // OldLoadFactor returns the old "load_factor" field's value of the Account entity.
  2876. // If the Account object wasn't provided to the builder, the object is fetched from the database.
  2877. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2878. func (m *AccountMutation) OldLoadFactor(ctx context.Context) (v *int, err error) {
  2879. if !m.op.Is(OpUpdateOne) {
  2880. return v, errors.New("OldLoadFactor is only allowed on UpdateOne operations")
  2881. }
  2882. if m.id == nil || m.oldValue == nil {
  2883. return v, errors.New("OldLoadFactor requires an ID field in the mutation")
  2884. }
  2885. oldValue, err := m.oldValue(ctx)
  2886. if err != nil {
  2887. return v, fmt.Errorf("querying old value for OldLoadFactor: %w", err)
  2888. }
  2889. return oldValue.LoadFactor, nil
  2890. }
  2891. // AddLoadFactor adds i to the "load_factor" field.
  2892. func (m *AccountMutation) AddLoadFactor(i int) {
  2893. if m.addload_factor != nil {
  2894. *m.addload_factor += i
  2895. } else {
  2896. m.addload_factor = &i
  2897. }
  2898. }
  2899. // AddedLoadFactor returns the value that was added to the "load_factor" field in this mutation.
  2900. func (m *AccountMutation) AddedLoadFactor() (r int, exists bool) {
  2901. v := m.addload_factor
  2902. if v == nil {
  2903. return
  2904. }
  2905. return *v, true
  2906. }
  2907. // ClearLoadFactor clears the value of the "load_factor" field.
  2908. func (m *AccountMutation) ClearLoadFactor() {
  2909. m.load_factor = nil
  2910. m.addload_factor = nil
  2911. m.clearedFields[account.FieldLoadFactor] = struct{}{}
  2912. }
  2913. // LoadFactorCleared returns if the "load_factor" field was cleared in this mutation.
  2914. func (m *AccountMutation) LoadFactorCleared() bool {
  2915. _, ok := m.clearedFields[account.FieldLoadFactor]
  2916. return ok
  2917. }
  2918. // ResetLoadFactor resets all changes to the "load_factor" field.
  2919. func (m *AccountMutation) ResetLoadFactor() {
  2920. m.load_factor = nil
  2921. m.addload_factor = nil
  2922. delete(m.clearedFields, account.FieldLoadFactor)
  2923. }
  2924. // SetPriority sets the "priority" field.
  2925. func (m *AccountMutation) SetPriority(i int) {
  2926. m.priority = &i
  2927. m.addpriority = nil
  2928. }
  2929. // Priority returns the value of the "priority" field in the mutation.
  2930. func (m *AccountMutation) Priority() (r int, exists bool) {
  2931. v := m.priority
  2932. if v == nil {
  2933. return
  2934. }
  2935. return *v, true
  2936. }
  2937. // OldPriority returns the old "priority" field's value of the Account entity.
  2938. // If the Account object wasn't provided to the builder, the object is fetched from the database.
  2939. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2940. func (m *AccountMutation) OldPriority(ctx context.Context) (v int, err error) {
  2941. if !m.op.Is(OpUpdateOne) {
  2942. return v, errors.New("OldPriority is only allowed on UpdateOne operations")
  2943. }
  2944. if m.id == nil || m.oldValue == nil {
  2945. return v, errors.New("OldPriority requires an ID field in the mutation")
  2946. }
  2947. oldValue, err := m.oldValue(ctx)
  2948. if err != nil {
  2949. return v, fmt.Errorf("querying old value for OldPriority: %w", err)
  2950. }
  2951. return oldValue.Priority, nil
  2952. }
  2953. // AddPriority adds i to the "priority" field.
  2954. func (m *AccountMutation) AddPriority(i int) {
  2955. if m.addpriority != nil {
  2956. *m.addpriority += i
  2957. } else {
  2958. m.addpriority = &i
  2959. }
  2960. }
  2961. // AddedPriority returns the value that was added to the "priority" field in this mutation.
  2962. func (m *AccountMutation) AddedPriority() (r int, exists bool) {
  2963. v := m.addpriority
  2964. if v == nil {
  2965. return
  2966. }
  2967. return *v, true
  2968. }
  2969. // ResetPriority resets all changes to the "priority" field.
  2970. func (m *AccountMutation) ResetPriority() {
  2971. m.priority = nil
  2972. m.addpriority = nil
  2973. }
  2974. // SetRateMultiplier sets the "rate_multiplier" field.
  2975. func (m *AccountMutation) SetRateMultiplier(f float64) {
  2976. m.rate_multiplier = &f
  2977. m.addrate_multiplier = nil
  2978. }
  2979. // RateMultiplier returns the value of the "rate_multiplier" field in the mutation.
  2980. func (m *AccountMutation) RateMultiplier() (r float64, exists bool) {
  2981. v := m.rate_multiplier
  2982. if v == nil {
  2983. return
  2984. }
  2985. return *v, true
  2986. }
  2987. // OldRateMultiplier returns the old "rate_multiplier" field's value of the Account entity.
  2988. // If the Account object wasn't provided to the builder, the object is fetched from the database.
  2989. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2990. func (m *AccountMutation) OldRateMultiplier(ctx context.Context) (v float64, err error) {
  2991. if !m.op.Is(OpUpdateOne) {
  2992. return v, errors.New("OldRateMultiplier is only allowed on UpdateOne operations")
  2993. }
  2994. if m.id == nil || m.oldValue == nil {
  2995. return v, errors.New("OldRateMultiplier requires an ID field in the mutation")
  2996. }
  2997. oldValue, err := m.oldValue(ctx)
  2998. if err != nil {
  2999. return v, fmt.Errorf("querying old value for OldRateMultiplier: %w", err)
  3000. }
  3001. return oldValue.RateMultiplier, nil
  3002. }
  3003. // AddRateMultiplier adds f to the "rate_multiplier" field.
  3004. func (m *AccountMutation) AddRateMultiplier(f float64) {
  3005. if m.addrate_multiplier != nil {
  3006. *m.addrate_multiplier += f
  3007. } else {
  3008. m.addrate_multiplier = &f
  3009. }
  3010. }
  3011. // AddedRateMultiplier returns the value that was added to the "rate_multiplier" field in this mutation.
  3012. func (m *AccountMutation) AddedRateMultiplier() (r float64, exists bool) {
  3013. v := m.addrate_multiplier
  3014. if v == nil {
  3015. return
  3016. }
  3017. return *v, true
  3018. }
  3019. // ResetRateMultiplier resets all changes to the "rate_multiplier" field.
  3020. func (m *AccountMutation) ResetRateMultiplier() {
  3021. m.rate_multiplier = nil
  3022. m.addrate_multiplier = nil
  3023. }
  3024. // SetStatus sets the "status" field.
  3025. func (m *AccountMutation) SetStatus(s string) {
  3026. m.status = &s
  3027. }
  3028. // Status returns the value of the "status" field in the mutation.
  3029. func (m *AccountMutation) Status() (r string, exists bool) {
  3030. v := m.status
  3031. if v == nil {
  3032. return
  3033. }
  3034. return *v, true
  3035. }
  3036. // OldStatus returns the old "status" field's value of the Account entity.
  3037. // If the Account object wasn't provided to the builder, the object is fetched from the database.
  3038. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3039. func (m *AccountMutation) OldStatus(ctx context.Context) (v string, err error) {
  3040. if !m.op.Is(OpUpdateOne) {
  3041. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  3042. }
  3043. if m.id == nil || m.oldValue == nil {
  3044. return v, errors.New("OldStatus requires an ID field in the mutation")
  3045. }
  3046. oldValue, err := m.oldValue(ctx)
  3047. if err != nil {
  3048. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  3049. }
  3050. return oldValue.Status, nil
  3051. }
  3052. // ResetStatus resets all changes to the "status" field.
  3053. func (m *AccountMutation) ResetStatus() {
  3054. m.status = nil
  3055. }
  3056. // SetErrorMessage sets the "error_message" field.
  3057. func (m *AccountMutation) SetErrorMessage(s string) {
  3058. m.error_message = &s
  3059. }
  3060. // ErrorMessage returns the value of the "error_message" field in the mutation.
  3061. func (m *AccountMutation) ErrorMessage() (r string, exists bool) {
  3062. v := m.error_message
  3063. if v == nil {
  3064. return
  3065. }
  3066. return *v, true
  3067. }
  3068. // OldErrorMessage returns the old "error_message" field's value of the Account entity.
  3069. // If the Account object wasn't provided to the builder, the object is fetched from the database.
  3070. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3071. func (m *AccountMutation) OldErrorMessage(ctx context.Context) (v *string, err error) {
  3072. if !m.op.Is(OpUpdateOne) {
  3073. return v, errors.New("OldErrorMessage is only allowed on UpdateOne operations")
  3074. }
  3075. if m.id == nil || m.oldValue == nil {
  3076. return v, errors.New("OldErrorMessage requires an ID field in the mutation")
  3077. }
  3078. oldValue, err := m.oldValue(ctx)
  3079. if err != nil {
  3080. return v, fmt.Errorf("querying old value for OldErrorMessage: %w", err)
  3081. }
  3082. return oldValue.ErrorMessage, nil
  3083. }
  3084. // ClearErrorMessage clears the value of the "error_message" field.
  3085. func (m *AccountMutation) ClearErrorMessage() {
  3086. m.error_message = nil
  3087. m.clearedFields[account.FieldErrorMessage] = struct{}{}
  3088. }
  3089. // ErrorMessageCleared returns if the "error_message" field was cleared in this mutation.
  3090. func (m *AccountMutation) ErrorMessageCleared() bool {
  3091. _, ok := m.clearedFields[account.FieldErrorMessage]
  3092. return ok
  3093. }
  3094. // ResetErrorMessage resets all changes to the "error_message" field.
  3095. func (m *AccountMutation) ResetErrorMessage() {
  3096. m.error_message = nil
  3097. delete(m.clearedFields, account.FieldErrorMessage)
  3098. }
  3099. // SetLastUsedAt sets the "last_used_at" field.
  3100. func (m *AccountMutation) SetLastUsedAt(t time.Time) {
  3101. m.last_used_at = &t
  3102. }
  3103. // LastUsedAt returns the value of the "last_used_at" field in the mutation.
  3104. func (m *AccountMutation) LastUsedAt() (r time.Time, exists bool) {
  3105. v := m.last_used_at
  3106. if v == nil {
  3107. return
  3108. }
  3109. return *v, true
  3110. }
  3111. // OldLastUsedAt returns the old "last_used_at" field's value of the Account entity.
  3112. // If the Account object wasn't provided to the builder, the object is fetched from the database.
  3113. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3114. func (m *AccountMutation) OldLastUsedAt(ctx context.Context) (v *time.Time, err error) {
  3115. if !m.op.Is(OpUpdateOne) {
  3116. return v, errors.New("OldLastUsedAt is only allowed on UpdateOne operations")
  3117. }
  3118. if m.id == nil || m.oldValue == nil {
  3119. return v, errors.New("OldLastUsedAt requires an ID field in the mutation")
  3120. }
  3121. oldValue, err := m.oldValue(ctx)
  3122. if err != nil {
  3123. return v, fmt.Errorf("querying old value for OldLastUsedAt: %w", err)
  3124. }
  3125. return oldValue.LastUsedAt, nil
  3126. }
  3127. // ClearLastUsedAt clears the value of the "last_used_at" field.
  3128. func (m *AccountMutation) ClearLastUsedAt() {
  3129. m.last_used_at = nil
  3130. m.clearedFields[account.FieldLastUsedAt] = struct{}{}
  3131. }
  3132. // LastUsedAtCleared returns if the "last_used_at" field was cleared in this mutation.
  3133. func (m *AccountMutation) LastUsedAtCleared() bool {
  3134. _, ok := m.clearedFields[account.FieldLastUsedAt]
  3135. return ok
  3136. }
  3137. // ResetLastUsedAt resets all changes to the "last_used_at" field.
  3138. func (m *AccountMutation) ResetLastUsedAt() {
  3139. m.last_used_at = nil
  3140. delete(m.clearedFields, account.FieldLastUsedAt)
  3141. }
  3142. // SetExpiresAt sets the "expires_at" field.
  3143. func (m *AccountMutation) SetExpiresAt(t time.Time) {
  3144. m.expires_at = &t
  3145. }
  3146. // ExpiresAt returns the value of the "expires_at" field in the mutation.
  3147. func (m *AccountMutation) ExpiresAt() (r time.Time, exists bool) {
  3148. v := m.expires_at
  3149. if v == nil {
  3150. return
  3151. }
  3152. return *v, true
  3153. }
  3154. // OldExpiresAt returns the old "expires_at" field's value of the Account entity.
  3155. // If the Account object wasn't provided to the builder, the object is fetched from the database.
  3156. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3157. func (m *AccountMutation) OldExpiresAt(ctx context.Context) (v *time.Time, err error) {
  3158. if !m.op.Is(OpUpdateOne) {
  3159. return v, errors.New("OldExpiresAt is only allowed on UpdateOne operations")
  3160. }
  3161. if m.id == nil || m.oldValue == nil {
  3162. return v, errors.New("OldExpiresAt requires an ID field in the mutation")
  3163. }
  3164. oldValue, err := m.oldValue(ctx)
  3165. if err != nil {
  3166. return v, fmt.Errorf("querying old value for OldExpiresAt: %w", err)
  3167. }
  3168. return oldValue.ExpiresAt, nil
  3169. }
  3170. // ClearExpiresAt clears the value of the "expires_at" field.
  3171. func (m *AccountMutation) ClearExpiresAt() {
  3172. m.expires_at = nil
  3173. m.clearedFields[account.FieldExpiresAt] = struct{}{}
  3174. }
  3175. // ExpiresAtCleared returns if the "expires_at" field was cleared in this mutation.
  3176. func (m *AccountMutation) ExpiresAtCleared() bool {
  3177. _, ok := m.clearedFields[account.FieldExpiresAt]
  3178. return ok
  3179. }
  3180. // ResetExpiresAt resets all changes to the "expires_at" field.
  3181. func (m *AccountMutation) ResetExpiresAt() {
  3182. m.expires_at = nil
  3183. delete(m.clearedFields, account.FieldExpiresAt)
  3184. }
  3185. // SetAutoPauseOnExpired sets the "auto_pause_on_expired" field.
  3186. func (m *AccountMutation) SetAutoPauseOnExpired(b bool) {
  3187. m.auto_pause_on_expired = &b
  3188. }
  3189. // AutoPauseOnExpired returns the value of the "auto_pause_on_expired" field in the mutation.
  3190. func (m *AccountMutation) AutoPauseOnExpired() (r bool, exists bool) {
  3191. v := m.auto_pause_on_expired
  3192. if v == nil {
  3193. return
  3194. }
  3195. return *v, true
  3196. }
  3197. // OldAutoPauseOnExpired returns the old "auto_pause_on_expired" field's value of the Account entity.
  3198. // If the Account object wasn't provided to the builder, the object is fetched from the database.
  3199. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3200. func (m *AccountMutation) OldAutoPauseOnExpired(ctx context.Context) (v bool, err error) {
  3201. if !m.op.Is(OpUpdateOne) {
  3202. return v, errors.New("OldAutoPauseOnExpired is only allowed on UpdateOne operations")
  3203. }
  3204. if m.id == nil || m.oldValue == nil {
  3205. return v, errors.New("OldAutoPauseOnExpired requires an ID field in the mutation")
  3206. }
  3207. oldValue, err := m.oldValue(ctx)
  3208. if err != nil {
  3209. return v, fmt.Errorf("querying old value for OldAutoPauseOnExpired: %w", err)
  3210. }
  3211. return oldValue.AutoPauseOnExpired, nil
  3212. }
  3213. // ResetAutoPauseOnExpired resets all changes to the "auto_pause_on_expired" field.
  3214. func (m *AccountMutation) ResetAutoPauseOnExpired() {
  3215. m.auto_pause_on_expired = nil
  3216. }
  3217. // SetSchedulable sets the "schedulable" field.
  3218. func (m *AccountMutation) SetSchedulable(b bool) {
  3219. m.schedulable = &b
  3220. }
  3221. // Schedulable returns the value of the "schedulable" field in the mutation.
  3222. func (m *AccountMutation) Schedulable() (r bool, exists bool) {
  3223. v := m.schedulable
  3224. if v == nil {
  3225. return
  3226. }
  3227. return *v, true
  3228. }
  3229. // OldSchedulable returns the old "schedulable" field's value of the Account entity.
  3230. // If the Account object wasn't provided to the builder, the object is fetched from the database.
  3231. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3232. func (m *AccountMutation) OldSchedulable(ctx context.Context) (v bool, err error) {
  3233. if !m.op.Is(OpUpdateOne) {
  3234. return v, errors.New("OldSchedulable is only allowed on UpdateOne operations")
  3235. }
  3236. if m.id == nil || m.oldValue == nil {
  3237. return v, errors.New("OldSchedulable requires an ID field in the mutation")
  3238. }
  3239. oldValue, err := m.oldValue(ctx)
  3240. if err != nil {
  3241. return v, fmt.Errorf("querying old value for OldSchedulable: %w", err)
  3242. }
  3243. return oldValue.Schedulable, nil
  3244. }
  3245. // ResetSchedulable resets all changes to the "schedulable" field.
  3246. func (m *AccountMutation) ResetSchedulable() {
  3247. m.schedulable = nil
  3248. }
  3249. // SetRateLimitedAt sets the "rate_limited_at" field.
  3250. func (m *AccountMutation) SetRateLimitedAt(t time.Time) {
  3251. m.rate_limited_at = &t
  3252. }
  3253. // RateLimitedAt returns the value of the "rate_limited_at" field in the mutation.
  3254. func (m *AccountMutation) RateLimitedAt() (r time.Time, exists bool) {
  3255. v := m.rate_limited_at
  3256. if v == nil {
  3257. return
  3258. }
  3259. return *v, true
  3260. }
  3261. // OldRateLimitedAt returns the old "rate_limited_at" field's value of the Account entity.
  3262. // If the Account object wasn't provided to the builder, the object is fetched from the database.
  3263. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3264. func (m *AccountMutation) OldRateLimitedAt(ctx context.Context) (v *time.Time, err error) {
  3265. if !m.op.Is(OpUpdateOne) {
  3266. return v, errors.New("OldRateLimitedAt is only allowed on UpdateOne operations")
  3267. }
  3268. if m.id == nil || m.oldValue == nil {
  3269. return v, errors.New("OldRateLimitedAt requires an ID field in the mutation")
  3270. }
  3271. oldValue, err := m.oldValue(ctx)
  3272. if err != nil {
  3273. return v, fmt.Errorf("querying old value for OldRateLimitedAt: %w", err)
  3274. }
  3275. return oldValue.RateLimitedAt, nil
  3276. }
  3277. // ClearRateLimitedAt clears the value of the "rate_limited_at" field.
  3278. func (m *AccountMutation) ClearRateLimitedAt() {
  3279. m.rate_limited_at = nil
  3280. m.clearedFields[account.FieldRateLimitedAt] = struct{}{}
  3281. }
  3282. // RateLimitedAtCleared returns if the "rate_limited_at" field was cleared in this mutation.
  3283. func (m *AccountMutation) RateLimitedAtCleared() bool {
  3284. _, ok := m.clearedFields[account.FieldRateLimitedAt]
  3285. return ok
  3286. }
  3287. // ResetRateLimitedAt resets all changes to the "rate_limited_at" field.
  3288. func (m *AccountMutation) ResetRateLimitedAt() {
  3289. m.rate_limited_at = nil
  3290. delete(m.clearedFields, account.FieldRateLimitedAt)
  3291. }
  3292. // SetRateLimitResetAt sets the "rate_limit_reset_at" field.
  3293. func (m *AccountMutation) SetRateLimitResetAt(t time.Time) {
  3294. m.rate_limit_reset_at = &t
  3295. }
  3296. // RateLimitResetAt returns the value of the "rate_limit_reset_at" field in the mutation.
  3297. func (m *AccountMutation) RateLimitResetAt() (r time.Time, exists bool) {
  3298. v := m.rate_limit_reset_at
  3299. if v == nil {
  3300. return
  3301. }
  3302. return *v, true
  3303. }
  3304. // OldRateLimitResetAt returns the old "rate_limit_reset_at" field's value of the Account entity.
  3305. // If the Account object wasn't provided to the builder, the object is fetched from the database.
  3306. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3307. func (m *AccountMutation) OldRateLimitResetAt(ctx context.Context) (v *time.Time, err error) {
  3308. if !m.op.Is(OpUpdateOne) {
  3309. return v, errors.New("OldRateLimitResetAt is only allowed on UpdateOne operations")
  3310. }
  3311. if m.id == nil || m.oldValue == nil {
  3312. return v, errors.New("OldRateLimitResetAt requires an ID field in the mutation")
  3313. }
  3314. oldValue, err := m.oldValue(ctx)
  3315. if err != nil {
  3316. return v, fmt.Errorf("querying old value for OldRateLimitResetAt: %w", err)
  3317. }
  3318. return oldValue.RateLimitResetAt, nil
  3319. }
  3320. // ClearRateLimitResetAt clears the value of the "rate_limit_reset_at" field.
  3321. func (m *AccountMutation) ClearRateLimitResetAt() {
  3322. m.rate_limit_reset_at = nil
  3323. m.clearedFields[account.FieldRateLimitResetAt] = struct{}{}
  3324. }
  3325. // RateLimitResetAtCleared returns if the "rate_limit_reset_at" field was cleared in this mutation.
  3326. func (m *AccountMutation) RateLimitResetAtCleared() bool {
  3327. _, ok := m.clearedFields[account.FieldRateLimitResetAt]
  3328. return ok
  3329. }
  3330. // ResetRateLimitResetAt resets all changes to the "rate_limit_reset_at" field.
  3331. func (m *AccountMutation) ResetRateLimitResetAt() {
  3332. m.rate_limit_reset_at = nil
  3333. delete(m.clearedFields, account.FieldRateLimitResetAt)
  3334. }
  3335. // SetOverloadUntil sets the "overload_until" field.
  3336. func (m *AccountMutation) SetOverloadUntil(t time.Time) {
  3337. m.overload_until = &t
  3338. }
  3339. // OverloadUntil returns the value of the "overload_until" field in the mutation.
  3340. func (m *AccountMutation) OverloadUntil() (r time.Time, exists bool) {
  3341. v := m.overload_until
  3342. if v == nil {
  3343. return
  3344. }
  3345. return *v, true
  3346. }
  3347. // OldOverloadUntil returns the old "overload_until" field's value of the Account entity.
  3348. // If the Account object wasn't provided to the builder, the object is fetched from the database.
  3349. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3350. func (m *AccountMutation) OldOverloadUntil(ctx context.Context) (v *time.Time, err error) {
  3351. if !m.op.Is(OpUpdateOne) {
  3352. return v, errors.New("OldOverloadUntil is only allowed on UpdateOne operations")
  3353. }
  3354. if m.id == nil || m.oldValue == nil {
  3355. return v, errors.New("OldOverloadUntil requires an ID field in the mutation")
  3356. }
  3357. oldValue, err := m.oldValue(ctx)
  3358. if err != nil {
  3359. return v, fmt.Errorf("querying old value for OldOverloadUntil: %w", err)
  3360. }
  3361. return oldValue.OverloadUntil, nil
  3362. }
  3363. // ClearOverloadUntil clears the value of the "overload_until" field.
  3364. func (m *AccountMutation) ClearOverloadUntil() {
  3365. m.overload_until = nil
  3366. m.clearedFields[account.FieldOverloadUntil] = struct{}{}
  3367. }
  3368. // OverloadUntilCleared returns if the "overload_until" field was cleared in this mutation.
  3369. func (m *AccountMutation) OverloadUntilCleared() bool {
  3370. _, ok := m.clearedFields[account.FieldOverloadUntil]
  3371. return ok
  3372. }
  3373. // ResetOverloadUntil resets all changes to the "overload_until" field.
  3374. func (m *AccountMutation) ResetOverloadUntil() {
  3375. m.overload_until = nil
  3376. delete(m.clearedFields, account.FieldOverloadUntil)
  3377. }
  3378. // SetTempUnschedulableUntil sets the "temp_unschedulable_until" field.
  3379. func (m *AccountMutation) SetTempUnschedulableUntil(t time.Time) {
  3380. m.temp_unschedulable_until = &t
  3381. }
  3382. // TempUnschedulableUntil returns the value of the "temp_unschedulable_until" field in the mutation.
  3383. func (m *AccountMutation) TempUnschedulableUntil() (r time.Time, exists bool) {
  3384. v := m.temp_unschedulable_until
  3385. if v == nil {
  3386. return
  3387. }
  3388. return *v, true
  3389. }
  3390. // OldTempUnschedulableUntil returns the old "temp_unschedulable_until" field's value of the Account entity.
  3391. // If the Account object wasn't provided to the builder, the object is fetched from the database.
  3392. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3393. func (m *AccountMutation) OldTempUnschedulableUntil(ctx context.Context) (v *time.Time, err error) {
  3394. if !m.op.Is(OpUpdateOne) {
  3395. return v, errors.New("OldTempUnschedulableUntil is only allowed on UpdateOne operations")
  3396. }
  3397. if m.id == nil || m.oldValue == nil {
  3398. return v, errors.New("OldTempUnschedulableUntil requires an ID field in the mutation")
  3399. }
  3400. oldValue, err := m.oldValue(ctx)
  3401. if err != nil {
  3402. return v, fmt.Errorf("querying old value for OldTempUnschedulableUntil: %w", err)
  3403. }
  3404. return oldValue.TempUnschedulableUntil, nil
  3405. }
  3406. // ClearTempUnschedulableUntil clears the value of the "temp_unschedulable_until" field.
  3407. func (m *AccountMutation) ClearTempUnschedulableUntil() {
  3408. m.temp_unschedulable_until = nil
  3409. m.clearedFields[account.FieldTempUnschedulableUntil] = struct{}{}
  3410. }
  3411. // TempUnschedulableUntilCleared returns if the "temp_unschedulable_until" field was cleared in this mutation.
  3412. func (m *AccountMutation) TempUnschedulableUntilCleared() bool {
  3413. _, ok := m.clearedFields[account.FieldTempUnschedulableUntil]
  3414. return ok
  3415. }
  3416. // ResetTempUnschedulableUntil resets all changes to the "temp_unschedulable_until" field.
  3417. func (m *AccountMutation) ResetTempUnschedulableUntil() {
  3418. m.temp_unschedulable_until = nil
  3419. delete(m.clearedFields, account.FieldTempUnschedulableUntil)
  3420. }
  3421. // SetTempUnschedulableReason sets the "temp_unschedulable_reason" field.
  3422. func (m *AccountMutation) SetTempUnschedulableReason(s string) {
  3423. m.temp_unschedulable_reason = &s
  3424. }
  3425. // TempUnschedulableReason returns the value of the "temp_unschedulable_reason" field in the mutation.
  3426. func (m *AccountMutation) TempUnschedulableReason() (r string, exists bool) {
  3427. v := m.temp_unschedulable_reason
  3428. if v == nil {
  3429. return
  3430. }
  3431. return *v, true
  3432. }
  3433. // OldTempUnschedulableReason returns the old "temp_unschedulable_reason" field's value of the Account entity.
  3434. // If the Account object wasn't provided to the builder, the object is fetched from the database.
  3435. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3436. func (m *AccountMutation) OldTempUnschedulableReason(ctx context.Context) (v *string, err error) {
  3437. if !m.op.Is(OpUpdateOne) {
  3438. return v, errors.New("OldTempUnschedulableReason is only allowed on UpdateOne operations")
  3439. }
  3440. if m.id == nil || m.oldValue == nil {
  3441. return v, errors.New("OldTempUnschedulableReason requires an ID field in the mutation")
  3442. }
  3443. oldValue, err := m.oldValue(ctx)
  3444. if err != nil {
  3445. return v, fmt.Errorf("querying old value for OldTempUnschedulableReason: %w", err)
  3446. }
  3447. return oldValue.TempUnschedulableReason, nil
  3448. }
  3449. // ClearTempUnschedulableReason clears the value of the "temp_unschedulable_reason" field.
  3450. func (m *AccountMutation) ClearTempUnschedulableReason() {
  3451. m.temp_unschedulable_reason = nil
  3452. m.clearedFields[account.FieldTempUnschedulableReason] = struct{}{}
  3453. }
  3454. // TempUnschedulableReasonCleared returns if the "temp_unschedulable_reason" field was cleared in this mutation.
  3455. func (m *AccountMutation) TempUnschedulableReasonCleared() bool {
  3456. _, ok := m.clearedFields[account.FieldTempUnschedulableReason]
  3457. return ok
  3458. }
  3459. // ResetTempUnschedulableReason resets all changes to the "temp_unschedulable_reason" field.
  3460. func (m *AccountMutation) ResetTempUnschedulableReason() {
  3461. m.temp_unschedulable_reason = nil
  3462. delete(m.clearedFields, account.FieldTempUnschedulableReason)
  3463. }
  3464. // SetSessionWindowStart sets the "session_window_start" field.
  3465. func (m *AccountMutation) SetSessionWindowStart(t time.Time) {
  3466. m.session_window_start = &t
  3467. }
  3468. // SessionWindowStart returns the value of the "session_window_start" field in the mutation.
  3469. func (m *AccountMutation) SessionWindowStart() (r time.Time, exists bool) {
  3470. v := m.session_window_start
  3471. if v == nil {
  3472. return
  3473. }
  3474. return *v, true
  3475. }
  3476. // OldSessionWindowStart returns the old "session_window_start" field's value of the Account entity.
  3477. // If the Account object wasn't provided to the builder, the object is fetched from the database.
  3478. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3479. func (m *AccountMutation) OldSessionWindowStart(ctx context.Context) (v *time.Time, err error) {
  3480. if !m.op.Is(OpUpdateOne) {
  3481. return v, errors.New("OldSessionWindowStart is only allowed on UpdateOne operations")
  3482. }
  3483. if m.id == nil || m.oldValue == nil {
  3484. return v, errors.New("OldSessionWindowStart requires an ID field in the mutation")
  3485. }
  3486. oldValue, err := m.oldValue(ctx)
  3487. if err != nil {
  3488. return v, fmt.Errorf("querying old value for OldSessionWindowStart: %w", err)
  3489. }
  3490. return oldValue.SessionWindowStart, nil
  3491. }
  3492. // ClearSessionWindowStart clears the value of the "session_window_start" field.
  3493. func (m *AccountMutation) ClearSessionWindowStart() {
  3494. m.session_window_start = nil
  3495. m.clearedFields[account.FieldSessionWindowStart] = struct{}{}
  3496. }
  3497. // SessionWindowStartCleared returns if the "session_window_start" field was cleared in this mutation.
  3498. func (m *AccountMutation) SessionWindowStartCleared() bool {
  3499. _, ok := m.clearedFields[account.FieldSessionWindowStart]
  3500. return ok
  3501. }
  3502. // ResetSessionWindowStart resets all changes to the "session_window_start" field.
  3503. func (m *AccountMutation) ResetSessionWindowStart() {
  3504. m.session_window_start = nil
  3505. delete(m.clearedFields, account.FieldSessionWindowStart)
  3506. }
  3507. // SetSessionWindowEnd sets the "session_window_end" field.
  3508. func (m *AccountMutation) SetSessionWindowEnd(t time.Time) {
  3509. m.session_window_end = &t
  3510. }
  3511. // SessionWindowEnd returns the value of the "session_window_end" field in the mutation.
  3512. func (m *AccountMutation) SessionWindowEnd() (r time.Time, exists bool) {
  3513. v := m.session_window_end
  3514. if v == nil {
  3515. return
  3516. }
  3517. return *v, true
  3518. }
  3519. // OldSessionWindowEnd returns the old "session_window_end" field's value of the Account entity.
  3520. // If the Account object wasn't provided to the builder, the object is fetched from the database.
  3521. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3522. func (m *AccountMutation) OldSessionWindowEnd(ctx context.Context) (v *time.Time, err error) {
  3523. if !m.op.Is(OpUpdateOne) {
  3524. return v, errors.New("OldSessionWindowEnd is only allowed on UpdateOne operations")
  3525. }
  3526. if m.id == nil || m.oldValue == nil {
  3527. return v, errors.New("OldSessionWindowEnd requires an ID field in the mutation")
  3528. }
  3529. oldValue, err := m.oldValue(ctx)
  3530. if err != nil {
  3531. return v, fmt.Errorf("querying old value for OldSessionWindowEnd: %w", err)
  3532. }
  3533. return oldValue.SessionWindowEnd, nil
  3534. }
  3535. // ClearSessionWindowEnd clears the value of the "session_window_end" field.
  3536. func (m *AccountMutation) ClearSessionWindowEnd() {
  3537. m.session_window_end = nil
  3538. m.clearedFields[account.FieldSessionWindowEnd] = struct{}{}
  3539. }
  3540. // SessionWindowEndCleared returns if the "session_window_end" field was cleared in this mutation.
  3541. func (m *AccountMutation) SessionWindowEndCleared() bool {
  3542. _, ok := m.clearedFields[account.FieldSessionWindowEnd]
  3543. return ok
  3544. }
  3545. // ResetSessionWindowEnd resets all changes to the "session_window_end" field.
  3546. func (m *AccountMutation) ResetSessionWindowEnd() {
  3547. m.session_window_end = nil
  3548. delete(m.clearedFields, account.FieldSessionWindowEnd)
  3549. }
  3550. // SetSessionWindowStatus sets the "session_window_status" field.
  3551. func (m *AccountMutation) SetSessionWindowStatus(s string) {
  3552. m.session_window_status = &s
  3553. }
  3554. // SessionWindowStatus returns the value of the "session_window_status" field in the mutation.
  3555. func (m *AccountMutation) SessionWindowStatus() (r string, exists bool) {
  3556. v := m.session_window_status
  3557. if v == nil {
  3558. return
  3559. }
  3560. return *v, true
  3561. }
  3562. // OldSessionWindowStatus returns the old "session_window_status" field's value of the Account entity.
  3563. // If the Account object wasn't provided to the builder, the object is fetched from the database.
  3564. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3565. func (m *AccountMutation) OldSessionWindowStatus(ctx context.Context) (v *string, err error) {
  3566. if !m.op.Is(OpUpdateOne) {
  3567. return v, errors.New("OldSessionWindowStatus is only allowed on UpdateOne operations")
  3568. }
  3569. if m.id == nil || m.oldValue == nil {
  3570. return v, errors.New("OldSessionWindowStatus requires an ID field in the mutation")
  3571. }
  3572. oldValue, err := m.oldValue(ctx)
  3573. if err != nil {
  3574. return v, fmt.Errorf("querying old value for OldSessionWindowStatus: %w", err)
  3575. }
  3576. return oldValue.SessionWindowStatus, nil
  3577. }
  3578. // ClearSessionWindowStatus clears the value of the "session_window_status" field.
  3579. func (m *AccountMutation) ClearSessionWindowStatus() {
  3580. m.session_window_status = nil
  3581. m.clearedFields[account.FieldSessionWindowStatus] = struct{}{}
  3582. }
  3583. // SessionWindowStatusCleared returns if the "session_window_status" field was cleared in this mutation.
  3584. func (m *AccountMutation) SessionWindowStatusCleared() bool {
  3585. _, ok := m.clearedFields[account.FieldSessionWindowStatus]
  3586. return ok
  3587. }
  3588. // ResetSessionWindowStatus resets all changes to the "session_window_status" field.
  3589. func (m *AccountMutation) ResetSessionWindowStatus() {
  3590. m.session_window_status = nil
  3591. delete(m.clearedFields, account.FieldSessionWindowStatus)
  3592. }
  3593. // SetParentAccountID sets the "parent_account_id" field.
  3594. func (m *AccountMutation) SetParentAccountID(i int64) {
  3595. m.parent = &i
  3596. }
  3597. // ParentAccountID returns the value of the "parent_account_id" field in the mutation.
  3598. func (m *AccountMutation) ParentAccountID() (r int64, exists bool) {
  3599. v := m.parent
  3600. if v == nil {
  3601. return
  3602. }
  3603. return *v, true
  3604. }
  3605. // OldParentAccountID returns the old "parent_account_id" field's value of the Account entity.
  3606. // If the Account object wasn't provided to the builder, the object is fetched from the database.
  3607. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3608. func (m *AccountMutation) OldParentAccountID(ctx context.Context) (v *int64, err error) {
  3609. if !m.op.Is(OpUpdateOne) {
  3610. return v, errors.New("OldParentAccountID is only allowed on UpdateOne operations")
  3611. }
  3612. if m.id == nil || m.oldValue == nil {
  3613. return v, errors.New("OldParentAccountID requires an ID field in the mutation")
  3614. }
  3615. oldValue, err := m.oldValue(ctx)
  3616. if err != nil {
  3617. return v, fmt.Errorf("querying old value for OldParentAccountID: %w", err)
  3618. }
  3619. return oldValue.ParentAccountID, nil
  3620. }
  3621. // ClearParentAccountID clears the value of the "parent_account_id" field.
  3622. func (m *AccountMutation) ClearParentAccountID() {
  3623. m.parent = nil
  3624. m.clearedFields[account.FieldParentAccountID] = struct{}{}
  3625. }
  3626. // ParentAccountIDCleared returns if the "parent_account_id" field was cleared in this mutation.
  3627. func (m *AccountMutation) ParentAccountIDCleared() bool {
  3628. _, ok := m.clearedFields[account.FieldParentAccountID]
  3629. return ok
  3630. }
  3631. // ResetParentAccountID resets all changes to the "parent_account_id" field.
  3632. func (m *AccountMutation) ResetParentAccountID() {
  3633. m.parent = nil
  3634. delete(m.clearedFields, account.FieldParentAccountID)
  3635. }
  3636. // SetQuotaDimension sets the "quota_dimension" field.
  3637. func (m *AccountMutation) SetQuotaDimension(ad account.QuotaDimension) {
  3638. m.quota_dimension = &ad
  3639. }
  3640. // QuotaDimension returns the value of the "quota_dimension" field in the mutation.
  3641. func (m *AccountMutation) QuotaDimension() (r account.QuotaDimension, exists bool) {
  3642. v := m.quota_dimension
  3643. if v == nil {
  3644. return
  3645. }
  3646. return *v, true
  3647. }
  3648. // OldQuotaDimension returns the old "quota_dimension" field's value of the Account entity.
  3649. // If the Account object wasn't provided to the builder, the object is fetched from the database.
  3650. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3651. func (m *AccountMutation) OldQuotaDimension(ctx context.Context) (v account.QuotaDimension, err error) {
  3652. if !m.op.Is(OpUpdateOne) {
  3653. return v, errors.New("OldQuotaDimension is only allowed on UpdateOne operations")
  3654. }
  3655. if m.id == nil || m.oldValue == nil {
  3656. return v, errors.New("OldQuotaDimension requires an ID field in the mutation")
  3657. }
  3658. oldValue, err := m.oldValue(ctx)
  3659. if err != nil {
  3660. return v, fmt.Errorf("querying old value for OldQuotaDimension: %w", err)
  3661. }
  3662. return oldValue.QuotaDimension, nil
  3663. }
  3664. // ResetQuotaDimension resets all changes to the "quota_dimension" field.
  3665. func (m *AccountMutation) ResetQuotaDimension() {
  3666. m.quota_dimension = nil
  3667. }
  3668. // AddGroupIDs adds the "groups" edge to the Group entity by ids.
  3669. func (m *AccountMutation) AddGroupIDs(ids ...int64) {
  3670. if m.groups == nil {
  3671. m.groups = make(map[int64]struct{})
  3672. }
  3673. for i := range ids {
  3674. m.groups[ids[i]] = struct{}{}
  3675. }
  3676. }
  3677. // ClearGroups clears the "groups" edge to the Group entity.
  3678. func (m *AccountMutation) ClearGroups() {
  3679. m.clearedgroups = true
  3680. }
  3681. // GroupsCleared reports if the "groups" edge to the Group entity was cleared.
  3682. func (m *AccountMutation) GroupsCleared() bool {
  3683. return m.clearedgroups
  3684. }
  3685. // RemoveGroupIDs removes the "groups" edge to the Group entity by IDs.
  3686. func (m *AccountMutation) RemoveGroupIDs(ids ...int64) {
  3687. if m.removedgroups == nil {
  3688. m.removedgroups = make(map[int64]struct{})
  3689. }
  3690. for i := range ids {
  3691. delete(m.groups, ids[i])
  3692. m.removedgroups[ids[i]] = struct{}{}
  3693. }
  3694. }
  3695. // RemovedGroups returns the removed IDs of the "groups" edge to the Group entity.
  3696. func (m *AccountMutation) RemovedGroupsIDs() (ids []int64) {
  3697. for id := range m.removedgroups {
  3698. ids = append(ids, id)
  3699. }
  3700. return
  3701. }
  3702. // GroupsIDs returns the "groups" edge IDs in the mutation.
  3703. func (m *AccountMutation) GroupsIDs() (ids []int64) {
  3704. for id := range m.groups {
  3705. ids = append(ids, id)
  3706. }
  3707. return
  3708. }
  3709. // ResetGroups resets all changes to the "groups" edge.
  3710. func (m *AccountMutation) ResetGroups() {
  3711. m.groups = nil
  3712. m.clearedgroups = false
  3713. m.removedgroups = nil
  3714. }
  3715. // ClearProxy clears the "proxy" edge to the Proxy entity.
  3716. func (m *AccountMutation) ClearProxy() {
  3717. m.clearedproxy = true
  3718. m.clearedFields[account.FieldProxyID] = struct{}{}
  3719. }
  3720. // ProxyCleared reports if the "proxy" edge to the Proxy entity was cleared.
  3721. func (m *AccountMutation) ProxyCleared() bool {
  3722. return m.ProxyIDCleared() || m.clearedproxy
  3723. }
  3724. // ProxyIDs returns the "proxy" edge IDs in the mutation.
  3725. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  3726. // ProxyID instead. It exists only for internal usage by the builders.
  3727. func (m *AccountMutation) ProxyIDs() (ids []int64) {
  3728. if id := m.proxy; id != nil {
  3729. ids = append(ids, *id)
  3730. }
  3731. return
  3732. }
  3733. // ResetProxy resets all changes to the "proxy" edge.
  3734. func (m *AccountMutation) ResetProxy() {
  3735. m.proxy = nil
  3736. m.clearedproxy = false
  3737. }
  3738. // SetParentID sets the "parent" edge to the Account entity by id.
  3739. func (m *AccountMutation) SetParentID(id int64) {
  3740. m.parent = &id
  3741. }
  3742. // ClearParent clears the "parent" edge to the Account entity.
  3743. func (m *AccountMutation) ClearParent() {
  3744. m.clearedparent = true
  3745. m.clearedFields[account.FieldParentAccountID] = struct{}{}
  3746. }
  3747. // ParentCleared reports if the "parent" edge to the Account entity was cleared.
  3748. func (m *AccountMutation) ParentCleared() bool {
  3749. return m.ParentAccountIDCleared() || m.clearedparent
  3750. }
  3751. // ParentID returns the "parent" edge ID in the mutation.
  3752. func (m *AccountMutation) ParentID() (id int64, exists bool) {
  3753. if m.parent != nil {
  3754. return *m.parent, true
  3755. }
  3756. return
  3757. }
  3758. // ParentIDs returns the "parent" edge IDs in the mutation.
  3759. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  3760. // ParentID instead. It exists only for internal usage by the builders.
  3761. func (m *AccountMutation) ParentIDs() (ids []int64) {
  3762. if id := m.parent; id != nil {
  3763. ids = append(ids, *id)
  3764. }
  3765. return
  3766. }
  3767. // ResetParent resets all changes to the "parent" edge.
  3768. func (m *AccountMutation) ResetParent() {
  3769. m.parent = nil
  3770. m.clearedparent = false
  3771. }
  3772. // AddChildIDs adds the "children" edge to the Account entity by ids.
  3773. func (m *AccountMutation) AddChildIDs(ids ...int64) {
  3774. if m.children == nil {
  3775. m.children = make(map[int64]struct{})
  3776. }
  3777. for i := range ids {
  3778. m.children[ids[i]] = struct{}{}
  3779. }
  3780. }
  3781. // ClearChildren clears the "children" edge to the Account entity.
  3782. func (m *AccountMutation) ClearChildren() {
  3783. m.clearedchildren = true
  3784. }
  3785. // ChildrenCleared reports if the "children" edge to the Account entity was cleared.
  3786. func (m *AccountMutation) ChildrenCleared() bool {
  3787. return m.clearedchildren
  3788. }
  3789. // RemoveChildIDs removes the "children" edge to the Account entity by IDs.
  3790. func (m *AccountMutation) RemoveChildIDs(ids ...int64) {
  3791. if m.removedchildren == nil {
  3792. m.removedchildren = make(map[int64]struct{})
  3793. }
  3794. for i := range ids {
  3795. delete(m.children, ids[i])
  3796. m.removedchildren[ids[i]] = struct{}{}
  3797. }
  3798. }
  3799. // RemovedChildren returns the removed IDs of the "children" edge to the Account entity.
  3800. func (m *AccountMutation) RemovedChildrenIDs() (ids []int64) {
  3801. for id := range m.removedchildren {
  3802. ids = append(ids, id)
  3803. }
  3804. return
  3805. }
  3806. // ChildrenIDs returns the "children" edge IDs in the mutation.
  3807. func (m *AccountMutation) ChildrenIDs() (ids []int64) {
  3808. for id := range m.children {
  3809. ids = append(ids, id)
  3810. }
  3811. return
  3812. }
  3813. // ResetChildren resets all changes to the "children" edge.
  3814. func (m *AccountMutation) ResetChildren() {
  3815. m.children = nil
  3816. m.clearedchildren = false
  3817. m.removedchildren = nil
  3818. }
  3819. // AddUsageLogIDs adds the "usage_logs" edge to the UsageLog entity by ids.
  3820. func (m *AccountMutation) AddUsageLogIDs(ids ...int64) {
  3821. if m.usage_logs == nil {
  3822. m.usage_logs = make(map[int64]struct{})
  3823. }
  3824. for i := range ids {
  3825. m.usage_logs[ids[i]] = struct{}{}
  3826. }
  3827. }
  3828. // ClearUsageLogs clears the "usage_logs" edge to the UsageLog entity.
  3829. func (m *AccountMutation) ClearUsageLogs() {
  3830. m.clearedusage_logs = true
  3831. }
  3832. // UsageLogsCleared reports if the "usage_logs" edge to the UsageLog entity was cleared.
  3833. func (m *AccountMutation) UsageLogsCleared() bool {
  3834. return m.clearedusage_logs
  3835. }
  3836. // RemoveUsageLogIDs removes the "usage_logs" edge to the UsageLog entity by IDs.
  3837. func (m *AccountMutation) RemoveUsageLogIDs(ids ...int64) {
  3838. if m.removedusage_logs == nil {
  3839. m.removedusage_logs = make(map[int64]struct{})
  3840. }
  3841. for i := range ids {
  3842. delete(m.usage_logs, ids[i])
  3843. m.removedusage_logs[ids[i]] = struct{}{}
  3844. }
  3845. }
  3846. // RemovedUsageLogs returns the removed IDs of the "usage_logs" edge to the UsageLog entity.
  3847. func (m *AccountMutation) RemovedUsageLogsIDs() (ids []int64) {
  3848. for id := range m.removedusage_logs {
  3849. ids = append(ids, id)
  3850. }
  3851. return
  3852. }
  3853. // UsageLogsIDs returns the "usage_logs" edge IDs in the mutation.
  3854. func (m *AccountMutation) UsageLogsIDs() (ids []int64) {
  3855. for id := range m.usage_logs {
  3856. ids = append(ids, id)
  3857. }
  3858. return
  3859. }
  3860. // ResetUsageLogs resets all changes to the "usage_logs" edge.
  3861. func (m *AccountMutation) ResetUsageLogs() {
  3862. m.usage_logs = nil
  3863. m.clearedusage_logs = false
  3864. m.removedusage_logs = nil
  3865. }
  3866. // Where appends a list predicates to the AccountMutation builder.
  3867. func (m *AccountMutation) Where(ps ...predicate.Account) {
  3868. m.predicates = append(m.predicates, ps...)
  3869. }
  3870. // WhereP appends storage-level predicates to the AccountMutation builder. Using this method,
  3871. // users can use type-assertion to append predicates that do not depend on any generated package.
  3872. func (m *AccountMutation) WhereP(ps ...func(*sql.Selector)) {
  3873. p := make([]predicate.Account, len(ps))
  3874. for i := range ps {
  3875. p[i] = ps[i]
  3876. }
  3877. m.Where(p...)
  3878. }
  3879. // Op returns the operation name.
  3880. func (m *AccountMutation) Op() Op {
  3881. return m.op
  3882. }
  3883. // SetOp allows setting the mutation operation.
  3884. func (m *AccountMutation) SetOp(op Op) {
  3885. m.op = op
  3886. }
  3887. // Type returns the node type of this mutation (Account).
  3888. func (m *AccountMutation) Type() string {
  3889. return m.typ
  3890. }
  3891. // Fields returns all fields that were changed during this mutation. Note that in
  3892. // order to get all numeric fields that were incremented/decremented, call
  3893. // AddedFields().
  3894. func (m *AccountMutation) Fields() []string {
  3895. fields := make([]string, 0, 31)
  3896. if m.created_at != nil {
  3897. fields = append(fields, account.FieldCreatedAt)
  3898. }
  3899. if m.updated_at != nil {
  3900. fields = append(fields, account.FieldUpdatedAt)
  3901. }
  3902. if m.deleted_at != nil {
  3903. fields = append(fields, account.FieldDeletedAt)
  3904. }
  3905. if m.name != nil {
  3906. fields = append(fields, account.FieldName)
  3907. }
  3908. if m.notes != nil {
  3909. fields = append(fields, account.FieldNotes)
  3910. }
  3911. if m.platform != nil {
  3912. fields = append(fields, account.FieldPlatform)
  3913. }
  3914. if m._type != nil {
  3915. fields = append(fields, account.FieldType)
  3916. }
  3917. if m.credentials != nil {
  3918. fields = append(fields, account.FieldCredentials)
  3919. }
  3920. if m.extra != nil {
  3921. fields = append(fields, account.FieldExtra)
  3922. }
  3923. if m.proxy != nil {
  3924. fields = append(fields, account.FieldProxyID)
  3925. }
  3926. if m.proxy_fallback_origin_id != nil {
  3927. fields = append(fields, account.FieldProxyFallbackOriginID)
  3928. }
  3929. if m.concurrency != nil {
  3930. fields = append(fields, account.FieldConcurrency)
  3931. }
  3932. if m.load_factor != nil {
  3933. fields = append(fields, account.FieldLoadFactor)
  3934. }
  3935. if m.priority != nil {
  3936. fields = append(fields, account.FieldPriority)
  3937. }
  3938. if m.rate_multiplier != nil {
  3939. fields = append(fields, account.FieldRateMultiplier)
  3940. }
  3941. if m.status != nil {
  3942. fields = append(fields, account.FieldStatus)
  3943. }
  3944. if m.error_message != nil {
  3945. fields = append(fields, account.FieldErrorMessage)
  3946. }
  3947. if m.last_used_at != nil {
  3948. fields = append(fields, account.FieldLastUsedAt)
  3949. }
  3950. if m.expires_at != nil {
  3951. fields = append(fields, account.FieldExpiresAt)
  3952. }
  3953. if m.auto_pause_on_expired != nil {
  3954. fields = append(fields, account.FieldAutoPauseOnExpired)
  3955. }
  3956. if m.schedulable != nil {
  3957. fields = append(fields, account.FieldSchedulable)
  3958. }
  3959. if m.rate_limited_at != nil {
  3960. fields = append(fields, account.FieldRateLimitedAt)
  3961. }
  3962. if m.rate_limit_reset_at != nil {
  3963. fields = append(fields, account.FieldRateLimitResetAt)
  3964. }
  3965. if m.overload_until != nil {
  3966. fields = append(fields, account.FieldOverloadUntil)
  3967. }
  3968. if m.temp_unschedulable_until != nil {
  3969. fields = append(fields, account.FieldTempUnschedulableUntil)
  3970. }
  3971. if m.temp_unschedulable_reason != nil {
  3972. fields = append(fields, account.FieldTempUnschedulableReason)
  3973. }
  3974. if m.session_window_start != nil {
  3975. fields = append(fields, account.FieldSessionWindowStart)
  3976. }
  3977. if m.session_window_end != nil {
  3978. fields = append(fields, account.FieldSessionWindowEnd)
  3979. }
  3980. if m.session_window_status != nil {
  3981. fields = append(fields, account.FieldSessionWindowStatus)
  3982. }
  3983. if m.parent != nil {
  3984. fields = append(fields, account.FieldParentAccountID)
  3985. }
  3986. if m.quota_dimension != nil {
  3987. fields = append(fields, account.FieldQuotaDimension)
  3988. }
  3989. return fields
  3990. }
  3991. // Field returns the value of a field with the given name. The second boolean
  3992. // return value indicates that this field was not set, or was not defined in the
  3993. // schema.
  3994. func (m *AccountMutation) Field(name string) (ent.Value, bool) {
  3995. switch name {
  3996. case account.FieldCreatedAt:
  3997. return m.CreatedAt()
  3998. case account.FieldUpdatedAt:
  3999. return m.UpdatedAt()
  4000. case account.FieldDeletedAt:
  4001. return m.DeletedAt()
  4002. case account.FieldName:
  4003. return m.Name()
  4004. case account.FieldNotes:
  4005. return m.Notes()
  4006. case account.FieldPlatform:
  4007. return m.Platform()
  4008. case account.FieldType:
  4009. return m.GetType()
  4010. case account.FieldCredentials:
  4011. return m.Credentials()
  4012. case account.FieldExtra:
  4013. return m.Extra()
  4014. case account.FieldProxyID:
  4015. return m.ProxyID()
  4016. case account.FieldProxyFallbackOriginID:
  4017. return m.ProxyFallbackOriginID()
  4018. case account.FieldConcurrency:
  4019. return m.Concurrency()
  4020. case account.FieldLoadFactor:
  4021. return m.LoadFactor()
  4022. case account.FieldPriority:
  4023. return m.Priority()
  4024. case account.FieldRateMultiplier:
  4025. return m.RateMultiplier()
  4026. case account.FieldStatus:
  4027. return m.Status()
  4028. case account.FieldErrorMessage:
  4029. return m.ErrorMessage()
  4030. case account.FieldLastUsedAt:
  4031. return m.LastUsedAt()
  4032. case account.FieldExpiresAt:
  4033. return m.ExpiresAt()
  4034. case account.FieldAutoPauseOnExpired:
  4035. return m.AutoPauseOnExpired()
  4036. case account.FieldSchedulable:
  4037. return m.Schedulable()
  4038. case account.FieldRateLimitedAt:
  4039. return m.RateLimitedAt()
  4040. case account.FieldRateLimitResetAt:
  4041. return m.RateLimitResetAt()
  4042. case account.FieldOverloadUntil:
  4043. return m.OverloadUntil()
  4044. case account.FieldTempUnschedulableUntil:
  4045. return m.TempUnschedulableUntil()
  4046. case account.FieldTempUnschedulableReason:
  4047. return m.TempUnschedulableReason()
  4048. case account.FieldSessionWindowStart:
  4049. return m.SessionWindowStart()
  4050. case account.FieldSessionWindowEnd:
  4051. return m.SessionWindowEnd()
  4052. case account.FieldSessionWindowStatus:
  4053. return m.SessionWindowStatus()
  4054. case account.FieldParentAccountID:
  4055. return m.ParentAccountID()
  4056. case account.FieldQuotaDimension:
  4057. return m.QuotaDimension()
  4058. }
  4059. return nil, false
  4060. }
  4061. // OldField returns the old value of the field from the database. An error is
  4062. // returned if the mutation operation is not UpdateOne, or the query to the
  4063. // database failed.
  4064. func (m *AccountMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  4065. switch name {
  4066. case account.FieldCreatedAt:
  4067. return m.OldCreatedAt(ctx)
  4068. case account.FieldUpdatedAt:
  4069. return m.OldUpdatedAt(ctx)
  4070. case account.FieldDeletedAt:
  4071. return m.OldDeletedAt(ctx)
  4072. case account.FieldName:
  4073. return m.OldName(ctx)
  4074. case account.FieldNotes:
  4075. return m.OldNotes(ctx)
  4076. case account.FieldPlatform:
  4077. return m.OldPlatform(ctx)
  4078. case account.FieldType:
  4079. return m.OldType(ctx)
  4080. case account.FieldCredentials:
  4081. return m.OldCredentials(ctx)
  4082. case account.FieldExtra:
  4083. return m.OldExtra(ctx)
  4084. case account.FieldProxyID:
  4085. return m.OldProxyID(ctx)
  4086. case account.FieldProxyFallbackOriginID:
  4087. return m.OldProxyFallbackOriginID(ctx)
  4088. case account.FieldConcurrency:
  4089. return m.OldConcurrency(ctx)
  4090. case account.FieldLoadFactor:
  4091. return m.OldLoadFactor(ctx)
  4092. case account.FieldPriority:
  4093. return m.OldPriority(ctx)
  4094. case account.FieldRateMultiplier:
  4095. return m.OldRateMultiplier(ctx)
  4096. case account.FieldStatus:
  4097. return m.OldStatus(ctx)
  4098. case account.FieldErrorMessage:
  4099. return m.OldErrorMessage(ctx)
  4100. case account.FieldLastUsedAt:
  4101. return m.OldLastUsedAt(ctx)
  4102. case account.FieldExpiresAt:
  4103. return m.OldExpiresAt(ctx)
  4104. case account.FieldAutoPauseOnExpired:
  4105. return m.OldAutoPauseOnExpired(ctx)
  4106. case account.FieldSchedulable:
  4107. return m.OldSchedulable(ctx)
  4108. case account.FieldRateLimitedAt:
  4109. return m.OldRateLimitedAt(ctx)
  4110. case account.FieldRateLimitResetAt:
  4111. return m.OldRateLimitResetAt(ctx)
  4112. case account.FieldOverloadUntil:
  4113. return m.OldOverloadUntil(ctx)
  4114. case account.FieldTempUnschedulableUntil:
  4115. return m.OldTempUnschedulableUntil(ctx)
  4116. case account.FieldTempUnschedulableReason:
  4117. return m.OldTempUnschedulableReason(ctx)
  4118. case account.FieldSessionWindowStart:
  4119. return m.OldSessionWindowStart(ctx)
  4120. case account.FieldSessionWindowEnd:
  4121. return m.OldSessionWindowEnd(ctx)
  4122. case account.FieldSessionWindowStatus:
  4123. return m.OldSessionWindowStatus(ctx)
  4124. case account.FieldParentAccountID:
  4125. return m.OldParentAccountID(ctx)
  4126. case account.FieldQuotaDimension:
  4127. return m.OldQuotaDimension(ctx)
  4128. }
  4129. return nil, fmt.Errorf("unknown Account field %s", name)
  4130. }
  4131. // SetField sets the value of a field with the given name. It returns an error if
  4132. // the field is not defined in the schema, or if the type mismatched the field
  4133. // type.
  4134. func (m *AccountMutation) SetField(name string, value ent.Value) error {
  4135. switch name {
  4136. case account.FieldCreatedAt:
  4137. v, ok := value.(time.Time)
  4138. if !ok {
  4139. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4140. }
  4141. m.SetCreatedAt(v)
  4142. return nil
  4143. case account.FieldUpdatedAt:
  4144. v, ok := value.(time.Time)
  4145. if !ok {
  4146. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4147. }
  4148. m.SetUpdatedAt(v)
  4149. return nil
  4150. case account.FieldDeletedAt:
  4151. v, ok := value.(time.Time)
  4152. if !ok {
  4153. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4154. }
  4155. m.SetDeletedAt(v)
  4156. return nil
  4157. case account.FieldName:
  4158. v, ok := value.(string)
  4159. if !ok {
  4160. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4161. }
  4162. m.SetName(v)
  4163. return nil
  4164. case account.FieldNotes:
  4165. v, ok := value.(string)
  4166. if !ok {
  4167. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4168. }
  4169. m.SetNotes(v)
  4170. return nil
  4171. case account.FieldPlatform:
  4172. v, ok := value.(string)
  4173. if !ok {
  4174. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4175. }
  4176. m.SetPlatform(v)
  4177. return nil
  4178. case account.FieldType:
  4179. v, ok := value.(string)
  4180. if !ok {
  4181. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4182. }
  4183. m.SetType(v)
  4184. return nil
  4185. case account.FieldCredentials:
  4186. v, ok := value.(map[string]interface{})
  4187. if !ok {
  4188. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4189. }
  4190. m.SetCredentials(v)
  4191. return nil
  4192. case account.FieldExtra:
  4193. v, ok := value.(map[string]interface{})
  4194. if !ok {
  4195. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4196. }
  4197. m.SetExtra(v)
  4198. return nil
  4199. case account.FieldProxyID:
  4200. v, ok := value.(int64)
  4201. if !ok {
  4202. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4203. }
  4204. m.SetProxyID(v)
  4205. return nil
  4206. case account.FieldProxyFallbackOriginID:
  4207. v, ok := value.(int64)
  4208. if !ok {
  4209. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4210. }
  4211. m.SetProxyFallbackOriginID(v)
  4212. return nil
  4213. case account.FieldConcurrency:
  4214. v, ok := value.(int)
  4215. if !ok {
  4216. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4217. }
  4218. m.SetConcurrency(v)
  4219. return nil
  4220. case account.FieldLoadFactor:
  4221. v, ok := value.(int)
  4222. if !ok {
  4223. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4224. }
  4225. m.SetLoadFactor(v)
  4226. return nil
  4227. case account.FieldPriority:
  4228. v, ok := value.(int)
  4229. if !ok {
  4230. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4231. }
  4232. m.SetPriority(v)
  4233. return nil
  4234. case account.FieldRateMultiplier:
  4235. v, ok := value.(float64)
  4236. if !ok {
  4237. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4238. }
  4239. m.SetRateMultiplier(v)
  4240. return nil
  4241. case account.FieldStatus:
  4242. v, ok := value.(string)
  4243. if !ok {
  4244. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4245. }
  4246. m.SetStatus(v)
  4247. return nil
  4248. case account.FieldErrorMessage:
  4249. v, ok := value.(string)
  4250. if !ok {
  4251. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4252. }
  4253. m.SetErrorMessage(v)
  4254. return nil
  4255. case account.FieldLastUsedAt:
  4256. v, ok := value.(time.Time)
  4257. if !ok {
  4258. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4259. }
  4260. m.SetLastUsedAt(v)
  4261. return nil
  4262. case account.FieldExpiresAt:
  4263. v, ok := value.(time.Time)
  4264. if !ok {
  4265. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4266. }
  4267. m.SetExpiresAt(v)
  4268. return nil
  4269. case account.FieldAutoPauseOnExpired:
  4270. v, ok := value.(bool)
  4271. if !ok {
  4272. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4273. }
  4274. m.SetAutoPauseOnExpired(v)
  4275. return nil
  4276. case account.FieldSchedulable:
  4277. v, ok := value.(bool)
  4278. if !ok {
  4279. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4280. }
  4281. m.SetSchedulable(v)
  4282. return nil
  4283. case account.FieldRateLimitedAt:
  4284. v, ok := value.(time.Time)
  4285. if !ok {
  4286. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4287. }
  4288. m.SetRateLimitedAt(v)
  4289. return nil
  4290. case account.FieldRateLimitResetAt:
  4291. v, ok := value.(time.Time)
  4292. if !ok {
  4293. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4294. }
  4295. m.SetRateLimitResetAt(v)
  4296. return nil
  4297. case account.FieldOverloadUntil:
  4298. v, ok := value.(time.Time)
  4299. if !ok {
  4300. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4301. }
  4302. m.SetOverloadUntil(v)
  4303. return nil
  4304. case account.FieldTempUnschedulableUntil:
  4305. v, ok := value.(time.Time)
  4306. if !ok {
  4307. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4308. }
  4309. m.SetTempUnschedulableUntil(v)
  4310. return nil
  4311. case account.FieldTempUnschedulableReason:
  4312. v, ok := value.(string)
  4313. if !ok {
  4314. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4315. }
  4316. m.SetTempUnschedulableReason(v)
  4317. return nil
  4318. case account.FieldSessionWindowStart:
  4319. v, ok := value.(time.Time)
  4320. if !ok {
  4321. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4322. }
  4323. m.SetSessionWindowStart(v)
  4324. return nil
  4325. case account.FieldSessionWindowEnd:
  4326. v, ok := value.(time.Time)
  4327. if !ok {
  4328. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4329. }
  4330. m.SetSessionWindowEnd(v)
  4331. return nil
  4332. case account.FieldSessionWindowStatus:
  4333. v, ok := value.(string)
  4334. if !ok {
  4335. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4336. }
  4337. m.SetSessionWindowStatus(v)
  4338. return nil
  4339. case account.FieldParentAccountID:
  4340. v, ok := value.(int64)
  4341. if !ok {
  4342. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4343. }
  4344. m.SetParentAccountID(v)
  4345. return nil
  4346. case account.FieldQuotaDimension:
  4347. v, ok := value.(account.QuotaDimension)
  4348. if !ok {
  4349. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4350. }
  4351. m.SetQuotaDimension(v)
  4352. return nil
  4353. }
  4354. return fmt.Errorf("unknown Account field %s", name)
  4355. }
  4356. // AddedFields returns all numeric fields that were incremented/decremented during
  4357. // this mutation.
  4358. func (m *AccountMutation) AddedFields() []string {
  4359. var fields []string
  4360. if m.addproxy_fallback_origin_id != nil {
  4361. fields = append(fields, account.FieldProxyFallbackOriginID)
  4362. }
  4363. if m.addconcurrency != nil {
  4364. fields = append(fields, account.FieldConcurrency)
  4365. }
  4366. if m.addload_factor != nil {
  4367. fields = append(fields, account.FieldLoadFactor)
  4368. }
  4369. if m.addpriority != nil {
  4370. fields = append(fields, account.FieldPriority)
  4371. }
  4372. if m.addrate_multiplier != nil {
  4373. fields = append(fields, account.FieldRateMultiplier)
  4374. }
  4375. return fields
  4376. }
  4377. // AddedField returns the numeric value that was incremented/decremented on a field
  4378. // with the given name. The second boolean return value indicates that this field
  4379. // was not set, or was not defined in the schema.
  4380. func (m *AccountMutation) AddedField(name string) (ent.Value, bool) {
  4381. switch name {
  4382. case account.FieldProxyFallbackOriginID:
  4383. return m.AddedProxyFallbackOriginID()
  4384. case account.FieldConcurrency:
  4385. return m.AddedConcurrency()
  4386. case account.FieldLoadFactor:
  4387. return m.AddedLoadFactor()
  4388. case account.FieldPriority:
  4389. return m.AddedPriority()
  4390. case account.FieldRateMultiplier:
  4391. return m.AddedRateMultiplier()
  4392. }
  4393. return nil, false
  4394. }
  4395. // AddField adds the value to the field with the given name. It returns an error if
  4396. // the field is not defined in the schema, or if the type mismatched the field
  4397. // type.
  4398. func (m *AccountMutation) AddField(name string, value ent.Value) error {
  4399. switch name {
  4400. case account.FieldProxyFallbackOriginID:
  4401. v, ok := value.(int64)
  4402. if !ok {
  4403. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4404. }
  4405. m.AddProxyFallbackOriginID(v)
  4406. return nil
  4407. case account.FieldConcurrency:
  4408. v, ok := value.(int)
  4409. if !ok {
  4410. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4411. }
  4412. m.AddConcurrency(v)
  4413. return nil
  4414. case account.FieldLoadFactor:
  4415. v, ok := value.(int)
  4416. if !ok {
  4417. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4418. }
  4419. m.AddLoadFactor(v)
  4420. return nil
  4421. case account.FieldPriority:
  4422. v, ok := value.(int)
  4423. if !ok {
  4424. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4425. }
  4426. m.AddPriority(v)
  4427. return nil
  4428. case account.FieldRateMultiplier:
  4429. v, ok := value.(float64)
  4430. if !ok {
  4431. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4432. }
  4433. m.AddRateMultiplier(v)
  4434. return nil
  4435. }
  4436. return fmt.Errorf("unknown Account numeric field %s", name)
  4437. }
  4438. // ClearedFields returns all nullable fields that were cleared during this
  4439. // mutation.
  4440. func (m *AccountMutation) ClearedFields() []string {
  4441. var fields []string
  4442. if m.FieldCleared(account.FieldDeletedAt) {
  4443. fields = append(fields, account.FieldDeletedAt)
  4444. }
  4445. if m.FieldCleared(account.FieldNotes) {
  4446. fields = append(fields, account.FieldNotes)
  4447. }
  4448. if m.FieldCleared(account.FieldProxyID) {
  4449. fields = append(fields, account.FieldProxyID)
  4450. }
  4451. if m.FieldCleared(account.FieldProxyFallbackOriginID) {
  4452. fields = append(fields, account.FieldProxyFallbackOriginID)
  4453. }
  4454. if m.FieldCleared(account.FieldLoadFactor) {
  4455. fields = append(fields, account.FieldLoadFactor)
  4456. }
  4457. if m.FieldCleared(account.FieldErrorMessage) {
  4458. fields = append(fields, account.FieldErrorMessage)
  4459. }
  4460. if m.FieldCleared(account.FieldLastUsedAt) {
  4461. fields = append(fields, account.FieldLastUsedAt)
  4462. }
  4463. if m.FieldCleared(account.FieldExpiresAt) {
  4464. fields = append(fields, account.FieldExpiresAt)
  4465. }
  4466. if m.FieldCleared(account.FieldRateLimitedAt) {
  4467. fields = append(fields, account.FieldRateLimitedAt)
  4468. }
  4469. if m.FieldCleared(account.FieldRateLimitResetAt) {
  4470. fields = append(fields, account.FieldRateLimitResetAt)
  4471. }
  4472. if m.FieldCleared(account.FieldOverloadUntil) {
  4473. fields = append(fields, account.FieldOverloadUntil)
  4474. }
  4475. if m.FieldCleared(account.FieldTempUnschedulableUntil) {
  4476. fields = append(fields, account.FieldTempUnschedulableUntil)
  4477. }
  4478. if m.FieldCleared(account.FieldTempUnschedulableReason) {
  4479. fields = append(fields, account.FieldTempUnschedulableReason)
  4480. }
  4481. if m.FieldCleared(account.FieldSessionWindowStart) {
  4482. fields = append(fields, account.FieldSessionWindowStart)
  4483. }
  4484. if m.FieldCleared(account.FieldSessionWindowEnd) {
  4485. fields = append(fields, account.FieldSessionWindowEnd)
  4486. }
  4487. if m.FieldCleared(account.FieldSessionWindowStatus) {
  4488. fields = append(fields, account.FieldSessionWindowStatus)
  4489. }
  4490. if m.FieldCleared(account.FieldParentAccountID) {
  4491. fields = append(fields, account.FieldParentAccountID)
  4492. }
  4493. return fields
  4494. }
  4495. // FieldCleared returns a boolean indicating if a field with the given name was
  4496. // cleared in this mutation.
  4497. func (m *AccountMutation) FieldCleared(name string) bool {
  4498. _, ok := m.clearedFields[name]
  4499. return ok
  4500. }
  4501. // ClearField clears the value of the field with the given name. It returns an
  4502. // error if the field is not defined in the schema.
  4503. func (m *AccountMutation) ClearField(name string) error {
  4504. switch name {
  4505. case account.FieldDeletedAt:
  4506. m.ClearDeletedAt()
  4507. return nil
  4508. case account.FieldNotes:
  4509. m.ClearNotes()
  4510. return nil
  4511. case account.FieldProxyID:
  4512. m.ClearProxyID()
  4513. return nil
  4514. case account.FieldProxyFallbackOriginID:
  4515. m.ClearProxyFallbackOriginID()
  4516. return nil
  4517. case account.FieldLoadFactor:
  4518. m.ClearLoadFactor()
  4519. return nil
  4520. case account.FieldErrorMessage:
  4521. m.ClearErrorMessage()
  4522. return nil
  4523. case account.FieldLastUsedAt:
  4524. m.ClearLastUsedAt()
  4525. return nil
  4526. case account.FieldExpiresAt:
  4527. m.ClearExpiresAt()
  4528. return nil
  4529. case account.FieldRateLimitedAt:
  4530. m.ClearRateLimitedAt()
  4531. return nil
  4532. case account.FieldRateLimitResetAt:
  4533. m.ClearRateLimitResetAt()
  4534. return nil
  4535. case account.FieldOverloadUntil:
  4536. m.ClearOverloadUntil()
  4537. return nil
  4538. case account.FieldTempUnschedulableUntil:
  4539. m.ClearTempUnschedulableUntil()
  4540. return nil
  4541. case account.FieldTempUnschedulableReason:
  4542. m.ClearTempUnschedulableReason()
  4543. return nil
  4544. case account.FieldSessionWindowStart:
  4545. m.ClearSessionWindowStart()
  4546. return nil
  4547. case account.FieldSessionWindowEnd:
  4548. m.ClearSessionWindowEnd()
  4549. return nil
  4550. case account.FieldSessionWindowStatus:
  4551. m.ClearSessionWindowStatus()
  4552. return nil
  4553. case account.FieldParentAccountID:
  4554. m.ClearParentAccountID()
  4555. return nil
  4556. }
  4557. return fmt.Errorf("unknown Account nullable field %s", name)
  4558. }
  4559. // ResetField resets all changes in the mutation for the field with the given name.
  4560. // It returns an error if the field is not defined in the schema.
  4561. func (m *AccountMutation) ResetField(name string) error {
  4562. switch name {
  4563. case account.FieldCreatedAt:
  4564. m.ResetCreatedAt()
  4565. return nil
  4566. case account.FieldUpdatedAt:
  4567. m.ResetUpdatedAt()
  4568. return nil
  4569. case account.FieldDeletedAt:
  4570. m.ResetDeletedAt()
  4571. return nil
  4572. case account.FieldName:
  4573. m.ResetName()
  4574. return nil
  4575. case account.FieldNotes:
  4576. m.ResetNotes()
  4577. return nil
  4578. case account.FieldPlatform:
  4579. m.ResetPlatform()
  4580. return nil
  4581. case account.FieldType:
  4582. m.ResetType()
  4583. return nil
  4584. case account.FieldCredentials:
  4585. m.ResetCredentials()
  4586. return nil
  4587. case account.FieldExtra:
  4588. m.ResetExtra()
  4589. return nil
  4590. case account.FieldProxyID:
  4591. m.ResetProxyID()
  4592. return nil
  4593. case account.FieldProxyFallbackOriginID:
  4594. m.ResetProxyFallbackOriginID()
  4595. return nil
  4596. case account.FieldConcurrency:
  4597. m.ResetConcurrency()
  4598. return nil
  4599. case account.FieldLoadFactor:
  4600. m.ResetLoadFactor()
  4601. return nil
  4602. case account.FieldPriority:
  4603. m.ResetPriority()
  4604. return nil
  4605. case account.FieldRateMultiplier:
  4606. m.ResetRateMultiplier()
  4607. return nil
  4608. case account.FieldStatus:
  4609. m.ResetStatus()
  4610. return nil
  4611. case account.FieldErrorMessage:
  4612. m.ResetErrorMessage()
  4613. return nil
  4614. case account.FieldLastUsedAt:
  4615. m.ResetLastUsedAt()
  4616. return nil
  4617. case account.FieldExpiresAt:
  4618. m.ResetExpiresAt()
  4619. return nil
  4620. case account.FieldAutoPauseOnExpired:
  4621. m.ResetAutoPauseOnExpired()
  4622. return nil
  4623. case account.FieldSchedulable:
  4624. m.ResetSchedulable()
  4625. return nil
  4626. case account.FieldRateLimitedAt:
  4627. m.ResetRateLimitedAt()
  4628. return nil
  4629. case account.FieldRateLimitResetAt:
  4630. m.ResetRateLimitResetAt()
  4631. return nil
  4632. case account.FieldOverloadUntil:
  4633. m.ResetOverloadUntil()
  4634. return nil
  4635. case account.FieldTempUnschedulableUntil:
  4636. m.ResetTempUnschedulableUntil()
  4637. return nil
  4638. case account.FieldTempUnschedulableReason:
  4639. m.ResetTempUnschedulableReason()
  4640. return nil
  4641. case account.FieldSessionWindowStart:
  4642. m.ResetSessionWindowStart()
  4643. return nil
  4644. case account.FieldSessionWindowEnd:
  4645. m.ResetSessionWindowEnd()
  4646. return nil
  4647. case account.FieldSessionWindowStatus:
  4648. m.ResetSessionWindowStatus()
  4649. return nil
  4650. case account.FieldParentAccountID:
  4651. m.ResetParentAccountID()
  4652. return nil
  4653. case account.FieldQuotaDimension:
  4654. m.ResetQuotaDimension()
  4655. return nil
  4656. }
  4657. return fmt.Errorf("unknown Account field %s", name)
  4658. }
  4659. // AddedEdges returns all edge names that were set/added in this mutation.
  4660. func (m *AccountMutation) AddedEdges() []string {
  4661. edges := make([]string, 0, 5)
  4662. if m.groups != nil {
  4663. edges = append(edges, account.EdgeGroups)
  4664. }
  4665. if m.proxy != nil {
  4666. edges = append(edges, account.EdgeProxy)
  4667. }
  4668. if m.parent != nil {
  4669. edges = append(edges, account.EdgeParent)
  4670. }
  4671. if m.children != nil {
  4672. edges = append(edges, account.EdgeChildren)
  4673. }
  4674. if m.usage_logs != nil {
  4675. edges = append(edges, account.EdgeUsageLogs)
  4676. }
  4677. return edges
  4678. }
  4679. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  4680. // name in this mutation.
  4681. func (m *AccountMutation) AddedIDs(name string) []ent.Value {
  4682. switch name {
  4683. case account.EdgeGroups:
  4684. ids := make([]ent.Value, 0, len(m.groups))
  4685. for id := range m.groups {
  4686. ids = append(ids, id)
  4687. }
  4688. return ids
  4689. case account.EdgeProxy:
  4690. if id := m.proxy; id != nil {
  4691. return []ent.Value{*id}
  4692. }
  4693. case account.EdgeParent:
  4694. if id := m.parent; id != nil {
  4695. return []ent.Value{*id}
  4696. }
  4697. case account.EdgeChildren:
  4698. ids := make([]ent.Value, 0, len(m.children))
  4699. for id := range m.children {
  4700. ids = append(ids, id)
  4701. }
  4702. return ids
  4703. case account.EdgeUsageLogs:
  4704. ids := make([]ent.Value, 0, len(m.usage_logs))
  4705. for id := range m.usage_logs {
  4706. ids = append(ids, id)
  4707. }
  4708. return ids
  4709. }
  4710. return nil
  4711. }
  4712. // RemovedEdges returns all edge names that were removed in this mutation.
  4713. func (m *AccountMutation) RemovedEdges() []string {
  4714. edges := make([]string, 0, 5)
  4715. if m.removedgroups != nil {
  4716. edges = append(edges, account.EdgeGroups)
  4717. }
  4718. if m.removedchildren != nil {
  4719. edges = append(edges, account.EdgeChildren)
  4720. }
  4721. if m.removedusage_logs != nil {
  4722. edges = append(edges, account.EdgeUsageLogs)
  4723. }
  4724. return edges
  4725. }
  4726. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  4727. // the given name in this mutation.
  4728. func (m *AccountMutation) RemovedIDs(name string) []ent.Value {
  4729. switch name {
  4730. case account.EdgeGroups:
  4731. ids := make([]ent.Value, 0, len(m.removedgroups))
  4732. for id := range m.removedgroups {
  4733. ids = append(ids, id)
  4734. }
  4735. return ids
  4736. case account.EdgeChildren:
  4737. ids := make([]ent.Value, 0, len(m.removedchildren))
  4738. for id := range m.removedchildren {
  4739. ids = append(ids, id)
  4740. }
  4741. return ids
  4742. case account.EdgeUsageLogs:
  4743. ids := make([]ent.Value, 0, len(m.removedusage_logs))
  4744. for id := range m.removedusage_logs {
  4745. ids = append(ids, id)
  4746. }
  4747. return ids
  4748. }
  4749. return nil
  4750. }
  4751. // ClearedEdges returns all edge names that were cleared in this mutation.
  4752. func (m *AccountMutation) ClearedEdges() []string {
  4753. edges := make([]string, 0, 5)
  4754. if m.clearedgroups {
  4755. edges = append(edges, account.EdgeGroups)
  4756. }
  4757. if m.clearedproxy {
  4758. edges = append(edges, account.EdgeProxy)
  4759. }
  4760. if m.clearedparent {
  4761. edges = append(edges, account.EdgeParent)
  4762. }
  4763. if m.clearedchildren {
  4764. edges = append(edges, account.EdgeChildren)
  4765. }
  4766. if m.clearedusage_logs {
  4767. edges = append(edges, account.EdgeUsageLogs)
  4768. }
  4769. return edges
  4770. }
  4771. // EdgeCleared returns a boolean which indicates if the edge with the given name
  4772. // was cleared in this mutation.
  4773. func (m *AccountMutation) EdgeCleared(name string) bool {
  4774. switch name {
  4775. case account.EdgeGroups:
  4776. return m.clearedgroups
  4777. case account.EdgeProxy:
  4778. return m.clearedproxy
  4779. case account.EdgeParent:
  4780. return m.clearedparent
  4781. case account.EdgeChildren:
  4782. return m.clearedchildren
  4783. case account.EdgeUsageLogs:
  4784. return m.clearedusage_logs
  4785. }
  4786. return false
  4787. }
  4788. // ClearEdge clears the value of the edge with the given name. It returns an error
  4789. // if that edge is not defined in the schema.
  4790. func (m *AccountMutation) ClearEdge(name string) error {
  4791. switch name {
  4792. case account.EdgeProxy:
  4793. m.ClearProxy()
  4794. return nil
  4795. case account.EdgeParent:
  4796. m.ClearParent()
  4797. return nil
  4798. }
  4799. return fmt.Errorf("unknown Account unique edge %s", name)
  4800. }
  4801. // ResetEdge resets all changes to the edge with the given name in this mutation.
  4802. // It returns an error if the edge is not defined in the schema.
  4803. func (m *AccountMutation) ResetEdge(name string) error {
  4804. switch name {
  4805. case account.EdgeGroups:
  4806. m.ResetGroups()
  4807. return nil
  4808. case account.EdgeProxy:
  4809. m.ResetProxy()
  4810. return nil
  4811. case account.EdgeParent:
  4812. m.ResetParent()
  4813. return nil
  4814. case account.EdgeChildren:
  4815. m.ResetChildren()
  4816. return nil
  4817. case account.EdgeUsageLogs:
  4818. m.ResetUsageLogs()
  4819. return nil
  4820. }
  4821. return fmt.Errorf("unknown Account edge %s", name)
  4822. }
  4823. // AccountGroupMutation represents an operation that mutates the AccountGroup nodes in the graph.
  4824. type AccountGroupMutation struct {
  4825. config
  4826. op Op
  4827. typ string
  4828. priority *int
  4829. addpriority *int
  4830. created_at *time.Time
  4831. clearedFields map[string]struct{}
  4832. account *int64
  4833. clearedaccount bool
  4834. group *int64
  4835. clearedgroup bool
  4836. done bool
  4837. oldValue func(context.Context) (*AccountGroup, error)
  4838. predicates []predicate.AccountGroup
  4839. }
  4840. var _ ent.Mutation = (*AccountGroupMutation)(nil)
  4841. // accountgroupOption allows management of the mutation configuration using functional options.
  4842. type accountgroupOption func(*AccountGroupMutation)
  4843. // newAccountGroupMutation creates new mutation for the AccountGroup entity.
  4844. func newAccountGroupMutation(c config, op Op, opts ...accountgroupOption) *AccountGroupMutation {
  4845. m := &AccountGroupMutation{
  4846. config: c,
  4847. op: op,
  4848. typ: TypeAccountGroup,
  4849. clearedFields: make(map[string]struct{}),
  4850. }
  4851. for _, opt := range opts {
  4852. opt(m)
  4853. }
  4854. return m
  4855. }
  4856. // Client returns a new `ent.Client` from the mutation. If the mutation was
  4857. // executed in a transaction (ent.Tx), a transactional client is returned.
  4858. func (m AccountGroupMutation) Client() *Client {
  4859. client := &Client{config: m.config}
  4860. client.init()
  4861. return client
  4862. }
  4863. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  4864. // it returns an error otherwise.
  4865. func (m AccountGroupMutation) Tx() (*Tx, error) {
  4866. if _, ok := m.driver.(*txDriver); !ok {
  4867. return nil, errors.New("ent: mutation is not running in a transaction")
  4868. }
  4869. tx := &Tx{config: m.config}
  4870. tx.init()
  4871. return tx, nil
  4872. }
  4873. // SetAccountID sets the "account_id" field.
  4874. func (m *AccountGroupMutation) SetAccountID(i int64) {
  4875. m.account = &i
  4876. }
  4877. // AccountID returns the value of the "account_id" field in the mutation.
  4878. func (m *AccountGroupMutation) AccountID() (r int64, exists bool) {
  4879. v := m.account
  4880. if v == nil {
  4881. return
  4882. }
  4883. return *v, true
  4884. }
  4885. // ResetAccountID resets all changes to the "account_id" field.
  4886. func (m *AccountGroupMutation) ResetAccountID() {
  4887. m.account = nil
  4888. }
  4889. // SetGroupID sets the "group_id" field.
  4890. func (m *AccountGroupMutation) SetGroupID(i int64) {
  4891. m.group = &i
  4892. }
  4893. // GroupID returns the value of the "group_id" field in the mutation.
  4894. func (m *AccountGroupMutation) GroupID() (r int64, exists bool) {
  4895. v := m.group
  4896. if v == nil {
  4897. return
  4898. }
  4899. return *v, true
  4900. }
  4901. // ResetGroupID resets all changes to the "group_id" field.
  4902. func (m *AccountGroupMutation) ResetGroupID() {
  4903. m.group = nil
  4904. }
  4905. // SetPriority sets the "priority" field.
  4906. func (m *AccountGroupMutation) SetPriority(i int) {
  4907. m.priority = &i
  4908. m.addpriority = nil
  4909. }
  4910. // Priority returns the value of the "priority" field in the mutation.
  4911. func (m *AccountGroupMutation) Priority() (r int, exists bool) {
  4912. v := m.priority
  4913. if v == nil {
  4914. return
  4915. }
  4916. return *v, true
  4917. }
  4918. // AddPriority adds i to the "priority" field.
  4919. func (m *AccountGroupMutation) AddPriority(i int) {
  4920. if m.addpriority != nil {
  4921. *m.addpriority += i
  4922. } else {
  4923. m.addpriority = &i
  4924. }
  4925. }
  4926. // AddedPriority returns the value that was added to the "priority" field in this mutation.
  4927. func (m *AccountGroupMutation) AddedPriority() (r int, exists bool) {
  4928. v := m.addpriority
  4929. if v == nil {
  4930. return
  4931. }
  4932. return *v, true
  4933. }
  4934. // ResetPriority resets all changes to the "priority" field.
  4935. func (m *AccountGroupMutation) ResetPriority() {
  4936. m.priority = nil
  4937. m.addpriority = nil
  4938. }
  4939. // SetCreatedAt sets the "created_at" field.
  4940. func (m *AccountGroupMutation) SetCreatedAt(t time.Time) {
  4941. m.created_at = &t
  4942. }
  4943. // CreatedAt returns the value of the "created_at" field in the mutation.
  4944. func (m *AccountGroupMutation) CreatedAt() (r time.Time, exists bool) {
  4945. v := m.created_at
  4946. if v == nil {
  4947. return
  4948. }
  4949. return *v, true
  4950. }
  4951. // ResetCreatedAt resets all changes to the "created_at" field.
  4952. func (m *AccountGroupMutation) ResetCreatedAt() {
  4953. m.created_at = nil
  4954. }
  4955. // ClearAccount clears the "account" edge to the Account entity.
  4956. func (m *AccountGroupMutation) ClearAccount() {
  4957. m.clearedaccount = true
  4958. m.clearedFields[accountgroup.FieldAccountID] = struct{}{}
  4959. }
  4960. // AccountCleared reports if the "account" edge to the Account entity was cleared.
  4961. func (m *AccountGroupMutation) AccountCleared() bool {
  4962. return m.clearedaccount
  4963. }
  4964. // AccountIDs returns the "account" edge IDs in the mutation.
  4965. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  4966. // AccountID instead. It exists only for internal usage by the builders.
  4967. func (m *AccountGroupMutation) AccountIDs() (ids []int64) {
  4968. if id := m.account; id != nil {
  4969. ids = append(ids, *id)
  4970. }
  4971. return
  4972. }
  4973. // ResetAccount resets all changes to the "account" edge.
  4974. func (m *AccountGroupMutation) ResetAccount() {
  4975. m.account = nil
  4976. m.clearedaccount = false
  4977. }
  4978. // ClearGroup clears the "group" edge to the Group entity.
  4979. func (m *AccountGroupMutation) ClearGroup() {
  4980. m.clearedgroup = true
  4981. m.clearedFields[accountgroup.FieldGroupID] = struct{}{}
  4982. }
  4983. // GroupCleared reports if the "group" edge to the Group entity was cleared.
  4984. func (m *AccountGroupMutation) GroupCleared() bool {
  4985. return m.clearedgroup
  4986. }
  4987. // GroupIDs returns the "group" edge IDs in the mutation.
  4988. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  4989. // GroupID instead. It exists only for internal usage by the builders.
  4990. func (m *AccountGroupMutation) GroupIDs() (ids []int64) {
  4991. if id := m.group; id != nil {
  4992. ids = append(ids, *id)
  4993. }
  4994. return
  4995. }
  4996. // ResetGroup resets all changes to the "group" edge.
  4997. func (m *AccountGroupMutation) ResetGroup() {
  4998. m.group = nil
  4999. m.clearedgroup = false
  5000. }
  5001. // Where appends a list predicates to the AccountGroupMutation builder.
  5002. func (m *AccountGroupMutation) Where(ps ...predicate.AccountGroup) {
  5003. m.predicates = append(m.predicates, ps...)
  5004. }
  5005. // WhereP appends storage-level predicates to the AccountGroupMutation builder. Using this method,
  5006. // users can use type-assertion to append predicates that do not depend on any generated package.
  5007. func (m *AccountGroupMutation) WhereP(ps ...func(*sql.Selector)) {
  5008. p := make([]predicate.AccountGroup, len(ps))
  5009. for i := range ps {
  5010. p[i] = ps[i]
  5011. }
  5012. m.Where(p...)
  5013. }
  5014. // Op returns the operation name.
  5015. func (m *AccountGroupMutation) Op() Op {
  5016. return m.op
  5017. }
  5018. // SetOp allows setting the mutation operation.
  5019. func (m *AccountGroupMutation) SetOp(op Op) {
  5020. m.op = op
  5021. }
  5022. // Type returns the node type of this mutation (AccountGroup).
  5023. func (m *AccountGroupMutation) Type() string {
  5024. return m.typ
  5025. }
  5026. // Fields returns all fields that were changed during this mutation. Note that in
  5027. // order to get all numeric fields that were incremented/decremented, call
  5028. // AddedFields().
  5029. func (m *AccountGroupMutation) Fields() []string {
  5030. fields := make([]string, 0, 4)
  5031. if m.account != nil {
  5032. fields = append(fields, accountgroup.FieldAccountID)
  5033. }
  5034. if m.group != nil {
  5035. fields = append(fields, accountgroup.FieldGroupID)
  5036. }
  5037. if m.priority != nil {
  5038. fields = append(fields, accountgroup.FieldPriority)
  5039. }
  5040. if m.created_at != nil {
  5041. fields = append(fields, accountgroup.FieldCreatedAt)
  5042. }
  5043. return fields
  5044. }
  5045. // Field returns the value of a field with the given name. The second boolean
  5046. // return value indicates that this field was not set, or was not defined in the
  5047. // schema.
  5048. func (m *AccountGroupMutation) Field(name string) (ent.Value, bool) {
  5049. switch name {
  5050. case accountgroup.FieldAccountID:
  5051. return m.AccountID()
  5052. case accountgroup.FieldGroupID:
  5053. return m.GroupID()
  5054. case accountgroup.FieldPriority:
  5055. return m.Priority()
  5056. case accountgroup.FieldCreatedAt:
  5057. return m.CreatedAt()
  5058. }
  5059. return nil, false
  5060. }
  5061. // OldField returns the old value of the field from the database. An error is
  5062. // returned if the mutation operation is not UpdateOne, or the query to the
  5063. // database failed.
  5064. func (m *AccountGroupMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  5065. return nil, errors.New("edge schema AccountGroup does not support getting old values")
  5066. }
  5067. // SetField sets the value of a field with the given name. It returns an error if
  5068. // the field is not defined in the schema, or if the type mismatched the field
  5069. // type.
  5070. func (m *AccountGroupMutation) SetField(name string, value ent.Value) error {
  5071. switch name {
  5072. case accountgroup.FieldAccountID:
  5073. v, ok := value.(int64)
  5074. if !ok {
  5075. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5076. }
  5077. m.SetAccountID(v)
  5078. return nil
  5079. case accountgroup.FieldGroupID:
  5080. v, ok := value.(int64)
  5081. if !ok {
  5082. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5083. }
  5084. m.SetGroupID(v)
  5085. return nil
  5086. case accountgroup.FieldPriority:
  5087. v, ok := value.(int)
  5088. if !ok {
  5089. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5090. }
  5091. m.SetPriority(v)
  5092. return nil
  5093. case accountgroup.FieldCreatedAt:
  5094. v, ok := value.(time.Time)
  5095. if !ok {
  5096. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5097. }
  5098. m.SetCreatedAt(v)
  5099. return nil
  5100. }
  5101. return fmt.Errorf("unknown AccountGroup field %s", name)
  5102. }
  5103. // AddedFields returns all numeric fields that were incremented/decremented during
  5104. // this mutation.
  5105. func (m *AccountGroupMutation) AddedFields() []string {
  5106. var fields []string
  5107. if m.addpriority != nil {
  5108. fields = append(fields, accountgroup.FieldPriority)
  5109. }
  5110. return fields
  5111. }
  5112. // AddedField returns the numeric value that was incremented/decremented on a field
  5113. // with the given name. The second boolean return value indicates that this field
  5114. // was not set, or was not defined in the schema.
  5115. func (m *AccountGroupMutation) AddedField(name string) (ent.Value, bool) {
  5116. switch name {
  5117. case accountgroup.FieldPriority:
  5118. return m.AddedPriority()
  5119. }
  5120. return nil, false
  5121. }
  5122. // AddField adds the value to the field with the given name. It returns an error if
  5123. // the field is not defined in the schema, or if the type mismatched the field
  5124. // type.
  5125. func (m *AccountGroupMutation) AddField(name string, value ent.Value) error {
  5126. switch name {
  5127. case accountgroup.FieldPriority:
  5128. v, ok := value.(int)
  5129. if !ok {
  5130. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5131. }
  5132. m.AddPriority(v)
  5133. return nil
  5134. }
  5135. return fmt.Errorf("unknown AccountGroup numeric field %s", name)
  5136. }
  5137. // ClearedFields returns all nullable fields that were cleared during this
  5138. // mutation.
  5139. func (m *AccountGroupMutation) ClearedFields() []string {
  5140. return nil
  5141. }
  5142. // FieldCleared returns a boolean indicating if a field with the given name was
  5143. // cleared in this mutation.
  5144. func (m *AccountGroupMutation) FieldCleared(name string) bool {
  5145. _, ok := m.clearedFields[name]
  5146. return ok
  5147. }
  5148. // ClearField clears the value of the field with the given name. It returns an
  5149. // error if the field is not defined in the schema.
  5150. func (m *AccountGroupMutation) ClearField(name string) error {
  5151. return fmt.Errorf("unknown AccountGroup nullable field %s", name)
  5152. }
  5153. // ResetField resets all changes in the mutation for the field with the given name.
  5154. // It returns an error if the field is not defined in the schema.
  5155. func (m *AccountGroupMutation) ResetField(name string) error {
  5156. switch name {
  5157. case accountgroup.FieldAccountID:
  5158. m.ResetAccountID()
  5159. return nil
  5160. case accountgroup.FieldGroupID:
  5161. m.ResetGroupID()
  5162. return nil
  5163. case accountgroup.FieldPriority:
  5164. m.ResetPriority()
  5165. return nil
  5166. case accountgroup.FieldCreatedAt:
  5167. m.ResetCreatedAt()
  5168. return nil
  5169. }
  5170. return fmt.Errorf("unknown AccountGroup field %s", name)
  5171. }
  5172. // AddedEdges returns all edge names that were set/added in this mutation.
  5173. func (m *AccountGroupMutation) AddedEdges() []string {
  5174. edges := make([]string, 0, 2)
  5175. if m.account != nil {
  5176. edges = append(edges, accountgroup.EdgeAccount)
  5177. }
  5178. if m.group != nil {
  5179. edges = append(edges, accountgroup.EdgeGroup)
  5180. }
  5181. return edges
  5182. }
  5183. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  5184. // name in this mutation.
  5185. func (m *AccountGroupMutation) AddedIDs(name string) []ent.Value {
  5186. switch name {
  5187. case accountgroup.EdgeAccount:
  5188. if id := m.account; id != nil {
  5189. return []ent.Value{*id}
  5190. }
  5191. case accountgroup.EdgeGroup:
  5192. if id := m.group; id != nil {
  5193. return []ent.Value{*id}
  5194. }
  5195. }
  5196. return nil
  5197. }
  5198. // RemovedEdges returns all edge names that were removed in this mutation.
  5199. func (m *AccountGroupMutation) RemovedEdges() []string {
  5200. edges := make([]string, 0, 2)
  5201. return edges
  5202. }
  5203. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  5204. // the given name in this mutation.
  5205. func (m *AccountGroupMutation) RemovedIDs(name string) []ent.Value {
  5206. return nil
  5207. }
  5208. // ClearedEdges returns all edge names that were cleared in this mutation.
  5209. func (m *AccountGroupMutation) ClearedEdges() []string {
  5210. edges := make([]string, 0, 2)
  5211. if m.clearedaccount {
  5212. edges = append(edges, accountgroup.EdgeAccount)
  5213. }
  5214. if m.clearedgroup {
  5215. edges = append(edges, accountgroup.EdgeGroup)
  5216. }
  5217. return edges
  5218. }
  5219. // EdgeCleared returns a boolean which indicates if the edge with the given name
  5220. // was cleared in this mutation.
  5221. func (m *AccountGroupMutation) EdgeCleared(name string) bool {
  5222. switch name {
  5223. case accountgroup.EdgeAccount:
  5224. return m.clearedaccount
  5225. case accountgroup.EdgeGroup:
  5226. return m.clearedgroup
  5227. }
  5228. return false
  5229. }
  5230. // ClearEdge clears the value of the edge with the given name. It returns an error
  5231. // if that edge is not defined in the schema.
  5232. func (m *AccountGroupMutation) ClearEdge(name string) error {
  5233. switch name {
  5234. case accountgroup.EdgeAccount:
  5235. m.ClearAccount()
  5236. return nil
  5237. case accountgroup.EdgeGroup:
  5238. m.ClearGroup()
  5239. return nil
  5240. }
  5241. return fmt.Errorf("unknown AccountGroup unique edge %s", name)
  5242. }
  5243. // ResetEdge resets all changes to the edge with the given name in this mutation.
  5244. // It returns an error if the edge is not defined in the schema.
  5245. func (m *AccountGroupMutation) ResetEdge(name string) error {
  5246. switch name {
  5247. case accountgroup.EdgeAccount:
  5248. m.ResetAccount()
  5249. return nil
  5250. case accountgroup.EdgeGroup:
  5251. m.ResetGroup()
  5252. return nil
  5253. }
  5254. return fmt.Errorf("unknown AccountGroup edge %s", name)
  5255. }
  5256. // AnnouncementMutation represents an operation that mutates the Announcement nodes in the graph.
  5257. type AnnouncementMutation struct {
  5258. config
  5259. op Op
  5260. typ string
  5261. id *int64
  5262. title *string
  5263. content *string
  5264. status *string
  5265. notify_mode *string
  5266. targeting *domain.AnnouncementTargeting
  5267. starts_at *time.Time
  5268. ends_at *time.Time
  5269. created_by *int64
  5270. addcreated_by *int64
  5271. updated_by *int64
  5272. addupdated_by *int64
  5273. created_at *time.Time
  5274. updated_at *time.Time
  5275. clearedFields map[string]struct{}
  5276. reads map[int64]struct{}
  5277. removedreads map[int64]struct{}
  5278. clearedreads bool
  5279. done bool
  5280. oldValue func(context.Context) (*Announcement, error)
  5281. predicates []predicate.Announcement
  5282. }
  5283. var _ ent.Mutation = (*AnnouncementMutation)(nil)
  5284. // announcementOption allows management of the mutation configuration using functional options.
  5285. type announcementOption func(*AnnouncementMutation)
  5286. // newAnnouncementMutation creates new mutation for the Announcement entity.
  5287. func newAnnouncementMutation(c config, op Op, opts ...announcementOption) *AnnouncementMutation {
  5288. m := &AnnouncementMutation{
  5289. config: c,
  5290. op: op,
  5291. typ: TypeAnnouncement,
  5292. clearedFields: make(map[string]struct{}),
  5293. }
  5294. for _, opt := range opts {
  5295. opt(m)
  5296. }
  5297. return m
  5298. }
  5299. // withAnnouncementID sets the ID field of the mutation.
  5300. func withAnnouncementID(id int64) announcementOption {
  5301. return func(m *AnnouncementMutation) {
  5302. var (
  5303. err error
  5304. once sync.Once
  5305. value *Announcement
  5306. )
  5307. m.oldValue = func(ctx context.Context) (*Announcement, error) {
  5308. once.Do(func() {
  5309. if m.done {
  5310. err = errors.New("querying old values post mutation is not allowed")
  5311. } else {
  5312. value, err = m.Client().Announcement.Get(ctx, id)
  5313. }
  5314. })
  5315. return value, err
  5316. }
  5317. m.id = &id
  5318. }
  5319. }
  5320. // withAnnouncement sets the old Announcement of the mutation.
  5321. func withAnnouncement(node *Announcement) announcementOption {
  5322. return func(m *AnnouncementMutation) {
  5323. m.oldValue = func(context.Context) (*Announcement, error) {
  5324. return node, nil
  5325. }
  5326. m.id = &node.ID
  5327. }
  5328. }
  5329. // Client returns a new `ent.Client` from the mutation. If the mutation was
  5330. // executed in a transaction (ent.Tx), a transactional client is returned.
  5331. func (m AnnouncementMutation) Client() *Client {
  5332. client := &Client{config: m.config}
  5333. client.init()
  5334. return client
  5335. }
  5336. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  5337. // it returns an error otherwise.
  5338. func (m AnnouncementMutation) Tx() (*Tx, error) {
  5339. if _, ok := m.driver.(*txDriver); !ok {
  5340. return nil, errors.New("ent: mutation is not running in a transaction")
  5341. }
  5342. tx := &Tx{config: m.config}
  5343. tx.init()
  5344. return tx, nil
  5345. }
  5346. // ID returns the ID value in the mutation. Note that the ID is only available
  5347. // if it was provided to the builder or after it was returned from the database.
  5348. func (m *AnnouncementMutation) ID() (id int64, exists bool) {
  5349. if m.id == nil {
  5350. return
  5351. }
  5352. return *m.id, true
  5353. }
  5354. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  5355. // That means, if the mutation is applied within a transaction with an isolation level such
  5356. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  5357. // or updated by the mutation.
  5358. func (m *AnnouncementMutation) IDs(ctx context.Context) ([]int64, error) {
  5359. switch {
  5360. case m.op.Is(OpUpdateOne | OpDeleteOne):
  5361. id, exists := m.ID()
  5362. if exists {
  5363. return []int64{id}, nil
  5364. }
  5365. fallthrough
  5366. case m.op.Is(OpUpdate | OpDelete):
  5367. return m.Client().Announcement.Query().Where(m.predicates...).IDs(ctx)
  5368. default:
  5369. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  5370. }
  5371. }
  5372. // SetTitle sets the "title" field.
  5373. func (m *AnnouncementMutation) SetTitle(s string) {
  5374. m.title = &s
  5375. }
  5376. // Title returns the value of the "title" field in the mutation.
  5377. func (m *AnnouncementMutation) Title() (r string, exists bool) {
  5378. v := m.title
  5379. if v == nil {
  5380. return
  5381. }
  5382. return *v, true
  5383. }
  5384. // OldTitle returns the old "title" field's value of the Announcement entity.
  5385. // If the Announcement object wasn't provided to the builder, the object is fetched from the database.
  5386. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5387. func (m *AnnouncementMutation) OldTitle(ctx context.Context) (v string, err error) {
  5388. if !m.op.Is(OpUpdateOne) {
  5389. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  5390. }
  5391. if m.id == nil || m.oldValue == nil {
  5392. return v, errors.New("OldTitle requires an ID field in the mutation")
  5393. }
  5394. oldValue, err := m.oldValue(ctx)
  5395. if err != nil {
  5396. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  5397. }
  5398. return oldValue.Title, nil
  5399. }
  5400. // ResetTitle resets all changes to the "title" field.
  5401. func (m *AnnouncementMutation) ResetTitle() {
  5402. m.title = nil
  5403. }
  5404. // SetContent sets the "content" field.
  5405. func (m *AnnouncementMutation) SetContent(s string) {
  5406. m.content = &s
  5407. }
  5408. // Content returns the value of the "content" field in the mutation.
  5409. func (m *AnnouncementMutation) Content() (r string, exists bool) {
  5410. v := m.content
  5411. if v == nil {
  5412. return
  5413. }
  5414. return *v, true
  5415. }
  5416. // OldContent returns the old "content" field's value of the Announcement entity.
  5417. // If the Announcement object wasn't provided to the builder, the object is fetched from the database.
  5418. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5419. func (m *AnnouncementMutation) OldContent(ctx context.Context) (v string, err error) {
  5420. if !m.op.Is(OpUpdateOne) {
  5421. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  5422. }
  5423. if m.id == nil || m.oldValue == nil {
  5424. return v, errors.New("OldContent requires an ID field in the mutation")
  5425. }
  5426. oldValue, err := m.oldValue(ctx)
  5427. if err != nil {
  5428. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  5429. }
  5430. return oldValue.Content, nil
  5431. }
  5432. // ResetContent resets all changes to the "content" field.
  5433. func (m *AnnouncementMutation) ResetContent() {
  5434. m.content = nil
  5435. }
  5436. // SetStatus sets the "status" field.
  5437. func (m *AnnouncementMutation) SetStatus(s string) {
  5438. m.status = &s
  5439. }
  5440. // Status returns the value of the "status" field in the mutation.
  5441. func (m *AnnouncementMutation) Status() (r string, exists bool) {
  5442. v := m.status
  5443. if v == nil {
  5444. return
  5445. }
  5446. return *v, true
  5447. }
  5448. // OldStatus returns the old "status" field's value of the Announcement entity.
  5449. // If the Announcement object wasn't provided to the builder, the object is fetched from the database.
  5450. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5451. func (m *AnnouncementMutation) OldStatus(ctx context.Context) (v string, err error) {
  5452. if !m.op.Is(OpUpdateOne) {
  5453. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  5454. }
  5455. if m.id == nil || m.oldValue == nil {
  5456. return v, errors.New("OldStatus requires an ID field in the mutation")
  5457. }
  5458. oldValue, err := m.oldValue(ctx)
  5459. if err != nil {
  5460. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  5461. }
  5462. return oldValue.Status, nil
  5463. }
  5464. // ResetStatus resets all changes to the "status" field.
  5465. func (m *AnnouncementMutation) ResetStatus() {
  5466. m.status = nil
  5467. }
  5468. // SetNotifyMode sets the "notify_mode" field.
  5469. func (m *AnnouncementMutation) SetNotifyMode(s string) {
  5470. m.notify_mode = &s
  5471. }
  5472. // NotifyMode returns the value of the "notify_mode" field in the mutation.
  5473. func (m *AnnouncementMutation) NotifyMode() (r string, exists bool) {
  5474. v := m.notify_mode
  5475. if v == nil {
  5476. return
  5477. }
  5478. return *v, true
  5479. }
  5480. // OldNotifyMode returns the old "notify_mode" field's value of the Announcement entity.
  5481. // If the Announcement object wasn't provided to the builder, the object is fetched from the database.
  5482. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5483. func (m *AnnouncementMutation) OldNotifyMode(ctx context.Context) (v string, err error) {
  5484. if !m.op.Is(OpUpdateOne) {
  5485. return v, errors.New("OldNotifyMode is only allowed on UpdateOne operations")
  5486. }
  5487. if m.id == nil || m.oldValue == nil {
  5488. return v, errors.New("OldNotifyMode requires an ID field in the mutation")
  5489. }
  5490. oldValue, err := m.oldValue(ctx)
  5491. if err != nil {
  5492. return v, fmt.Errorf("querying old value for OldNotifyMode: %w", err)
  5493. }
  5494. return oldValue.NotifyMode, nil
  5495. }
  5496. // ResetNotifyMode resets all changes to the "notify_mode" field.
  5497. func (m *AnnouncementMutation) ResetNotifyMode() {
  5498. m.notify_mode = nil
  5499. }
  5500. // SetTargeting sets the "targeting" field.
  5501. func (m *AnnouncementMutation) SetTargeting(dt domain.AnnouncementTargeting) {
  5502. m.targeting = &dt
  5503. }
  5504. // Targeting returns the value of the "targeting" field in the mutation.
  5505. func (m *AnnouncementMutation) Targeting() (r domain.AnnouncementTargeting, exists bool) {
  5506. v := m.targeting
  5507. if v == nil {
  5508. return
  5509. }
  5510. return *v, true
  5511. }
  5512. // OldTargeting returns the old "targeting" field's value of the Announcement entity.
  5513. // If the Announcement object wasn't provided to the builder, the object is fetched from the database.
  5514. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5515. func (m *AnnouncementMutation) OldTargeting(ctx context.Context) (v domain.AnnouncementTargeting, err error) {
  5516. if !m.op.Is(OpUpdateOne) {
  5517. return v, errors.New("OldTargeting is only allowed on UpdateOne operations")
  5518. }
  5519. if m.id == nil || m.oldValue == nil {
  5520. return v, errors.New("OldTargeting requires an ID field in the mutation")
  5521. }
  5522. oldValue, err := m.oldValue(ctx)
  5523. if err != nil {
  5524. return v, fmt.Errorf("querying old value for OldTargeting: %w", err)
  5525. }
  5526. return oldValue.Targeting, nil
  5527. }
  5528. // ClearTargeting clears the value of the "targeting" field.
  5529. func (m *AnnouncementMutation) ClearTargeting() {
  5530. m.targeting = nil
  5531. m.clearedFields[announcement.FieldTargeting] = struct{}{}
  5532. }
  5533. // TargetingCleared returns if the "targeting" field was cleared in this mutation.
  5534. func (m *AnnouncementMutation) TargetingCleared() bool {
  5535. _, ok := m.clearedFields[announcement.FieldTargeting]
  5536. return ok
  5537. }
  5538. // ResetTargeting resets all changes to the "targeting" field.
  5539. func (m *AnnouncementMutation) ResetTargeting() {
  5540. m.targeting = nil
  5541. delete(m.clearedFields, announcement.FieldTargeting)
  5542. }
  5543. // SetStartsAt sets the "starts_at" field.
  5544. func (m *AnnouncementMutation) SetStartsAt(t time.Time) {
  5545. m.starts_at = &t
  5546. }
  5547. // StartsAt returns the value of the "starts_at" field in the mutation.
  5548. func (m *AnnouncementMutation) StartsAt() (r time.Time, exists bool) {
  5549. v := m.starts_at
  5550. if v == nil {
  5551. return
  5552. }
  5553. return *v, true
  5554. }
  5555. // OldStartsAt returns the old "starts_at" field's value of the Announcement entity.
  5556. // If the Announcement object wasn't provided to the builder, the object is fetched from the database.
  5557. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5558. func (m *AnnouncementMutation) OldStartsAt(ctx context.Context) (v *time.Time, err error) {
  5559. if !m.op.Is(OpUpdateOne) {
  5560. return v, errors.New("OldStartsAt is only allowed on UpdateOne operations")
  5561. }
  5562. if m.id == nil || m.oldValue == nil {
  5563. return v, errors.New("OldStartsAt requires an ID field in the mutation")
  5564. }
  5565. oldValue, err := m.oldValue(ctx)
  5566. if err != nil {
  5567. return v, fmt.Errorf("querying old value for OldStartsAt: %w", err)
  5568. }
  5569. return oldValue.StartsAt, nil
  5570. }
  5571. // ClearStartsAt clears the value of the "starts_at" field.
  5572. func (m *AnnouncementMutation) ClearStartsAt() {
  5573. m.starts_at = nil
  5574. m.clearedFields[announcement.FieldStartsAt] = struct{}{}
  5575. }
  5576. // StartsAtCleared returns if the "starts_at" field was cleared in this mutation.
  5577. func (m *AnnouncementMutation) StartsAtCleared() bool {
  5578. _, ok := m.clearedFields[announcement.FieldStartsAt]
  5579. return ok
  5580. }
  5581. // ResetStartsAt resets all changes to the "starts_at" field.
  5582. func (m *AnnouncementMutation) ResetStartsAt() {
  5583. m.starts_at = nil
  5584. delete(m.clearedFields, announcement.FieldStartsAt)
  5585. }
  5586. // SetEndsAt sets the "ends_at" field.
  5587. func (m *AnnouncementMutation) SetEndsAt(t time.Time) {
  5588. m.ends_at = &t
  5589. }
  5590. // EndsAt returns the value of the "ends_at" field in the mutation.
  5591. func (m *AnnouncementMutation) EndsAt() (r time.Time, exists bool) {
  5592. v := m.ends_at
  5593. if v == nil {
  5594. return
  5595. }
  5596. return *v, true
  5597. }
  5598. // OldEndsAt returns the old "ends_at" field's value of the Announcement entity.
  5599. // If the Announcement object wasn't provided to the builder, the object is fetched from the database.
  5600. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5601. func (m *AnnouncementMutation) OldEndsAt(ctx context.Context) (v *time.Time, err error) {
  5602. if !m.op.Is(OpUpdateOne) {
  5603. return v, errors.New("OldEndsAt is only allowed on UpdateOne operations")
  5604. }
  5605. if m.id == nil || m.oldValue == nil {
  5606. return v, errors.New("OldEndsAt requires an ID field in the mutation")
  5607. }
  5608. oldValue, err := m.oldValue(ctx)
  5609. if err != nil {
  5610. return v, fmt.Errorf("querying old value for OldEndsAt: %w", err)
  5611. }
  5612. return oldValue.EndsAt, nil
  5613. }
  5614. // ClearEndsAt clears the value of the "ends_at" field.
  5615. func (m *AnnouncementMutation) ClearEndsAt() {
  5616. m.ends_at = nil
  5617. m.clearedFields[announcement.FieldEndsAt] = struct{}{}
  5618. }
  5619. // EndsAtCleared returns if the "ends_at" field was cleared in this mutation.
  5620. func (m *AnnouncementMutation) EndsAtCleared() bool {
  5621. _, ok := m.clearedFields[announcement.FieldEndsAt]
  5622. return ok
  5623. }
  5624. // ResetEndsAt resets all changes to the "ends_at" field.
  5625. func (m *AnnouncementMutation) ResetEndsAt() {
  5626. m.ends_at = nil
  5627. delete(m.clearedFields, announcement.FieldEndsAt)
  5628. }
  5629. // SetCreatedBy sets the "created_by" field.
  5630. func (m *AnnouncementMutation) SetCreatedBy(i int64) {
  5631. m.created_by = &i
  5632. m.addcreated_by = nil
  5633. }
  5634. // CreatedBy returns the value of the "created_by" field in the mutation.
  5635. func (m *AnnouncementMutation) CreatedBy() (r int64, exists bool) {
  5636. v := m.created_by
  5637. if v == nil {
  5638. return
  5639. }
  5640. return *v, true
  5641. }
  5642. // OldCreatedBy returns the old "created_by" field's value of the Announcement entity.
  5643. // If the Announcement object wasn't provided to the builder, the object is fetched from the database.
  5644. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5645. func (m *AnnouncementMutation) OldCreatedBy(ctx context.Context) (v *int64, err error) {
  5646. if !m.op.Is(OpUpdateOne) {
  5647. return v, errors.New("OldCreatedBy is only allowed on UpdateOne operations")
  5648. }
  5649. if m.id == nil || m.oldValue == nil {
  5650. return v, errors.New("OldCreatedBy requires an ID field in the mutation")
  5651. }
  5652. oldValue, err := m.oldValue(ctx)
  5653. if err != nil {
  5654. return v, fmt.Errorf("querying old value for OldCreatedBy: %w", err)
  5655. }
  5656. return oldValue.CreatedBy, nil
  5657. }
  5658. // AddCreatedBy adds i to the "created_by" field.
  5659. func (m *AnnouncementMutation) AddCreatedBy(i int64) {
  5660. if m.addcreated_by != nil {
  5661. *m.addcreated_by += i
  5662. } else {
  5663. m.addcreated_by = &i
  5664. }
  5665. }
  5666. // AddedCreatedBy returns the value that was added to the "created_by" field in this mutation.
  5667. func (m *AnnouncementMutation) AddedCreatedBy() (r int64, exists bool) {
  5668. v := m.addcreated_by
  5669. if v == nil {
  5670. return
  5671. }
  5672. return *v, true
  5673. }
  5674. // ClearCreatedBy clears the value of the "created_by" field.
  5675. func (m *AnnouncementMutation) ClearCreatedBy() {
  5676. m.created_by = nil
  5677. m.addcreated_by = nil
  5678. m.clearedFields[announcement.FieldCreatedBy] = struct{}{}
  5679. }
  5680. // CreatedByCleared returns if the "created_by" field was cleared in this mutation.
  5681. func (m *AnnouncementMutation) CreatedByCleared() bool {
  5682. _, ok := m.clearedFields[announcement.FieldCreatedBy]
  5683. return ok
  5684. }
  5685. // ResetCreatedBy resets all changes to the "created_by" field.
  5686. func (m *AnnouncementMutation) ResetCreatedBy() {
  5687. m.created_by = nil
  5688. m.addcreated_by = nil
  5689. delete(m.clearedFields, announcement.FieldCreatedBy)
  5690. }
  5691. // SetUpdatedBy sets the "updated_by" field.
  5692. func (m *AnnouncementMutation) SetUpdatedBy(i int64) {
  5693. m.updated_by = &i
  5694. m.addupdated_by = nil
  5695. }
  5696. // UpdatedBy returns the value of the "updated_by" field in the mutation.
  5697. func (m *AnnouncementMutation) UpdatedBy() (r int64, exists bool) {
  5698. v := m.updated_by
  5699. if v == nil {
  5700. return
  5701. }
  5702. return *v, true
  5703. }
  5704. // OldUpdatedBy returns the old "updated_by" field's value of the Announcement entity.
  5705. // If the Announcement object wasn't provided to the builder, the object is fetched from the database.
  5706. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5707. func (m *AnnouncementMutation) OldUpdatedBy(ctx context.Context) (v *int64, err error) {
  5708. if !m.op.Is(OpUpdateOne) {
  5709. return v, errors.New("OldUpdatedBy is only allowed on UpdateOne operations")
  5710. }
  5711. if m.id == nil || m.oldValue == nil {
  5712. return v, errors.New("OldUpdatedBy requires an ID field in the mutation")
  5713. }
  5714. oldValue, err := m.oldValue(ctx)
  5715. if err != nil {
  5716. return v, fmt.Errorf("querying old value for OldUpdatedBy: %w", err)
  5717. }
  5718. return oldValue.UpdatedBy, nil
  5719. }
  5720. // AddUpdatedBy adds i to the "updated_by" field.
  5721. func (m *AnnouncementMutation) AddUpdatedBy(i int64) {
  5722. if m.addupdated_by != nil {
  5723. *m.addupdated_by += i
  5724. } else {
  5725. m.addupdated_by = &i
  5726. }
  5727. }
  5728. // AddedUpdatedBy returns the value that was added to the "updated_by" field in this mutation.
  5729. func (m *AnnouncementMutation) AddedUpdatedBy() (r int64, exists bool) {
  5730. v := m.addupdated_by
  5731. if v == nil {
  5732. return
  5733. }
  5734. return *v, true
  5735. }
  5736. // ClearUpdatedBy clears the value of the "updated_by" field.
  5737. func (m *AnnouncementMutation) ClearUpdatedBy() {
  5738. m.updated_by = nil
  5739. m.addupdated_by = nil
  5740. m.clearedFields[announcement.FieldUpdatedBy] = struct{}{}
  5741. }
  5742. // UpdatedByCleared returns if the "updated_by" field was cleared in this mutation.
  5743. func (m *AnnouncementMutation) UpdatedByCleared() bool {
  5744. _, ok := m.clearedFields[announcement.FieldUpdatedBy]
  5745. return ok
  5746. }
  5747. // ResetUpdatedBy resets all changes to the "updated_by" field.
  5748. func (m *AnnouncementMutation) ResetUpdatedBy() {
  5749. m.updated_by = nil
  5750. m.addupdated_by = nil
  5751. delete(m.clearedFields, announcement.FieldUpdatedBy)
  5752. }
  5753. // SetCreatedAt sets the "created_at" field.
  5754. func (m *AnnouncementMutation) SetCreatedAt(t time.Time) {
  5755. m.created_at = &t
  5756. }
  5757. // CreatedAt returns the value of the "created_at" field in the mutation.
  5758. func (m *AnnouncementMutation) CreatedAt() (r time.Time, exists bool) {
  5759. v := m.created_at
  5760. if v == nil {
  5761. return
  5762. }
  5763. return *v, true
  5764. }
  5765. // OldCreatedAt returns the old "created_at" field's value of the Announcement entity.
  5766. // If the Announcement object wasn't provided to the builder, the object is fetched from the database.
  5767. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5768. func (m *AnnouncementMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  5769. if !m.op.Is(OpUpdateOne) {
  5770. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  5771. }
  5772. if m.id == nil || m.oldValue == nil {
  5773. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  5774. }
  5775. oldValue, err := m.oldValue(ctx)
  5776. if err != nil {
  5777. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  5778. }
  5779. return oldValue.CreatedAt, nil
  5780. }
  5781. // ResetCreatedAt resets all changes to the "created_at" field.
  5782. func (m *AnnouncementMutation) ResetCreatedAt() {
  5783. m.created_at = nil
  5784. }
  5785. // SetUpdatedAt sets the "updated_at" field.
  5786. func (m *AnnouncementMutation) SetUpdatedAt(t time.Time) {
  5787. m.updated_at = &t
  5788. }
  5789. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  5790. func (m *AnnouncementMutation) UpdatedAt() (r time.Time, exists bool) {
  5791. v := m.updated_at
  5792. if v == nil {
  5793. return
  5794. }
  5795. return *v, true
  5796. }
  5797. // OldUpdatedAt returns the old "updated_at" field's value of the Announcement entity.
  5798. // If the Announcement object wasn't provided to the builder, the object is fetched from the database.
  5799. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5800. func (m *AnnouncementMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  5801. if !m.op.Is(OpUpdateOne) {
  5802. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  5803. }
  5804. if m.id == nil || m.oldValue == nil {
  5805. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  5806. }
  5807. oldValue, err := m.oldValue(ctx)
  5808. if err != nil {
  5809. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  5810. }
  5811. return oldValue.UpdatedAt, nil
  5812. }
  5813. // ResetUpdatedAt resets all changes to the "updated_at" field.
  5814. func (m *AnnouncementMutation) ResetUpdatedAt() {
  5815. m.updated_at = nil
  5816. }
  5817. // AddReadIDs adds the "reads" edge to the AnnouncementRead entity by ids.
  5818. func (m *AnnouncementMutation) AddReadIDs(ids ...int64) {
  5819. if m.reads == nil {
  5820. m.reads = make(map[int64]struct{})
  5821. }
  5822. for i := range ids {
  5823. m.reads[ids[i]] = struct{}{}
  5824. }
  5825. }
  5826. // ClearReads clears the "reads" edge to the AnnouncementRead entity.
  5827. func (m *AnnouncementMutation) ClearReads() {
  5828. m.clearedreads = true
  5829. }
  5830. // ReadsCleared reports if the "reads" edge to the AnnouncementRead entity was cleared.
  5831. func (m *AnnouncementMutation) ReadsCleared() bool {
  5832. return m.clearedreads
  5833. }
  5834. // RemoveReadIDs removes the "reads" edge to the AnnouncementRead entity by IDs.
  5835. func (m *AnnouncementMutation) RemoveReadIDs(ids ...int64) {
  5836. if m.removedreads == nil {
  5837. m.removedreads = make(map[int64]struct{})
  5838. }
  5839. for i := range ids {
  5840. delete(m.reads, ids[i])
  5841. m.removedreads[ids[i]] = struct{}{}
  5842. }
  5843. }
  5844. // RemovedReads returns the removed IDs of the "reads" edge to the AnnouncementRead entity.
  5845. func (m *AnnouncementMutation) RemovedReadsIDs() (ids []int64) {
  5846. for id := range m.removedreads {
  5847. ids = append(ids, id)
  5848. }
  5849. return
  5850. }
  5851. // ReadsIDs returns the "reads" edge IDs in the mutation.
  5852. func (m *AnnouncementMutation) ReadsIDs() (ids []int64) {
  5853. for id := range m.reads {
  5854. ids = append(ids, id)
  5855. }
  5856. return
  5857. }
  5858. // ResetReads resets all changes to the "reads" edge.
  5859. func (m *AnnouncementMutation) ResetReads() {
  5860. m.reads = nil
  5861. m.clearedreads = false
  5862. m.removedreads = nil
  5863. }
  5864. // Where appends a list predicates to the AnnouncementMutation builder.
  5865. func (m *AnnouncementMutation) Where(ps ...predicate.Announcement) {
  5866. m.predicates = append(m.predicates, ps...)
  5867. }
  5868. // WhereP appends storage-level predicates to the AnnouncementMutation builder. Using this method,
  5869. // users can use type-assertion to append predicates that do not depend on any generated package.
  5870. func (m *AnnouncementMutation) WhereP(ps ...func(*sql.Selector)) {
  5871. p := make([]predicate.Announcement, len(ps))
  5872. for i := range ps {
  5873. p[i] = ps[i]
  5874. }
  5875. m.Where(p...)
  5876. }
  5877. // Op returns the operation name.
  5878. func (m *AnnouncementMutation) Op() Op {
  5879. return m.op
  5880. }
  5881. // SetOp allows setting the mutation operation.
  5882. func (m *AnnouncementMutation) SetOp(op Op) {
  5883. m.op = op
  5884. }
  5885. // Type returns the node type of this mutation (Announcement).
  5886. func (m *AnnouncementMutation) Type() string {
  5887. return m.typ
  5888. }
  5889. // Fields returns all fields that were changed during this mutation. Note that in
  5890. // order to get all numeric fields that were incremented/decremented, call
  5891. // AddedFields().
  5892. func (m *AnnouncementMutation) Fields() []string {
  5893. fields := make([]string, 0, 11)
  5894. if m.title != nil {
  5895. fields = append(fields, announcement.FieldTitle)
  5896. }
  5897. if m.content != nil {
  5898. fields = append(fields, announcement.FieldContent)
  5899. }
  5900. if m.status != nil {
  5901. fields = append(fields, announcement.FieldStatus)
  5902. }
  5903. if m.notify_mode != nil {
  5904. fields = append(fields, announcement.FieldNotifyMode)
  5905. }
  5906. if m.targeting != nil {
  5907. fields = append(fields, announcement.FieldTargeting)
  5908. }
  5909. if m.starts_at != nil {
  5910. fields = append(fields, announcement.FieldStartsAt)
  5911. }
  5912. if m.ends_at != nil {
  5913. fields = append(fields, announcement.FieldEndsAt)
  5914. }
  5915. if m.created_by != nil {
  5916. fields = append(fields, announcement.FieldCreatedBy)
  5917. }
  5918. if m.updated_by != nil {
  5919. fields = append(fields, announcement.FieldUpdatedBy)
  5920. }
  5921. if m.created_at != nil {
  5922. fields = append(fields, announcement.FieldCreatedAt)
  5923. }
  5924. if m.updated_at != nil {
  5925. fields = append(fields, announcement.FieldUpdatedAt)
  5926. }
  5927. return fields
  5928. }
  5929. // Field returns the value of a field with the given name. The second boolean
  5930. // return value indicates that this field was not set, or was not defined in the
  5931. // schema.
  5932. func (m *AnnouncementMutation) Field(name string) (ent.Value, bool) {
  5933. switch name {
  5934. case announcement.FieldTitle:
  5935. return m.Title()
  5936. case announcement.FieldContent:
  5937. return m.Content()
  5938. case announcement.FieldStatus:
  5939. return m.Status()
  5940. case announcement.FieldNotifyMode:
  5941. return m.NotifyMode()
  5942. case announcement.FieldTargeting:
  5943. return m.Targeting()
  5944. case announcement.FieldStartsAt:
  5945. return m.StartsAt()
  5946. case announcement.FieldEndsAt:
  5947. return m.EndsAt()
  5948. case announcement.FieldCreatedBy:
  5949. return m.CreatedBy()
  5950. case announcement.FieldUpdatedBy:
  5951. return m.UpdatedBy()
  5952. case announcement.FieldCreatedAt:
  5953. return m.CreatedAt()
  5954. case announcement.FieldUpdatedAt:
  5955. return m.UpdatedAt()
  5956. }
  5957. return nil, false
  5958. }
  5959. // OldField returns the old value of the field from the database. An error is
  5960. // returned if the mutation operation is not UpdateOne, or the query to the
  5961. // database failed.
  5962. func (m *AnnouncementMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  5963. switch name {
  5964. case announcement.FieldTitle:
  5965. return m.OldTitle(ctx)
  5966. case announcement.FieldContent:
  5967. return m.OldContent(ctx)
  5968. case announcement.FieldStatus:
  5969. return m.OldStatus(ctx)
  5970. case announcement.FieldNotifyMode:
  5971. return m.OldNotifyMode(ctx)
  5972. case announcement.FieldTargeting:
  5973. return m.OldTargeting(ctx)
  5974. case announcement.FieldStartsAt:
  5975. return m.OldStartsAt(ctx)
  5976. case announcement.FieldEndsAt:
  5977. return m.OldEndsAt(ctx)
  5978. case announcement.FieldCreatedBy:
  5979. return m.OldCreatedBy(ctx)
  5980. case announcement.FieldUpdatedBy:
  5981. return m.OldUpdatedBy(ctx)
  5982. case announcement.FieldCreatedAt:
  5983. return m.OldCreatedAt(ctx)
  5984. case announcement.FieldUpdatedAt:
  5985. return m.OldUpdatedAt(ctx)
  5986. }
  5987. return nil, fmt.Errorf("unknown Announcement field %s", name)
  5988. }
  5989. // SetField sets the value of a field with the given name. It returns an error if
  5990. // the field is not defined in the schema, or if the type mismatched the field
  5991. // type.
  5992. func (m *AnnouncementMutation) SetField(name string, value ent.Value) error {
  5993. switch name {
  5994. case announcement.FieldTitle:
  5995. v, ok := value.(string)
  5996. if !ok {
  5997. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5998. }
  5999. m.SetTitle(v)
  6000. return nil
  6001. case announcement.FieldContent:
  6002. v, ok := value.(string)
  6003. if !ok {
  6004. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6005. }
  6006. m.SetContent(v)
  6007. return nil
  6008. case announcement.FieldStatus:
  6009. v, ok := value.(string)
  6010. if !ok {
  6011. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6012. }
  6013. m.SetStatus(v)
  6014. return nil
  6015. case announcement.FieldNotifyMode:
  6016. v, ok := value.(string)
  6017. if !ok {
  6018. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6019. }
  6020. m.SetNotifyMode(v)
  6021. return nil
  6022. case announcement.FieldTargeting:
  6023. v, ok := value.(domain.AnnouncementTargeting)
  6024. if !ok {
  6025. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6026. }
  6027. m.SetTargeting(v)
  6028. return nil
  6029. case announcement.FieldStartsAt:
  6030. v, ok := value.(time.Time)
  6031. if !ok {
  6032. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6033. }
  6034. m.SetStartsAt(v)
  6035. return nil
  6036. case announcement.FieldEndsAt:
  6037. v, ok := value.(time.Time)
  6038. if !ok {
  6039. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6040. }
  6041. m.SetEndsAt(v)
  6042. return nil
  6043. case announcement.FieldCreatedBy:
  6044. v, ok := value.(int64)
  6045. if !ok {
  6046. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6047. }
  6048. m.SetCreatedBy(v)
  6049. return nil
  6050. case announcement.FieldUpdatedBy:
  6051. v, ok := value.(int64)
  6052. if !ok {
  6053. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6054. }
  6055. m.SetUpdatedBy(v)
  6056. return nil
  6057. case announcement.FieldCreatedAt:
  6058. v, ok := value.(time.Time)
  6059. if !ok {
  6060. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6061. }
  6062. m.SetCreatedAt(v)
  6063. return nil
  6064. case announcement.FieldUpdatedAt:
  6065. v, ok := value.(time.Time)
  6066. if !ok {
  6067. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6068. }
  6069. m.SetUpdatedAt(v)
  6070. return nil
  6071. }
  6072. return fmt.Errorf("unknown Announcement field %s", name)
  6073. }
  6074. // AddedFields returns all numeric fields that were incremented/decremented during
  6075. // this mutation.
  6076. func (m *AnnouncementMutation) AddedFields() []string {
  6077. var fields []string
  6078. if m.addcreated_by != nil {
  6079. fields = append(fields, announcement.FieldCreatedBy)
  6080. }
  6081. if m.addupdated_by != nil {
  6082. fields = append(fields, announcement.FieldUpdatedBy)
  6083. }
  6084. return fields
  6085. }
  6086. // AddedField returns the numeric value that was incremented/decremented on a field
  6087. // with the given name. The second boolean return value indicates that this field
  6088. // was not set, or was not defined in the schema.
  6089. func (m *AnnouncementMutation) AddedField(name string) (ent.Value, bool) {
  6090. switch name {
  6091. case announcement.FieldCreatedBy:
  6092. return m.AddedCreatedBy()
  6093. case announcement.FieldUpdatedBy:
  6094. return m.AddedUpdatedBy()
  6095. }
  6096. return nil, false
  6097. }
  6098. // AddField adds the value to the field with the given name. It returns an error if
  6099. // the field is not defined in the schema, or if the type mismatched the field
  6100. // type.
  6101. func (m *AnnouncementMutation) AddField(name string, value ent.Value) error {
  6102. switch name {
  6103. case announcement.FieldCreatedBy:
  6104. v, ok := value.(int64)
  6105. if !ok {
  6106. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6107. }
  6108. m.AddCreatedBy(v)
  6109. return nil
  6110. case announcement.FieldUpdatedBy:
  6111. v, ok := value.(int64)
  6112. if !ok {
  6113. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6114. }
  6115. m.AddUpdatedBy(v)
  6116. return nil
  6117. }
  6118. return fmt.Errorf("unknown Announcement numeric field %s", name)
  6119. }
  6120. // ClearedFields returns all nullable fields that were cleared during this
  6121. // mutation.
  6122. func (m *AnnouncementMutation) ClearedFields() []string {
  6123. var fields []string
  6124. if m.FieldCleared(announcement.FieldTargeting) {
  6125. fields = append(fields, announcement.FieldTargeting)
  6126. }
  6127. if m.FieldCleared(announcement.FieldStartsAt) {
  6128. fields = append(fields, announcement.FieldStartsAt)
  6129. }
  6130. if m.FieldCleared(announcement.FieldEndsAt) {
  6131. fields = append(fields, announcement.FieldEndsAt)
  6132. }
  6133. if m.FieldCleared(announcement.FieldCreatedBy) {
  6134. fields = append(fields, announcement.FieldCreatedBy)
  6135. }
  6136. if m.FieldCleared(announcement.FieldUpdatedBy) {
  6137. fields = append(fields, announcement.FieldUpdatedBy)
  6138. }
  6139. return fields
  6140. }
  6141. // FieldCleared returns a boolean indicating if a field with the given name was
  6142. // cleared in this mutation.
  6143. func (m *AnnouncementMutation) FieldCleared(name string) bool {
  6144. _, ok := m.clearedFields[name]
  6145. return ok
  6146. }
  6147. // ClearField clears the value of the field with the given name. It returns an
  6148. // error if the field is not defined in the schema.
  6149. func (m *AnnouncementMutation) ClearField(name string) error {
  6150. switch name {
  6151. case announcement.FieldTargeting:
  6152. m.ClearTargeting()
  6153. return nil
  6154. case announcement.FieldStartsAt:
  6155. m.ClearStartsAt()
  6156. return nil
  6157. case announcement.FieldEndsAt:
  6158. m.ClearEndsAt()
  6159. return nil
  6160. case announcement.FieldCreatedBy:
  6161. m.ClearCreatedBy()
  6162. return nil
  6163. case announcement.FieldUpdatedBy:
  6164. m.ClearUpdatedBy()
  6165. return nil
  6166. }
  6167. return fmt.Errorf("unknown Announcement nullable field %s", name)
  6168. }
  6169. // ResetField resets all changes in the mutation for the field with the given name.
  6170. // It returns an error if the field is not defined in the schema.
  6171. func (m *AnnouncementMutation) ResetField(name string) error {
  6172. switch name {
  6173. case announcement.FieldTitle:
  6174. m.ResetTitle()
  6175. return nil
  6176. case announcement.FieldContent:
  6177. m.ResetContent()
  6178. return nil
  6179. case announcement.FieldStatus:
  6180. m.ResetStatus()
  6181. return nil
  6182. case announcement.FieldNotifyMode:
  6183. m.ResetNotifyMode()
  6184. return nil
  6185. case announcement.FieldTargeting:
  6186. m.ResetTargeting()
  6187. return nil
  6188. case announcement.FieldStartsAt:
  6189. m.ResetStartsAt()
  6190. return nil
  6191. case announcement.FieldEndsAt:
  6192. m.ResetEndsAt()
  6193. return nil
  6194. case announcement.FieldCreatedBy:
  6195. m.ResetCreatedBy()
  6196. return nil
  6197. case announcement.FieldUpdatedBy:
  6198. m.ResetUpdatedBy()
  6199. return nil
  6200. case announcement.FieldCreatedAt:
  6201. m.ResetCreatedAt()
  6202. return nil
  6203. case announcement.FieldUpdatedAt:
  6204. m.ResetUpdatedAt()
  6205. return nil
  6206. }
  6207. return fmt.Errorf("unknown Announcement field %s", name)
  6208. }
  6209. // AddedEdges returns all edge names that were set/added in this mutation.
  6210. func (m *AnnouncementMutation) AddedEdges() []string {
  6211. edges := make([]string, 0, 1)
  6212. if m.reads != nil {
  6213. edges = append(edges, announcement.EdgeReads)
  6214. }
  6215. return edges
  6216. }
  6217. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  6218. // name in this mutation.
  6219. func (m *AnnouncementMutation) AddedIDs(name string) []ent.Value {
  6220. switch name {
  6221. case announcement.EdgeReads:
  6222. ids := make([]ent.Value, 0, len(m.reads))
  6223. for id := range m.reads {
  6224. ids = append(ids, id)
  6225. }
  6226. return ids
  6227. }
  6228. return nil
  6229. }
  6230. // RemovedEdges returns all edge names that were removed in this mutation.
  6231. func (m *AnnouncementMutation) RemovedEdges() []string {
  6232. edges := make([]string, 0, 1)
  6233. if m.removedreads != nil {
  6234. edges = append(edges, announcement.EdgeReads)
  6235. }
  6236. return edges
  6237. }
  6238. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  6239. // the given name in this mutation.
  6240. func (m *AnnouncementMutation) RemovedIDs(name string) []ent.Value {
  6241. switch name {
  6242. case announcement.EdgeReads:
  6243. ids := make([]ent.Value, 0, len(m.removedreads))
  6244. for id := range m.removedreads {
  6245. ids = append(ids, id)
  6246. }
  6247. return ids
  6248. }
  6249. return nil
  6250. }
  6251. // ClearedEdges returns all edge names that were cleared in this mutation.
  6252. func (m *AnnouncementMutation) ClearedEdges() []string {
  6253. edges := make([]string, 0, 1)
  6254. if m.clearedreads {
  6255. edges = append(edges, announcement.EdgeReads)
  6256. }
  6257. return edges
  6258. }
  6259. // EdgeCleared returns a boolean which indicates if the edge with the given name
  6260. // was cleared in this mutation.
  6261. func (m *AnnouncementMutation) EdgeCleared(name string) bool {
  6262. switch name {
  6263. case announcement.EdgeReads:
  6264. return m.clearedreads
  6265. }
  6266. return false
  6267. }
  6268. // ClearEdge clears the value of the edge with the given name. It returns an error
  6269. // if that edge is not defined in the schema.
  6270. func (m *AnnouncementMutation) ClearEdge(name string) error {
  6271. switch name {
  6272. }
  6273. return fmt.Errorf("unknown Announcement unique edge %s", name)
  6274. }
  6275. // ResetEdge resets all changes to the edge with the given name in this mutation.
  6276. // It returns an error if the edge is not defined in the schema.
  6277. func (m *AnnouncementMutation) ResetEdge(name string) error {
  6278. switch name {
  6279. case announcement.EdgeReads:
  6280. m.ResetReads()
  6281. return nil
  6282. }
  6283. return fmt.Errorf("unknown Announcement edge %s", name)
  6284. }
  6285. // AnnouncementReadMutation represents an operation that mutates the AnnouncementRead nodes in the graph.
  6286. type AnnouncementReadMutation struct {
  6287. config
  6288. op Op
  6289. typ string
  6290. id *int64
  6291. read_at *time.Time
  6292. created_at *time.Time
  6293. clearedFields map[string]struct{}
  6294. announcement *int64
  6295. clearedannouncement bool
  6296. user *int64
  6297. cleareduser bool
  6298. done bool
  6299. oldValue func(context.Context) (*AnnouncementRead, error)
  6300. predicates []predicate.AnnouncementRead
  6301. }
  6302. var _ ent.Mutation = (*AnnouncementReadMutation)(nil)
  6303. // announcementreadOption allows management of the mutation configuration using functional options.
  6304. type announcementreadOption func(*AnnouncementReadMutation)
  6305. // newAnnouncementReadMutation creates new mutation for the AnnouncementRead entity.
  6306. func newAnnouncementReadMutation(c config, op Op, opts ...announcementreadOption) *AnnouncementReadMutation {
  6307. m := &AnnouncementReadMutation{
  6308. config: c,
  6309. op: op,
  6310. typ: TypeAnnouncementRead,
  6311. clearedFields: make(map[string]struct{}),
  6312. }
  6313. for _, opt := range opts {
  6314. opt(m)
  6315. }
  6316. return m
  6317. }
  6318. // withAnnouncementReadID sets the ID field of the mutation.
  6319. func withAnnouncementReadID(id int64) announcementreadOption {
  6320. return func(m *AnnouncementReadMutation) {
  6321. var (
  6322. err error
  6323. once sync.Once
  6324. value *AnnouncementRead
  6325. )
  6326. m.oldValue = func(ctx context.Context) (*AnnouncementRead, error) {
  6327. once.Do(func() {
  6328. if m.done {
  6329. err = errors.New("querying old values post mutation is not allowed")
  6330. } else {
  6331. value, err = m.Client().AnnouncementRead.Get(ctx, id)
  6332. }
  6333. })
  6334. return value, err
  6335. }
  6336. m.id = &id
  6337. }
  6338. }
  6339. // withAnnouncementRead sets the old AnnouncementRead of the mutation.
  6340. func withAnnouncementRead(node *AnnouncementRead) announcementreadOption {
  6341. return func(m *AnnouncementReadMutation) {
  6342. m.oldValue = func(context.Context) (*AnnouncementRead, error) {
  6343. return node, nil
  6344. }
  6345. m.id = &node.ID
  6346. }
  6347. }
  6348. // Client returns a new `ent.Client` from the mutation. If the mutation was
  6349. // executed in a transaction (ent.Tx), a transactional client is returned.
  6350. func (m AnnouncementReadMutation) Client() *Client {
  6351. client := &Client{config: m.config}
  6352. client.init()
  6353. return client
  6354. }
  6355. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  6356. // it returns an error otherwise.
  6357. func (m AnnouncementReadMutation) Tx() (*Tx, error) {
  6358. if _, ok := m.driver.(*txDriver); !ok {
  6359. return nil, errors.New("ent: mutation is not running in a transaction")
  6360. }
  6361. tx := &Tx{config: m.config}
  6362. tx.init()
  6363. return tx, nil
  6364. }
  6365. // ID returns the ID value in the mutation. Note that the ID is only available
  6366. // if it was provided to the builder or after it was returned from the database.
  6367. func (m *AnnouncementReadMutation) ID() (id int64, exists bool) {
  6368. if m.id == nil {
  6369. return
  6370. }
  6371. return *m.id, true
  6372. }
  6373. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  6374. // That means, if the mutation is applied within a transaction with an isolation level such
  6375. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  6376. // or updated by the mutation.
  6377. func (m *AnnouncementReadMutation) IDs(ctx context.Context) ([]int64, error) {
  6378. switch {
  6379. case m.op.Is(OpUpdateOne | OpDeleteOne):
  6380. id, exists := m.ID()
  6381. if exists {
  6382. return []int64{id}, nil
  6383. }
  6384. fallthrough
  6385. case m.op.Is(OpUpdate | OpDelete):
  6386. return m.Client().AnnouncementRead.Query().Where(m.predicates...).IDs(ctx)
  6387. default:
  6388. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  6389. }
  6390. }
  6391. // SetAnnouncementID sets the "announcement_id" field.
  6392. func (m *AnnouncementReadMutation) SetAnnouncementID(i int64) {
  6393. m.announcement = &i
  6394. }
  6395. // AnnouncementID returns the value of the "announcement_id" field in the mutation.
  6396. func (m *AnnouncementReadMutation) AnnouncementID() (r int64, exists bool) {
  6397. v := m.announcement
  6398. if v == nil {
  6399. return
  6400. }
  6401. return *v, true
  6402. }
  6403. // OldAnnouncementID returns the old "announcement_id" field's value of the AnnouncementRead entity.
  6404. // If the AnnouncementRead object wasn't provided to the builder, the object is fetched from the database.
  6405. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6406. func (m *AnnouncementReadMutation) OldAnnouncementID(ctx context.Context) (v int64, err error) {
  6407. if !m.op.Is(OpUpdateOne) {
  6408. return v, errors.New("OldAnnouncementID is only allowed on UpdateOne operations")
  6409. }
  6410. if m.id == nil || m.oldValue == nil {
  6411. return v, errors.New("OldAnnouncementID requires an ID field in the mutation")
  6412. }
  6413. oldValue, err := m.oldValue(ctx)
  6414. if err != nil {
  6415. return v, fmt.Errorf("querying old value for OldAnnouncementID: %w", err)
  6416. }
  6417. return oldValue.AnnouncementID, nil
  6418. }
  6419. // ResetAnnouncementID resets all changes to the "announcement_id" field.
  6420. func (m *AnnouncementReadMutation) ResetAnnouncementID() {
  6421. m.announcement = nil
  6422. }
  6423. // SetUserID sets the "user_id" field.
  6424. func (m *AnnouncementReadMutation) SetUserID(i int64) {
  6425. m.user = &i
  6426. }
  6427. // UserID returns the value of the "user_id" field in the mutation.
  6428. func (m *AnnouncementReadMutation) UserID() (r int64, exists bool) {
  6429. v := m.user
  6430. if v == nil {
  6431. return
  6432. }
  6433. return *v, true
  6434. }
  6435. // OldUserID returns the old "user_id" field's value of the AnnouncementRead entity.
  6436. // If the AnnouncementRead object wasn't provided to the builder, the object is fetched from the database.
  6437. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6438. func (m *AnnouncementReadMutation) OldUserID(ctx context.Context) (v int64, err error) {
  6439. if !m.op.Is(OpUpdateOne) {
  6440. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  6441. }
  6442. if m.id == nil || m.oldValue == nil {
  6443. return v, errors.New("OldUserID requires an ID field in the mutation")
  6444. }
  6445. oldValue, err := m.oldValue(ctx)
  6446. if err != nil {
  6447. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  6448. }
  6449. return oldValue.UserID, nil
  6450. }
  6451. // ResetUserID resets all changes to the "user_id" field.
  6452. func (m *AnnouncementReadMutation) ResetUserID() {
  6453. m.user = nil
  6454. }
  6455. // SetReadAt sets the "read_at" field.
  6456. func (m *AnnouncementReadMutation) SetReadAt(t time.Time) {
  6457. m.read_at = &t
  6458. }
  6459. // ReadAt returns the value of the "read_at" field in the mutation.
  6460. func (m *AnnouncementReadMutation) ReadAt() (r time.Time, exists bool) {
  6461. v := m.read_at
  6462. if v == nil {
  6463. return
  6464. }
  6465. return *v, true
  6466. }
  6467. // OldReadAt returns the old "read_at" field's value of the AnnouncementRead entity.
  6468. // If the AnnouncementRead object wasn't provided to the builder, the object is fetched from the database.
  6469. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6470. func (m *AnnouncementReadMutation) OldReadAt(ctx context.Context) (v time.Time, err error) {
  6471. if !m.op.Is(OpUpdateOne) {
  6472. return v, errors.New("OldReadAt is only allowed on UpdateOne operations")
  6473. }
  6474. if m.id == nil || m.oldValue == nil {
  6475. return v, errors.New("OldReadAt requires an ID field in the mutation")
  6476. }
  6477. oldValue, err := m.oldValue(ctx)
  6478. if err != nil {
  6479. return v, fmt.Errorf("querying old value for OldReadAt: %w", err)
  6480. }
  6481. return oldValue.ReadAt, nil
  6482. }
  6483. // ResetReadAt resets all changes to the "read_at" field.
  6484. func (m *AnnouncementReadMutation) ResetReadAt() {
  6485. m.read_at = nil
  6486. }
  6487. // SetCreatedAt sets the "created_at" field.
  6488. func (m *AnnouncementReadMutation) SetCreatedAt(t time.Time) {
  6489. m.created_at = &t
  6490. }
  6491. // CreatedAt returns the value of the "created_at" field in the mutation.
  6492. func (m *AnnouncementReadMutation) CreatedAt() (r time.Time, exists bool) {
  6493. v := m.created_at
  6494. if v == nil {
  6495. return
  6496. }
  6497. return *v, true
  6498. }
  6499. // OldCreatedAt returns the old "created_at" field's value of the AnnouncementRead entity.
  6500. // If the AnnouncementRead object wasn't provided to the builder, the object is fetched from the database.
  6501. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6502. func (m *AnnouncementReadMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  6503. if !m.op.Is(OpUpdateOne) {
  6504. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  6505. }
  6506. if m.id == nil || m.oldValue == nil {
  6507. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  6508. }
  6509. oldValue, err := m.oldValue(ctx)
  6510. if err != nil {
  6511. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  6512. }
  6513. return oldValue.CreatedAt, nil
  6514. }
  6515. // ResetCreatedAt resets all changes to the "created_at" field.
  6516. func (m *AnnouncementReadMutation) ResetCreatedAt() {
  6517. m.created_at = nil
  6518. }
  6519. // ClearAnnouncement clears the "announcement" edge to the Announcement entity.
  6520. func (m *AnnouncementReadMutation) ClearAnnouncement() {
  6521. m.clearedannouncement = true
  6522. m.clearedFields[announcementread.FieldAnnouncementID] = struct{}{}
  6523. }
  6524. // AnnouncementCleared reports if the "announcement" edge to the Announcement entity was cleared.
  6525. func (m *AnnouncementReadMutation) AnnouncementCleared() bool {
  6526. return m.clearedannouncement
  6527. }
  6528. // AnnouncementIDs returns the "announcement" edge IDs in the mutation.
  6529. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  6530. // AnnouncementID instead. It exists only for internal usage by the builders.
  6531. func (m *AnnouncementReadMutation) AnnouncementIDs() (ids []int64) {
  6532. if id := m.announcement; id != nil {
  6533. ids = append(ids, *id)
  6534. }
  6535. return
  6536. }
  6537. // ResetAnnouncement resets all changes to the "announcement" edge.
  6538. func (m *AnnouncementReadMutation) ResetAnnouncement() {
  6539. m.announcement = nil
  6540. m.clearedannouncement = false
  6541. }
  6542. // ClearUser clears the "user" edge to the User entity.
  6543. func (m *AnnouncementReadMutation) ClearUser() {
  6544. m.cleareduser = true
  6545. m.clearedFields[announcementread.FieldUserID] = struct{}{}
  6546. }
  6547. // UserCleared reports if the "user" edge to the User entity was cleared.
  6548. func (m *AnnouncementReadMutation) UserCleared() bool {
  6549. return m.cleareduser
  6550. }
  6551. // UserIDs returns the "user" edge IDs in the mutation.
  6552. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  6553. // UserID instead. It exists only for internal usage by the builders.
  6554. func (m *AnnouncementReadMutation) UserIDs() (ids []int64) {
  6555. if id := m.user; id != nil {
  6556. ids = append(ids, *id)
  6557. }
  6558. return
  6559. }
  6560. // ResetUser resets all changes to the "user" edge.
  6561. func (m *AnnouncementReadMutation) ResetUser() {
  6562. m.user = nil
  6563. m.cleareduser = false
  6564. }
  6565. // Where appends a list predicates to the AnnouncementReadMutation builder.
  6566. func (m *AnnouncementReadMutation) Where(ps ...predicate.AnnouncementRead) {
  6567. m.predicates = append(m.predicates, ps...)
  6568. }
  6569. // WhereP appends storage-level predicates to the AnnouncementReadMutation builder. Using this method,
  6570. // users can use type-assertion to append predicates that do not depend on any generated package.
  6571. func (m *AnnouncementReadMutation) WhereP(ps ...func(*sql.Selector)) {
  6572. p := make([]predicate.AnnouncementRead, len(ps))
  6573. for i := range ps {
  6574. p[i] = ps[i]
  6575. }
  6576. m.Where(p...)
  6577. }
  6578. // Op returns the operation name.
  6579. func (m *AnnouncementReadMutation) Op() Op {
  6580. return m.op
  6581. }
  6582. // SetOp allows setting the mutation operation.
  6583. func (m *AnnouncementReadMutation) SetOp(op Op) {
  6584. m.op = op
  6585. }
  6586. // Type returns the node type of this mutation (AnnouncementRead).
  6587. func (m *AnnouncementReadMutation) Type() string {
  6588. return m.typ
  6589. }
  6590. // Fields returns all fields that were changed during this mutation. Note that in
  6591. // order to get all numeric fields that were incremented/decremented, call
  6592. // AddedFields().
  6593. func (m *AnnouncementReadMutation) Fields() []string {
  6594. fields := make([]string, 0, 4)
  6595. if m.announcement != nil {
  6596. fields = append(fields, announcementread.FieldAnnouncementID)
  6597. }
  6598. if m.user != nil {
  6599. fields = append(fields, announcementread.FieldUserID)
  6600. }
  6601. if m.read_at != nil {
  6602. fields = append(fields, announcementread.FieldReadAt)
  6603. }
  6604. if m.created_at != nil {
  6605. fields = append(fields, announcementread.FieldCreatedAt)
  6606. }
  6607. return fields
  6608. }
  6609. // Field returns the value of a field with the given name. The second boolean
  6610. // return value indicates that this field was not set, or was not defined in the
  6611. // schema.
  6612. func (m *AnnouncementReadMutation) Field(name string) (ent.Value, bool) {
  6613. switch name {
  6614. case announcementread.FieldAnnouncementID:
  6615. return m.AnnouncementID()
  6616. case announcementread.FieldUserID:
  6617. return m.UserID()
  6618. case announcementread.FieldReadAt:
  6619. return m.ReadAt()
  6620. case announcementread.FieldCreatedAt:
  6621. return m.CreatedAt()
  6622. }
  6623. return nil, false
  6624. }
  6625. // OldField returns the old value of the field from the database. An error is
  6626. // returned if the mutation operation is not UpdateOne, or the query to the
  6627. // database failed.
  6628. func (m *AnnouncementReadMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  6629. switch name {
  6630. case announcementread.FieldAnnouncementID:
  6631. return m.OldAnnouncementID(ctx)
  6632. case announcementread.FieldUserID:
  6633. return m.OldUserID(ctx)
  6634. case announcementread.FieldReadAt:
  6635. return m.OldReadAt(ctx)
  6636. case announcementread.FieldCreatedAt:
  6637. return m.OldCreatedAt(ctx)
  6638. }
  6639. return nil, fmt.Errorf("unknown AnnouncementRead field %s", name)
  6640. }
  6641. // SetField sets the value of a field with the given name. It returns an error if
  6642. // the field is not defined in the schema, or if the type mismatched the field
  6643. // type.
  6644. func (m *AnnouncementReadMutation) SetField(name string, value ent.Value) error {
  6645. switch name {
  6646. case announcementread.FieldAnnouncementID:
  6647. v, ok := value.(int64)
  6648. if !ok {
  6649. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6650. }
  6651. m.SetAnnouncementID(v)
  6652. return nil
  6653. case announcementread.FieldUserID:
  6654. v, ok := value.(int64)
  6655. if !ok {
  6656. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6657. }
  6658. m.SetUserID(v)
  6659. return nil
  6660. case announcementread.FieldReadAt:
  6661. v, ok := value.(time.Time)
  6662. if !ok {
  6663. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6664. }
  6665. m.SetReadAt(v)
  6666. return nil
  6667. case announcementread.FieldCreatedAt:
  6668. v, ok := value.(time.Time)
  6669. if !ok {
  6670. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6671. }
  6672. m.SetCreatedAt(v)
  6673. return nil
  6674. }
  6675. return fmt.Errorf("unknown AnnouncementRead field %s", name)
  6676. }
  6677. // AddedFields returns all numeric fields that were incremented/decremented during
  6678. // this mutation.
  6679. func (m *AnnouncementReadMutation) AddedFields() []string {
  6680. var fields []string
  6681. return fields
  6682. }
  6683. // AddedField returns the numeric value that was incremented/decremented on a field
  6684. // with the given name. The second boolean return value indicates that this field
  6685. // was not set, or was not defined in the schema.
  6686. func (m *AnnouncementReadMutation) AddedField(name string) (ent.Value, bool) {
  6687. switch name {
  6688. }
  6689. return nil, false
  6690. }
  6691. // AddField adds the value to the field with the given name. It returns an error if
  6692. // the field is not defined in the schema, or if the type mismatched the field
  6693. // type.
  6694. func (m *AnnouncementReadMutation) AddField(name string, value ent.Value) error {
  6695. switch name {
  6696. }
  6697. return fmt.Errorf("unknown AnnouncementRead numeric field %s", name)
  6698. }
  6699. // ClearedFields returns all nullable fields that were cleared during this
  6700. // mutation.
  6701. func (m *AnnouncementReadMutation) ClearedFields() []string {
  6702. return nil
  6703. }
  6704. // FieldCleared returns a boolean indicating if a field with the given name was
  6705. // cleared in this mutation.
  6706. func (m *AnnouncementReadMutation) FieldCleared(name string) bool {
  6707. _, ok := m.clearedFields[name]
  6708. return ok
  6709. }
  6710. // ClearField clears the value of the field with the given name. It returns an
  6711. // error if the field is not defined in the schema.
  6712. func (m *AnnouncementReadMutation) ClearField(name string) error {
  6713. return fmt.Errorf("unknown AnnouncementRead nullable field %s", name)
  6714. }
  6715. // ResetField resets all changes in the mutation for the field with the given name.
  6716. // It returns an error if the field is not defined in the schema.
  6717. func (m *AnnouncementReadMutation) ResetField(name string) error {
  6718. switch name {
  6719. case announcementread.FieldAnnouncementID:
  6720. m.ResetAnnouncementID()
  6721. return nil
  6722. case announcementread.FieldUserID:
  6723. m.ResetUserID()
  6724. return nil
  6725. case announcementread.FieldReadAt:
  6726. m.ResetReadAt()
  6727. return nil
  6728. case announcementread.FieldCreatedAt:
  6729. m.ResetCreatedAt()
  6730. return nil
  6731. }
  6732. return fmt.Errorf("unknown AnnouncementRead field %s", name)
  6733. }
  6734. // AddedEdges returns all edge names that were set/added in this mutation.
  6735. func (m *AnnouncementReadMutation) AddedEdges() []string {
  6736. edges := make([]string, 0, 2)
  6737. if m.announcement != nil {
  6738. edges = append(edges, announcementread.EdgeAnnouncement)
  6739. }
  6740. if m.user != nil {
  6741. edges = append(edges, announcementread.EdgeUser)
  6742. }
  6743. return edges
  6744. }
  6745. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  6746. // name in this mutation.
  6747. func (m *AnnouncementReadMutation) AddedIDs(name string) []ent.Value {
  6748. switch name {
  6749. case announcementread.EdgeAnnouncement:
  6750. if id := m.announcement; id != nil {
  6751. return []ent.Value{*id}
  6752. }
  6753. case announcementread.EdgeUser:
  6754. if id := m.user; id != nil {
  6755. return []ent.Value{*id}
  6756. }
  6757. }
  6758. return nil
  6759. }
  6760. // RemovedEdges returns all edge names that were removed in this mutation.
  6761. func (m *AnnouncementReadMutation) RemovedEdges() []string {
  6762. edges := make([]string, 0, 2)
  6763. return edges
  6764. }
  6765. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  6766. // the given name in this mutation.
  6767. func (m *AnnouncementReadMutation) RemovedIDs(name string) []ent.Value {
  6768. return nil
  6769. }
  6770. // ClearedEdges returns all edge names that were cleared in this mutation.
  6771. func (m *AnnouncementReadMutation) ClearedEdges() []string {
  6772. edges := make([]string, 0, 2)
  6773. if m.clearedannouncement {
  6774. edges = append(edges, announcementread.EdgeAnnouncement)
  6775. }
  6776. if m.cleareduser {
  6777. edges = append(edges, announcementread.EdgeUser)
  6778. }
  6779. return edges
  6780. }
  6781. // EdgeCleared returns a boolean which indicates if the edge with the given name
  6782. // was cleared in this mutation.
  6783. func (m *AnnouncementReadMutation) EdgeCleared(name string) bool {
  6784. switch name {
  6785. case announcementread.EdgeAnnouncement:
  6786. return m.clearedannouncement
  6787. case announcementread.EdgeUser:
  6788. return m.cleareduser
  6789. }
  6790. return false
  6791. }
  6792. // ClearEdge clears the value of the edge with the given name. It returns an error
  6793. // if that edge is not defined in the schema.
  6794. func (m *AnnouncementReadMutation) ClearEdge(name string) error {
  6795. switch name {
  6796. case announcementread.EdgeAnnouncement:
  6797. m.ClearAnnouncement()
  6798. return nil
  6799. case announcementread.EdgeUser:
  6800. m.ClearUser()
  6801. return nil
  6802. }
  6803. return fmt.Errorf("unknown AnnouncementRead unique edge %s", name)
  6804. }
  6805. // ResetEdge resets all changes to the edge with the given name in this mutation.
  6806. // It returns an error if the edge is not defined in the schema.
  6807. func (m *AnnouncementReadMutation) ResetEdge(name string) error {
  6808. switch name {
  6809. case announcementread.EdgeAnnouncement:
  6810. m.ResetAnnouncement()
  6811. return nil
  6812. case announcementread.EdgeUser:
  6813. m.ResetUser()
  6814. return nil
  6815. }
  6816. return fmt.Errorf("unknown AnnouncementRead edge %s", name)
  6817. }
  6818. // AuthIdentityMutation represents an operation that mutates the AuthIdentity nodes in the graph.
  6819. type AuthIdentityMutation struct {
  6820. config
  6821. op Op
  6822. typ string
  6823. id *int64
  6824. created_at *time.Time
  6825. updated_at *time.Time
  6826. provider_type *string
  6827. provider_key *string
  6828. provider_subject *string
  6829. verified_at *time.Time
  6830. issuer *string
  6831. metadata *map[string]interface{}
  6832. clearedFields map[string]struct{}
  6833. user *int64
  6834. cleareduser bool
  6835. channels map[int64]struct{}
  6836. removedchannels map[int64]struct{}
  6837. clearedchannels bool
  6838. adoption_decisions map[int64]struct{}
  6839. removedadoption_decisions map[int64]struct{}
  6840. clearedadoption_decisions bool
  6841. done bool
  6842. oldValue func(context.Context) (*AuthIdentity, error)
  6843. predicates []predicate.AuthIdentity
  6844. }
  6845. var _ ent.Mutation = (*AuthIdentityMutation)(nil)
  6846. // authidentityOption allows management of the mutation configuration using functional options.
  6847. type authidentityOption func(*AuthIdentityMutation)
  6848. // newAuthIdentityMutation creates new mutation for the AuthIdentity entity.
  6849. func newAuthIdentityMutation(c config, op Op, opts ...authidentityOption) *AuthIdentityMutation {
  6850. m := &AuthIdentityMutation{
  6851. config: c,
  6852. op: op,
  6853. typ: TypeAuthIdentity,
  6854. clearedFields: make(map[string]struct{}),
  6855. }
  6856. for _, opt := range opts {
  6857. opt(m)
  6858. }
  6859. return m
  6860. }
  6861. // withAuthIdentityID sets the ID field of the mutation.
  6862. func withAuthIdentityID(id int64) authidentityOption {
  6863. return func(m *AuthIdentityMutation) {
  6864. var (
  6865. err error
  6866. once sync.Once
  6867. value *AuthIdentity
  6868. )
  6869. m.oldValue = func(ctx context.Context) (*AuthIdentity, error) {
  6870. once.Do(func() {
  6871. if m.done {
  6872. err = errors.New("querying old values post mutation is not allowed")
  6873. } else {
  6874. value, err = m.Client().AuthIdentity.Get(ctx, id)
  6875. }
  6876. })
  6877. return value, err
  6878. }
  6879. m.id = &id
  6880. }
  6881. }
  6882. // withAuthIdentity sets the old AuthIdentity of the mutation.
  6883. func withAuthIdentity(node *AuthIdentity) authidentityOption {
  6884. return func(m *AuthIdentityMutation) {
  6885. m.oldValue = func(context.Context) (*AuthIdentity, error) {
  6886. return node, nil
  6887. }
  6888. m.id = &node.ID
  6889. }
  6890. }
  6891. // Client returns a new `ent.Client` from the mutation. If the mutation was
  6892. // executed in a transaction (ent.Tx), a transactional client is returned.
  6893. func (m AuthIdentityMutation) Client() *Client {
  6894. client := &Client{config: m.config}
  6895. client.init()
  6896. return client
  6897. }
  6898. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  6899. // it returns an error otherwise.
  6900. func (m AuthIdentityMutation) Tx() (*Tx, error) {
  6901. if _, ok := m.driver.(*txDriver); !ok {
  6902. return nil, errors.New("ent: mutation is not running in a transaction")
  6903. }
  6904. tx := &Tx{config: m.config}
  6905. tx.init()
  6906. return tx, nil
  6907. }
  6908. // ID returns the ID value in the mutation. Note that the ID is only available
  6909. // if it was provided to the builder or after it was returned from the database.
  6910. func (m *AuthIdentityMutation) ID() (id int64, exists bool) {
  6911. if m.id == nil {
  6912. return
  6913. }
  6914. return *m.id, true
  6915. }
  6916. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  6917. // That means, if the mutation is applied within a transaction with an isolation level such
  6918. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  6919. // or updated by the mutation.
  6920. func (m *AuthIdentityMutation) IDs(ctx context.Context) ([]int64, error) {
  6921. switch {
  6922. case m.op.Is(OpUpdateOne | OpDeleteOne):
  6923. id, exists := m.ID()
  6924. if exists {
  6925. return []int64{id}, nil
  6926. }
  6927. fallthrough
  6928. case m.op.Is(OpUpdate | OpDelete):
  6929. return m.Client().AuthIdentity.Query().Where(m.predicates...).IDs(ctx)
  6930. default:
  6931. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  6932. }
  6933. }
  6934. // SetCreatedAt sets the "created_at" field.
  6935. func (m *AuthIdentityMutation) SetCreatedAt(t time.Time) {
  6936. m.created_at = &t
  6937. }
  6938. // CreatedAt returns the value of the "created_at" field in the mutation.
  6939. func (m *AuthIdentityMutation) CreatedAt() (r time.Time, exists bool) {
  6940. v := m.created_at
  6941. if v == nil {
  6942. return
  6943. }
  6944. return *v, true
  6945. }
  6946. // OldCreatedAt returns the old "created_at" field's value of the AuthIdentity entity.
  6947. // If the AuthIdentity object wasn't provided to the builder, the object is fetched from the database.
  6948. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6949. func (m *AuthIdentityMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  6950. if !m.op.Is(OpUpdateOne) {
  6951. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  6952. }
  6953. if m.id == nil || m.oldValue == nil {
  6954. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  6955. }
  6956. oldValue, err := m.oldValue(ctx)
  6957. if err != nil {
  6958. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  6959. }
  6960. return oldValue.CreatedAt, nil
  6961. }
  6962. // ResetCreatedAt resets all changes to the "created_at" field.
  6963. func (m *AuthIdentityMutation) ResetCreatedAt() {
  6964. m.created_at = nil
  6965. }
  6966. // SetUpdatedAt sets the "updated_at" field.
  6967. func (m *AuthIdentityMutation) SetUpdatedAt(t time.Time) {
  6968. m.updated_at = &t
  6969. }
  6970. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  6971. func (m *AuthIdentityMutation) UpdatedAt() (r time.Time, exists bool) {
  6972. v := m.updated_at
  6973. if v == nil {
  6974. return
  6975. }
  6976. return *v, true
  6977. }
  6978. // OldUpdatedAt returns the old "updated_at" field's value of the AuthIdentity entity.
  6979. // If the AuthIdentity object wasn't provided to the builder, the object is fetched from the database.
  6980. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6981. func (m *AuthIdentityMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  6982. if !m.op.Is(OpUpdateOne) {
  6983. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  6984. }
  6985. if m.id == nil || m.oldValue == nil {
  6986. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  6987. }
  6988. oldValue, err := m.oldValue(ctx)
  6989. if err != nil {
  6990. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  6991. }
  6992. return oldValue.UpdatedAt, nil
  6993. }
  6994. // ResetUpdatedAt resets all changes to the "updated_at" field.
  6995. func (m *AuthIdentityMutation) ResetUpdatedAt() {
  6996. m.updated_at = nil
  6997. }
  6998. // SetUserID sets the "user_id" field.
  6999. func (m *AuthIdentityMutation) SetUserID(i int64) {
  7000. m.user = &i
  7001. }
  7002. // UserID returns the value of the "user_id" field in the mutation.
  7003. func (m *AuthIdentityMutation) UserID() (r int64, exists bool) {
  7004. v := m.user
  7005. if v == nil {
  7006. return
  7007. }
  7008. return *v, true
  7009. }
  7010. // OldUserID returns the old "user_id" field's value of the AuthIdentity entity.
  7011. // If the AuthIdentity object wasn't provided to the builder, the object is fetched from the database.
  7012. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7013. func (m *AuthIdentityMutation) OldUserID(ctx context.Context) (v int64, err error) {
  7014. if !m.op.Is(OpUpdateOne) {
  7015. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  7016. }
  7017. if m.id == nil || m.oldValue == nil {
  7018. return v, errors.New("OldUserID requires an ID field in the mutation")
  7019. }
  7020. oldValue, err := m.oldValue(ctx)
  7021. if err != nil {
  7022. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  7023. }
  7024. return oldValue.UserID, nil
  7025. }
  7026. // ResetUserID resets all changes to the "user_id" field.
  7027. func (m *AuthIdentityMutation) ResetUserID() {
  7028. m.user = nil
  7029. }
  7030. // SetProviderType sets the "provider_type" field.
  7031. func (m *AuthIdentityMutation) SetProviderType(s string) {
  7032. m.provider_type = &s
  7033. }
  7034. // ProviderType returns the value of the "provider_type" field in the mutation.
  7035. func (m *AuthIdentityMutation) ProviderType() (r string, exists bool) {
  7036. v := m.provider_type
  7037. if v == nil {
  7038. return
  7039. }
  7040. return *v, true
  7041. }
  7042. // OldProviderType returns the old "provider_type" field's value of the AuthIdentity entity.
  7043. // If the AuthIdentity object wasn't provided to the builder, the object is fetched from the database.
  7044. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7045. func (m *AuthIdentityMutation) OldProviderType(ctx context.Context) (v string, err error) {
  7046. if !m.op.Is(OpUpdateOne) {
  7047. return v, errors.New("OldProviderType is only allowed on UpdateOne operations")
  7048. }
  7049. if m.id == nil || m.oldValue == nil {
  7050. return v, errors.New("OldProviderType requires an ID field in the mutation")
  7051. }
  7052. oldValue, err := m.oldValue(ctx)
  7053. if err != nil {
  7054. return v, fmt.Errorf("querying old value for OldProviderType: %w", err)
  7055. }
  7056. return oldValue.ProviderType, nil
  7057. }
  7058. // ResetProviderType resets all changes to the "provider_type" field.
  7059. func (m *AuthIdentityMutation) ResetProviderType() {
  7060. m.provider_type = nil
  7061. }
  7062. // SetProviderKey sets the "provider_key" field.
  7063. func (m *AuthIdentityMutation) SetProviderKey(s string) {
  7064. m.provider_key = &s
  7065. }
  7066. // ProviderKey returns the value of the "provider_key" field in the mutation.
  7067. func (m *AuthIdentityMutation) ProviderKey() (r string, exists bool) {
  7068. v := m.provider_key
  7069. if v == nil {
  7070. return
  7071. }
  7072. return *v, true
  7073. }
  7074. // OldProviderKey returns the old "provider_key" field's value of the AuthIdentity entity.
  7075. // If the AuthIdentity object wasn't provided to the builder, the object is fetched from the database.
  7076. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7077. func (m *AuthIdentityMutation) OldProviderKey(ctx context.Context) (v string, err error) {
  7078. if !m.op.Is(OpUpdateOne) {
  7079. return v, errors.New("OldProviderKey is only allowed on UpdateOne operations")
  7080. }
  7081. if m.id == nil || m.oldValue == nil {
  7082. return v, errors.New("OldProviderKey requires an ID field in the mutation")
  7083. }
  7084. oldValue, err := m.oldValue(ctx)
  7085. if err != nil {
  7086. return v, fmt.Errorf("querying old value for OldProviderKey: %w", err)
  7087. }
  7088. return oldValue.ProviderKey, nil
  7089. }
  7090. // ResetProviderKey resets all changes to the "provider_key" field.
  7091. func (m *AuthIdentityMutation) ResetProviderKey() {
  7092. m.provider_key = nil
  7093. }
  7094. // SetProviderSubject sets the "provider_subject" field.
  7095. func (m *AuthIdentityMutation) SetProviderSubject(s string) {
  7096. m.provider_subject = &s
  7097. }
  7098. // ProviderSubject returns the value of the "provider_subject" field in the mutation.
  7099. func (m *AuthIdentityMutation) ProviderSubject() (r string, exists bool) {
  7100. v := m.provider_subject
  7101. if v == nil {
  7102. return
  7103. }
  7104. return *v, true
  7105. }
  7106. // OldProviderSubject returns the old "provider_subject" field's value of the AuthIdentity entity.
  7107. // If the AuthIdentity object wasn't provided to the builder, the object is fetched from the database.
  7108. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7109. func (m *AuthIdentityMutation) OldProviderSubject(ctx context.Context) (v string, err error) {
  7110. if !m.op.Is(OpUpdateOne) {
  7111. return v, errors.New("OldProviderSubject is only allowed on UpdateOne operations")
  7112. }
  7113. if m.id == nil || m.oldValue == nil {
  7114. return v, errors.New("OldProviderSubject requires an ID field in the mutation")
  7115. }
  7116. oldValue, err := m.oldValue(ctx)
  7117. if err != nil {
  7118. return v, fmt.Errorf("querying old value for OldProviderSubject: %w", err)
  7119. }
  7120. return oldValue.ProviderSubject, nil
  7121. }
  7122. // ResetProviderSubject resets all changes to the "provider_subject" field.
  7123. func (m *AuthIdentityMutation) ResetProviderSubject() {
  7124. m.provider_subject = nil
  7125. }
  7126. // SetVerifiedAt sets the "verified_at" field.
  7127. func (m *AuthIdentityMutation) SetVerifiedAt(t time.Time) {
  7128. m.verified_at = &t
  7129. }
  7130. // VerifiedAt returns the value of the "verified_at" field in the mutation.
  7131. func (m *AuthIdentityMutation) VerifiedAt() (r time.Time, exists bool) {
  7132. v := m.verified_at
  7133. if v == nil {
  7134. return
  7135. }
  7136. return *v, true
  7137. }
  7138. // OldVerifiedAt returns the old "verified_at" field's value of the AuthIdentity entity.
  7139. // If the AuthIdentity object wasn't provided to the builder, the object is fetched from the database.
  7140. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7141. func (m *AuthIdentityMutation) OldVerifiedAt(ctx context.Context) (v *time.Time, err error) {
  7142. if !m.op.Is(OpUpdateOne) {
  7143. return v, errors.New("OldVerifiedAt is only allowed on UpdateOne operations")
  7144. }
  7145. if m.id == nil || m.oldValue == nil {
  7146. return v, errors.New("OldVerifiedAt requires an ID field in the mutation")
  7147. }
  7148. oldValue, err := m.oldValue(ctx)
  7149. if err != nil {
  7150. return v, fmt.Errorf("querying old value for OldVerifiedAt: %w", err)
  7151. }
  7152. return oldValue.VerifiedAt, nil
  7153. }
  7154. // ClearVerifiedAt clears the value of the "verified_at" field.
  7155. func (m *AuthIdentityMutation) ClearVerifiedAt() {
  7156. m.verified_at = nil
  7157. m.clearedFields[authidentity.FieldVerifiedAt] = struct{}{}
  7158. }
  7159. // VerifiedAtCleared returns if the "verified_at" field was cleared in this mutation.
  7160. func (m *AuthIdentityMutation) VerifiedAtCleared() bool {
  7161. _, ok := m.clearedFields[authidentity.FieldVerifiedAt]
  7162. return ok
  7163. }
  7164. // ResetVerifiedAt resets all changes to the "verified_at" field.
  7165. func (m *AuthIdentityMutation) ResetVerifiedAt() {
  7166. m.verified_at = nil
  7167. delete(m.clearedFields, authidentity.FieldVerifiedAt)
  7168. }
  7169. // SetIssuer sets the "issuer" field.
  7170. func (m *AuthIdentityMutation) SetIssuer(s string) {
  7171. m.issuer = &s
  7172. }
  7173. // Issuer returns the value of the "issuer" field in the mutation.
  7174. func (m *AuthIdentityMutation) Issuer() (r string, exists bool) {
  7175. v := m.issuer
  7176. if v == nil {
  7177. return
  7178. }
  7179. return *v, true
  7180. }
  7181. // OldIssuer returns the old "issuer" field's value of the AuthIdentity entity.
  7182. // If the AuthIdentity object wasn't provided to the builder, the object is fetched from the database.
  7183. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7184. func (m *AuthIdentityMutation) OldIssuer(ctx context.Context) (v *string, err error) {
  7185. if !m.op.Is(OpUpdateOne) {
  7186. return v, errors.New("OldIssuer is only allowed on UpdateOne operations")
  7187. }
  7188. if m.id == nil || m.oldValue == nil {
  7189. return v, errors.New("OldIssuer requires an ID field in the mutation")
  7190. }
  7191. oldValue, err := m.oldValue(ctx)
  7192. if err != nil {
  7193. return v, fmt.Errorf("querying old value for OldIssuer: %w", err)
  7194. }
  7195. return oldValue.Issuer, nil
  7196. }
  7197. // ClearIssuer clears the value of the "issuer" field.
  7198. func (m *AuthIdentityMutation) ClearIssuer() {
  7199. m.issuer = nil
  7200. m.clearedFields[authidentity.FieldIssuer] = struct{}{}
  7201. }
  7202. // IssuerCleared returns if the "issuer" field was cleared in this mutation.
  7203. func (m *AuthIdentityMutation) IssuerCleared() bool {
  7204. _, ok := m.clearedFields[authidentity.FieldIssuer]
  7205. return ok
  7206. }
  7207. // ResetIssuer resets all changes to the "issuer" field.
  7208. func (m *AuthIdentityMutation) ResetIssuer() {
  7209. m.issuer = nil
  7210. delete(m.clearedFields, authidentity.FieldIssuer)
  7211. }
  7212. // SetMetadata sets the "metadata" field.
  7213. func (m *AuthIdentityMutation) SetMetadata(value map[string]interface{}) {
  7214. m.metadata = &value
  7215. }
  7216. // Metadata returns the value of the "metadata" field in the mutation.
  7217. func (m *AuthIdentityMutation) Metadata() (r map[string]interface{}, exists bool) {
  7218. v := m.metadata
  7219. if v == nil {
  7220. return
  7221. }
  7222. return *v, true
  7223. }
  7224. // OldMetadata returns the old "metadata" field's value of the AuthIdentity entity.
  7225. // If the AuthIdentity object wasn't provided to the builder, the object is fetched from the database.
  7226. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7227. func (m *AuthIdentityMutation) OldMetadata(ctx context.Context) (v map[string]interface{}, err error) {
  7228. if !m.op.Is(OpUpdateOne) {
  7229. return v, errors.New("OldMetadata is only allowed on UpdateOne operations")
  7230. }
  7231. if m.id == nil || m.oldValue == nil {
  7232. return v, errors.New("OldMetadata requires an ID field in the mutation")
  7233. }
  7234. oldValue, err := m.oldValue(ctx)
  7235. if err != nil {
  7236. return v, fmt.Errorf("querying old value for OldMetadata: %w", err)
  7237. }
  7238. return oldValue.Metadata, nil
  7239. }
  7240. // ResetMetadata resets all changes to the "metadata" field.
  7241. func (m *AuthIdentityMutation) ResetMetadata() {
  7242. m.metadata = nil
  7243. }
  7244. // ClearUser clears the "user" edge to the User entity.
  7245. func (m *AuthIdentityMutation) ClearUser() {
  7246. m.cleareduser = true
  7247. m.clearedFields[authidentity.FieldUserID] = struct{}{}
  7248. }
  7249. // UserCleared reports if the "user" edge to the User entity was cleared.
  7250. func (m *AuthIdentityMutation) UserCleared() bool {
  7251. return m.cleareduser
  7252. }
  7253. // UserIDs returns the "user" edge IDs in the mutation.
  7254. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  7255. // UserID instead. It exists only for internal usage by the builders.
  7256. func (m *AuthIdentityMutation) UserIDs() (ids []int64) {
  7257. if id := m.user; id != nil {
  7258. ids = append(ids, *id)
  7259. }
  7260. return
  7261. }
  7262. // ResetUser resets all changes to the "user" edge.
  7263. func (m *AuthIdentityMutation) ResetUser() {
  7264. m.user = nil
  7265. m.cleareduser = false
  7266. }
  7267. // AddChannelIDs adds the "channels" edge to the AuthIdentityChannel entity by ids.
  7268. func (m *AuthIdentityMutation) AddChannelIDs(ids ...int64) {
  7269. if m.channels == nil {
  7270. m.channels = make(map[int64]struct{})
  7271. }
  7272. for i := range ids {
  7273. m.channels[ids[i]] = struct{}{}
  7274. }
  7275. }
  7276. // ClearChannels clears the "channels" edge to the AuthIdentityChannel entity.
  7277. func (m *AuthIdentityMutation) ClearChannels() {
  7278. m.clearedchannels = true
  7279. }
  7280. // ChannelsCleared reports if the "channels" edge to the AuthIdentityChannel entity was cleared.
  7281. func (m *AuthIdentityMutation) ChannelsCleared() bool {
  7282. return m.clearedchannels
  7283. }
  7284. // RemoveChannelIDs removes the "channels" edge to the AuthIdentityChannel entity by IDs.
  7285. func (m *AuthIdentityMutation) RemoveChannelIDs(ids ...int64) {
  7286. if m.removedchannels == nil {
  7287. m.removedchannels = make(map[int64]struct{})
  7288. }
  7289. for i := range ids {
  7290. delete(m.channels, ids[i])
  7291. m.removedchannels[ids[i]] = struct{}{}
  7292. }
  7293. }
  7294. // RemovedChannels returns the removed IDs of the "channels" edge to the AuthIdentityChannel entity.
  7295. func (m *AuthIdentityMutation) RemovedChannelsIDs() (ids []int64) {
  7296. for id := range m.removedchannels {
  7297. ids = append(ids, id)
  7298. }
  7299. return
  7300. }
  7301. // ChannelsIDs returns the "channels" edge IDs in the mutation.
  7302. func (m *AuthIdentityMutation) ChannelsIDs() (ids []int64) {
  7303. for id := range m.channels {
  7304. ids = append(ids, id)
  7305. }
  7306. return
  7307. }
  7308. // ResetChannels resets all changes to the "channels" edge.
  7309. func (m *AuthIdentityMutation) ResetChannels() {
  7310. m.channels = nil
  7311. m.clearedchannels = false
  7312. m.removedchannels = nil
  7313. }
  7314. // AddAdoptionDecisionIDs adds the "adoption_decisions" edge to the IdentityAdoptionDecision entity by ids.
  7315. func (m *AuthIdentityMutation) AddAdoptionDecisionIDs(ids ...int64) {
  7316. if m.adoption_decisions == nil {
  7317. m.adoption_decisions = make(map[int64]struct{})
  7318. }
  7319. for i := range ids {
  7320. m.adoption_decisions[ids[i]] = struct{}{}
  7321. }
  7322. }
  7323. // ClearAdoptionDecisions clears the "adoption_decisions" edge to the IdentityAdoptionDecision entity.
  7324. func (m *AuthIdentityMutation) ClearAdoptionDecisions() {
  7325. m.clearedadoption_decisions = true
  7326. }
  7327. // AdoptionDecisionsCleared reports if the "adoption_decisions" edge to the IdentityAdoptionDecision entity was cleared.
  7328. func (m *AuthIdentityMutation) AdoptionDecisionsCleared() bool {
  7329. return m.clearedadoption_decisions
  7330. }
  7331. // RemoveAdoptionDecisionIDs removes the "adoption_decisions" edge to the IdentityAdoptionDecision entity by IDs.
  7332. func (m *AuthIdentityMutation) RemoveAdoptionDecisionIDs(ids ...int64) {
  7333. if m.removedadoption_decisions == nil {
  7334. m.removedadoption_decisions = make(map[int64]struct{})
  7335. }
  7336. for i := range ids {
  7337. delete(m.adoption_decisions, ids[i])
  7338. m.removedadoption_decisions[ids[i]] = struct{}{}
  7339. }
  7340. }
  7341. // RemovedAdoptionDecisions returns the removed IDs of the "adoption_decisions" edge to the IdentityAdoptionDecision entity.
  7342. func (m *AuthIdentityMutation) RemovedAdoptionDecisionsIDs() (ids []int64) {
  7343. for id := range m.removedadoption_decisions {
  7344. ids = append(ids, id)
  7345. }
  7346. return
  7347. }
  7348. // AdoptionDecisionsIDs returns the "adoption_decisions" edge IDs in the mutation.
  7349. func (m *AuthIdentityMutation) AdoptionDecisionsIDs() (ids []int64) {
  7350. for id := range m.adoption_decisions {
  7351. ids = append(ids, id)
  7352. }
  7353. return
  7354. }
  7355. // ResetAdoptionDecisions resets all changes to the "adoption_decisions" edge.
  7356. func (m *AuthIdentityMutation) ResetAdoptionDecisions() {
  7357. m.adoption_decisions = nil
  7358. m.clearedadoption_decisions = false
  7359. m.removedadoption_decisions = nil
  7360. }
  7361. // Where appends a list predicates to the AuthIdentityMutation builder.
  7362. func (m *AuthIdentityMutation) Where(ps ...predicate.AuthIdentity) {
  7363. m.predicates = append(m.predicates, ps...)
  7364. }
  7365. // WhereP appends storage-level predicates to the AuthIdentityMutation builder. Using this method,
  7366. // users can use type-assertion to append predicates that do not depend on any generated package.
  7367. func (m *AuthIdentityMutation) WhereP(ps ...func(*sql.Selector)) {
  7368. p := make([]predicate.AuthIdentity, len(ps))
  7369. for i := range ps {
  7370. p[i] = ps[i]
  7371. }
  7372. m.Where(p...)
  7373. }
  7374. // Op returns the operation name.
  7375. func (m *AuthIdentityMutation) Op() Op {
  7376. return m.op
  7377. }
  7378. // SetOp allows setting the mutation operation.
  7379. func (m *AuthIdentityMutation) SetOp(op Op) {
  7380. m.op = op
  7381. }
  7382. // Type returns the node type of this mutation (AuthIdentity).
  7383. func (m *AuthIdentityMutation) Type() string {
  7384. return m.typ
  7385. }
  7386. // Fields returns all fields that were changed during this mutation. Note that in
  7387. // order to get all numeric fields that were incremented/decremented, call
  7388. // AddedFields().
  7389. func (m *AuthIdentityMutation) Fields() []string {
  7390. fields := make([]string, 0, 9)
  7391. if m.created_at != nil {
  7392. fields = append(fields, authidentity.FieldCreatedAt)
  7393. }
  7394. if m.updated_at != nil {
  7395. fields = append(fields, authidentity.FieldUpdatedAt)
  7396. }
  7397. if m.user != nil {
  7398. fields = append(fields, authidentity.FieldUserID)
  7399. }
  7400. if m.provider_type != nil {
  7401. fields = append(fields, authidentity.FieldProviderType)
  7402. }
  7403. if m.provider_key != nil {
  7404. fields = append(fields, authidentity.FieldProviderKey)
  7405. }
  7406. if m.provider_subject != nil {
  7407. fields = append(fields, authidentity.FieldProviderSubject)
  7408. }
  7409. if m.verified_at != nil {
  7410. fields = append(fields, authidentity.FieldVerifiedAt)
  7411. }
  7412. if m.issuer != nil {
  7413. fields = append(fields, authidentity.FieldIssuer)
  7414. }
  7415. if m.metadata != nil {
  7416. fields = append(fields, authidentity.FieldMetadata)
  7417. }
  7418. return fields
  7419. }
  7420. // Field returns the value of a field with the given name. The second boolean
  7421. // return value indicates that this field was not set, or was not defined in the
  7422. // schema.
  7423. func (m *AuthIdentityMutation) Field(name string) (ent.Value, bool) {
  7424. switch name {
  7425. case authidentity.FieldCreatedAt:
  7426. return m.CreatedAt()
  7427. case authidentity.FieldUpdatedAt:
  7428. return m.UpdatedAt()
  7429. case authidentity.FieldUserID:
  7430. return m.UserID()
  7431. case authidentity.FieldProviderType:
  7432. return m.ProviderType()
  7433. case authidentity.FieldProviderKey:
  7434. return m.ProviderKey()
  7435. case authidentity.FieldProviderSubject:
  7436. return m.ProviderSubject()
  7437. case authidentity.FieldVerifiedAt:
  7438. return m.VerifiedAt()
  7439. case authidentity.FieldIssuer:
  7440. return m.Issuer()
  7441. case authidentity.FieldMetadata:
  7442. return m.Metadata()
  7443. }
  7444. return nil, false
  7445. }
  7446. // OldField returns the old value of the field from the database. An error is
  7447. // returned if the mutation operation is not UpdateOne, or the query to the
  7448. // database failed.
  7449. func (m *AuthIdentityMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  7450. switch name {
  7451. case authidentity.FieldCreatedAt:
  7452. return m.OldCreatedAt(ctx)
  7453. case authidentity.FieldUpdatedAt:
  7454. return m.OldUpdatedAt(ctx)
  7455. case authidentity.FieldUserID:
  7456. return m.OldUserID(ctx)
  7457. case authidentity.FieldProviderType:
  7458. return m.OldProviderType(ctx)
  7459. case authidentity.FieldProviderKey:
  7460. return m.OldProviderKey(ctx)
  7461. case authidentity.FieldProviderSubject:
  7462. return m.OldProviderSubject(ctx)
  7463. case authidentity.FieldVerifiedAt:
  7464. return m.OldVerifiedAt(ctx)
  7465. case authidentity.FieldIssuer:
  7466. return m.OldIssuer(ctx)
  7467. case authidentity.FieldMetadata:
  7468. return m.OldMetadata(ctx)
  7469. }
  7470. return nil, fmt.Errorf("unknown AuthIdentity field %s", name)
  7471. }
  7472. // SetField sets the value of a field with the given name. It returns an error if
  7473. // the field is not defined in the schema, or if the type mismatched the field
  7474. // type.
  7475. func (m *AuthIdentityMutation) SetField(name string, value ent.Value) error {
  7476. switch name {
  7477. case authidentity.FieldCreatedAt:
  7478. v, ok := value.(time.Time)
  7479. if !ok {
  7480. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7481. }
  7482. m.SetCreatedAt(v)
  7483. return nil
  7484. case authidentity.FieldUpdatedAt:
  7485. v, ok := value.(time.Time)
  7486. if !ok {
  7487. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7488. }
  7489. m.SetUpdatedAt(v)
  7490. return nil
  7491. case authidentity.FieldUserID:
  7492. v, ok := value.(int64)
  7493. if !ok {
  7494. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7495. }
  7496. m.SetUserID(v)
  7497. return nil
  7498. case authidentity.FieldProviderType:
  7499. v, ok := value.(string)
  7500. if !ok {
  7501. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7502. }
  7503. m.SetProviderType(v)
  7504. return nil
  7505. case authidentity.FieldProviderKey:
  7506. v, ok := value.(string)
  7507. if !ok {
  7508. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7509. }
  7510. m.SetProviderKey(v)
  7511. return nil
  7512. case authidentity.FieldProviderSubject:
  7513. v, ok := value.(string)
  7514. if !ok {
  7515. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7516. }
  7517. m.SetProviderSubject(v)
  7518. return nil
  7519. case authidentity.FieldVerifiedAt:
  7520. v, ok := value.(time.Time)
  7521. if !ok {
  7522. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7523. }
  7524. m.SetVerifiedAt(v)
  7525. return nil
  7526. case authidentity.FieldIssuer:
  7527. v, ok := value.(string)
  7528. if !ok {
  7529. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7530. }
  7531. m.SetIssuer(v)
  7532. return nil
  7533. case authidentity.FieldMetadata:
  7534. v, ok := value.(map[string]interface{})
  7535. if !ok {
  7536. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7537. }
  7538. m.SetMetadata(v)
  7539. return nil
  7540. }
  7541. return fmt.Errorf("unknown AuthIdentity field %s", name)
  7542. }
  7543. // AddedFields returns all numeric fields that were incremented/decremented during
  7544. // this mutation.
  7545. func (m *AuthIdentityMutation) AddedFields() []string {
  7546. var fields []string
  7547. return fields
  7548. }
  7549. // AddedField returns the numeric value that was incremented/decremented on a field
  7550. // with the given name. The second boolean return value indicates that this field
  7551. // was not set, or was not defined in the schema.
  7552. func (m *AuthIdentityMutation) AddedField(name string) (ent.Value, bool) {
  7553. switch name {
  7554. }
  7555. return nil, false
  7556. }
  7557. // AddField adds the value to the field with the given name. It returns an error if
  7558. // the field is not defined in the schema, or if the type mismatched the field
  7559. // type.
  7560. func (m *AuthIdentityMutation) AddField(name string, value ent.Value) error {
  7561. switch name {
  7562. }
  7563. return fmt.Errorf("unknown AuthIdentity numeric field %s", name)
  7564. }
  7565. // ClearedFields returns all nullable fields that were cleared during this
  7566. // mutation.
  7567. func (m *AuthIdentityMutation) ClearedFields() []string {
  7568. var fields []string
  7569. if m.FieldCleared(authidentity.FieldVerifiedAt) {
  7570. fields = append(fields, authidentity.FieldVerifiedAt)
  7571. }
  7572. if m.FieldCleared(authidentity.FieldIssuer) {
  7573. fields = append(fields, authidentity.FieldIssuer)
  7574. }
  7575. return fields
  7576. }
  7577. // FieldCleared returns a boolean indicating if a field with the given name was
  7578. // cleared in this mutation.
  7579. func (m *AuthIdentityMutation) FieldCleared(name string) bool {
  7580. _, ok := m.clearedFields[name]
  7581. return ok
  7582. }
  7583. // ClearField clears the value of the field with the given name. It returns an
  7584. // error if the field is not defined in the schema.
  7585. func (m *AuthIdentityMutation) ClearField(name string) error {
  7586. switch name {
  7587. case authidentity.FieldVerifiedAt:
  7588. m.ClearVerifiedAt()
  7589. return nil
  7590. case authidentity.FieldIssuer:
  7591. m.ClearIssuer()
  7592. return nil
  7593. }
  7594. return fmt.Errorf("unknown AuthIdentity nullable field %s", name)
  7595. }
  7596. // ResetField resets all changes in the mutation for the field with the given name.
  7597. // It returns an error if the field is not defined in the schema.
  7598. func (m *AuthIdentityMutation) ResetField(name string) error {
  7599. switch name {
  7600. case authidentity.FieldCreatedAt:
  7601. m.ResetCreatedAt()
  7602. return nil
  7603. case authidentity.FieldUpdatedAt:
  7604. m.ResetUpdatedAt()
  7605. return nil
  7606. case authidentity.FieldUserID:
  7607. m.ResetUserID()
  7608. return nil
  7609. case authidentity.FieldProviderType:
  7610. m.ResetProviderType()
  7611. return nil
  7612. case authidentity.FieldProviderKey:
  7613. m.ResetProviderKey()
  7614. return nil
  7615. case authidentity.FieldProviderSubject:
  7616. m.ResetProviderSubject()
  7617. return nil
  7618. case authidentity.FieldVerifiedAt:
  7619. m.ResetVerifiedAt()
  7620. return nil
  7621. case authidentity.FieldIssuer:
  7622. m.ResetIssuer()
  7623. return nil
  7624. case authidentity.FieldMetadata:
  7625. m.ResetMetadata()
  7626. return nil
  7627. }
  7628. return fmt.Errorf("unknown AuthIdentity field %s", name)
  7629. }
  7630. // AddedEdges returns all edge names that were set/added in this mutation.
  7631. func (m *AuthIdentityMutation) AddedEdges() []string {
  7632. edges := make([]string, 0, 3)
  7633. if m.user != nil {
  7634. edges = append(edges, authidentity.EdgeUser)
  7635. }
  7636. if m.channels != nil {
  7637. edges = append(edges, authidentity.EdgeChannels)
  7638. }
  7639. if m.adoption_decisions != nil {
  7640. edges = append(edges, authidentity.EdgeAdoptionDecisions)
  7641. }
  7642. return edges
  7643. }
  7644. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  7645. // name in this mutation.
  7646. func (m *AuthIdentityMutation) AddedIDs(name string) []ent.Value {
  7647. switch name {
  7648. case authidentity.EdgeUser:
  7649. if id := m.user; id != nil {
  7650. return []ent.Value{*id}
  7651. }
  7652. case authidentity.EdgeChannels:
  7653. ids := make([]ent.Value, 0, len(m.channels))
  7654. for id := range m.channels {
  7655. ids = append(ids, id)
  7656. }
  7657. return ids
  7658. case authidentity.EdgeAdoptionDecisions:
  7659. ids := make([]ent.Value, 0, len(m.adoption_decisions))
  7660. for id := range m.adoption_decisions {
  7661. ids = append(ids, id)
  7662. }
  7663. return ids
  7664. }
  7665. return nil
  7666. }
  7667. // RemovedEdges returns all edge names that were removed in this mutation.
  7668. func (m *AuthIdentityMutation) RemovedEdges() []string {
  7669. edges := make([]string, 0, 3)
  7670. if m.removedchannels != nil {
  7671. edges = append(edges, authidentity.EdgeChannels)
  7672. }
  7673. if m.removedadoption_decisions != nil {
  7674. edges = append(edges, authidentity.EdgeAdoptionDecisions)
  7675. }
  7676. return edges
  7677. }
  7678. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  7679. // the given name in this mutation.
  7680. func (m *AuthIdentityMutation) RemovedIDs(name string) []ent.Value {
  7681. switch name {
  7682. case authidentity.EdgeChannels:
  7683. ids := make([]ent.Value, 0, len(m.removedchannels))
  7684. for id := range m.removedchannels {
  7685. ids = append(ids, id)
  7686. }
  7687. return ids
  7688. case authidentity.EdgeAdoptionDecisions:
  7689. ids := make([]ent.Value, 0, len(m.removedadoption_decisions))
  7690. for id := range m.removedadoption_decisions {
  7691. ids = append(ids, id)
  7692. }
  7693. return ids
  7694. }
  7695. return nil
  7696. }
  7697. // ClearedEdges returns all edge names that were cleared in this mutation.
  7698. func (m *AuthIdentityMutation) ClearedEdges() []string {
  7699. edges := make([]string, 0, 3)
  7700. if m.cleareduser {
  7701. edges = append(edges, authidentity.EdgeUser)
  7702. }
  7703. if m.clearedchannels {
  7704. edges = append(edges, authidentity.EdgeChannels)
  7705. }
  7706. if m.clearedadoption_decisions {
  7707. edges = append(edges, authidentity.EdgeAdoptionDecisions)
  7708. }
  7709. return edges
  7710. }
  7711. // EdgeCleared returns a boolean which indicates if the edge with the given name
  7712. // was cleared in this mutation.
  7713. func (m *AuthIdentityMutation) EdgeCleared(name string) bool {
  7714. switch name {
  7715. case authidentity.EdgeUser:
  7716. return m.cleareduser
  7717. case authidentity.EdgeChannels:
  7718. return m.clearedchannels
  7719. case authidentity.EdgeAdoptionDecisions:
  7720. return m.clearedadoption_decisions
  7721. }
  7722. return false
  7723. }
  7724. // ClearEdge clears the value of the edge with the given name. It returns an error
  7725. // if that edge is not defined in the schema.
  7726. func (m *AuthIdentityMutation) ClearEdge(name string) error {
  7727. switch name {
  7728. case authidentity.EdgeUser:
  7729. m.ClearUser()
  7730. return nil
  7731. }
  7732. return fmt.Errorf("unknown AuthIdentity unique edge %s", name)
  7733. }
  7734. // ResetEdge resets all changes to the edge with the given name in this mutation.
  7735. // It returns an error if the edge is not defined in the schema.
  7736. func (m *AuthIdentityMutation) ResetEdge(name string) error {
  7737. switch name {
  7738. case authidentity.EdgeUser:
  7739. m.ResetUser()
  7740. return nil
  7741. case authidentity.EdgeChannels:
  7742. m.ResetChannels()
  7743. return nil
  7744. case authidentity.EdgeAdoptionDecisions:
  7745. m.ResetAdoptionDecisions()
  7746. return nil
  7747. }
  7748. return fmt.Errorf("unknown AuthIdentity edge %s", name)
  7749. }
  7750. // AuthIdentityChannelMutation represents an operation that mutates the AuthIdentityChannel nodes in the graph.
  7751. type AuthIdentityChannelMutation struct {
  7752. config
  7753. op Op
  7754. typ string
  7755. id *int64
  7756. created_at *time.Time
  7757. updated_at *time.Time
  7758. provider_type *string
  7759. provider_key *string
  7760. channel *string
  7761. channel_app_id *string
  7762. channel_subject *string
  7763. metadata *map[string]interface{}
  7764. clearedFields map[string]struct{}
  7765. identity *int64
  7766. clearedidentity bool
  7767. done bool
  7768. oldValue func(context.Context) (*AuthIdentityChannel, error)
  7769. predicates []predicate.AuthIdentityChannel
  7770. }
  7771. var _ ent.Mutation = (*AuthIdentityChannelMutation)(nil)
  7772. // authidentitychannelOption allows management of the mutation configuration using functional options.
  7773. type authidentitychannelOption func(*AuthIdentityChannelMutation)
  7774. // newAuthIdentityChannelMutation creates new mutation for the AuthIdentityChannel entity.
  7775. func newAuthIdentityChannelMutation(c config, op Op, opts ...authidentitychannelOption) *AuthIdentityChannelMutation {
  7776. m := &AuthIdentityChannelMutation{
  7777. config: c,
  7778. op: op,
  7779. typ: TypeAuthIdentityChannel,
  7780. clearedFields: make(map[string]struct{}),
  7781. }
  7782. for _, opt := range opts {
  7783. opt(m)
  7784. }
  7785. return m
  7786. }
  7787. // withAuthIdentityChannelID sets the ID field of the mutation.
  7788. func withAuthIdentityChannelID(id int64) authidentitychannelOption {
  7789. return func(m *AuthIdentityChannelMutation) {
  7790. var (
  7791. err error
  7792. once sync.Once
  7793. value *AuthIdentityChannel
  7794. )
  7795. m.oldValue = func(ctx context.Context) (*AuthIdentityChannel, error) {
  7796. once.Do(func() {
  7797. if m.done {
  7798. err = errors.New("querying old values post mutation is not allowed")
  7799. } else {
  7800. value, err = m.Client().AuthIdentityChannel.Get(ctx, id)
  7801. }
  7802. })
  7803. return value, err
  7804. }
  7805. m.id = &id
  7806. }
  7807. }
  7808. // withAuthIdentityChannel sets the old AuthIdentityChannel of the mutation.
  7809. func withAuthIdentityChannel(node *AuthIdentityChannel) authidentitychannelOption {
  7810. return func(m *AuthIdentityChannelMutation) {
  7811. m.oldValue = func(context.Context) (*AuthIdentityChannel, error) {
  7812. return node, nil
  7813. }
  7814. m.id = &node.ID
  7815. }
  7816. }
  7817. // Client returns a new `ent.Client` from the mutation. If the mutation was
  7818. // executed in a transaction (ent.Tx), a transactional client is returned.
  7819. func (m AuthIdentityChannelMutation) Client() *Client {
  7820. client := &Client{config: m.config}
  7821. client.init()
  7822. return client
  7823. }
  7824. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  7825. // it returns an error otherwise.
  7826. func (m AuthIdentityChannelMutation) Tx() (*Tx, error) {
  7827. if _, ok := m.driver.(*txDriver); !ok {
  7828. return nil, errors.New("ent: mutation is not running in a transaction")
  7829. }
  7830. tx := &Tx{config: m.config}
  7831. tx.init()
  7832. return tx, nil
  7833. }
  7834. // ID returns the ID value in the mutation. Note that the ID is only available
  7835. // if it was provided to the builder or after it was returned from the database.
  7836. func (m *AuthIdentityChannelMutation) ID() (id int64, exists bool) {
  7837. if m.id == nil {
  7838. return
  7839. }
  7840. return *m.id, true
  7841. }
  7842. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  7843. // That means, if the mutation is applied within a transaction with an isolation level such
  7844. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  7845. // or updated by the mutation.
  7846. func (m *AuthIdentityChannelMutation) IDs(ctx context.Context) ([]int64, error) {
  7847. switch {
  7848. case m.op.Is(OpUpdateOne | OpDeleteOne):
  7849. id, exists := m.ID()
  7850. if exists {
  7851. return []int64{id}, nil
  7852. }
  7853. fallthrough
  7854. case m.op.Is(OpUpdate | OpDelete):
  7855. return m.Client().AuthIdentityChannel.Query().Where(m.predicates...).IDs(ctx)
  7856. default:
  7857. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  7858. }
  7859. }
  7860. // SetCreatedAt sets the "created_at" field.
  7861. func (m *AuthIdentityChannelMutation) SetCreatedAt(t time.Time) {
  7862. m.created_at = &t
  7863. }
  7864. // CreatedAt returns the value of the "created_at" field in the mutation.
  7865. func (m *AuthIdentityChannelMutation) CreatedAt() (r time.Time, exists bool) {
  7866. v := m.created_at
  7867. if v == nil {
  7868. return
  7869. }
  7870. return *v, true
  7871. }
  7872. // OldCreatedAt returns the old "created_at" field's value of the AuthIdentityChannel entity.
  7873. // If the AuthIdentityChannel object wasn't provided to the builder, the object is fetched from the database.
  7874. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7875. func (m *AuthIdentityChannelMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  7876. if !m.op.Is(OpUpdateOne) {
  7877. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  7878. }
  7879. if m.id == nil || m.oldValue == nil {
  7880. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  7881. }
  7882. oldValue, err := m.oldValue(ctx)
  7883. if err != nil {
  7884. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  7885. }
  7886. return oldValue.CreatedAt, nil
  7887. }
  7888. // ResetCreatedAt resets all changes to the "created_at" field.
  7889. func (m *AuthIdentityChannelMutation) ResetCreatedAt() {
  7890. m.created_at = nil
  7891. }
  7892. // SetUpdatedAt sets the "updated_at" field.
  7893. func (m *AuthIdentityChannelMutation) SetUpdatedAt(t time.Time) {
  7894. m.updated_at = &t
  7895. }
  7896. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  7897. func (m *AuthIdentityChannelMutation) UpdatedAt() (r time.Time, exists bool) {
  7898. v := m.updated_at
  7899. if v == nil {
  7900. return
  7901. }
  7902. return *v, true
  7903. }
  7904. // OldUpdatedAt returns the old "updated_at" field's value of the AuthIdentityChannel entity.
  7905. // If the AuthIdentityChannel object wasn't provided to the builder, the object is fetched from the database.
  7906. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7907. func (m *AuthIdentityChannelMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  7908. if !m.op.Is(OpUpdateOne) {
  7909. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  7910. }
  7911. if m.id == nil || m.oldValue == nil {
  7912. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  7913. }
  7914. oldValue, err := m.oldValue(ctx)
  7915. if err != nil {
  7916. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  7917. }
  7918. return oldValue.UpdatedAt, nil
  7919. }
  7920. // ResetUpdatedAt resets all changes to the "updated_at" field.
  7921. func (m *AuthIdentityChannelMutation) ResetUpdatedAt() {
  7922. m.updated_at = nil
  7923. }
  7924. // SetIdentityID sets the "identity_id" field.
  7925. func (m *AuthIdentityChannelMutation) SetIdentityID(i int64) {
  7926. m.identity = &i
  7927. }
  7928. // IdentityID returns the value of the "identity_id" field in the mutation.
  7929. func (m *AuthIdentityChannelMutation) IdentityID() (r int64, exists bool) {
  7930. v := m.identity
  7931. if v == nil {
  7932. return
  7933. }
  7934. return *v, true
  7935. }
  7936. // OldIdentityID returns the old "identity_id" field's value of the AuthIdentityChannel entity.
  7937. // If the AuthIdentityChannel object wasn't provided to the builder, the object is fetched from the database.
  7938. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7939. func (m *AuthIdentityChannelMutation) OldIdentityID(ctx context.Context) (v int64, err error) {
  7940. if !m.op.Is(OpUpdateOne) {
  7941. return v, errors.New("OldIdentityID is only allowed on UpdateOne operations")
  7942. }
  7943. if m.id == nil || m.oldValue == nil {
  7944. return v, errors.New("OldIdentityID requires an ID field in the mutation")
  7945. }
  7946. oldValue, err := m.oldValue(ctx)
  7947. if err != nil {
  7948. return v, fmt.Errorf("querying old value for OldIdentityID: %w", err)
  7949. }
  7950. return oldValue.IdentityID, nil
  7951. }
  7952. // ResetIdentityID resets all changes to the "identity_id" field.
  7953. func (m *AuthIdentityChannelMutation) ResetIdentityID() {
  7954. m.identity = nil
  7955. }
  7956. // SetProviderType sets the "provider_type" field.
  7957. func (m *AuthIdentityChannelMutation) SetProviderType(s string) {
  7958. m.provider_type = &s
  7959. }
  7960. // ProviderType returns the value of the "provider_type" field in the mutation.
  7961. func (m *AuthIdentityChannelMutation) ProviderType() (r string, exists bool) {
  7962. v := m.provider_type
  7963. if v == nil {
  7964. return
  7965. }
  7966. return *v, true
  7967. }
  7968. // OldProviderType returns the old "provider_type" field's value of the AuthIdentityChannel entity.
  7969. // If the AuthIdentityChannel object wasn't provided to the builder, the object is fetched from the database.
  7970. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7971. func (m *AuthIdentityChannelMutation) OldProviderType(ctx context.Context) (v string, err error) {
  7972. if !m.op.Is(OpUpdateOne) {
  7973. return v, errors.New("OldProviderType is only allowed on UpdateOne operations")
  7974. }
  7975. if m.id == nil || m.oldValue == nil {
  7976. return v, errors.New("OldProviderType requires an ID field in the mutation")
  7977. }
  7978. oldValue, err := m.oldValue(ctx)
  7979. if err != nil {
  7980. return v, fmt.Errorf("querying old value for OldProviderType: %w", err)
  7981. }
  7982. return oldValue.ProviderType, nil
  7983. }
  7984. // ResetProviderType resets all changes to the "provider_type" field.
  7985. func (m *AuthIdentityChannelMutation) ResetProviderType() {
  7986. m.provider_type = nil
  7987. }
  7988. // SetProviderKey sets the "provider_key" field.
  7989. func (m *AuthIdentityChannelMutation) SetProviderKey(s string) {
  7990. m.provider_key = &s
  7991. }
  7992. // ProviderKey returns the value of the "provider_key" field in the mutation.
  7993. func (m *AuthIdentityChannelMutation) ProviderKey() (r string, exists bool) {
  7994. v := m.provider_key
  7995. if v == nil {
  7996. return
  7997. }
  7998. return *v, true
  7999. }
  8000. // OldProviderKey returns the old "provider_key" field's value of the AuthIdentityChannel entity.
  8001. // If the AuthIdentityChannel object wasn't provided to the builder, the object is fetched from the database.
  8002. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8003. func (m *AuthIdentityChannelMutation) OldProviderKey(ctx context.Context) (v string, err error) {
  8004. if !m.op.Is(OpUpdateOne) {
  8005. return v, errors.New("OldProviderKey is only allowed on UpdateOne operations")
  8006. }
  8007. if m.id == nil || m.oldValue == nil {
  8008. return v, errors.New("OldProviderKey requires an ID field in the mutation")
  8009. }
  8010. oldValue, err := m.oldValue(ctx)
  8011. if err != nil {
  8012. return v, fmt.Errorf("querying old value for OldProviderKey: %w", err)
  8013. }
  8014. return oldValue.ProviderKey, nil
  8015. }
  8016. // ResetProviderKey resets all changes to the "provider_key" field.
  8017. func (m *AuthIdentityChannelMutation) ResetProviderKey() {
  8018. m.provider_key = nil
  8019. }
  8020. // SetChannel sets the "channel" field.
  8021. func (m *AuthIdentityChannelMutation) SetChannel(s string) {
  8022. m.channel = &s
  8023. }
  8024. // Channel returns the value of the "channel" field in the mutation.
  8025. func (m *AuthIdentityChannelMutation) Channel() (r string, exists bool) {
  8026. v := m.channel
  8027. if v == nil {
  8028. return
  8029. }
  8030. return *v, true
  8031. }
  8032. // OldChannel returns the old "channel" field's value of the AuthIdentityChannel entity.
  8033. // If the AuthIdentityChannel object wasn't provided to the builder, the object is fetched from the database.
  8034. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8035. func (m *AuthIdentityChannelMutation) OldChannel(ctx context.Context) (v string, err error) {
  8036. if !m.op.Is(OpUpdateOne) {
  8037. return v, errors.New("OldChannel is only allowed on UpdateOne operations")
  8038. }
  8039. if m.id == nil || m.oldValue == nil {
  8040. return v, errors.New("OldChannel requires an ID field in the mutation")
  8041. }
  8042. oldValue, err := m.oldValue(ctx)
  8043. if err != nil {
  8044. return v, fmt.Errorf("querying old value for OldChannel: %w", err)
  8045. }
  8046. return oldValue.Channel, nil
  8047. }
  8048. // ResetChannel resets all changes to the "channel" field.
  8049. func (m *AuthIdentityChannelMutation) ResetChannel() {
  8050. m.channel = nil
  8051. }
  8052. // SetChannelAppID sets the "channel_app_id" field.
  8053. func (m *AuthIdentityChannelMutation) SetChannelAppID(s string) {
  8054. m.channel_app_id = &s
  8055. }
  8056. // ChannelAppID returns the value of the "channel_app_id" field in the mutation.
  8057. func (m *AuthIdentityChannelMutation) ChannelAppID() (r string, exists bool) {
  8058. v := m.channel_app_id
  8059. if v == nil {
  8060. return
  8061. }
  8062. return *v, true
  8063. }
  8064. // OldChannelAppID returns the old "channel_app_id" field's value of the AuthIdentityChannel entity.
  8065. // If the AuthIdentityChannel object wasn't provided to the builder, the object is fetched from the database.
  8066. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8067. func (m *AuthIdentityChannelMutation) OldChannelAppID(ctx context.Context) (v string, err error) {
  8068. if !m.op.Is(OpUpdateOne) {
  8069. return v, errors.New("OldChannelAppID is only allowed on UpdateOne operations")
  8070. }
  8071. if m.id == nil || m.oldValue == nil {
  8072. return v, errors.New("OldChannelAppID requires an ID field in the mutation")
  8073. }
  8074. oldValue, err := m.oldValue(ctx)
  8075. if err != nil {
  8076. return v, fmt.Errorf("querying old value for OldChannelAppID: %w", err)
  8077. }
  8078. return oldValue.ChannelAppID, nil
  8079. }
  8080. // ResetChannelAppID resets all changes to the "channel_app_id" field.
  8081. func (m *AuthIdentityChannelMutation) ResetChannelAppID() {
  8082. m.channel_app_id = nil
  8083. }
  8084. // SetChannelSubject sets the "channel_subject" field.
  8085. func (m *AuthIdentityChannelMutation) SetChannelSubject(s string) {
  8086. m.channel_subject = &s
  8087. }
  8088. // ChannelSubject returns the value of the "channel_subject" field in the mutation.
  8089. func (m *AuthIdentityChannelMutation) ChannelSubject() (r string, exists bool) {
  8090. v := m.channel_subject
  8091. if v == nil {
  8092. return
  8093. }
  8094. return *v, true
  8095. }
  8096. // OldChannelSubject returns the old "channel_subject" field's value of the AuthIdentityChannel entity.
  8097. // If the AuthIdentityChannel object wasn't provided to the builder, the object is fetched from the database.
  8098. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8099. func (m *AuthIdentityChannelMutation) OldChannelSubject(ctx context.Context) (v string, err error) {
  8100. if !m.op.Is(OpUpdateOne) {
  8101. return v, errors.New("OldChannelSubject is only allowed on UpdateOne operations")
  8102. }
  8103. if m.id == nil || m.oldValue == nil {
  8104. return v, errors.New("OldChannelSubject requires an ID field in the mutation")
  8105. }
  8106. oldValue, err := m.oldValue(ctx)
  8107. if err != nil {
  8108. return v, fmt.Errorf("querying old value for OldChannelSubject: %w", err)
  8109. }
  8110. return oldValue.ChannelSubject, nil
  8111. }
  8112. // ResetChannelSubject resets all changes to the "channel_subject" field.
  8113. func (m *AuthIdentityChannelMutation) ResetChannelSubject() {
  8114. m.channel_subject = nil
  8115. }
  8116. // SetMetadata sets the "metadata" field.
  8117. func (m *AuthIdentityChannelMutation) SetMetadata(value map[string]interface{}) {
  8118. m.metadata = &value
  8119. }
  8120. // Metadata returns the value of the "metadata" field in the mutation.
  8121. func (m *AuthIdentityChannelMutation) Metadata() (r map[string]interface{}, exists bool) {
  8122. v := m.metadata
  8123. if v == nil {
  8124. return
  8125. }
  8126. return *v, true
  8127. }
  8128. // OldMetadata returns the old "metadata" field's value of the AuthIdentityChannel entity.
  8129. // If the AuthIdentityChannel object wasn't provided to the builder, the object is fetched from the database.
  8130. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8131. func (m *AuthIdentityChannelMutation) OldMetadata(ctx context.Context) (v map[string]interface{}, err error) {
  8132. if !m.op.Is(OpUpdateOne) {
  8133. return v, errors.New("OldMetadata is only allowed on UpdateOne operations")
  8134. }
  8135. if m.id == nil || m.oldValue == nil {
  8136. return v, errors.New("OldMetadata requires an ID field in the mutation")
  8137. }
  8138. oldValue, err := m.oldValue(ctx)
  8139. if err != nil {
  8140. return v, fmt.Errorf("querying old value for OldMetadata: %w", err)
  8141. }
  8142. return oldValue.Metadata, nil
  8143. }
  8144. // ResetMetadata resets all changes to the "metadata" field.
  8145. func (m *AuthIdentityChannelMutation) ResetMetadata() {
  8146. m.metadata = nil
  8147. }
  8148. // ClearIdentity clears the "identity" edge to the AuthIdentity entity.
  8149. func (m *AuthIdentityChannelMutation) ClearIdentity() {
  8150. m.clearedidentity = true
  8151. m.clearedFields[authidentitychannel.FieldIdentityID] = struct{}{}
  8152. }
  8153. // IdentityCleared reports if the "identity" edge to the AuthIdentity entity was cleared.
  8154. func (m *AuthIdentityChannelMutation) IdentityCleared() bool {
  8155. return m.clearedidentity
  8156. }
  8157. // IdentityIDs returns the "identity" edge IDs in the mutation.
  8158. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  8159. // IdentityID instead. It exists only for internal usage by the builders.
  8160. func (m *AuthIdentityChannelMutation) IdentityIDs() (ids []int64) {
  8161. if id := m.identity; id != nil {
  8162. ids = append(ids, *id)
  8163. }
  8164. return
  8165. }
  8166. // ResetIdentity resets all changes to the "identity" edge.
  8167. func (m *AuthIdentityChannelMutation) ResetIdentity() {
  8168. m.identity = nil
  8169. m.clearedidentity = false
  8170. }
  8171. // Where appends a list predicates to the AuthIdentityChannelMutation builder.
  8172. func (m *AuthIdentityChannelMutation) Where(ps ...predicate.AuthIdentityChannel) {
  8173. m.predicates = append(m.predicates, ps...)
  8174. }
  8175. // WhereP appends storage-level predicates to the AuthIdentityChannelMutation builder. Using this method,
  8176. // users can use type-assertion to append predicates that do not depend on any generated package.
  8177. func (m *AuthIdentityChannelMutation) WhereP(ps ...func(*sql.Selector)) {
  8178. p := make([]predicate.AuthIdentityChannel, len(ps))
  8179. for i := range ps {
  8180. p[i] = ps[i]
  8181. }
  8182. m.Where(p...)
  8183. }
  8184. // Op returns the operation name.
  8185. func (m *AuthIdentityChannelMutation) Op() Op {
  8186. return m.op
  8187. }
  8188. // SetOp allows setting the mutation operation.
  8189. func (m *AuthIdentityChannelMutation) SetOp(op Op) {
  8190. m.op = op
  8191. }
  8192. // Type returns the node type of this mutation (AuthIdentityChannel).
  8193. func (m *AuthIdentityChannelMutation) Type() string {
  8194. return m.typ
  8195. }
  8196. // Fields returns all fields that were changed during this mutation. Note that in
  8197. // order to get all numeric fields that were incremented/decremented, call
  8198. // AddedFields().
  8199. func (m *AuthIdentityChannelMutation) Fields() []string {
  8200. fields := make([]string, 0, 9)
  8201. if m.created_at != nil {
  8202. fields = append(fields, authidentitychannel.FieldCreatedAt)
  8203. }
  8204. if m.updated_at != nil {
  8205. fields = append(fields, authidentitychannel.FieldUpdatedAt)
  8206. }
  8207. if m.identity != nil {
  8208. fields = append(fields, authidentitychannel.FieldIdentityID)
  8209. }
  8210. if m.provider_type != nil {
  8211. fields = append(fields, authidentitychannel.FieldProviderType)
  8212. }
  8213. if m.provider_key != nil {
  8214. fields = append(fields, authidentitychannel.FieldProviderKey)
  8215. }
  8216. if m.channel != nil {
  8217. fields = append(fields, authidentitychannel.FieldChannel)
  8218. }
  8219. if m.channel_app_id != nil {
  8220. fields = append(fields, authidentitychannel.FieldChannelAppID)
  8221. }
  8222. if m.channel_subject != nil {
  8223. fields = append(fields, authidentitychannel.FieldChannelSubject)
  8224. }
  8225. if m.metadata != nil {
  8226. fields = append(fields, authidentitychannel.FieldMetadata)
  8227. }
  8228. return fields
  8229. }
  8230. // Field returns the value of a field with the given name. The second boolean
  8231. // return value indicates that this field was not set, or was not defined in the
  8232. // schema.
  8233. func (m *AuthIdentityChannelMutation) Field(name string) (ent.Value, bool) {
  8234. switch name {
  8235. case authidentitychannel.FieldCreatedAt:
  8236. return m.CreatedAt()
  8237. case authidentitychannel.FieldUpdatedAt:
  8238. return m.UpdatedAt()
  8239. case authidentitychannel.FieldIdentityID:
  8240. return m.IdentityID()
  8241. case authidentitychannel.FieldProviderType:
  8242. return m.ProviderType()
  8243. case authidentitychannel.FieldProviderKey:
  8244. return m.ProviderKey()
  8245. case authidentitychannel.FieldChannel:
  8246. return m.Channel()
  8247. case authidentitychannel.FieldChannelAppID:
  8248. return m.ChannelAppID()
  8249. case authidentitychannel.FieldChannelSubject:
  8250. return m.ChannelSubject()
  8251. case authidentitychannel.FieldMetadata:
  8252. return m.Metadata()
  8253. }
  8254. return nil, false
  8255. }
  8256. // OldField returns the old value of the field from the database. An error is
  8257. // returned if the mutation operation is not UpdateOne, or the query to the
  8258. // database failed.
  8259. func (m *AuthIdentityChannelMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  8260. switch name {
  8261. case authidentitychannel.FieldCreatedAt:
  8262. return m.OldCreatedAt(ctx)
  8263. case authidentitychannel.FieldUpdatedAt:
  8264. return m.OldUpdatedAt(ctx)
  8265. case authidentitychannel.FieldIdentityID:
  8266. return m.OldIdentityID(ctx)
  8267. case authidentitychannel.FieldProviderType:
  8268. return m.OldProviderType(ctx)
  8269. case authidentitychannel.FieldProviderKey:
  8270. return m.OldProviderKey(ctx)
  8271. case authidentitychannel.FieldChannel:
  8272. return m.OldChannel(ctx)
  8273. case authidentitychannel.FieldChannelAppID:
  8274. return m.OldChannelAppID(ctx)
  8275. case authidentitychannel.FieldChannelSubject:
  8276. return m.OldChannelSubject(ctx)
  8277. case authidentitychannel.FieldMetadata:
  8278. return m.OldMetadata(ctx)
  8279. }
  8280. return nil, fmt.Errorf("unknown AuthIdentityChannel field %s", name)
  8281. }
  8282. // SetField sets the value of a field with the given name. It returns an error if
  8283. // the field is not defined in the schema, or if the type mismatched the field
  8284. // type.
  8285. func (m *AuthIdentityChannelMutation) SetField(name string, value ent.Value) error {
  8286. switch name {
  8287. case authidentitychannel.FieldCreatedAt:
  8288. v, ok := value.(time.Time)
  8289. if !ok {
  8290. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8291. }
  8292. m.SetCreatedAt(v)
  8293. return nil
  8294. case authidentitychannel.FieldUpdatedAt:
  8295. v, ok := value.(time.Time)
  8296. if !ok {
  8297. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8298. }
  8299. m.SetUpdatedAt(v)
  8300. return nil
  8301. case authidentitychannel.FieldIdentityID:
  8302. v, ok := value.(int64)
  8303. if !ok {
  8304. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8305. }
  8306. m.SetIdentityID(v)
  8307. return nil
  8308. case authidentitychannel.FieldProviderType:
  8309. v, ok := value.(string)
  8310. if !ok {
  8311. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8312. }
  8313. m.SetProviderType(v)
  8314. return nil
  8315. case authidentitychannel.FieldProviderKey:
  8316. v, ok := value.(string)
  8317. if !ok {
  8318. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8319. }
  8320. m.SetProviderKey(v)
  8321. return nil
  8322. case authidentitychannel.FieldChannel:
  8323. v, ok := value.(string)
  8324. if !ok {
  8325. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8326. }
  8327. m.SetChannel(v)
  8328. return nil
  8329. case authidentitychannel.FieldChannelAppID:
  8330. v, ok := value.(string)
  8331. if !ok {
  8332. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8333. }
  8334. m.SetChannelAppID(v)
  8335. return nil
  8336. case authidentitychannel.FieldChannelSubject:
  8337. v, ok := value.(string)
  8338. if !ok {
  8339. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8340. }
  8341. m.SetChannelSubject(v)
  8342. return nil
  8343. case authidentitychannel.FieldMetadata:
  8344. v, ok := value.(map[string]interface{})
  8345. if !ok {
  8346. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8347. }
  8348. m.SetMetadata(v)
  8349. return nil
  8350. }
  8351. return fmt.Errorf("unknown AuthIdentityChannel field %s", name)
  8352. }
  8353. // AddedFields returns all numeric fields that were incremented/decremented during
  8354. // this mutation.
  8355. func (m *AuthIdentityChannelMutation) AddedFields() []string {
  8356. var fields []string
  8357. return fields
  8358. }
  8359. // AddedField returns the numeric value that was incremented/decremented on a field
  8360. // with the given name. The second boolean return value indicates that this field
  8361. // was not set, or was not defined in the schema.
  8362. func (m *AuthIdentityChannelMutation) AddedField(name string) (ent.Value, bool) {
  8363. switch name {
  8364. }
  8365. return nil, false
  8366. }
  8367. // AddField adds the value to the field with the given name. It returns an error if
  8368. // the field is not defined in the schema, or if the type mismatched the field
  8369. // type.
  8370. func (m *AuthIdentityChannelMutation) AddField(name string, value ent.Value) error {
  8371. switch name {
  8372. }
  8373. return fmt.Errorf("unknown AuthIdentityChannel numeric field %s", name)
  8374. }
  8375. // ClearedFields returns all nullable fields that were cleared during this
  8376. // mutation.
  8377. func (m *AuthIdentityChannelMutation) ClearedFields() []string {
  8378. return nil
  8379. }
  8380. // FieldCleared returns a boolean indicating if a field with the given name was
  8381. // cleared in this mutation.
  8382. func (m *AuthIdentityChannelMutation) FieldCleared(name string) bool {
  8383. _, ok := m.clearedFields[name]
  8384. return ok
  8385. }
  8386. // ClearField clears the value of the field with the given name. It returns an
  8387. // error if the field is not defined in the schema.
  8388. func (m *AuthIdentityChannelMutation) ClearField(name string) error {
  8389. return fmt.Errorf("unknown AuthIdentityChannel nullable field %s", name)
  8390. }
  8391. // ResetField resets all changes in the mutation for the field with the given name.
  8392. // It returns an error if the field is not defined in the schema.
  8393. func (m *AuthIdentityChannelMutation) ResetField(name string) error {
  8394. switch name {
  8395. case authidentitychannel.FieldCreatedAt:
  8396. m.ResetCreatedAt()
  8397. return nil
  8398. case authidentitychannel.FieldUpdatedAt:
  8399. m.ResetUpdatedAt()
  8400. return nil
  8401. case authidentitychannel.FieldIdentityID:
  8402. m.ResetIdentityID()
  8403. return nil
  8404. case authidentitychannel.FieldProviderType:
  8405. m.ResetProviderType()
  8406. return nil
  8407. case authidentitychannel.FieldProviderKey:
  8408. m.ResetProviderKey()
  8409. return nil
  8410. case authidentitychannel.FieldChannel:
  8411. m.ResetChannel()
  8412. return nil
  8413. case authidentitychannel.FieldChannelAppID:
  8414. m.ResetChannelAppID()
  8415. return nil
  8416. case authidentitychannel.FieldChannelSubject:
  8417. m.ResetChannelSubject()
  8418. return nil
  8419. case authidentitychannel.FieldMetadata:
  8420. m.ResetMetadata()
  8421. return nil
  8422. }
  8423. return fmt.Errorf("unknown AuthIdentityChannel field %s", name)
  8424. }
  8425. // AddedEdges returns all edge names that were set/added in this mutation.
  8426. func (m *AuthIdentityChannelMutation) AddedEdges() []string {
  8427. edges := make([]string, 0, 1)
  8428. if m.identity != nil {
  8429. edges = append(edges, authidentitychannel.EdgeIdentity)
  8430. }
  8431. return edges
  8432. }
  8433. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  8434. // name in this mutation.
  8435. func (m *AuthIdentityChannelMutation) AddedIDs(name string) []ent.Value {
  8436. switch name {
  8437. case authidentitychannel.EdgeIdentity:
  8438. if id := m.identity; id != nil {
  8439. return []ent.Value{*id}
  8440. }
  8441. }
  8442. return nil
  8443. }
  8444. // RemovedEdges returns all edge names that were removed in this mutation.
  8445. func (m *AuthIdentityChannelMutation) RemovedEdges() []string {
  8446. edges := make([]string, 0, 1)
  8447. return edges
  8448. }
  8449. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  8450. // the given name in this mutation.
  8451. func (m *AuthIdentityChannelMutation) RemovedIDs(name string) []ent.Value {
  8452. return nil
  8453. }
  8454. // ClearedEdges returns all edge names that were cleared in this mutation.
  8455. func (m *AuthIdentityChannelMutation) ClearedEdges() []string {
  8456. edges := make([]string, 0, 1)
  8457. if m.clearedidentity {
  8458. edges = append(edges, authidentitychannel.EdgeIdentity)
  8459. }
  8460. return edges
  8461. }
  8462. // EdgeCleared returns a boolean which indicates if the edge with the given name
  8463. // was cleared in this mutation.
  8464. func (m *AuthIdentityChannelMutation) EdgeCleared(name string) bool {
  8465. switch name {
  8466. case authidentitychannel.EdgeIdentity:
  8467. return m.clearedidentity
  8468. }
  8469. return false
  8470. }
  8471. // ClearEdge clears the value of the edge with the given name. It returns an error
  8472. // if that edge is not defined in the schema.
  8473. func (m *AuthIdentityChannelMutation) ClearEdge(name string) error {
  8474. switch name {
  8475. case authidentitychannel.EdgeIdentity:
  8476. m.ClearIdentity()
  8477. return nil
  8478. }
  8479. return fmt.Errorf("unknown AuthIdentityChannel unique edge %s", name)
  8480. }
  8481. // ResetEdge resets all changes to the edge with the given name in this mutation.
  8482. // It returns an error if the edge is not defined in the schema.
  8483. func (m *AuthIdentityChannelMutation) ResetEdge(name string) error {
  8484. switch name {
  8485. case authidentitychannel.EdgeIdentity:
  8486. m.ResetIdentity()
  8487. return nil
  8488. }
  8489. return fmt.Errorf("unknown AuthIdentityChannel edge %s", name)
  8490. }
  8491. // BatchImageEventMutation represents an operation that mutates the BatchImageEvent nodes in the graph.
  8492. type BatchImageEventMutation struct {
  8493. config
  8494. op Op
  8495. typ string
  8496. id *int64
  8497. job_id *string
  8498. event_type *string
  8499. payload *map[string]interface{}
  8500. event_hash *string
  8501. created_at *time.Time
  8502. clearedFields map[string]struct{}
  8503. done bool
  8504. oldValue func(context.Context) (*BatchImageEvent, error)
  8505. predicates []predicate.BatchImageEvent
  8506. }
  8507. var _ ent.Mutation = (*BatchImageEventMutation)(nil)
  8508. // batchimageeventOption allows management of the mutation configuration using functional options.
  8509. type batchimageeventOption func(*BatchImageEventMutation)
  8510. // newBatchImageEventMutation creates new mutation for the BatchImageEvent entity.
  8511. func newBatchImageEventMutation(c config, op Op, opts ...batchimageeventOption) *BatchImageEventMutation {
  8512. m := &BatchImageEventMutation{
  8513. config: c,
  8514. op: op,
  8515. typ: TypeBatchImageEvent,
  8516. clearedFields: make(map[string]struct{}),
  8517. }
  8518. for _, opt := range opts {
  8519. opt(m)
  8520. }
  8521. return m
  8522. }
  8523. // withBatchImageEventID sets the ID field of the mutation.
  8524. func withBatchImageEventID(id int64) batchimageeventOption {
  8525. return func(m *BatchImageEventMutation) {
  8526. var (
  8527. err error
  8528. once sync.Once
  8529. value *BatchImageEvent
  8530. )
  8531. m.oldValue = func(ctx context.Context) (*BatchImageEvent, error) {
  8532. once.Do(func() {
  8533. if m.done {
  8534. err = errors.New("querying old values post mutation is not allowed")
  8535. } else {
  8536. value, err = m.Client().BatchImageEvent.Get(ctx, id)
  8537. }
  8538. })
  8539. return value, err
  8540. }
  8541. m.id = &id
  8542. }
  8543. }
  8544. // withBatchImageEvent sets the old BatchImageEvent of the mutation.
  8545. func withBatchImageEvent(node *BatchImageEvent) batchimageeventOption {
  8546. return func(m *BatchImageEventMutation) {
  8547. m.oldValue = func(context.Context) (*BatchImageEvent, error) {
  8548. return node, nil
  8549. }
  8550. m.id = &node.ID
  8551. }
  8552. }
  8553. // Client returns a new `ent.Client` from the mutation. If the mutation was
  8554. // executed in a transaction (ent.Tx), a transactional client is returned.
  8555. func (m BatchImageEventMutation) Client() *Client {
  8556. client := &Client{config: m.config}
  8557. client.init()
  8558. return client
  8559. }
  8560. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  8561. // it returns an error otherwise.
  8562. func (m BatchImageEventMutation) Tx() (*Tx, error) {
  8563. if _, ok := m.driver.(*txDriver); !ok {
  8564. return nil, errors.New("ent: mutation is not running in a transaction")
  8565. }
  8566. tx := &Tx{config: m.config}
  8567. tx.init()
  8568. return tx, nil
  8569. }
  8570. // ID returns the ID value in the mutation. Note that the ID is only available
  8571. // if it was provided to the builder or after it was returned from the database.
  8572. func (m *BatchImageEventMutation) ID() (id int64, exists bool) {
  8573. if m.id == nil {
  8574. return
  8575. }
  8576. return *m.id, true
  8577. }
  8578. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  8579. // That means, if the mutation is applied within a transaction with an isolation level such
  8580. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  8581. // or updated by the mutation.
  8582. func (m *BatchImageEventMutation) IDs(ctx context.Context) ([]int64, error) {
  8583. switch {
  8584. case m.op.Is(OpUpdateOne | OpDeleteOne):
  8585. id, exists := m.ID()
  8586. if exists {
  8587. return []int64{id}, nil
  8588. }
  8589. fallthrough
  8590. case m.op.Is(OpUpdate | OpDelete):
  8591. return m.Client().BatchImageEvent.Query().Where(m.predicates...).IDs(ctx)
  8592. default:
  8593. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  8594. }
  8595. }
  8596. // SetJobID sets the "job_id" field.
  8597. func (m *BatchImageEventMutation) SetJobID(s string) {
  8598. m.job_id = &s
  8599. }
  8600. // JobID returns the value of the "job_id" field in the mutation.
  8601. func (m *BatchImageEventMutation) JobID() (r string, exists bool) {
  8602. v := m.job_id
  8603. if v == nil {
  8604. return
  8605. }
  8606. return *v, true
  8607. }
  8608. // OldJobID returns the old "job_id" field's value of the BatchImageEvent entity.
  8609. // If the BatchImageEvent object wasn't provided to the builder, the object is fetched from the database.
  8610. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8611. func (m *BatchImageEventMutation) OldJobID(ctx context.Context) (v string, err error) {
  8612. if !m.op.Is(OpUpdateOne) {
  8613. return v, errors.New("OldJobID is only allowed on UpdateOne operations")
  8614. }
  8615. if m.id == nil || m.oldValue == nil {
  8616. return v, errors.New("OldJobID requires an ID field in the mutation")
  8617. }
  8618. oldValue, err := m.oldValue(ctx)
  8619. if err != nil {
  8620. return v, fmt.Errorf("querying old value for OldJobID: %w", err)
  8621. }
  8622. return oldValue.JobID, nil
  8623. }
  8624. // ResetJobID resets all changes to the "job_id" field.
  8625. func (m *BatchImageEventMutation) ResetJobID() {
  8626. m.job_id = nil
  8627. }
  8628. // SetEventType sets the "event_type" field.
  8629. func (m *BatchImageEventMutation) SetEventType(s string) {
  8630. m.event_type = &s
  8631. }
  8632. // EventType returns the value of the "event_type" field in the mutation.
  8633. func (m *BatchImageEventMutation) EventType() (r string, exists bool) {
  8634. v := m.event_type
  8635. if v == nil {
  8636. return
  8637. }
  8638. return *v, true
  8639. }
  8640. // OldEventType returns the old "event_type" field's value of the BatchImageEvent entity.
  8641. // If the BatchImageEvent object wasn't provided to the builder, the object is fetched from the database.
  8642. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8643. func (m *BatchImageEventMutation) OldEventType(ctx context.Context) (v string, err error) {
  8644. if !m.op.Is(OpUpdateOne) {
  8645. return v, errors.New("OldEventType is only allowed on UpdateOne operations")
  8646. }
  8647. if m.id == nil || m.oldValue == nil {
  8648. return v, errors.New("OldEventType requires an ID field in the mutation")
  8649. }
  8650. oldValue, err := m.oldValue(ctx)
  8651. if err != nil {
  8652. return v, fmt.Errorf("querying old value for OldEventType: %w", err)
  8653. }
  8654. return oldValue.EventType, nil
  8655. }
  8656. // ResetEventType resets all changes to the "event_type" field.
  8657. func (m *BatchImageEventMutation) ResetEventType() {
  8658. m.event_type = nil
  8659. }
  8660. // SetPayload sets the "payload" field.
  8661. func (m *BatchImageEventMutation) SetPayload(value map[string]interface{}) {
  8662. m.payload = &value
  8663. }
  8664. // Payload returns the value of the "payload" field in the mutation.
  8665. func (m *BatchImageEventMutation) Payload() (r map[string]interface{}, exists bool) {
  8666. v := m.payload
  8667. if v == nil {
  8668. return
  8669. }
  8670. return *v, true
  8671. }
  8672. // OldPayload returns the old "payload" field's value of the BatchImageEvent entity.
  8673. // If the BatchImageEvent object wasn't provided to the builder, the object is fetched from the database.
  8674. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8675. func (m *BatchImageEventMutation) OldPayload(ctx context.Context) (v map[string]interface{}, err error) {
  8676. if !m.op.Is(OpUpdateOne) {
  8677. return v, errors.New("OldPayload is only allowed on UpdateOne operations")
  8678. }
  8679. if m.id == nil || m.oldValue == nil {
  8680. return v, errors.New("OldPayload requires an ID field in the mutation")
  8681. }
  8682. oldValue, err := m.oldValue(ctx)
  8683. if err != nil {
  8684. return v, fmt.Errorf("querying old value for OldPayload: %w", err)
  8685. }
  8686. return oldValue.Payload, nil
  8687. }
  8688. // ClearPayload clears the value of the "payload" field.
  8689. func (m *BatchImageEventMutation) ClearPayload() {
  8690. m.payload = nil
  8691. m.clearedFields[batchimageevent.FieldPayload] = struct{}{}
  8692. }
  8693. // PayloadCleared returns if the "payload" field was cleared in this mutation.
  8694. func (m *BatchImageEventMutation) PayloadCleared() bool {
  8695. _, ok := m.clearedFields[batchimageevent.FieldPayload]
  8696. return ok
  8697. }
  8698. // ResetPayload resets all changes to the "payload" field.
  8699. func (m *BatchImageEventMutation) ResetPayload() {
  8700. m.payload = nil
  8701. delete(m.clearedFields, batchimageevent.FieldPayload)
  8702. }
  8703. // SetEventHash sets the "event_hash" field.
  8704. func (m *BatchImageEventMutation) SetEventHash(s string) {
  8705. m.event_hash = &s
  8706. }
  8707. // EventHash returns the value of the "event_hash" field in the mutation.
  8708. func (m *BatchImageEventMutation) EventHash() (r string, exists bool) {
  8709. v := m.event_hash
  8710. if v == nil {
  8711. return
  8712. }
  8713. return *v, true
  8714. }
  8715. // OldEventHash returns the old "event_hash" field's value of the BatchImageEvent entity.
  8716. // If the BatchImageEvent object wasn't provided to the builder, the object is fetched from the database.
  8717. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8718. func (m *BatchImageEventMutation) OldEventHash(ctx context.Context) (v *string, err error) {
  8719. if !m.op.Is(OpUpdateOne) {
  8720. return v, errors.New("OldEventHash is only allowed on UpdateOne operations")
  8721. }
  8722. if m.id == nil || m.oldValue == nil {
  8723. return v, errors.New("OldEventHash requires an ID field in the mutation")
  8724. }
  8725. oldValue, err := m.oldValue(ctx)
  8726. if err != nil {
  8727. return v, fmt.Errorf("querying old value for OldEventHash: %w", err)
  8728. }
  8729. return oldValue.EventHash, nil
  8730. }
  8731. // ClearEventHash clears the value of the "event_hash" field.
  8732. func (m *BatchImageEventMutation) ClearEventHash() {
  8733. m.event_hash = nil
  8734. m.clearedFields[batchimageevent.FieldEventHash] = struct{}{}
  8735. }
  8736. // EventHashCleared returns if the "event_hash" field was cleared in this mutation.
  8737. func (m *BatchImageEventMutation) EventHashCleared() bool {
  8738. _, ok := m.clearedFields[batchimageevent.FieldEventHash]
  8739. return ok
  8740. }
  8741. // ResetEventHash resets all changes to the "event_hash" field.
  8742. func (m *BatchImageEventMutation) ResetEventHash() {
  8743. m.event_hash = nil
  8744. delete(m.clearedFields, batchimageevent.FieldEventHash)
  8745. }
  8746. // SetCreatedAt sets the "created_at" field.
  8747. func (m *BatchImageEventMutation) SetCreatedAt(t time.Time) {
  8748. m.created_at = &t
  8749. }
  8750. // CreatedAt returns the value of the "created_at" field in the mutation.
  8751. func (m *BatchImageEventMutation) CreatedAt() (r time.Time, exists bool) {
  8752. v := m.created_at
  8753. if v == nil {
  8754. return
  8755. }
  8756. return *v, true
  8757. }
  8758. // OldCreatedAt returns the old "created_at" field's value of the BatchImageEvent entity.
  8759. // If the BatchImageEvent object wasn't provided to the builder, the object is fetched from the database.
  8760. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8761. func (m *BatchImageEventMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  8762. if !m.op.Is(OpUpdateOne) {
  8763. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  8764. }
  8765. if m.id == nil || m.oldValue == nil {
  8766. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  8767. }
  8768. oldValue, err := m.oldValue(ctx)
  8769. if err != nil {
  8770. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  8771. }
  8772. return oldValue.CreatedAt, nil
  8773. }
  8774. // ResetCreatedAt resets all changes to the "created_at" field.
  8775. func (m *BatchImageEventMutation) ResetCreatedAt() {
  8776. m.created_at = nil
  8777. }
  8778. // Where appends a list predicates to the BatchImageEventMutation builder.
  8779. func (m *BatchImageEventMutation) Where(ps ...predicate.BatchImageEvent) {
  8780. m.predicates = append(m.predicates, ps...)
  8781. }
  8782. // WhereP appends storage-level predicates to the BatchImageEventMutation builder. Using this method,
  8783. // users can use type-assertion to append predicates that do not depend on any generated package.
  8784. func (m *BatchImageEventMutation) WhereP(ps ...func(*sql.Selector)) {
  8785. p := make([]predicate.BatchImageEvent, len(ps))
  8786. for i := range ps {
  8787. p[i] = ps[i]
  8788. }
  8789. m.Where(p...)
  8790. }
  8791. // Op returns the operation name.
  8792. func (m *BatchImageEventMutation) Op() Op {
  8793. return m.op
  8794. }
  8795. // SetOp allows setting the mutation operation.
  8796. func (m *BatchImageEventMutation) SetOp(op Op) {
  8797. m.op = op
  8798. }
  8799. // Type returns the node type of this mutation (BatchImageEvent).
  8800. func (m *BatchImageEventMutation) Type() string {
  8801. return m.typ
  8802. }
  8803. // Fields returns all fields that were changed during this mutation. Note that in
  8804. // order to get all numeric fields that were incremented/decremented, call
  8805. // AddedFields().
  8806. func (m *BatchImageEventMutation) Fields() []string {
  8807. fields := make([]string, 0, 5)
  8808. if m.job_id != nil {
  8809. fields = append(fields, batchimageevent.FieldJobID)
  8810. }
  8811. if m.event_type != nil {
  8812. fields = append(fields, batchimageevent.FieldEventType)
  8813. }
  8814. if m.payload != nil {
  8815. fields = append(fields, batchimageevent.FieldPayload)
  8816. }
  8817. if m.event_hash != nil {
  8818. fields = append(fields, batchimageevent.FieldEventHash)
  8819. }
  8820. if m.created_at != nil {
  8821. fields = append(fields, batchimageevent.FieldCreatedAt)
  8822. }
  8823. return fields
  8824. }
  8825. // Field returns the value of a field with the given name. The second boolean
  8826. // return value indicates that this field was not set, or was not defined in the
  8827. // schema.
  8828. func (m *BatchImageEventMutation) Field(name string) (ent.Value, bool) {
  8829. switch name {
  8830. case batchimageevent.FieldJobID:
  8831. return m.JobID()
  8832. case batchimageevent.FieldEventType:
  8833. return m.EventType()
  8834. case batchimageevent.FieldPayload:
  8835. return m.Payload()
  8836. case batchimageevent.FieldEventHash:
  8837. return m.EventHash()
  8838. case batchimageevent.FieldCreatedAt:
  8839. return m.CreatedAt()
  8840. }
  8841. return nil, false
  8842. }
  8843. // OldField returns the old value of the field from the database. An error is
  8844. // returned if the mutation operation is not UpdateOne, or the query to the
  8845. // database failed.
  8846. func (m *BatchImageEventMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  8847. switch name {
  8848. case batchimageevent.FieldJobID:
  8849. return m.OldJobID(ctx)
  8850. case batchimageevent.FieldEventType:
  8851. return m.OldEventType(ctx)
  8852. case batchimageevent.FieldPayload:
  8853. return m.OldPayload(ctx)
  8854. case batchimageevent.FieldEventHash:
  8855. return m.OldEventHash(ctx)
  8856. case batchimageevent.FieldCreatedAt:
  8857. return m.OldCreatedAt(ctx)
  8858. }
  8859. return nil, fmt.Errorf("unknown BatchImageEvent field %s", name)
  8860. }
  8861. // SetField sets the value of a field with the given name. It returns an error if
  8862. // the field is not defined in the schema, or if the type mismatched the field
  8863. // type.
  8864. func (m *BatchImageEventMutation) SetField(name string, value ent.Value) error {
  8865. switch name {
  8866. case batchimageevent.FieldJobID:
  8867. v, ok := value.(string)
  8868. if !ok {
  8869. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8870. }
  8871. m.SetJobID(v)
  8872. return nil
  8873. case batchimageevent.FieldEventType:
  8874. v, ok := value.(string)
  8875. if !ok {
  8876. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8877. }
  8878. m.SetEventType(v)
  8879. return nil
  8880. case batchimageevent.FieldPayload:
  8881. v, ok := value.(map[string]interface{})
  8882. if !ok {
  8883. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8884. }
  8885. m.SetPayload(v)
  8886. return nil
  8887. case batchimageevent.FieldEventHash:
  8888. v, ok := value.(string)
  8889. if !ok {
  8890. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8891. }
  8892. m.SetEventHash(v)
  8893. return nil
  8894. case batchimageevent.FieldCreatedAt:
  8895. v, ok := value.(time.Time)
  8896. if !ok {
  8897. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8898. }
  8899. m.SetCreatedAt(v)
  8900. return nil
  8901. }
  8902. return fmt.Errorf("unknown BatchImageEvent field %s", name)
  8903. }
  8904. // AddedFields returns all numeric fields that were incremented/decremented during
  8905. // this mutation.
  8906. func (m *BatchImageEventMutation) AddedFields() []string {
  8907. return nil
  8908. }
  8909. // AddedField returns the numeric value that was incremented/decremented on a field
  8910. // with the given name. The second boolean return value indicates that this field
  8911. // was not set, or was not defined in the schema.
  8912. func (m *BatchImageEventMutation) AddedField(name string) (ent.Value, bool) {
  8913. return nil, false
  8914. }
  8915. // AddField adds the value to the field with the given name. It returns an error if
  8916. // the field is not defined in the schema, or if the type mismatched the field
  8917. // type.
  8918. func (m *BatchImageEventMutation) AddField(name string, value ent.Value) error {
  8919. switch name {
  8920. }
  8921. return fmt.Errorf("unknown BatchImageEvent numeric field %s", name)
  8922. }
  8923. // ClearedFields returns all nullable fields that were cleared during this
  8924. // mutation.
  8925. func (m *BatchImageEventMutation) ClearedFields() []string {
  8926. var fields []string
  8927. if m.FieldCleared(batchimageevent.FieldPayload) {
  8928. fields = append(fields, batchimageevent.FieldPayload)
  8929. }
  8930. if m.FieldCleared(batchimageevent.FieldEventHash) {
  8931. fields = append(fields, batchimageevent.FieldEventHash)
  8932. }
  8933. return fields
  8934. }
  8935. // FieldCleared returns a boolean indicating if a field with the given name was
  8936. // cleared in this mutation.
  8937. func (m *BatchImageEventMutation) FieldCleared(name string) bool {
  8938. _, ok := m.clearedFields[name]
  8939. return ok
  8940. }
  8941. // ClearField clears the value of the field with the given name. It returns an
  8942. // error if the field is not defined in the schema.
  8943. func (m *BatchImageEventMutation) ClearField(name string) error {
  8944. switch name {
  8945. case batchimageevent.FieldPayload:
  8946. m.ClearPayload()
  8947. return nil
  8948. case batchimageevent.FieldEventHash:
  8949. m.ClearEventHash()
  8950. return nil
  8951. }
  8952. return fmt.Errorf("unknown BatchImageEvent nullable field %s", name)
  8953. }
  8954. // ResetField resets all changes in the mutation for the field with the given name.
  8955. // It returns an error if the field is not defined in the schema.
  8956. func (m *BatchImageEventMutation) ResetField(name string) error {
  8957. switch name {
  8958. case batchimageevent.FieldJobID:
  8959. m.ResetJobID()
  8960. return nil
  8961. case batchimageevent.FieldEventType:
  8962. m.ResetEventType()
  8963. return nil
  8964. case batchimageevent.FieldPayload:
  8965. m.ResetPayload()
  8966. return nil
  8967. case batchimageevent.FieldEventHash:
  8968. m.ResetEventHash()
  8969. return nil
  8970. case batchimageevent.FieldCreatedAt:
  8971. m.ResetCreatedAt()
  8972. return nil
  8973. }
  8974. return fmt.Errorf("unknown BatchImageEvent field %s", name)
  8975. }
  8976. // AddedEdges returns all edge names that were set/added in this mutation.
  8977. func (m *BatchImageEventMutation) AddedEdges() []string {
  8978. edges := make([]string, 0, 0)
  8979. return edges
  8980. }
  8981. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  8982. // name in this mutation.
  8983. func (m *BatchImageEventMutation) AddedIDs(name string) []ent.Value {
  8984. return nil
  8985. }
  8986. // RemovedEdges returns all edge names that were removed in this mutation.
  8987. func (m *BatchImageEventMutation) RemovedEdges() []string {
  8988. edges := make([]string, 0, 0)
  8989. return edges
  8990. }
  8991. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  8992. // the given name in this mutation.
  8993. func (m *BatchImageEventMutation) RemovedIDs(name string) []ent.Value {
  8994. return nil
  8995. }
  8996. // ClearedEdges returns all edge names that were cleared in this mutation.
  8997. func (m *BatchImageEventMutation) ClearedEdges() []string {
  8998. edges := make([]string, 0, 0)
  8999. return edges
  9000. }
  9001. // EdgeCleared returns a boolean which indicates if the edge with the given name
  9002. // was cleared in this mutation.
  9003. func (m *BatchImageEventMutation) EdgeCleared(name string) bool {
  9004. return false
  9005. }
  9006. // ClearEdge clears the value of the edge with the given name. It returns an error
  9007. // if that edge is not defined in the schema.
  9008. func (m *BatchImageEventMutation) ClearEdge(name string) error {
  9009. return fmt.Errorf("unknown BatchImageEvent unique edge %s", name)
  9010. }
  9011. // ResetEdge resets all changes to the edge with the given name in this mutation.
  9012. // It returns an error if the edge is not defined in the schema.
  9013. func (m *BatchImageEventMutation) ResetEdge(name string) error {
  9014. return fmt.Errorf("unknown BatchImageEvent edge %s", name)
  9015. }
  9016. // BatchImageItemMutation represents an operation that mutates the BatchImageItem nodes in the graph.
  9017. type BatchImageItemMutation struct {
  9018. config
  9019. op Op
  9020. typ string
  9021. id *int64
  9022. job_id *string
  9023. custom_id *string
  9024. status *string
  9025. request_hash *string
  9026. prompt_preview *string
  9027. provider_source_object *string
  9028. source_line_number *int
  9029. addsource_line_number *int
  9030. source_byte_offset *int64
  9031. addsource_byte_offset *int64
  9032. source_byte_length *int64
  9033. addsource_byte_length *int64
  9034. mime_type *string
  9035. file_extension *string
  9036. image_count *int
  9037. addimage_count *int
  9038. error_code *string
  9039. error_message *string
  9040. billed_amount *float64
  9041. addbilled_amount *float64
  9042. created_at *time.Time
  9043. indexed_at *time.Time
  9044. clearedFields map[string]struct{}
  9045. done bool
  9046. oldValue func(context.Context) (*BatchImageItem, error)
  9047. predicates []predicate.BatchImageItem
  9048. }
  9049. var _ ent.Mutation = (*BatchImageItemMutation)(nil)
  9050. // batchimageitemOption allows management of the mutation configuration using functional options.
  9051. type batchimageitemOption func(*BatchImageItemMutation)
  9052. // newBatchImageItemMutation creates new mutation for the BatchImageItem entity.
  9053. func newBatchImageItemMutation(c config, op Op, opts ...batchimageitemOption) *BatchImageItemMutation {
  9054. m := &BatchImageItemMutation{
  9055. config: c,
  9056. op: op,
  9057. typ: TypeBatchImageItem,
  9058. clearedFields: make(map[string]struct{}),
  9059. }
  9060. for _, opt := range opts {
  9061. opt(m)
  9062. }
  9063. return m
  9064. }
  9065. // withBatchImageItemID sets the ID field of the mutation.
  9066. func withBatchImageItemID(id int64) batchimageitemOption {
  9067. return func(m *BatchImageItemMutation) {
  9068. var (
  9069. err error
  9070. once sync.Once
  9071. value *BatchImageItem
  9072. )
  9073. m.oldValue = func(ctx context.Context) (*BatchImageItem, error) {
  9074. once.Do(func() {
  9075. if m.done {
  9076. err = errors.New("querying old values post mutation is not allowed")
  9077. } else {
  9078. value, err = m.Client().BatchImageItem.Get(ctx, id)
  9079. }
  9080. })
  9081. return value, err
  9082. }
  9083. m.id = &id
  9084. }
  9085. }
  9086. // withBatchImageItem sets the old BatchImageItem of the mutation.
  9087. func withBatchImageItem(node *BatchImageItem) batchimageitemOption {
  9088. return func(m *BatchImageItemMutation) {
  9089. m.oldValue = func(context.Context) (*BatchImageItem, error) {
  9090. return node, nil
  9091. }
  9092. m.id = &node.ID
  9093. }
  9094. }
  9095. // Client returns a new `ent.Client` from the mutation. If the mutation was
  9096. // executed in a transaction (ent.Tx), a transactional client is returned.
  9097. func (m BatchImageItemMutation) Client() *Client {
  9098. client := &Client{config: m.config}
  9099. client.init()
  9100. return client
  9101. }
  9102. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  9103. // it returns an error otherwise.
  9104. func (m BatchImageItemMutation) Tx() (*Tx, error) {
  9105. if _, ok := m.driver.(*txDriver); !ok {
  9106. return nil, errors.New("ent: mutation is not running in a transaction")
  9107. }
  9108. tx := &Tx{config: m.config}
  9109. tx.init()
  9110. return tx, nil
  9111. }
  9112. // ID returns the ID value in the mutation. Note that the ID is only available
  9113. // if it was provided to the builder or after it was returned from the database.
  9114. func (m *BatchImageItemMutation) ID() (id int64, exists bool) {
  9115. if m.id == nil {
  9116. return
  9117. }
  9118. return *m.id, true
  9119. }
  9120. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  9121. // That means, if the mutation is applied within a transaction with an isolation level such
  9122. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  9123. // or updated by the mutation.
  9124. func (m *BatchImageItemMutation) IDs(ctx context.Context) ([]int64, error) {
  9125. switch {
  9126. case m.op.Is(OpUpdateOne | OpDeleteOne):
  9127. id, exists := m.ID()
  9128. if exists {
  9129. return []int64{id}, nil
  9130. }
  9131. fallthrough
  9132. case m.op.Is(OpUpdate | OpDelete):
  9133. return m.Client().BatchImageItem.Query().Where(m.predicates...).IDs(ctx)
  9134. default:
  9135. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  9136. }
  9137. }
  9138. // SetJobID sets the "job_id" field.
  9139. func (m *BatchImageItemMutation) SetJobID(s string) {
  9140. m.job_id = &s
  9141. }
  9142. // JobID returns the value of the "job_id" field in the mutation.
  9143. func (m *BatchImageItemMutation) JobID() (r string, exists bool) {
  9144. v := m.job_id
  9145. if v == nil {
  9146. return
  9147. }
  9148. return *v, true
  9149. }
  9150. // OldJobID returns the old "job_id" field's value of the BatchImageItem entity.
  9151. // If the BatchImageItem object wasn't provided to the builder, the object is fetched from the database.
  9152. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9153. func (m *BatchImageItemMutation) OldJobID(ctx context.Context) (v string, err error) {
  9154. if !m.op.Is(OpUpdateOne) {
  9155. return v, errors.New("OldJobID is only allowed on UpdateOne operations")
  9156. }
  9157. if m.id == nil || m.oldValue == nil {
  9158. return v, errors.New("OldJobID requires an ID field in the mutation")
  9159. }
  9160. oldValue, err := m.oldValue(ctx)
  9161. if err != nil {
  9162. return v, fmt.Errorf("querying old value for OldJobID: %w", err)
  9163. }
  9164. return oldValue.JobID, nil
  9165. }
  9166. // ResetJobID resets all changes to the "job_id" field.
  9167. func (m *BatchImageItemMutation) ResetJobID() {
  9168. m.job_id = nil
  9169. }
  9170. // SetCustomID sets the "custom_id" field.
  9171. func (m *BatchImageItemMutation) SetCustomID(s string) {
  9172. m.custom_id = &s
  9173. }
  9174. // CustomID returns the value of the "custom_id" field in the mutation.
  9175. func (m *BatchImageItemMutation) CustomID() (r string, exists bool) {
  9176. v := m.custom_id
  9177. if v == nil {
  9178. return
  9179. }
  9180. return *v, true
  9181. }
  9182. // OldCustomID returns the old "custom_id" field's value of the BatchImageItem entity.
  9183. // If the BatchImageItem object wasn't provided to the builder, the object is fetched from the database.
  9184. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9185. func (m *BatchImageItemMutation) OldCustomID(ctx context.Context) (v string, err error) {
  9186. if !m.op.Is(OpUpdateOne) {
  9187. return v, errors.New("OldCustomID is only allowed on UpdateOne operations")
  9188. }
  9189. if m.id == nil || m.oldValue == nil {
  9190. return v, errors.New("OldCustomID requires an ID field in the mutation")
  9191. }
  9192. oldValue, err := m.oldValue(ctx)
  9193. if err != nil {
  9194. return v, fmt.Errorf("querying old value for OldCustomID: %w", err)
  9195. }
  9196. return oldValue.CustomID, nil
  9197. }
  9198. // ResetCustomID resets all changes to the "custom_id" field.
  9199. func (m *BatchImageItemMutation) ResetCustomID() {
  9200. m.custom_id = nil
  9201. }
  9202. // SetStatus sets the "status" field.
  9203. func (m *BatchImageItemMutation) SetStatus(s string) {
  9204. m.status = &s
  9205. }
  9206. // Status returns the value of the "status" field in the mutation.
  9207. func (m *BatchImageItemMutation) Status() (r string, exists bool) {
  9208. v := m.status
  9209. if v == nil {
  9210. return
  9211. }
  9212. return *v, true
  9213. }
  9214. // OldStatus returns the old "status" field's value of the BatchImageItem entity.
  9215. // If the BatchImageItem object wasn't provided to the builder, the object is fetched from the database.
  9216. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9217. func (m *BatchImageItemMutation) OldStatus(ctx context.Context) (v string, err error) {
  9218. if !m.op.Is(OpUpdateOne) {
  9219. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  9220. }
  9221. if m.id == nil || m.oldValue == nil {
  9222. return v, errors.New("OldStatus requires an ID field in the mutation")
  9223. }
  9224. oldValue, err := m.oldValue(ctx)
  9225. if err != nil {
  9226. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  9227. }
  9228. return oldValue.Status, nil
  9229. }
  9230. // ResetStatus resets all changes to the "status" field.
  9231. func (m *BatchImageItemMutation) ResetStatus() {
  9232. m.status = nil
  9233. }
  9234. // SetRequestHash sets the "request_hash" field.
  9235. func (m *BatchImageItemMutation) SetRequestHash(s string) {
  9236. m.request_hash = &s
  9237. }
  9238. // RequestHash returns the value of the "request_hash" field in the mutation.
  9239. func (m *BatchImageItemMutation) RequestHash() (r string, exists bool) {
  9240. v := m.request_hash
  9241. if v == nil {
  9242. return
  9243. }
  9244. return *v, true
  9245. }
  9246. // OldRequestHash returns the old "request_hash" field's value of the BatchImageItem entity.
  9247. // If the BatchImageItem object wasn't provided to the builder, the object is fetched from the database.
  9248. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9249. func (m *BatchImageItemMutation) OldRequestHash(ctx context.Context) (v *string, err error) {
  9250. if !m.op.Is(OpUpdateOne) {
  9251. return v, errors.New("OldRequestHash is only allowed on UpdateOne operations")
  9252. }
  9253. if m.id == nil || m.oldValue == nil {
  9254. return v, errors.New("OldRequestHash requires an ID field in the mutation")
  9255. }
  9256. oldValue, err := m.oldValue(ctx)
  9257. if err != nil {
  9258. return v, fmt.Errorf("querying old value for OldRequestHash: %w", err)
  9259. }
  9260. return oldValue.RequestHash, nil
  9261. }
  9262. // ClearRequestHash clears the value of the "request_hash" field.
  9263. func (m *BatchImageItemMutation) ClearRequestHash() {
  9264. m.request_hash = nil
  9265. m.clearedFields[batchimageitem.FieldRequestHash] = struct{}{}
  9266. }
  9267. // RequestHashCleared returns if the "request_hash" field was cleared in this mutation.
  9268. func (m *BatchImageItemMutation) RequestHashCleared() bool {
  9269. _, ok := m.clearedFields[batchimageitem.FieldRequestHash]
  9270. return ok
  9271. }
  9272. // ResetRequestHash resets all changes to the "request_hash" field.
  9273. func (m *BatchImageItemMutation) ResetRequestHash() {
  9274. m.request_hash = nil
  9275. delete(m.clearedFields, batchimageitem.FieldRequestHash)
  9276. }
  9277. // SetPromptPreview sets the "prompt_preview" field.
  9278. func (m *BatchImageItemMutation) SetPromptPreview(s string) {
  9279. m.prompt_preview = &s
  9280. }
  9281. // PromptPreview returns the value of the "prompt_preview" field in the mutation.
  9282. func (m *BatchImageItemMutation) PromptPreview() (r string, exists bool) {
  9283. v := m.prompt_preview
  9284. if v == nil {
  9285. return
  9286. }
  9287. return *v, true
  9288. }
  9289. // OldPromptPreview returns the old "prompt_preview" field's value of the BatchImageItem entity.
  9290. // If the BatchImageItem object wasn't provided to the builder, the object is fetched from the database.
  9291. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9292. func (m *BatchImageItemMutation) OldPromptPreview(ctx context.Context) (v *string, err error) {
  9293. if !m.op.Is(OpUpdateOne) {
  9294. return v, errors.New("OldPromptPreview is only allowed on UpdateOne operations")
  9295. }
  9296. if m.id == nil || m.oldValue == nil {
  9297. return v, errors.New("OldPromptPreview requires an ID field in the mutation")
  9298. }
  9299. oldValue, err := m.oldValue(ctx)
  9300. if err != nil {
  9301. return v, fmt.Errorf("querying old value for OldPromptPreview: %w", err)
  9302. }
  9303. return oldValue.PromptPreview, nil
  9304. }
  9305. // ClearPromptPreview clears the value of the "prompt_preview" field.
  9306. func (m *BatchImageItemMutation) ClearPromptPreview() {
  9307. m.prompt_preview = nil
  9308. m.clearedFields[batchimageitem.FieldPromptPreview] = struct{}{}
  9309. }
  9310. // PromptPreviewCleared returns if the "prompt_preview" field was cleared in this mutation.
  9311. func (m *BatchImageItemMutation) PromptPreviewCleared() bool {
  9312. _, ok := m.clearedFields[batchimageitem.FieldPromptPreview]
  9313. return ok
  9314. }
  9315. // ResetPromptPreview resets all changes to the "prompt_preview" field.
  9316. func (m *BatchImageItemMutation) ResetPromptPreview() {
  9317. m.prompt_preview = nil
  9318. delete(m.clearedFields, batchimageitem.FieldPromptPreview)
  9319. }
  9320. // SetProviderSourceObject sets the "provider_source_object" field.
  9321. func (m *BatchImageItemMutation) SetProviderSourceObject(s string) {
  9322. m.provider_source_object = &s
  9323. }
  9324. // ProviderSourceObject returns the value of the "provider_source_object" field in the mutation.
  9325. func (m *BatchImageItemMutation) ProviderSourceObject() (r string, exists bool) {
  9326. v := m.provider_source_object
  9327. if v == nil {
  9328. return
  9329. }
  9330. return *v, true
  9331. }
  9332. // OldProviderSourceObject returns the old "provider_source_object" field's value of the BatchImageItem entity.
  9333. // If the BatchImageItem object wasn't provided to the builder, the object is fetched from the database.
  9334. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9335. func (m *BatchImageItemMutation) OldProviderSourceObject(ctx context.Context) (v *string, err error) {
  9336. if !m.op.Is(OpUpdateOne) {
  9337. return v, errors.New("OldProviderSourceObject is only allowed on UpdateOne operations")
  9338. }
  9339. if m.id == nil || m.oldValue == nil {
  9340. return v, errors.New("OldProviderSourceObject requires an ID field in the mutation")
  9341. }
  9342. oldValue, err := m.oldValue(ctx)
  9343. if err != nil {
  9344. return v, fmt.Errorf("querying old value for OldProviderSourceObject: %w", err)
  9345. }
  9346. return oldValue.ProviderSourceObject, nil
  9347. }
  9348. // ClearProviderSourceObject clears the value of the "provider_source_object" field.
  9349. func (m *BatchImageItemMutation) ClearProviderSourceObject() {
  9350. m.provider_source_object = nil
  9351. m.clearedFields[batchimageitem.FieldProviderSourceObject] = struct{}{}
  9352. }
  9353. // ProviderSourceObjectCleared returns if the "provider_source_object" field was cleared in this mutation.
  9354. func (m *BatchImageItemMutation) ProviderSourceObjectCleared() bool {
  9355. _, ok := m.clearedFields[batchimageitem.FieldProviderSourceObject]
  9356. return ok
  9357. }
  9358. // ResetProviderSourceObject resets all changes to the "provider_source_object" field.
  9359. func (m *BatchImageItemMutation) ResetProviderSourceObject() {
  9360. m.provider_source_object = nil
  9361. delete(m.clearedFields, batchimageitem.FieldProviderSourceObject)
  9362. }
  9363. // SetSourceLineNumber sets the "source_line_number" field.
  9364. func (m *BatchImageItemMutation) SetSourceLineNumber(i int) {
  9365. m.source_line_number = &i
  9366. m.addsource_line_number = nil
  9367. }
  9368. // SourceLineNumber returns the value of the "source_line_number" field in the mutation.
  9369. func (m *BatchImageItemMutation) SourceLineNumber() (r int, exists bool) {
  9370. v := m.source_line_number
  9371. if v == nil {
  9372. return
  9373. }
  9374. return *v, true
  9375. }
  9376. // OldSourceLineNumber returns the old "source_line_number" field's value of the BatchImageItem entity.
  9377. // If the BatchImageItem object wasn't provided to the builder, the object is fetched from the database.
  9378. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9379. func (m *BatchImageItemMutation) OldSourceLineNumber(ctx context.Context) (v *int, err error) {
  9380. if !m.op.Is(OpUpdateOne) {
  9381. return v, errors.New("OldSourceLineNumber is only allowed on UpdateOne operations")
  9382. }
  9383. if m.id == nil || m.oldValue == nil {
  9384. return v, errors.New("OldSourceLineNumber requires an ID field in the mutation")
  9385. }
  9386. oldValue, err := m.oldValue(ctx)
  9387. if err != nil {
  9388. return v, fmt.Errorf("querying old value for OldSourceLineNumber: %w", err)
  9389. }
  9390. return oldValue.SourceLineNumber, nil
  9391. }
  9392. // AddSourceLineNumber adds i to the "source_line_number" field.
  9393. func (m *BatchImageItemMutation) AddSourceLineNumber(i int) {
  9394. if m.addsource_line_number != nil {
  9395. *m.addsource_line_number += i
  9396. } else {
  9397. m.addsource_line_number = &i
  9398. }
  9399. }
  9400. // AddedSourceLineNumber returns the value that was added to the "source_line_number" field in this mutation.
  9401. func (m *BatchImageItemMutation) AddedSourceLineNumber() (r int, exists bool) {
  9402. v := m.addsource_line_number
  9403. if v == nil {
  9404. return
  9405. }
  9406. return *v, true
  9407. }
  9408. // ClearSourceLineNumber clears the value of the "source_line_number" field.
  9409. func (m *BatchImageItemMutation) ClearSourceLineNumber() {
  9410. m.source_line_number = nil
  9411. m.addsource_line_number = nil
  9412. m.clearedFields[batchimageitem.FieldSourceLineNumber] = struct{}{}
  9413. }
  9414. // SourceLineNumberCleared returns if the "source_line_number" field was cleared in this mutation.
  9415. func (m *BatchImageItemMutation) SourceLineNumberCleared() bool {
  9416. _, ok := m.clearedFields[batchimageitem.FieldSourceLineNumber]
  9417. return ok
  9418. }
  9419. // ResetSourceLineNumber resets all changes to the "source_line_number" field.
  9420. func (m *BatchImageItemMutation) ResetSourceLineNumber() {
  9421. m.source_line_number = nil
  9422. m.addsource_line_number = nil
  9423. delete(m.clearedFields, batchimageitem.FieldSourceLineNumber)
  9424. }
  9425. // SetSourceByteOffset sets the "source_byte_offset" field.
  9426. func (m *BatchImageItemMutation) SetSourceByteOffset(i int64) {
  9427. m.source_byte_offset = &i
  9428. m.addsource_byte_offset = nil
  9429. }
  9430. // SourceByteOffset returns the value of the "source_byte_offset" field in the mutation.
  9431. func (m *BatchImageItemMutation) SourceByteOffset() (r int64, exists bool) {
  9432. v := m.source_byte_offset
  9433. if v == nil {
  9434. return
  9435. }
  9436. return *v, true
  9437. }
  9438. // OldSourceByteOffset returns the old "source_byte_offset" field's value of the BatchImageItem entity.
  9439. // If the BatchImageItem object wasn't provided to the builder, the object is fetched from the database.
  9440. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9441. func (m *BatchImageItemMutation) OldSourceByteOffset(ctx context.Context) (v *int64, err error) {
  9442. if !m.op.Is(OpUpdateOne) {
  9443. return v, errors.New("OldSourceByteOffset is only allowed on UpdateOne operations")
  9444. }
  9445. if m.id == nil || m.oldValue == nil {
  9446. return v, errors.New("OldSourceByteOffset requires an ID field in the mutation")
  9447. }
  9448. oldValue, err := m.oldValue(ctx)
  9449. if err != nil {
  9450. return v, fmt.Errorf("querying old value for OldSourceByteOffset: %w", err)
  9451. }
  9452. return oldValue.SourceByteOffset, nil
  9453. }
  9454. // AddSourceByteOffset adds i to the "source_byte_offset" field.
  9455. func (m *BatchImageItemMutation) AddSourceByteOffset(i int64) {
  9456. if m.addsource_byte_offset != nil {
  9457. *m.addsource_byte_offset += i
  9458. } else {
  9459. m.addsource_byte_offset = &i
  9460. }
  9461. }
  9462. // AddedSourceByteOffset returns the value that was added to the "source_byte_offset" field in this mutation.
  9463. func (m *BatchImageItemMutation) AddedSourceByteOffset() (r int64, exists bool) {
  9464. v := m.addsource_byte_offset
  9465. if v == nil {
  9466. return
  9467. }
  9468. return *v, true
  9469. }
  9470. // ClearSourceByteOffset clears the value of the "source_byte_offset" field.
  9471. func (m *BatchImageItemMutation) ClearSourceByteOffset() {
  9472. m.source_byte_offset = nil
  9473. m.addsource_byte_offset = nil
  9474. m.clearedFields[batchimageitem.FieldSourceByteOffset] = struct{}{}
  9475. }
  9476. // SourceByteOffsetCleared returns if the "source_byte_offset" field was cleared in this mutation.
  9477. func (m *BatchImageItemMutation) SourceByteOffsetCleared() bool {
  9478. _, ok := m.clearedFields[batchimageitem.FieldSourceByteOffset]
  9479. return ok
  9480. }
  9481. // ResetSourceByteOffset resets all changes to the "source_byte_offset" field.
  9482. func (m *BatchImageItemMutation) ResetSourceByteOffset() {
  9483. m.source_byte_offset = nil
  9484. m.addsource_byte_offset = nil
  9485. delete(m.clearedFields, batchimageitem.FieldSourceByteOffset)
  9486. }
  9487. // SetSourceByteLength sets the "source_byte_length" field.
  9488. func (m *BatchImageItemMutation) SetSourceByteLength(i int64) {
  9489. m.source_byte_length = &i
  9490. m.addsource_byte_length = nil
  9491. }
  9492. // SourceByteLength returns the value of the "source_byte_length" field in the mutation.
  9493. func (m *BatchImageItemMutation) SourceByteLength() (r int64, exists bool) {
  9494. v := m.source_byte_length
  9495. if v == nil {
  9496. return
  9497. }
  9498. return *v, true
  9499. }
  9500. // OldSourceByteLength returns the old "source_byte_length" field's value of the BatchImageItem entity.
  9501. // If the BatchImageItem object wasn't provided to the builder, the object is fetched from the database.
  9502. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9503. func (m *BatchImageItemMutation) OldSourceByteLength(ctx context.Context) (v *int64, err error) {
  9504. if !m.op.Is(OpUpdateOne) {
  9505. return v, errors.New("OldSourceByteLength is only allowed on UpdateOne operations")
  9506. }
  9507. if m.id == nil || m.oldValue == nil {
  9508. return v, errors.New("OldSourceByteLength requires an ID field in the mutation")
  9509. }
  9510. oldValue, err := m.oldValue(ctx)
  9511. if err != nil {
  9512. return v, fmt.Errorf("querying old value for OldSourceByteLength: %w", err)
  9513. }
  9514. return oldValue.SourceByteLength, nil
  9515. }
  9516. // AddSourceByteLength adds i to the "source_byte_length" field.
  9517. func (m *BatchImageItemMutation) AddSourceByteLength(i int64) {
  9518. if m.addsource_byte_length != nil {
  9519. *m.addsource_byte_length += i
  9520. } else {
  9521. m.addsource_byte_length = &i
  9522. }
  9523. }
  9524. // AddedSourceByteLength returns the value that was added to the "source_byte_length" field in this mutation.
  9525. func (m *BatchImageItemMutation) AddedSourceByteLength() (r int64, exists bool) {
  9526. v := m.addsource_byte_length
  9527. if v == nil {
  9528. return
  9529. }
  9530. return *v, true
  9531. }
  9532. // ClearSourceByteLength clears the value of the "source_byte_length" field.
  9533. func (m *BatchImageItemMutation) ClearSourceByteLength() {
  9534. m.source_byte_length = nil
  9535. m.addsource_byte_length = nil
  9536. m.clearedFields[batchimageitem.FieldSourceByteLength] = struct{}{}
  9537. }
  9538. // SourceByteLengthCleared returns if the "source_byte_length" field was cleared in this mutation.
  9539. func (m *BatchImageItemMutation) SourceByteLengthCleared() bool {
  9540. _, ok := m.clearedFields[batchimageitem.FieldSourceByteLength]
  9541. return ok
  9542. }
  9543. // ResetSourceByteLength resets all changes to the "source_byte_length" field.
  9544. func (m *BatchImageItemMutation) ResetSourceByteLength() {
  9545. m.source_byte_length = nil
  9546. m.addsource_byte_length = nil
  9547. delete(m.clearedFields, batchimageitem.FieldSourceByteLength)
  9548. }
  9549. // SetMimeType sets the "mime_type" field.
  9550. func (m *BatchImageItemMutation) SetMimeType(s string) {
  9551. m.mime_type = &s
  9552. }
  9553. // MimeType returns the value of the "mime_type" field in the mutation.
  9554. func (m *BatchImageItemMutation) MimeType() (r string, exists bool) {
  9555. v := m.mime_type
  9556. if v == nil {
  9557. return
  9558. }
  9559. return *v, true
  9560. }
  9561. // OldMimeType returns the old "mime_type" field's value of the BatchImageItem entity.
  9562. // If the BatchImageItem object wasn't provided to the builder, the object is fetched from the database.
  9563. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9564. func (m *BatchImageItemMutation) OldMimeType(ctx context.Context) (v *string, err error) {
  9565. if !m.op.Is(OpUpdateOne) {
  9566. return v, errors.New("OldMimeType is only allowed on UpdateOne operations")
  9567. }
  9568. if m.id == nil || m.oldValue == nil {
  9569. return v, errors.New("OldMimeType requires an ID field in the mutation")
  9570. }
  9571. oldValue, err := m.oldValue(ctx)
  9572. if err != nil {
  9573. return v, fmt.Errorf("querying old value for OldMimeType: %w", err)
  9574. }
  9575. return oldValue.MimeType, nil
  9576. }
  9577. // ClearMimeType clears the value of the "mime_type" field.
  9578. func (m *BatchImageItemMutation) ClearMimeType() {
  9579. m.mime_type = nil
  9580. m.clearedFields[batchimageitem.FieldMimeType] = struct{}{}
  9581. }
  9582. // MimeTypeCleared returns if the "mime_type" field was cleared in this mutation.
  9583. func (m *BatchImageItemMutation) MimeTypeCleared() bool {
  9584. _, ok := m.clearedFields[batchimageitem.FieldMimeType]
  9585. return ok
  9586. }
  9587. // ResetMimeType resets all changes to the "mime_type" field.
  9588. func (m *BatchImageItemMutation) ResetMimeType() {
  9589. m.mime_type = nil
  9590. delete(m.clearedFields, batchimageitem.FieldMimeType)
  9591. }
  9592. // SetFileExtension sets the "file_extension" field.
  9593. func (m *BatchImageItemMutation) SetFileExtension(s string) {
  9594. m.file_extension = &s
  9595. }
  9596. // FileExtension returns the value of the "file_extension" field in the mutation.
  9597. func (m *BatchImageItemMutation) FileExtension() (r string, exists bool) {
  9598. v := m.file_extension
  9599. if v == nil {
  9600. return
  9601. }
  9602. return *v, true
  9603. }
  9604. // OldFileExtension returns the old "file_extension" field's value of the BatchImageItem entity.
  9605. // If the BatchImageItem object wasn't provided to the builder, the object is fetched from the database.
  9606. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9607. func (m *BatchImageItemMutation) OldFileExtension(ctx context.Context) (v *string, err error) {
  9608. if !m.op.Is(OpUpdateOne) {
  9609. return v, errors.New("OldFileExtension is only allowed on UpdateOne operations")
  9610. }
  9611. if m.id == nil || m.oldValue == nil {
  9612. return v, errors.New("OldFileExtension requires an ID field in the mutation")
  9613. }
  9614. oldValue, err := m.oldValue(ctx)
  9615. if err != nil {
  9616. return v, fmt.Errorf("querying old value for OldFileExtension: %w", err)
  9617. }
  9618. return oldValue.FileExtension, nil
  9619. }
  9620. // ClearFileExtension clears the value of the "file_extension" field.
  9621. func (m *BatchImageItemMutation) ClearFileExtension() {
  9622. m.file_extension = nil
  9623. m.clearedFields[batchimageitem.FieldFileExtension] = struct{}{}
  9624. }
  9625. // FileExtensionCleared returns if the "file_extension" field was cleared in this mutation.
  9626. func (m *BatchImageItemMutation) FileExtensionCleared() bool {
  9627. _, ok := m.clearedFields[batchimageitem.FieldFileExtension]
  9628. return ok
  9629. }
  9630. // ResetFileExtension resets all changes to the "file_extension" field.
  9631. func (m *BatchImageItemMutation) ResetFileExtension() {
  9632. m.file_extension = nil
  9633. delete(m.clearedFields, batchimageitem.FieldFileExtension)
  9634. }
  9635. // SetImageCount sets the "image_count" field.
  9636. func (m *BatchImageItemMutation) SetImageCount(i int) {
  9637. m.image_count = &i
  9638. m.addimage_count = nil
  9639. }
  9640. // ImageCount returns the value of the "image_count" field in the mutation.
  9641. func (m *BatchImageItemMutation) ImageCount() (r int, exists bool) {
  9642. v := m.image_count
  9643. if v == nil {
  9644. return
  9645. }
  9646. return *v, true
  9647. }
  9648. // OldImageCount returns the old "image_count" field's value of the BatchImageItem entity.
  9649. // If the BatchImageItem object wasn't provided to the builder, the object is fetched from the database.
  9650. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9651. func (m *BatchImageItemMutation) OldImageCount(ctx context.Context) (v int, err error) {
  9652. if !m.op.Is(OpUpdateOne) {
  9653. return v, errors.New("OldImageCount is only allowed on UpdateOne operations")
  9654. }
  9655. if m.id == nil || m.oldValue == nil {
  9656. return v, errors.New("OldImageCount requires an ID field in the mutation")
  9657. }
  9658. oldValue, err := m.oldValue(ctx)
  9659. if err != nil {
  9660. return v, fmt.Errorf("querying old value for OldImageCount: %w", err)
  9661. }
  9662. return oldValue.ImageCount, nil
  9663. }
  9664. // AddImageCount adds i to the "image_count" field.
  9665. func (m *BatchImageItemMutation) AddImageCount(i int) {
  9666. if m.addimage_count != nil {
  9667. *m.addimage_count += i
  9668. } else {
  9669. m.addimage_count = &i
  9670. }
  9671. }
  9672. // AddedImageCount returns the value that was added to the "image_count" field in this mutation.
  9673. func (m *BatchImageItemMutation) AddedImageCount() (r int, exists bool) {
  9674. v := m.addimage_count
  9675. if v == nil {
  9676. return
  9677. }
  9678. return *v, true
  9679. }
  9680. // ResetImageCount resets all changes to the "image_count" field.
  9681. func (m *BatchImageItemMutation) ResetImageCount() {
  9682. m.image_count = nil
  9683. m.addimage_count = nil
  9684. }
  9685. // SetErrorCode sets the "error_code" field.
  9686. func (m *BatchImageItemMutation) SetErrorCode(s string) {
  9687. m.error_code = &s
  9688. }
  9689. // ErrorCode returns the value of the "error_code" field in the mutation.
  9690. func (m *BatchImageItemMutation) ErrorCode() (r string, exists bool) {
  9691. v := m.error_code
  9692. if v == nil {
  9693. return
  9694. }
  9695. return *v, true
  9696. }
  9697. // OldErrorCode returns the old "error_code" field's value of the BatchImageItem entity.
  9698. // If the BatchImageItem object wasn't provided to the builder, the object is fetched from the database.
  9699. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9700. func (m *BatchImageItemMutation) OldErrorCode(ctx context.Context) (v *string, err error) {
  9701. if !m.op.Is(OpUpdateOne) {
  9702. return v, errors.New("OldErrorCode is only allowed on UpdateOne operations")
  9703. }
  9704. if m.id == nil || m.oldValue == nil {
  9705. return v, errors.New("OldErrorCode requires an ID field in the mutation")
  9706. }
  9707. oldValue, err := m.oldValue(ctx)
  9708. if err != nil {
  9709. return v, fmt.Errorf("querying old value for OldErrorCode: %w", err)
  9710. }
  9711. return oldValue.ErrorCode, nil
  9712. }
  9713. // ClearErrorCode clears the value of the "error_code" field.
  9714. func (m *BatchImageItemMutation) ClearErrorCode() {
  9715. m.error_code = nil
  9716. m.clearedFields[batchimageitem.FieldErrorCode] = struct{}{}
  9717. }
  9718. // ErrorCodeCleared returns if the "error_code" field was cleared in this mutation.
  9719. func (m *BatchImageItemMutation) ErrorCodeCleared() bool {
  9720. _, ok := m.clearedFields[batchimageitem.FieldErrorCode]
  9721. return ok
  9722. }
  9723. // ResetErrorCode resets all changes to the "error_code" field.
  9724. func (m *BatchImageItemMutation) ResetErrorCode() {
  9725. m.error_code = nil
  9726. delete(m.clearedFields, batchimageitem.FieldErrorCode)
  9727. }
  9728. // SetErrorMessage sets the "error_message" field.
  9729. func (m *BatchImageItemMutation) SetErrorMessage(s string) {
  9730. m.error_message = &s
  9731. }
  9732. // ErrorMessage returns the value of the "error_message" field in the mutation.
  9733. func (m *BatchImageItemMutation) ErrorMessage() (r string, exists bool) {
  9734. v := m.error_message
  9735. if v == nil {
  9736. return
  9737. }
  9738. return *v, true
  9739. }
  9740. // OldErrorMessage returns the old "error_message" field's value of the BatchImageItem entity.
  9741. // If the BatchImageItem object wasn't provided to the builder, the object is fetched from the database.
  9742. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9743. func (m *BatchImageItemMutation) OldErrorMessage(ctx context.Context) (v *string, err error) {
  9744. if !m.op.Is(OpUpdateOne) {
  9745. return v, errors.New("OldErrorMessage is only allowed on UpdateOne operations")
  9746. }
  9747. if m.id == nil || m.oldValue == nil {
  9748. return v, errors.New("OldErrorMessage requires an ID field in the mutation")
  9749. }
  9750. oldValue, err := m.oldValue(ctx)
  9751. if err != nil {
  9752. return v, fmt.Errorf("querying old value for OldErrorMessage: %w", err)
  9753. }
  9754. return oldValue.ErrorMessage, nil
  9755. }
  9756. // ClearErrorMessage clears the value of the "error_message" field.
  9757. func (m *BatchImageItemMutation) ClearErrorMessage() {
  9758. m.error_message = nil
  9759. m.clearedFields[batchimageitem.FieldErrorMessage] = struct{}{}
  9760. }
  9761. // ErrorMessageCleared returns if the "error_message" field was cleared in this mutation.
  9762. func (m *BatchImageItemMutation) ErrorMessageCleared() bool {
  9763. _, ok := m.clearedFields[batchimageitem.FieldErrorMessage]
  9764. return ok
  9765. }
  9766. // ResetErrorMessage resets all changes to the "error_message" field.
  9767. func (m *BatchImageItemMutation) ResetErrorMessage() {
  9768. m.error_message = nil
  9769. delete(m.clearedFields, batchimageitem.FieldErrorMessage)
  9770. }
  9771. // SetBilledAmount sets the "billed_amount" field.
  9772. func (m *BatchImageItemMutation) SetBilledAmount(f float64) {
  9773. m.billed_amount = &f
  9774. m.addbilled_amount = nil
  9775. }
  9776. // BilledAmount returns the value of the "billed_amount" field in the mutation.
  9777. func (m *BatchImageItemMutation) BilledAmount() (r float64, exists bool) {
  9778. v := m.billed_amount
  9779. if v == nil {
  9780. return
  9781. }
  9782. return *v, true
  9783. }
  9784. // OldBilledAmount returns the old "billed_amount" field's value of the BatchImageItem entity.
  9785. // If the BatchImageItem object wasn't provided to the builder, the object is fetched from the database.
  9786. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9787. func (m *BatchImageItemMutation) OldBilledAmount(ctx context.Context) (v *float64, err error) {
  9788. if !m.op.Is(OpUpdateOne) {
  9789. return v, errors.New("OldBilledAmount is only allowed on UpdateOne operations")
  9790. }
  9791. if m.id == nil || m.oldValue == nil {
  9792. return v, errors.New("OldBilledAmount requires an ID field in the mutation")
  9793. }
  9794. oldValue, err := m.oldValue(ctx)
  9795. if err != nil {
  9796. return v, fmt.Errorf("querying old value for OldBilledAmount: %w", err)
  9797. }
  9798. return oldValue.BilledAmount, nil
  9799. }
  9800. // AddBilledAmount adds f to the "billed_amount" field.
  9801. func (m *BatchImageItemMutation) AddBilledAmount(f float64) {
  9802. if m.addbilled_amount != nil {
  9803. *m.addbilled_amount += f
  9804. } else {
  9805. m.addbilled_amount = &f
  9806. }
  9807. }
  9808. // AddedBilledAmount returns the value that was added to the "billed_amount" field in this mutation.
  9809. func (m *BatchImageItemMutation) AddedBilledAmount() (r float64, exists bool) {
  9810. v := m.addbilled_amount
  9811. if v == nil {
  9812. return
  9813. }
  9814. return *v, true
  9815. }
  9816. // ClearBilledAmount clears the value of the "billed_amount" field.
  9817. func (m *BatchImageItemMutation) ClearBilledAmount() {
  9818. m.billed_amount = nil
  9819. m.addbilled_amount = nil
  9820. m.clearedFields[batchimageitem.FieldBilledAmount] = struct{}{}
  9821. }
  9822. // BilledAmountCleared returns if the "billed_amount" field was cleared in this mutation.
  9823. func (m *BatchImageItemMutation) BilledAmountCleared() bool {
  9824. _, ok := m.clearedFields[batchimageitem.FieldBilledAmount]
  9825. return ok
  9826. }
  9827. // ResetBilledAmount resets all changes to the "billed_amount" field.
  9828. func (m *BatchImageItemMutation) ResetBilledAmount() {
  9829. m.billed_amount = nil
  9830. m.addbilled_amount = nil
  9831. delete(m.clearedFields, batchimageitem.FieldBilledAmount)
  9832. }
  9833. // SetCreatedAt sets the "created_at" field.
  9834. func (m *BatchImageItemMutation) SetCreatedAt(t time.Time) {
  9835. m.created_at = &t
  9836. }
  9837. // CreatedAt returns the value of the "created_at" field in the mutation.
  9838. func (m *BatchImageItemMutation) CreatedAt() (r time.Time, exists bool) {
  9839. v := m.created_at
  9840. if v == nil {
  9841. return
  9842. }
  9843. return *v, true
  9844. }
  9845. // OldCreatedAt returns the old "created_at" field's value of the BatchImageItem entity.
  9846. // If the BatchImageItem object wasn't provided to the builder, the object is fetched from the database.
  9847. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9848. func (m *BatchImageItemMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  9849. if !m.op.Is(OpUpdateOne) {
  9850. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  9851. }
  9852. if m.id == nil || m.oldValue == nil {
  9853. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  9854. }
  9855. oldValue, err := m.oldValue(ctx)
  9856. if err != nil {
  9857. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  9858. }
  9859. return oldValue.CreatedAt, nil
  9860. }
  9861. // ResetCreatedAt resets all changes to the "created_at" field.
  9862. func (m *BatchImageItemMutation) ResetCreatedAt() {
  9863. m.created_at = nil
  9864. }
  9865. // SetIndexedAt sets the "indexed_at" field.
  9866. func (m *BatchImageItemMutation) SetIndexedAt(t time.Time) {
  9867. m.indexed_at = &t
  9868. }
  9869. // IndexedAt returns the value of the "indexed_at" field in the mutation.
  9870. func (m *BatchImageItemMutation) IndexedAt() (r time.Time, exists bool) {
  9871. v := m.indexed_at
  9872. if v == nil {
  9873. return
  9874. }
  9875. return *v, true
  9876. }
  9877. // OldIndexedAt returns the old "indexed_at" field's value of the BatchImageItem entity.
  9878. // If the BatchImageItem object wasn't provided to the builder, the object is fetched from the database.
  9879. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9880. func (m *BatchImageItemMutation) OldIndexedAt(ctx context.Context) (v *time.Time, err error) {
  9881. if !m.op.Is(OpUpdateOne) {
  9882. return v, errors.New("OldIndexedAt is only allowed on UpdateOne operations")
  9883. }
  9884. if m.id == nil || m.oldValue == nil {
  9885. return v, errors.New("OldIndexedAt requires an ID field in the mutation")
  9886. }
  9887. oldValue, err := m.oldValue(ctx)
  9888. if err != nil {
  9889. return v, fmt.Errorf("querying old value for OldIndexedAt: %w", err)
  9890. }
  9891. return oldValue.IndexedAt, nil
  9892. }
  9893. // ClearIndexedAt clears the value of the "indexed_at" field.
  9894. func (m *BatchImageItemMutation) ClearIndexedAt() {
  9895. m.indexed_at = nil
  9896. m.clearedFields[batchimageitem.FieldIndexedAt] = struct{}{}
  9897. }
  9898. // IndexedAtCleared returns if the "indexed_at" field was cleared in this mutation.
  9899. func (m *BatchImageItemMutation) IndexedAtCleared() bool {
  9900. _, ok := m.clearedFields[batchimageitem.FieldIndexedAt]
  9901. return ok
  9902. }
  9903. // ResetIndexedAt resets all changes to the "indexed_at" field.
  9904. func (m *BatchImageItemMutation) ResetIndexedAt() {
  9905. m.indexed_at = nil
  9906. delete(m.clearedFields, batchimageitem.FieldIndexedAt)
  9907. }
  9908. // Where appends a list predicates to the BatchImageItemMutation builder.
  9909. func (m *BatchImageItemMutation) Where(ps ...predicate.BatchImageItem) {
  9910. m.predicates = append(m.predicates, ps...)
  9911. }
  9912. // WhereP appends storage-level predicates to the BatchImageItemMutation builder. Using this method,
  9913. // users can use type-assertion to append predicates that do not depend on any generated package.
  9914. func (m *BatchImageItemMutation) WhereP(ps ...func(*sql.Selector)) {
  9915. p := make([]predicate.BatchImageItem, len(ps))
  9916. for i := range ps {
  9917. p[i] = ps[i]
  9918. }
  9919. m.Where(p...)
  9920. }
  9921. // Op returns the operation name.
  9922. func (m *BatchImageItemMutation) Op() Op {
  9923. return m.op
  9924. }
  9925. // SetOp allows setting the mutation operation.
  9926. func (m *BatchImageItemMutation) SetOp(op Op) {
  9927. m.op = op
  9928. }
  9929. // Type returns the node type of this mutation (BatchImageItem).
  9930. func (m *BatchImageItemMutation) Type() string {
  9931. return m.typ
  9932. }
  9933. // Fields returns all fields that were changed during this mutation. Note that in
  9934. // order to get all numeric fields that were incremented/decremented, call
  9935. // AddedFields().
  9936. func (m *BatchImageItemMutation) Fields() []string {
  9937. fields := make([]string, 0, 17)
  9938. if m.job_id != nil {
  9939. fields = append(fields, batchimageitem.FieldJobID)
  9940. }
  9941. if m.custom_id != nil {
  9942. fields = append(fields, batchimageitem.FieldCustomID)
  9943. }
  9944. if m.status != nil {
  9945. fields = append(fields, batchimageitem.FieldStatus)
  9946. }
  9947. if m.request_hash != nil {
  9948. fields = append(fields, batchimageitem.FieldRequestHash)
  9949. }
  9950. if m.prompt_preview != nil {
  9951. fields = append(fields, batchimageitem.FieldPromptPreview)
  9952. }
  9953. if m.provider_source_object != nil {
  9954. fields = append(fields, batchimageitem.FieldProviderSourceObject)
  9955. }
  9956. if m.source_line_number != nil {
  9957. fields = append(fields, batchimageitem.FieldSourceLineNumber)
  9958. }
  9959. if m.source_byte_offset != nil {
  9960. fields = append(fields, batchimageitem.FieldSourceByteOffset)
  9961. }
  9962. if m.source_byte_length != nil {
  9963. fields = append(fields, batchimageitem.FieldSourceByteLength)
  9964. }
  9965. if m.mime_type != nil {
  9966. fields = append(fields, batchimageitem.FieldMimeType)
  9967. }
  9968. if m.file_extension != nil {
  9969. fields = append(fields, batchimageitem.FieldFileExtension)
  9970. }
  9971. if m.image_count != nil {
  9972. fields = append(fields, batchimageitem.FieldImageCount)
  9973. }
  9974. if m.error_code != nil {
  9975. fields = append(fields, batchimageitem.FieldErrorCode)
  9976. }
  9977. if m.error_message != nil {
  9978. fields = append(fields, batchimageitem.FieldErrorMessage)
  9979. }
  9980. if m.billed_amount != nil {
  9981. fields = append(fields, batchimageitem.FieldBilledAmount)
  9982. }
  9983. if m.created_at != nil {
  9984. fields = append(fields, batchimageitem.FieldCreatedAt)
  9985. }
  9986. if m.indexed_at != nil {
  9987. fields = append(fields, batchimageitem.FieldIndexedAt)
  9988. }
  9989. return fields
  9990. }
  9991. // Field returns the value of a field with the given name. The second boolean
  9992. // return value indicates that this field was not set, or was not defined in the
  9993. // schema.
  9994. func (m *BatchImageItemMutation) Field(name string) (ent.Value, bool) {
  9995. switch name {
  9996. case batchimageitem.FieldJobID:
  9997. return m.JobID()
  9998. case batchimageitem.FieldCustomID:
  9999. return m.CustomID()
  10000. case batchimageitem.FieldStatus:
  10001. return m.Status()
  10002. case batchimageitem.FieldRequestHash:
  10003. return m.RequestHash()
  10004. case batchimageitem.FieldPromptPreview:
  10005. return m.PromptPreview()
  10006. case batchimageitem.FieldProviderSourceObject:
  10007. return m.ProviderSourceObject()
  10008. case batchimageitem.FieldSourceLineNumber:
  10009. return m.SourceLineNumber()
  10010. case batchimageitem.FieldSourceByteOffset:
  10011. return m.SourceByteOffset()
  10012. case batchimageitem.FieldSourceByteLength:
  10013. return m.SourceByteLength()
  10014. case batchimageitem.FieldMimeType:
  10015. return m.MimeType()
  10016. case batchimageitem.FieldFileExtension:
  10017. return m.FileExtension()
  10018. case batchimageitem.FieldImageCount:
  10019. return m.ImageCount()
  10020. case batchimageitem.FieldErrorCode:
  10021. return m.ErrorCode()
  10022. case batchimageitem.FieldErrorMessage:
  10023. return m.ErrorMessage()
  10024. case batchimageitem.FieldBilledAmount:
  10025. return m.BilledAmount()
  10026. case batchimageitem.FieldCreatedAt:
  10027. return m.CreatedAt()
  10028. case batchimageitem.FieldIndexedAt:
  10029. return m.IndexedAt()
  10030. }
  10031. return nil, false
  10032. }
  10033. // OldField returns the old value of the field from the database. An error is
  10034. // returned if the mutation operation is not UpdateOne, or the query to the
  10035. // database failed.
  10036. func (m *BatchImageItemMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  10037. switch name {
  10038. case batchimageitem.FieldJobID:
  10039. return m.OldJobID(ctx)
  10040. case batchimageitem.FieldCustomID:
  10041. return m.OldCustomID(ctx)
  10042. case batchimageitem.FieldStatus:
  10043. return m.OldStatus(ctx)
  10044. case batchimageitem.FieldRequestHash:
  10045. return m.OldRequestHash(ctx)
  10046. case batchimageitem.FieldPromptPreview:
  10047. return m.OldPromptPreview(ctx)
  10048. case batchimageitem.FieldProviderSourceObject:
  10049. return m.OldProviderSourceObject(ctx)
  10050. case batchimageitem.FieldSourceLineNumber:
  10051. return m.OldSourceLineNumber(ctx)
  10052. case batchimageitem.FieldSourceByteOffset:
  10053. return m.OldSourceByteOffset(ctx)
  10054. case batchimageitem.FieldSourceByteLength:
  10055. return m.OldSourceByteLength(ctx)
  10056. case batchimageitem.FieldMimeType:
  10057. return m.OldMimeType(ctx)
  10058. case batchimageitem.FieldFileExtension:
  10059. return m.OldFileExtension(ctx)
  10060. case batchimageitem.FieldImageCount:
  10061. return m.OldImageCount(ctx)
  10062. case batchimageitem.FieldErrorCode:
  10063. return m.OldErrorCode(ctx)
  10064. case batchimageitem.FieldErrorMessage:
  10065. return m.OldErrorMessage(ctx)
  10066. case batchimageitem.FieldBilledAmount:
  10067. return m.OldBilledAmount(ctx)
  10068. case batchimageitem.FieldCreatedAt:
  10069. return m.OldCreatedAt(ctx)
  10070. case batchimageitem.FieldIndexedAt:
  10071. return m.OldIndexedAt(ctx)
  10072. }
  10073. return nil, fmt.Errorf("unknown BatchImageItem field %s", name)
  10074. }
  10075. // SetField sets the value of a field with the given name. It returns an error if
  10076. // the field is not defined in the schema, or if the type mismatched the field
  10077. // type.
  10078. func (m *BatchImageItemMutation) SetField(name string, value ent.Value) error {
  10079. switch name {
  10080. case batchimageitem.FieldJobID:
  10081. v, ok := value.(string)
  10082. if !ok {
  10083. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10084. }
  10085. m.SetJobID(v)
  10086. return nil
  10087. case batchimageitem.FieldCustomID:
  10088. v, ok := value.(string)
  10089. if !ok {
  10090. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10091. }
  10092. m.SetCustomID(v)
  10093. return nil
  10094. case batchimageitem.FieldStatus:
  10095. v, ok := value.(string)
  10096. if !ok {
  10097. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10098. }
  10099. m.SetStatus(v)
  10100. return nil
  10101. case batchimageitem.FieldRequestHash:
  10102. v, ok := value.(string)
  10103. if !ok {
  10104. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10105. }
  10106. m.SetRequestHash(v)
  10107. return nil
  10108. case batchimageitem.FieldPromptPreview:
  10109. v, ok := value.(string)
  10110. if !ok {
  10111. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10112. }
  10113. m.SetPromptPreview(v)
  10114. return nil
  10115. case batchimageitem.FieldProviderSourceObject:
  10116. v, ok := value.(string)
  10117. if !ok {
  10118. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10119. }
  10120. m.SetProviderSourceObject(v)
  10121. return nil
  10122. case batchimageitem.FieldSourceLineNumber:
  10123. v, ok := value.(int)
  10124. if !ok {
  10125. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10126. }
  10127. m.SetSourceLineNumber(v)
  10128. return nil
  10129. case batchimageitem.FieldSourceByteOffset:
  10130. v, ok := value.(int64)
  10131. if !ok {
  10132. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10133. }
  10134. m.SetSourceByteOffset(v)
  10135. return nil
  10136. case batchimageitem.FieldSourceByteLength:
  10137. v, ok := value.(int64)
  10138. if !ok {
  10139. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10140. }
  10141. m.SetSourceByteLength(v)
  10142. return nil
  10143. case batchimageitem.FieldMimeType:
  10144. v, ok := value.(string)
  10145. if !ok {
  10146. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10147. }
  10148. m.SetMimeType(v)
  10149. return nil
  10150. case batchimageitem.FieldFileExtension:
  10151. v, ok := value.(string)
  10152. if !ok {
  10153. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10154. }
  10155. m.SetFileExtension(v)
  10156. return nil
  10157. case batchimageitem.FieldImageCount:
  10158. v, ok := value.(int)
  10159. if !ok {
  10160. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10161. }
  10162. m.SetImageCount(v)
  10163. return nil
  10164. case batchimageitem.FieldErrorCode:
  10165. v, ok := value.(string)
  10166. if !ok {
  10167. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10168. }
  10169. m.SetErrorCode(v)
  10170. return nil
  10171. case batchimageitem.FieldErrorMessage:
  10172. v, ok := value.(string)
  10173. if !ok {
  10174. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10175. }
  10176. m.SetErrorMessage(v)
  10177. return nil
  10178. case batchimageitem.FieldBilledAmount:
  10179. v, ok := value.(float64)
  10180. if !ok {
  10181. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10182. }
  10183. m.SetBilledAmount(v)
  10184. return nil
  10185. case batchimageitem.FieldCreatedAt:
  10186. v, ok := value.(time.Time)
  10187. if !ok {
  10188. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10189. }
  10190. m.SetCreatedAt(v)
  10191. return nil
  10192. case batchimageitem.FieldIndexedAt:
  10193. v, ok := value.(time.Time)
  10194. if !ok {
  10195. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10196. }
  10197. m.SetIndexedAt(v)
  10198. return nil
  10199. }
  10200. return fmt.Errorf("unknown BatchImageItem field %s", name)
  10201. }
  10202. // AddedFields returns all numeric fields that were incremented/decremented during
  10203. // this mutation.
  10204. func (m *BatchImageItemMutation) AddedFields() []string {
  10205. var fields []string
  10206. if m.addsource_line_number != nil {
  10207. fields = append(fields, batchimageitem.FieldSourceLineNumber)
  10208. }
  10209. if m.addsource_byte_offset != nil {
  10210. fields = append(fields, batchimageitem.FieldSourceByteOffset)
  10211. }
  10212. if m.addsource_byte_length != nil {
  10213. fields = append(fields, batchimageitem.FieldSourceByteLength)
  10214. }
  10215. if m.addimage_count != nil {
  10216. fields = append(fields, batchimageitem.FieldImageCount)
  10217. }
  10218. if m.addbilled_amount != nil {
  10219. fields = append(fields, batchimageitem.FieldBilledAmount)
  10220. }
  10221. return fields
  10222. }
  10223. // AddedField returns the numeric value that was incremented/decremented on a field
  10224. // with the given name. The second boolean return value indicates that this field
  10225. // was not set, or was not defined in the schema.
  10226. func (m *BatchImageItemMutation) AddedField(name string) (ent.Value, bool) {
  10227. switch name {
  10228. case batchimageitem.FieldSourceLineNumber:
  10229. return m.AddedSourceLineNumber()
  10230. case batchimageitem.FieldSourceByteOffset:
  10231. return m.AddedSourceByteOffset()
  10232. case batchimageitem.FieldSourceByteLength:
  10233. return m.AddedSourceByteLength()
  10234. case batchimageitem.FieldImageCount:
  10235. return m.AddedImageCount()
  10236. case batchimageitem.FieldBilledAmount:
  10237. return m.AddedBilledAmount()
  10238. }
  10239. return nil, false
  10240. }
  10241. // AddField adds the value to the field with the given name. It returns an error if
  10242. // the field is not defined in the schema, or if the type mismatched the field
  10243. // type.
  10244. func (m *BatchImageItemMutation) AddField(name string, value ent.Value) error {
  10245. switch name {
  10246. case batchimageitem.FieldSourceLineNumber:
  10247. v, ok := value.(int)
  10248. if !ok {
  10249. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10250. }
  10251. m.AddSourceLineNumber(v)
  10252. return nil
  10253. case batchimageitem.FieldSourceByteOffset:
  10254. v, ok := value.(int64)
  10255. if !ok {
  10256. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10257. }
  10258. m.AddSourceByteOffset(v)
  10259. return nil
  10260. case batchimageitem.FieldSourceByteLength:
  10261. v, ok := value.(int64)
  10262. if !ok {
  10263. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10264. }
  10265. m.AddSourceByteLength(v)
  10266. return nil
  10267. case batchimageitem.FieldImageCount:
  10268. v, ok := value.(int)
  10269. if !ok {
  10270. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10271. }
  10272. m.AddImageCount(v)
  10273. return nil
  10274. case batchimageitem.FieldBilledAmount:
  10275. v, ok := value.(float64)
  10276. if !ok {
  10277. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10278. }
  10279. m.AddBilledAmount(v)
  10280. return nil
  10281. }
  10282. return fmt.Errorf("unknown BatchImageItem numeric field %s", name)
  10283. }
  10284. // ClearedFields returns all nullable fields that were cleared during this
  10285. // mutation.
  10286. func (m *BatchImageItemMutation) ClearedFields() []string {
  10287. var fields []string
  10288. if m.FieldCleared(batchimageitem.FieldRequestHash) {
  10289. fields = append(fields, batchimageitem.FieldRequestHash)
  10290. }
  10291. if m.FieldCleared(batchimageitem.FieldPromptPreview) {
  10292. fields = append(fields, batchimageitem.FieldPromptPreview)
  10293. }
  10294. if m.FieldCleared(batchimageitem.FieldProviderSourceObject) {
  10295. fields = append(fields, batchimageitem.FieldProviderSourceObject)
  10296. }
  10297. if m.FieldCleared(batchimageitem.FieldSourceLineNumber) {
  10298. fields = append(fields, batchimageitem.FieldSourceLineNumber)
  10299. }
  10300. if m.FieldCleared(batchimageitem.FieldSourceByteOffset) {
  10301. fields = append(fields, batchimageitem.FieldSourceByteOffset)
  10302. }
  10303. if m.FieldCleared(batchimageitem.FieldSourceByteLength) {
  10304. fields = append(fields, batchimageitem.FieldSourceByteLength)
  10305. }
  10306. if m.FieldCleared(batchimageitem.FieldMimeType) {
  10307. fields = append(fields, batchimageitem.FieldMimeType)
  10308. }
  10309. if m.FieldCleared(batchimageitem.FieldFileExtension) {
  10310. fields = append(fields, batchimageitem.FieldFileExtension)
  10311. }
  10312. if m.FieldCleared(batchimageitem.FieldErrorCode) {
  10313. fields = append(fields, batchimageitem.FieldErrorCode)
  10314. }
  10315. if m.FieldCleared(batchimageitem.FieldErrorMessage) {
  10316. fields = append(fields, batchimageitem.FieldErrorMessage)
  10317. }
  10318. if m.FieldCleared(batchimageitem.FieldBilledAmount) {
  10319. fields = append(fields, batchimageitem.FieldBilledAmount)
  10320. }
  10321. if m.FieldCleared(batchimageitem.FieldIndexedAt) {
  10322. fields = append(fields, batchimageitem.FieldIndexedAt)
  10323. }
  10324. return fields
  10325. }
  10326. // FieldCleared returns a boolean indicating if a field with the given name was
  10327. // cleared in this mutation.
  10328. func (m *BatchImageItemMutation) FieldCleared(name string) bool {
  10329. _, ok := m.clearedFields[name]
  10330. return ok
  10331. }
  10332. // ClearField clears the value of the field with the given name. It returns an
  10333. // error if the field is not defined in the schema.
  10334. func (m *BatchImageItemMutation) ClearField(name string) error {
  10335. switch name {
  10336. case batchimageitem.FieldRequestHash:
  10337. m.ClearRequestHash()
  10338. return nil
  10339. case batchimageitem.FieldPromptPreview:
  10340. m.ClearPromptPreview()
  10341. return nil
  10342. case batchimageitem.FieldProviderSourceObject:
  10343. m.ClearProviderSourceObject()
  10344. return nil
  10345. case batchimageitem.FieldSourceLineNumber:
  10346. m.ClearSourceLineNumber()
  10347. return nil
  10348. case batchimageitem.FieldSourceByteOffset:
  10349. m.ClearSourceByteOffset()
  10350. return nil
  10351. case batchimageitem.FieldSourceByteLength:
  10352. m.ClearSourceByteLength()
  10353. return nil
  10354. case batchimageitem.FieldMimeType:
  10355. m.ClearMimeType()
  10356. return nil
  10357. case batchimageitem.FieldFileExtension:
  10358. m.ClearFileExtension()
  10359. return nil
  10360. case batchimageitem.FieldErrorCode:
  10361. m.ClearErrorCode()
  10362. return nil
  10363. case batchimageitem.FieldErrorMessage:
  10364. m.ClearErrorMessage()
  10365. return nil
  10366. case batchimageitem.FieldBilledAmount:
  10367. m.ClearBilledAmount()
  10368. return nil
  10369. case batchimageitem.FieldIndexedAt:
  10370. m.ClearIndexedAt()
  10371. return nil
  10372. }
  10373. return fmt.Errorf("unknown BatchImageItem nullable field %s", name)
  10374. }
  10375. // ResetField resets all changes in the mutation for the field with the given name.
  10376. // It returns an error if the field is not defined in the schema.
  10377. func (m *BatchImageItemMutation) ResetField(name string) error {
  10378. switch name {
  10379. case batchimageitem.FieldJobID:
  10380. m.ResetJobID()
  10381. return nil
  10382. case batchimageitem.FieldCustomID:
  10383. m.ResetCustomID()
  10384. return nil
  10385. case batchimageitem.FieldStatus:
  10386. m.ResetStatus()
  10387. return nil
  10388. case batchimageitem.FieldRequestHash:
  10389. m.ResetRequestHash()
  10390. return nil
  10391. case batchimageitem.FieldPromptPreview:
  10392. m.ResetPromptPreview()
  10393. return nil
  10394. case batchimageitem.FieldProviderSourceObject:
  10395. m.ResetProviderSourceObject()
  10396. return nil
  10397. case batchimageitem.FieldSourceLineNumber:
  10398. m.ResetSourceLineNumber()
  10399. return nil
  10400. case batchimageitem.FieldSourceByteOffset:
  10401. m.ResetSourceByteOffset()
  10402. return nil
  10403. case batchimageitem.FieldSourceByteLength:
  10404. m.ResetSourceByteLength()
  10405. return nil
  10406. case batchimageitem.FieldMimeType:
  10407. m.ResetMimeType()
  10408. return nil
  10409. case batchimageitem.FieldFileExtension:
  10410. m.ResetFileExtension()
  10411. return nil
  10412. case batchimageitem.FieldImageCount:
  10413. m.ResetImageCount()
  10414. return nil
  10415. case batchimageitem.FieldErrorCode:
  10416. m.ResetErrorCode()
  10417. return nil
  10418. case batchimageitem.FieldErrorMessage:
  10419. m.ResetErrorMessage()
  10420. return nil
  10421. case batchimageitem.FieldBilledAmount:
  10422. m.ResetBilledAmount()
  10423. return nil
  10424. case batchimageitem.FieldCreatedAt:
  10425. m.ResetCreatedAt()
  10426. return nil
  10427. case batchimageitem.FieldIndexedAt:
  10428. m.ResetIndexedAt()
  10429. return nil
  10430. }
  10431. return fmt.Errorf("unknown BatchImageItem field %s", name)
  10432. }
  10433. // AddedEdges returns all edge names that were set/added in this mutation.
  10434. func (m *BatchImageItemMutation) AddedEdges() []string {
  10435. edges := make([]string, 0, 0)
  10436. return edges
  10437. }
  10438. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  10439. // name in this mutation.
  10440. func (m *BatchImageItemMutation) AddedIDs(name string) []ent.Value {
  10441. return nil
  10442. }
  10443. // RemovedEdges returns all edge names that were removed in this mutation.
  10444. func (m *BatchImageItemMutation) RemovedEdges() []string {
  10445. edges := make([]string, 0, 0)
  10446. return edges
  10447. }
  10448. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  10449. // the given name in this mutation.
  10450. func (m *BatchImageItemMutation) RemovedIDs(name string) []ent.Value {
  10451. return nil
  10452. }
  10453. // ClearedEdges returns all edge names that were cleared in this mutation.
  10454. func (m *BatchImageItemMutation) ClearedEdges() []string {
  10455. edges := make([]string, 0, 0)
  10456. return edges
  10457. }
  10458. // EdgeCleared returns a boolean which indicates if the edge with the given name
  10459. // was cleared in this mutation.
  10460. func (m *BatchImageItemMutation) EdgeCleared(name string) bool {
  10461. return false
  10462. }
  10463. // ClearEdge clears the value of the edge with the given name. It returns an error
  10464. // if that edge is not defined in the schema.
  10465. func (m *BatchImageItemMutation) ClearEdge(name string) error {
  10466. return fmt.Errorf("unknown BatchImageItem unique edge %s", name)
  10467. }
  10468. // ResetEdge resets all changes to the edge with the given name in this mutation.
  10469. // It returns an error if the edge is not defined in the schema.
  10470. func (m *BatchImageItemMutation) ResetEdge(name string) error {
  10471. return fmt.Errorf("unknown BatchImageItem edge %s", name)
  10472. }
  10473. // BatchImageJobMutation represents an operation that mutates the BatchImageJob nodes in the graph.
  10474. type BatchImageJobMutation struct {
  10475. config
  10476. op Op
  10477. typ string
  10478. id *int64
  10479. batch_id *string
  10480. user_id *int64
  10481. adduser_id *int64
  10482. api_key_id *int64
  10483. addapi_key_id *int64
  10484. account_id *int64
  10485. addaccount_id *int64
  10486. provider *string
  10487. model *string
  10488. task_name *string
  10489. status *string
  10490. provider_job_name *string
  10491. provider_input_ref *string
  10492. provider_output_ref *string
  10493. gcs_input_uri *string
  10494. gcs_output_uri *string
  10495. item_count *int
  10496. additem_count *int
  10497. success_count *int
  10498. addsuccess_count *int
  10499. fail_count *int
  10500. addfail_count *int
  10501. cancelled_count *int
  10502. addcancelled_count *int
  10503. estimated_cost *float64
  10504. addestimated_cost *float64
  10505. hold_amount *float64
  10506. addhold_amount *float64
  10507. actual_cost *float64
  10508. addactual_cost *float64
  10509. currency *string
  10510. hold_id *string
  10511. idempotency_key *string
  10512. request_hash *string
  10513. manifest_hash *string
  10514. retry_count *int
  10515. addretry_count *int
  10516. version *int
  10517. addversion *int
  10518. output_expires_at *time.Time
  10519. input_deleted_at *time.Time
  10520. output_deleted_at *time.Time
  10521. downloaded_at *time.Time
  10522. user_deleted_at *time.Time
  10523. last_error_code *string
  10524. last_error_message *string
  10525. created_at *time.Time
  10526. updated_at *time.Time
  10527. submitted_at *time.Time
  10528. started_at *time.Time
  10529. finished_at *time.Time
  10530. settled_at *time.Time
  10531. clearedFields map[string]struct{}
  10532. done bool
  10533. oldValue func(context.Context) (*BatchImageJob, error)
  10534. predicates []predicate.BatchImageJob
  10535. }
  10536. var _ ent.Mutation = (*BatchImageJobMutation)(nil)
  10537. // batchimagejobOption allows management of the mutation configuration using functional options.
  10538. type batchimagejobOption func(*BatchImageJobMutation)
  10539. // newBatchImageJobMutation creates new mutation for the BatchImageJob entity.
  10540. func newBatchImageJobMutation(c config, op Op, opts ...batchimagejobOption) *BatchImageJobMutation {
  10541. m := &BatchImageJobMutation{
  10542. config: c,
  10543. op: op,
  10544. typ: TypeBatchImageJob,
  10545. clearedFields: make(map[string]struct{}),
  10546. }
  10547. for _, opt := range opts {
  10548. opt(m)
  10549. }
  10550. return m
  10551. }
  10552. // withBatchImageJobID sets the ID field of the mutation.
  10553. func withBatchImageJobID(id int64) batchimagejobOption {
  10554. return func(m *BatchImageJobMutation) {
  10555. var (
  10556. err error
  10557. once sync.Once
  10558. value *BatchImageJob
  10559. )
  10560. m.oldValue = func(ctx context.Context) (*BatchImageJob, error) {
  10561. once.Do(func() {
  10562. if m.done {
  10563. err = errors.New("querying old values post mutation is not allowed")
  10564. } else {
  10565. value, err = m.Client().BatchImageJob.Get(ctx, id)
  10566. }
  10567. })
  10568. return value, err
  10569. }
  10570. m.id = &id
  10571. }
  10572. }
  10573. // withBatchImageJob sets the old BatchImageJob of the mutation.
  10574. func withBatchImageJob(node *BatchImageJob) batchimagejobOption {
  10575. return func(m *BatchImageJobMutation) {
  10576. m.oldValue = func(context.Context) (*BatchImageJob, error) {
  10577. return node, nil
  10578. }
  10579. m.id = &node.ID
  10580. }
  10581. }
  10582. // Client returns a new `ent.Client` from the mutation. If the mutation was
  10583. // executed in a transaction (ent.Tx), a transactional client is returned.
  10584. func (m BatchImageJobMutation) Client() *Client {
  10585. client := &Client{config: m.config}
  10586. client.init()
  10587. return client
  10588. }
  10589. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  10590. // it returns an error otherwise.
  10591. func (m BatchImageJobMutation) Tx() (*Tx, error) {
  10592. if _, ok := m.driver.(*txDriver); !ok {
  10593. return nil, errors.New("ent: mutation is not running in a transaction")
  10594. }
  10595. tx := &Tx{config: m.config}
  10596. tx.init()
  10597. return tx, nil
  10598. }
  10599. // ID returns the ID value in the mutation. Note that the ID is only available
  10600. // if it was provided to the builder or after it was returned from the database.
  10601. func (m *BatchImageJobMutation) ID() (id int64, exists bool) {
  10602. if m.id == nil {
  10603. return
  10604. }
  10605. return *m.id, true
  10606. }
  10607. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  10608. // That means, if the mutation is applied within a transaction with an isolation level such
  10609. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  10610. // or updated by the mutation.
  10611. func (m *BatchImageJobMutation) IDs(ctx context.Context) ([]int64, error) {
  10612. switch {
  10613. case m.op.Is(OpUpdateOne | OpDeleteOne):
  10614. id, exists := m.ID()
  10615. if exists {
  10616. return []int64{id}, nil
  10617. }
  10618. fallthrough
  10619. case m.op.Is(OpUpdate | OpDelete):
  10620. return m.Client().BatchImageJob.Query().Where(m.predicates...).IDs(ctx)
  10621. default:
  10622. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  10623. }
  10624. }
  10625. // SetBatchID sets the "batch_id" field.
  10626. func (m *BatchImageJobMutation) SetBatchID(s string) {
  10627. m.batch_id = &s
  10628. }
  10629. // BatchID returns the value of the "batch_id" field in the mutation.
  10630. func (m *BatchImageJobMutation) BatchID() (r string, exists bool) {
  10631. v := m.batch_id
  10632. if v == nil {
  10633. return
  10634. }
  10635. return *v, true
  10636. }
  10637. // OldBatchID returns the old "batch_id" field's value of the BatchImageJob entity.
  10638. // If the BatchImageJob object wasn't provided to the builder, the object is fetched from the database.
  10639. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10640. func (m *BatchImageJobMutation) OldBatchID(ctx context.Context) (v string, err error) {
  10641. if !m.op.Is(OpUpdateOne) {
  10642. return v, errors.New("OldBatchID is only allowed on UpdateOne operations")
  10643. }
  10644. if m.id == nil || m.oldValue == nil {
  10645. return v, errors.New("OldBatchID requires an ID field in the mutation")
  10646. }
  10647. oldValue, err := m.oldValue(ctx)
  10648. if err != nil {
  10649. return v, fmt.Errorf("querying old value for OldBatchID: %w", err)
  10650. }
  10651. return oldValue.BatchID, nil
  10652. }
  10653. // ResetBatchID resets all changes to the "batch_id" field.
  10654. func (m *BatchImageJobMutation) ResetBatchID() {
  10655. m.batch_id = nil
  10656. }
  10657. // SetUserID sets the "user_id" field.
  10658. func (m *BatchImageJobMutation) SetUserID(i int64) {
  10659. m.user_id = &i
  10660. m.adduser_id = nil
  10661. }
  10662. // UserID returns the value of the "user_id" field in the mutation.
  10663. func (m *BatchImageJobMutation) UserID() (r int64, exists bool) {
  10664. v := m.user_id
  10665. if v == nil {
  10666. return
  10667. }
  10668. return *v, true
  10669. }
  10670. // OldUserID returns the old "user_id" field's value of the BatchImageJob entity.
  10671. // If the BatchImageJob object wasn't provided to the builder, the object is fetched from the database.
  10672. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10673. func (m *BatchImageJobMutation) OldUserID(ctx context.Context) (v int64, err error) {
  10674. if !m.op.Is(OpUpdateOne) {
  10675. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  10676. }
  10677. if m.id == nil || m.oldValue == nil {
  10678. return v, errors.New("OldUserID requires an ID field in the mutation")
  10679. }
  10680. oldValue, err := m.oldValue(ctx)
  10681. if err != nil {
  10682. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  10683. }
  10684. return oldValue.UserID, nil
  10685. }
  10686. // AddUserID adds i to the "user_id" field.
  10687. func (m *BatchImageJobMutation) AddUserID(i int64) {
  10688. if m.adduser_id != nil {
  10689. *m.adduser_id += i
  10690. } else {
  10691. m.adduser_id = &i
  10692. }
  10693. }
  10694. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  10695. func (m *BatchImageJobMutation) AddedUserID() (r int64, exists bool) {
  10696. v := m.adduser_id
  10697. if v == nil {
  10698. return
  10699. }
  10700. return *v, true
  10701. }
  10702. // ResetUserID resets all changes to the "user_id" field.
  10703. func (m *BatchImageJobMutation) ResetUserID() {
  10704. m.user_id = nil
  10705. m.adduser_id = nil
  10706. }
  10707. // SetAPIKeyID sets the "api_key_id" field.
  10708. func (m *BatchImageJobMutation) SetAPIKeyID(i int64) {
  10709. m.api_key_id = &i
  10710. m.addapi_key_id = nil
  10711. }
  10712. // APIKeyID returns the value of the "api_key_id" field in the mutation.
  10713. func (m *BatchImageJobMutation) APIKeyID() (r int64, exists bool) {
  10714. v := m.api_key_id
  10715. if v == nil {
  10716. return
  10717. }
  10718. return *v, true
  10719. }
  10720. // OldAPIKeyID returns the old "api_key_id" field's value of the BatchImageJob entity.
  10721. // If the BatchImageJob object wasn't provided to the builder, the object is fetched from the database.
  10722. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10723. func (m *BatchImageJobMutation) OldAPIKeyID(ctx context.Context) (v *int64, err error) {
  10724. if !m.op.Is(OpUpdateOne) {
  10725. return v, errors.New("OldAPIKeyID is only allowed on UpdateOne operations")
  10726. }
  10727. if m.id == nil || m.oldValue == nil {
  10728. return v, errors.New("OldAPIKeyID requires an ID field in the mutation")
  10729. }
  10730. oldValue, err := m.oldValue(ctx)
  10731. if err != nil {
  10732. return v, fmt.Errorf("querying old value for OldAPIKeyID: %w", err)
  10733. }
  10734. return oldValue.APIKeyID, nil
  10735. }
  10736. // AddAPIKeyID adds i to the "api_key_id" field.
  10737. func (m *BatchImageJobMutation) AddAPIKeyID(i int64) {
  10738. if m.addapi_key_id != nil {
  10739. *m.addapi_key_id += i
  10740. } else {
  10741. m.addapi_key_id = &i
  10742. }
  10743. }
  10744. // AddedAPIKeyID returns the value that was added to the "api_key_id" field in this mutation.
  10745. func (m *BatchImageJobMutation) AddedAPIKeyID() (r int64, exists bool) {
  10746. v := m.addapi_key_id
  10747. if v == nil {
  10748. return
  10749. }
  10750. return *v, true
  10751. }
  10752. // ClearAPIKeyID clears the value of the "api_key_id" field.
  10753. func (m *BatchImageJobMutation) ClearAPIKeyID() {
  10754. m.api_key_id = nil
  10755. m.addapi_key_id = nil
  10756. m.clearedFields[batchimagejob.FieldAPIKeyID] = struct{}{}
  10757. }
  10758. // APIKeyIDCleared returns if the "api_key_id" field was cleared in this mutation.
  10759. func (m *BatchImageJobMutation) APIKeyIDCleared() bool {
  10760. _, ok := m.clearedFields[batchimagejob.FieldAPIKeyID]
  10761. return ok
  10762. }
  10763. // ResetAPIKeyID resets all changes to the "api_key_id" field.
  10764. func (m *BatchImageJobMutation) ResetAPIKeyID() {
  10765. m.api_key_id = nil
  10766. m.addapi_key_id = nil
  10767. delete(m.clearedFields, batchimagejob.FieldAPIKeyID)
  10768. }
  10769. // SetAccountID sets the "account_id" field.
  10770. func (m *BatchImageJobMutation) SetAccountID(i int64) {
  10771. m.account_id = &i
  10772. m.addaccount_id = nil
  10773. }
  10774. // AccountID returns the value of the "account_id" field in the mutation.
  10775. func (m *BatchImageJobMutation) AccountID() (r int64, exists bool) {
  10776. v := m.account_id
  10777. if v == nil {
  10778. return
  10779. }
  10780. return *v, true
  10781. }
  10782. // OldAccountID returns the old "account_id" field's value of the BatchImageJob entity.
  10783. // If the BatchImageJob object wasn't provided to the builder, the object is fetched from the database.
  10784. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10785. func (m *BatchImageJobMutation) OldAccountID(ctx context.Context) (v *int64, err error) {
  10786. if !m.op.Is(OpUpdateOne) {
  10787. return v, errors.New("OldAccountID is only allowed on UpdateOne operations")
  10788. }
  10789. if m.id == nil || m.oldValue == nil {
  10790. return v, errors.New("OldAccountID requires an ID field in the mutation")
  10791. }
  10792. oldValue, err := m.oldValue(ctx)
  10793. if err != nil {
  10794. return v, fmt.Errorf("querying old value for OldAccountID: %w", err)
  10795. }
  10796. return oldValue.AccountID, nil
  10797. }
  10798. // AddAccountID adds i to the "account_id" field.
  10799. func (m *BatchImageJobMutation) AddAccountID(i int64) {
  10800. if m.addaccount_id != nil {
  10801. *m.addaccount_id += i
  10802. } else {
  10803. m.addaccount_id = &i
  10804. }
  10805. }
  10806. // AddedAccountID returns the value that was added to the "account_id" field in this mutation.
  10807. func (m *BatchImageJobMutation) AddedAccountID() (r int64, exists bool) {
  10808. v := m.addaccount_id
  10809. if v == nil {
  10810. return
  10811. }
  10812. return *v, true
  10813. }
  10814. // ClearAccountID clears the value of the "account_id" field.
  10815. func (m *BatchImageJobMutation) ClearAccountID() {
  10816. m.account_id = nil
  10817. m.addaccount_id = nil
  10818. m.clearedFields[batchimagejob.FieldAccountID] = struct{}{}
  10819. }
  10820. // AccountIDCleared returns if the "account_id" field was cleared in this mutation.
  10821. func (m *BatchImageJobMutation) AccountIDCleared() bool {
  10822. _, ok := m.clearedFields[batchimagejob.FieldAccountID]
  10823. return ok
  10824. }
  10825. // ResetAccountID resets all changes to the "account_id" field.
  10826. func (m *BatchImageJobMutation) ResetAccountID() {
  10827. m.account_id = nil
  10828. m.addaccount_id = nil
  10829. delete(m.clearedFields, batchimagejob.FieldAccountID)
  10830. }
  10831. // SetProvider sets the "provider" field.
  10832. func (m *BatchImageJobMutation) SetProvider(s string) {
  10833. m.provider = &s
  10834. }
  10835. // Provider returns the value of the "provider" field in the mutation.
  10836. func (m *BatchImageJobMutation) Provider() (r string, exists bool) {
  10837. v := m.provider
  10838. if v == nil {
  10839. return
  10840. }
  10841. return *v, true
  10842. }
  10843. // OldProvider returns the old "provider" field's value of the BatchImageJob entity.
  10844. // If the BatchImageJob object wasn't provided to the builder, the object is fetched from the database.
  10845. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10846. func (m *BatchImageJobMutation) OldProvider(ctx context.Context) (v string, err error) {
  10847. if !m.op.Is(OpUpdateOne) {
  10848. return v, errors.New("OldProvider is only allowed on UpdateOne operations")
  10849. }
  10850. if m.id == nil || m.oldValue == nil {
  10851. return v, errors.New("OldProvider requires an ID field in the mutation")
  10852. }
  10853. oldValue, err := m.oldValue(ctx)
  10854. if err != nil {
  10855. return v, fmt.Errorf("querying old value for OldProvider: %w", err)
  10856. }
  10857. return oldValue.Provider, nil
  10858. }
  10859. // ResetProvider resets all changes to the "provider" field.
  10860. func (m *BatchImageJobMutation) ResetProvider() {
  10861. m.provider = nil
  10862. }
  10863. // SetModel sets the "model" field.
  10864. func (m *BatchImageJobMutation) SetModel(s string) {
  10865. m.model = &s
  10866. }
  10867. // Model returns the value of the "model" field in the mutation.
  10868. func (m *BatchImageJobMutation) Model() (r string, exists bool) {
  10869. v := m.model
  10870. if v == nil {
  10871. return
  10872. }
  10873. return *v, true
  10874. }
  10875. // OldModel returns the old "model" field's value of the BatchImageJob entity.
  10876. // If the BatchImageJob object wasn't provided to the builder, the object is fetched from the database.
  10877. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10878. func (m *BatchImageJobMutation) OldModel(ctx context.Context) (v string, err error) {
  10879. if !m.op.Is(OpUpdateOne) {
  10880. return v, errors.New("OldModel is only allowed on UpdateOne operations")
  10881. }
  10882. if m.id == nil || m.oldValue == nil {
  10883. return v, errors.New("OldModel requires an ID field in the mutation")
  10884. }
  10885. oldValue, err := m.oldValue(ctx)
  10886. if err != nil {
  10887. return v, fmt.Errorf("querying old value for OldModel: %w", err)
  10888. }
  10889. return oldValue.Model, nil
  10890. }
  10891. // ResetModel resets all changes to the "model" field.
  10892. func (m *BatchImageJobMutation) ResetModel() {
  10893. m.model = nil
  10894. }
  10895. // SetTaskName sets the "task_name" field.
  10896. func (m *BatchImageJobMutation) SetTaskName(s string) {
  10897. m.task_name = &s
  10898. }
  10899. // TaskName returns the value of the "task_name" field in the mutation.
  10900. func (m *BatchImageJobMutation) TaskName() (r string, exists bool) {
  10901. v := m.task_name
  10902. if v == nil {
  10903. return
  10904. }
  10905. return *v, true
  10906. }
  10907. // OldTaskName returns the old "task_name" field's value of the BatchImageJob entity.
  10908. // If the BatchImageJob object wasn't provided to the builder, the object is fetched from the database.
  10909. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10910. func (m *BatchImageJobMutation) OldTaskName(ctx context.Context) (v string, err error) {
  10911. if !m.op.Is(OpUpdateOne) {
  10912. return v, errors.New("OldTaskName is only allowed on UpdateOne operations")
  10913. }
  10914. if m.id == nil || m.oldValue == nil {
  10915. return v, errors.New("OldTaskName requires an ID field in the mutation")
  10916. }
  10917. oldValue, err := m.oldValue(ctx)
  10918. if err != nil {
  10919. return v, fmt.Errorf("querying old value for OldTaskName: %w", err)
  10920. }
  10921. return oldValue.TaskName, nil
  10922. }
  10923. // ResetTaskName resets all changes to the "task_name" field.
  10924. func (m *BatchImageJobMutation) ResetTaskName() {
  10925. m.task_name = nil
  10926. }
  10927. // SetStatus sets the "status" field.
  10928. func (m *BatchImageJobMutation) SetStatus(s string) {
  10929. m.status = &s
  10930. }
  10931. // Status returns the value of the "status" field in the mutation.
  10932. func (m *BatchImageJobMutation) Status() (r string, exists bool) {
  10933. v := m.status
  10934. if v == nil {
  10935. return
  10936. }
  10937. return *v, true
  10938. }
  10939. // OldStatus returns the old "status" field's value of the BatchImageJob entity.
  10940. // If the BatchImageJob object wasn't provided to the builder, the object is fetched from the database.
  10941. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10942. func (m *BatchImageJobMutation) OldStatus(ctx context.Context) (v string, err error) {
  10943. if !m.op.Is(OpUpdateOne) {
  10944. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  10945. }
  10946. if m.id == nil || m.oldValue == nil {
  10947. return v, errors.New("OldStatus requires an ID field in the mutation")
  10948. }
  10949. oldValue, err := m.oldValue(ctx)
  10950. if err != nil {
  10951. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  10952. }
  10953. return oldValue.Status, nil
  10954. }
  10955. // ResetStatus resets all changes to the "status" field.
  10956. func (m *BatchImageJobMutation) ResetStatus() {
  10957. m.status = nil
  10958. }
  10959. // SetProviderJobName sets the "provider_job_name" field.
  10960. func (m *BatchImageJobMutation) SetProviderJobName(s string) {
  10961. m.provider_job_name = &s
  10962. }
  10963. // ProviderJobName returns the value of the "provider_job_name" field in the mutation.
  10964. func (m *BatchImageJobMutation) ProviderJobName() (r string, exists bool) {
  10965. v := m.provider_job_name
  10966. if v == nil {
  10967. return
  10968. }
  10969. return *v, true
  10970. }
  10971. // OldProviderJobName returns the old "provider_job_name" field's value of the BatchImageJob entity.
  10972. // If the BatchImageJob object wasn't provided to the builder, the object is fetched from the database.
  10973. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10974. func (m *BatchImageJobMutation) OldProviderJobName(ctx context.Context) (v *string, err error) {
  10975. if !m.op.Is(OpUpdateOne) {
  10976. return v, errors.New("OldProviderJobName is only allowed on UpdateOne operations")
  10977. }
  10978. if m.id == nil || m.oldValue == nil {
  10979. return v, errors.New("OldProviderJobName requires an ID field in the mutation")
  10980. }
  10981. oldValue, err := m.oldValue(ctx)
  10982. if err != nil {
  10983. return v, fmt.Errorf("querying old value for OldProviderJobName: %w", err)
  10984. }
  10985. return oldValue.ProviderJobName, nil
  10986. }
  10987. // ClearProviderJobName clears the value of the "provider_job_name" field.
  10988. func (m *BatchImageJobMutation) ClearProviderJobName() {
  10989. m.provider_job_name = nil
  10990. m.clearedFields[batchimagejob.FieldProviderJobName] = struct{}{}
  10991. }
  10992. // ProviderJobNameCleared returns if the "provider_job_name" field was cleared in this mutation.
  10993. func (m *BatchImageJobMutation) ProviderJobNameCleared() bool {
  10994. _, ok := m.clearedFields[batchimagejob.FieldProviderJobName]
  10995. return ok
  10996. }
  10997. // ResetProviderJobName resets all changes to the "provider_job_name" field.
  10998. func (m *BatchImageJobMutation) ResetProviderJobName() {
  10999. m.provider_job_name = nil
  11000. delete(m.clearedFields, batchimagejob.FieldProviderJobName)
  11001. }
  11002. // SetProviderInputRef sets the "provider_input_ref" field.
  11003. func (m *BatchImageJobMutation) SetProviderInputRef(s string) {
  11004. m.provider_input_ref = &s
  11005. }
  11006. // ProviderInputRef returns the value of the "provider_input_ref" field in the mutation.
  11007. func (m *BatchImageJobMutation) ProviderInputRef() (r string, exists bool) {
  11008. v := m.provider_input_ref
  11009. if v == nil {
  11010. return
  11011. }
  11012. return *v, true
  11013. }
  11014. // OldProviderInputRef returns the old "provider_input_ref" field's value of the BatchImageJob entity.
  11015. // If the BatchImageJob object wasn't provided to the builder, the object is fetched from the database.
  11016. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11017. func (m *BatchImageJobMutation) OldProviderInputRef(ctx context.Context) (v *string, err error) {
  11018. if !m.op.Is(OpUpdateOne) {
  11019. return v, errors.New("OldProviderInputRef is only allowed on UpdateOne operations")
  11020. }
  11021. if m.id == nil || m.oldValue == nil {
  11022. return v, errors.New("OldProviderInputRef requires an ID field in the mutation")
  11023. }
  11024. oldValue, err := m.oldValue(ctx)
  11025. if err != nil {
  11026. return v, fmt.Errorf("querying old value for OldProviderInputRef: %w", err)
  11027. }
  11028. return oldValue.ProviderInputRef, nil
  11029. }
  11030. // ClearProviderInputRef clears the value of the "provider_input_ref" field.
  11031. func (m *BatchImageJobMutation) ClearProviderInputRef() {
  11032. m.provider_input_ref = nil
  11033. m.clearedFields[batchimagejob.FieldProviderInputRef] = struct{}{}
  11034. }
  11035. // ProviderInputRefCleared returns if the "provider_input_ref" field was cleared in this mutation.
  11036. func (m *BatchImageJobMutation) ProviderInputRefCleared() bool {
  11037. _, ok := m.clearedFields[batchimagejob.FieldProviderInputRef]
  11038. return ok
  11039. }
  11040. // ResetProviderInputRef resets all changes to the "provider_input_ref" field.
  11041. func (m *BatchImageJobMutation) ResetProviderInputRef() {
  11042. m.provider_input_ref = nil
  11043. delete(m.clearedFields, batchimagejob.FieldProviderInputRef)
  11044. }
  11045. // SetProviderOutputRef sets the "provider_output_ref" field.
  11046. func (m *BatchImageJobMutation) SetProviderOutputRef(s string) {
  11047. m.provider_output_ref = &s
  11048. }
  11049. // ProviderOutputRef returns the value of the "provider_output_ref" field in the mutation.
  11050. func (m *BatchImageJobMutation) ProviderOutputRef() (r string, exists bool) {
  11051. v := m.provider_output_ref
  11052. if v == nil {
  11053. return
  11054. }
  11055. return *v, true
  11056. }
  11057. // OldProviderOutputRef returns the old "provider_output_ref" field's value of the BatchImageJob entity.
  11058. // If the BatchImageJob object wasn't provided to the builder, the object is fetched from the database.
  11059. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11060. func (m *BatchImageJobMutation) OldProviderOutputRef(ctx context.Context) (v *string, err error) {
  11061. if !m.op.Is(OpUpdateOne) {
  11062. return v, errors.New("OldProviderOutputRef is only allowed on UpdateOne operations")
  11063. }
  11064. if m.id == nil || m.oldValue == nil {
  11065. return v, errors.New("OldProviderOutputRef requires an ID field in the mutation")
  11066. }
  11067. oldValue, err := m.oldValue(ctx)
  11068. if err != nil {
  11069. return v, fmt.Errorf("querying old value for OldProviderOutputRef: %w", err)
  11070. }
  11071. return oldValue.ProviderOutputRef, nil
  11072. }
  11073. // ClearProviderOutputRef clears the value of the "provider_output_ref" field.
  11074. func (m *BatchImageJobMutation) ClearProviderOutputRef() {
  11075. m.provider_output_ref = nil
  11076. m.clearedFields[batchimagejob.FieldProviderOutputRef] = struct{}{}
  11077. }
  11078. // ProviderOutputRefCleared returns if the "provider_output_ref" field was cleared in this mutation.
  11079. func (m *BatchImageJobMutation) ProviderOutputRefCleared() bool {
  11080. _, ok := m.clearedFields[batchimagejob.FieldProviderOutputRef]
  11081. return ok
  11082. }
  11083. // ResetProviderOutputRef resets all changes to the "provider_output_ref" field.
  11084. func (m *BatchImageJobMutation) ResetProviderOutputRef() {
  11085. m.provider_output_ref = nil
  11086. delete(m.clearedFields, batchimagejob.FieldProviderOutputRef)
  11087. }
  11088. // SetGcsInputURI sets the "gcs_input_uri" field.
  11089. func (m *BatchImageJobMutation) SetGcsInputURI(s string) {
  11090. m.gcs_input_uri = &s
  11091. }
  11092. // GcsInputURI returns the value of the "gcs_input_uri" field in the mutation.
  11093. func (m *BatchImageJobMutation) GcsInputURI() (r string, exists bool) {
  11094. v := m.gcs_input_uri
  11095. if v == nil {
  11096. return
  11097. }
  11098. return *v, true
  11099. }
  11100. // OldGcsInputURI returns the old "gcs_input_uri" field's value of the BatchImageJob entity.
  11101. // If the BatchImageJob object wasn't provided to the builder, the object is fetched from the database.
  11102. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11103. func (m *BatchImageJobMutation) OldGcsInputURI(ctx context.Context) (v *string, err error) {
  11104. if !m.op.Is(OpUpdateOne) {
  11105. return v, errors.New("OldGcsInputURI is only allowed on UpdateOne operations")
  11106. }
  11107. if m.id == nil || m.oldValue == nil {
  11108. return v, errors.New("OldGcsInputURI requires an ID field in the mutation")
  11109. }
  11110. oldValue, err := m.oldValue(ctx)
  11111. if err != nil {
  11112. return v, fmt.Errorf("querying old value for OldGcsInputURI: %w", err)
  11113. }
  11114. return oldValue.GcsInputURI, nil
  11115. }
  11116. // ClearGcsInputURI clears the value of the "gcs_input_uri" field.
  11117. func (m *BatchImageJobMutation) ClearGcsInputURI() {
  11118. m.gcs_input_uri = nil
  11119. m.clearedFields[batchimagejob.FieldGcsInputURI] = struct{}{}
  11120. }
  11121. // GcsInputURICleared returns if the "gcs_input_uri" field was cleared in this mutation.
  11122. func (m *BatchImageJobMutation) GcsInputURICleared() bool {
  11123. _, ok := m.clearedFields[batchimagejob.FieldGcsInputURI]
  11124. return ok
  11125. }
  11126. // ResetGcsInputURI resets all changes to the "gcs_input_uri" field.
  11127. func (m *BatchImageJobMutation) ResetGcsInputURI() {
  11128. m.gcs_input_uri = nil
  11129. delete(m.clearedFields, batchimagejob.FieldGcsInputURI)
  11130. }
  11131. // SetGcsOutputURI sets the "gcs_output_uri" field.
  11132. func (m *BatchImageJobMutation) SetGcsOutputURI(s string) {
  11133. m.gcs_output_uri = &s
  11134. }
  11135. // GcsOutputURI returns the value of the "gcs_output_uri" field in the mutation.
  11136. func (m *BatchImageJobMutation) GcsOutputURI() (r string, exists bool) {
  11137. v := m.gcs_output_uri
  11138. if v == nil {
  11139. return
  11140. }
  11141. return *v, true
  11142. }
  11143. // OldGcsOutputURI returns the old "gcs_output_uri" field's value of the BatchImageJob entity.
  11144. // If the BatchImageJob object wasn't provided to the builder, the object is fetched from the database.
  11145. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11146. func (m *BatchImageJobMutation) OldGcsOutputURI(ctx context.Context) (v *string, err error) {
  11147. if !m.op.Is(OpUpdateOne) {
  11148. return v, errors.New("OldGcsOutputURI is only allowed on UpdateOne operations")
  11149. }
  11150. if m.id == nil || m.oldValue == nil {
  11151. return v, errors.New("OldGcsOutputURI requires an ID field in the mutation")
  11152. }
  11153. oldValue, err := m.oldValue(ctx)
  11154. if err != nil {
  11155. return v, fmt.Errorf("querying old value for OldGcsOutputURI: %w", err)
  11156. }
  11157. return oldValue.GcsOutputURI, nil
  11158. }
  11159. // ClearGcsOutputURI clears the value of the "gcs_output_uri" field.
  11160. func (m *BatchImageJobMutation) ClearGcsOutputURI() {
  11161. m.gcs_output_uri = nil
  11162. m.clearedFields[batchimagejob.FieldGcsOutputURI] = struct{}{}
  11163. }
  11164. // GcsOutputURICleared returns if the "gcs_output_uri" field was cleared in this mutation.
  11165. func (m *BatchImageJobMutation) GcsOutputURICleared() bool {
  11166. _, ok := m.clearedFields[batchimagejob.FieldGcsOutputURI]
  11167. return ok
  11168. }
  11169. // ResetGcsOutputURI resets all changes to the "gcs_output_uri" field.
  11170. func (m *BatchImageJobMutation) ResetGcsOutputURI() {
  11171. m.gcs_output_uri = nil
  11172. delete(m.clearedFields, batchimagejob.FieldGcsOutputURI)
  11173. }
  11174. // SetItemCount sets the "item_count" field.
  11175. func (m *BatchImageJobMutation) SetItemCount(i int) {
  11176. m.item_count = &i
  11177. m.additem_count = nil
  11178. }
  11179. // ItemCount returns the value of the "item_count" field in the mutation.
  11180. func (m *BatchImageJobMutation) ItemCount() (r int, exists bool) {
  11181. v := m.item_count
  11182. if v == nil {
  11183. return
  11184. }
  11185. return *v, true
  11186. }
  11187. // OldItemCount returns the old "item_count" field's value of the BatchImageJob entity.
  11188. // If the BatchImageJob object wasn't provided to the builder, the object is fetched from the database.
  11189. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11190. func (m *BatchImageJobMutation) OldItemCount(ctx context.Context) (v int, err error) {
  11191. if !m.op.Is(OpUpdateOne) {
  11192. return v, errors.New("OldItemCount is only allowed on UpdateOne operations")
  11193. }
  11194. if m.id == nil || m.oldValue == nil {
  11195. return v, errors.New("OldItemCount requires an ID field in the mutation")
  11196. }
  11197. oldValue, err := m.oldValue(ctx)
  11198. if err != nil {
  11199. return v, fmt.Errorf("querying old value for OldItemCount: %w", err)
  11200. }
  11201. return oldValue.ItemCount, nil
  11202. }
  11203. // AddItemCount adds i to the "item_count" field.
  11204. func (m *BatchImageJobMutation) AddItemCount(i int) {
  11205. if m.additem_count != nil {
  11206. *m.additem_count += i
  11207. } else {
  11208. m.additem_count = &i
  11209. }
  11210. }
  11211. // AddedItemCount returns the value that was added to the "item_count" field in this mutation.
  11212. func (m *BatchImageJobMutation) AddedItemCount() (r int, exists bool) {
  11213. v := m.additem_count
  11214. if v == nil {
  11215. return
  11216. }
  11217. return *v, true
  11218. }
  11219. // ResetItemCount resets all changes to the "item_count" field.
  11220. func (m *BatchImageJobMutation) ResetItemCount() {
  11221. m.item_count = nil
  11222. m.additem_count = nil
  11223. }
  11224. // SetSuccessCount sets the "success_count" field.
  11225. func (m *BatchImageJobMutation) SetSuccessCount(i int) {
  11226. m.success_count = &i
  11227. m.addsuccess_count = nil
  11228. }
  11229. // SuccessCount returns the value of the "success_count" field in the mutation.
  11230. func (m *BatchImageJobMutation) SuccessCount() (r int, exists bool) {
  11231. v := m.success_count
  11232. if v == nil {
  11233. return
  11234. }
  11235. return *v, true
  11236. }
  11237. // OldSuccessCount returns the old "success_count" field's value of the BatchImageJob entity.
  11238. // If the BatchImageJob object wasn't provided to the builder, the object is fetched from the database.
  11239. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11240. func (m *BatchImageJobMutation) OldSuccessCount(ctx context.Context) (v int, err error) {
  11241. if !m.op.Is(OpUpdateOne) {
  11242. return v, errors.New("OldSuccessCount is only allowed on UpdateOne operations")
  11243. }
  11244. if m.id == nil || m.oldValue == nil {
  11245. return v, errors.New("OldSuccessCount requires an ID field in the mutation")
  11246. }
  11247. oldValue, err := m.oldValue(ctx)
  11248. if err != nil {
  11249. return v, fmt.Errorf("querying old value for OldSuccessCount: %w", err)
  11250. }
  11251. return oldValue.SuccessCount, nil
  11252. }
  11253. // AddSuccessCount adds i to the "success_count" field.
  11254. func (m *BatchImageJobMutation) AddSuccessCount(i int) {
  11255. if m.addsuccess_count != nil {
  11256. *m.addsuccess_count += i
  11257. } else {
  11258. m.addsuccess_count = &i
  11259. }
  11260. }
  11261. // AddedSuccessCount returns the value that was added to the "success_count" field in this mutation.
  11262. func (m *BatchImageJobMutation) AddedSuccessCount() (r int, exists bool) {
  11263. v := m.addsuccess_count
  11264. if v == nil {
  11265. return
  11266. }
  11267. return *v, true
  11268. }
  11269. // ResetSuccessCount resets all changes to the "success_count" field.
  11270. func (m *BatchImageJobMutation) ResetSuccessCount() {
  11271. m.success_count = nil
  11272. m.addsuccess_count = nil
  11273. }
  11274. // SetFailCount sets the "fail_count" field.
  11275. func (m *BatchImageJobMutation) SetFailCount(i int) {
  11276. m.fail_count = &i
  11277. m.addfail_count = nil
  11278. }
  11279. // FailCount returns the value of the "fail_count" field in the mutation.
  11280. func (m *BatchImageJobMutation) FailCount() (r int, exists bool) {
  11281. v := m.fail_count
  11282. if v == nil {
  11283. return
  11284. }
  11285. return *v, true
  11286. }
  11287. // OldFailCount returns the old "fail_count" field's value of the BatchImageJob entity.
  11288. // If the BatchImageJob object wasn't provided to the builder, the object is fetched from the database.
  11289. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11290. func (m *BatchImageJobMutation) OldFailCount(ctx context.Context) (v int, err error) {
  11291. if !m.op.Is(OpUpdateOne) {
  11292. return v, errors.New("OldFailCount is only allowed on UpdateOne operations")
  11293. }
  11294. if m.id == nil || m.oldValue == nil {
  11295. return v, errors.New("OldFailCount requires an ID field in the mutation")
  11296. }
  11297. oldValue, err := m.oldValue(ctx)
  11298. if err != nil {
  11299. return v, fmt.Errorf("querying old value for OldFailCount: %w", err)
  11300. }
  11301. return oldValue.FailCount, nil
  11302. }
  11303. // AddFailCount adds i to the "fail_count" field.
  11304. func (m *BatchImageJobMutation) AddFailCount(i int) {
  11305. if m.addfail_count != nil {
  11306. *m.addfail_count += i
  11307. } else {
  11308. m.addfail_count = &i
  11309. }
  11310. }
  11311. // AddedFailCount returns the value that was added to the "fail_count" field in this mutation.
  11312. func (m *BatchImageJobMutation) AddedFailCount() (r int, exists bool) {
  11313. v := m.addfail_count
  11314. if v == nil {
  11315. return
  11316. }
  11317. return *v, true
  11318. }
  11319. // ResetFailCount resets all changes to the "fail_count" field.
  11320. func (m *BatchImageJobMutation) ResetFailCount() {
  11321. m.fail_count = nil
  11322. m.addfail_count = nil
  11323. }
  11324. // SetCancelledCount sets the "cancelled_count" field.
  11325. func (m *BatchImageJobMutation) SetCancelledCount(i int) {
  11326. m.cancelled_count = &i
  11327. m.addcancelled_count = nil
  11328. }
  11329. // CancelledCount returns the value of the "cancelled_count" field in the mutation.
  11330. func (m *BatchImageJobMutation) CancelledCount() (r int, exists bool) {
  11331. v := m.cancelled_count
  11332. if v == nil {
  11333. return
  11334. }
  11335. return *v, true
  11336. }
  11337. // OldCancelledCount returns the old "cancelled_count" field's value of the BatchImageJob entity.
  11338. // If the BatchImageJob object wasn't provided to the builder, the object is fetched from the database.
  11339. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11340. func (m *BatchImageJobMutation) OldCancelledCount(ctx context.Context) (v int, err error) {
  11341. if !m.op.Is(OpUpdateOne) {
  11342. return v, errors.New("OldCancelledCount is only allowed on UpdateOne operations")
  11343. }
  11344. if m.id == nil || m.oldValue == nil {
  11345. return v, errors.New("OldCancelledCount requires an ID field in the mutation")
  11346. }
  11347. oldValue, err := m.oldValue(ctx)
  11348. if err != nil {
  11349. return v, fmt.Errorf("querying old value for OldCancelledCount: %w", err)
  11350. }
  11351. return oldValue.CancelledCount, nil
  11352. }
  11353. // AddCancelledCount adds i to the "cancelled_count" field.
  11354. func (m *BatchImageJobMutation) AddCancelledCount(i int) {
  11355. if m.addcancelled_count != nil {
  11356. *m.addcancelled_count += i
  11357. } else {
  11358. m.addcancelled_count = &i
  11359. }
  11360. }
  11361. // AddedCancelledCount returns the value that was added to the "cancelled_count" field in this mutation.
  11362. func (m *BatchImageJobMutation) AddedCancelledCount() (r int, exists bool) {
  11363. v := m.addcancelled_count
  11364. if v == nil {
  11365. return
  11366. }
  11367. return *v, true
  11368. }
  11369. // ResetCancelledCount resets all changes to the "cancelled_count" field.
  11370. func (m *BatchImageJobMutation) ResetCancelledCount() {
  11371. m.cancelled_count = nil
  11372. m.addcancelled_count = nil
  11373. }
  11374. // SetEstimatedCost sets the "estimated_cost" field.
  11375. func (m *BatchImageJobMutation) SetEstimatedCost(f float64) {
  11376. m.estimated_cost = &f
  11377. m.addestimated_cost = nil
  11378. }
  11379. // EstimatedCost returns the value of the "estimated_cost" field in the mutation.
  11380. func (m *BatchImageJobMutation) EstimatedCost() (r float64, exists bool) {
  11381. v := m.estimated_cost
  11382. if v == nil {
  11383. return
  11384. }
  11385. return *v, true
  11386. }
  11387. // OldEstimatedCost returns the old "estimated_cost" field's value of the BatchImageJob entity.
  11388. // If the BatchImageJob object wasn't provided to the builder, the object is fetched from the database.
  11389. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11390. func (m *BatchImageJobMutation) OldEstimatedCost(ctx context.Context) (v float64, err error) {
  11391. if !m.op.Is(OpUpdateOne) {
  11392. return v, errors.New("OldEstimatedCost is only allowed on UpdateOne operations")
  11393. }
  11394. if m.id == nil || m.oldValue == nil {
  11395. return v, errors.New("OldEstimatedCost requires an ID field in the mutation")
  11396. }
  11397. oldValue, err := m.oldValue(ctx)
  11398. if err != nil {
  11399. return v, fmt.Errorf("querying old value for OldEstimatedCost: %w", err)
  11400. }
  11401. return oldValue.EstimatedCost, nil
  11402. }
  11403. // AddEstimatedCost adds f to the "estimated_cost" field.
  11404. func (m *BatchImageJobMutation) AddEstimatedCost(f float64) {
  11405. if m.addestimated_cost != nil {
  11406. *m.addestimated_cost += f
  11407. } else {
  11408. m.addestimated_cost = &f
  11409. }
  11410. }
  11411. // AddedEstimatedCost returns the value that was added to the "estimated_cost" field in this mutation.
  11412. func (m *BatchImageJobMutation) AddedEstimatedCost() (r float64, exists bool) {
  11413. v := m.addestimated_cost
  11414. if v == nil {
  11415. return
  11416. }
  11417. return *v, true
  11418. }
  11419. // ResetEstimatedCost resets all changes to the "estimated_cost" field.
  11420. func (m *BatchImageJobMutation) ResetEstimatedCost() {
  11421. m.estimated_cost = nil
  11422. m.addestimated_cost = nil
  11423. }
  11424. // SetHoldAmount sets the "hold_amount" field.
  11425. func (m *BatchImageJobMutation) SetHoldAmount(f float64) {
  11426. m.hold_amount = &f
  11427. m.addhold_amount = nil
  11428. }
  11429. // HoldAmount returns the value of the "hold_amount" field in the mutation.
  11430. func (m *BatchImageJobMutation) HoldAmount() (r float64, exists bool) {
  11431. v := m.hold_amount
  11432. if v == nil {
  11433. return
  11434. }
  11435. return *v, true
  11436. }
  11437. // OldHoldAmount returns the old "hold_amount" field's value of the BatchImageJob entity.
  11438. // If the BatchImageJob object wasn't provided to the builder, the object is fetched from the database.
  11439. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11440. func (m *BatchImageJobMutation) OldHoldAmount(ctx context.Context) (v *float64, err error) {
  11441. if !m.op.Is(OpUpdateOne) {
  11442. return v, errors.New("OldHoldAmount is only allowed on UpdateOne operations")
  11443. }
  11444. if m.id == nil || m.oldValue == nil {
  11445. return v, errors.New("OldHoldAmount requires an ID field in the mutation")
  11446. }
  11447. oldValue, err := m.oldValue(ctx)
  11448. if err != nil {
  11449. return v, fmt.Errorf("querying old value for OldHoldAmount: %w", err)
  11450. }
  11451. return oldValue.HoldAmount, nil
  11452. }
  11453. // AddHoldAmount adds f to the "hold_amount" field.
  11454. func (m *BatchImageJobMutation) AddHoldAmount(f float64) {
  11455. if m.addhold_amount != nil {
  11456. *m.addhold_amount += f
  11457. } else {
  11458. m.addhold_amount = &f
  11459. }
  11460. }
  11461. // AddedHoldAmount returns the value that was added to the "hold_amount" field in this mutation.
  11462. func (m *BatchImageJobMutation) AddedHoldAmount() (r float64, exists bool) {
  11463. v := m.addhold_amount
  11464. if v == nil {
  11465. return
  11466. }
  11467. return *v, true
  11468. }
  11469. // ClearHoldAmount clears the value of the "hold_amount" field.
  11470. func (m *BatchImageJobMutation) ClearHoldAmount() {
  11471. m.hold_amount = nil
  11472. m.addhold_amount = nil
  11473. m.clearedFields[batchimagejob.FieldHoldAmount] = struct{}{}
  11474. }
  11475. // HoldAmountCleared returns if the "hold_amount" field was cleared in this mutation.
  11476. func (m *BatchImageJobMutation) HoldAmountCleared() bool {
  11477. _, ok := m.clearedFields[batchimagejob.FieldHoldAmount]
  11478. return ok
  11479. }
  11480. // ResetHoldAmount resets all changes to the "hold_amount" field.
  11481. func (m *BatchImageJobMutation) ResetHoldAmount() {
  11482. m.hold_amount = nil
  11483. m.addhold_amount = nil
  11484. delete(m.clearedFields, batchimagejob.FieldHoldAmount)
  11485. }
  11486. // SetActualCost sets the "actual_cost" field.
  11487. func (m *BatchImageJobMutation) SetActualCost(f float64) {
  11488. m.actual_cost = &f
  11489. m.addactual_cost = nil
  11490. }
  11491. // ActualCost returns the value of the "actual_cost" field in the mutation.
  11492. func (m *BatchImageJobMutation) ActualCost() (r float64, exists bool) {
  11493. v := m.actual_cost
  11494. if v == nil {
  11495. return
  11496. }
  11497. return *v, true
  11498. }
  11499. // OldActualCost returns the old "actual_cost" field's value of the BatchImageJob entity.
  11500. // If the BatchImageJob object wasn't provided to the builder, the object is fetched from the database.
  11501. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11502. func (m *BatchImageJobMutation) OldActualCost(ctx context.Context) (v *float64, err error) {
  11503. if !m.op.Is(OpUpdateOne) {
  11504. return v, errors.New("OldActualCost is only allowed on UpdateOne operations")
  11505. }
  11506. if m.id == nil || m.oldValue == nil {
  11507. return v, errors.New("OldActualCost requires an ID field in the mutation")
  11508. }
  11509. oldValue, err := m.oldValue(ctx)
  11510. if err != nil {
  11511. return v, fmt.Errorf("querying old value for OldActualCost: %w", err)
  11512. }
  11513. return oldValue.ActualCost, nil
  11514. }
  11515. // AddActualCost adds f to the "actual_cost" field.
  11516. func (m *BatchImageJobMutation) AddActualCost(f float64) {
  11517. if m.addactual_cost != nil {
  11518. *m.addactual_cost += f
  11519. } else {
  11520. m.addactual_cost = &f
  11521. }
  11522. }
  11523. // AddedActualCost returns the value that was added to the "actual_cost" field in this mutation.
  11524. func (m *BatchImageJobMutation) AddedActualCost() (r float64, exists bool) {
  11525. v := m.addactual_cost
  11526. if v == nil {
  11527. return
  11528. }
  11529. return *v, true
  11530. }
  11531. // ClearActualCost clears the value of the "actual_cost" field.
  11532. func (m *BatchImageJobMutation) ClearActualCost() {
  11533. m.actual_cost = nil
  11534. m.addactual_cost = nil
  11535. m.clearedFields[batchimagejob.FieldActualCost] = struct{}{}
  11536. }
  11537. // ActualCostCleared returns if the "actual_cost" field was cleared in this mutation.
  11538. func (m *BatchImageJobMutation) ActualCostCleared() bool {
  11539. _, ok := m.clearedFields[batchimagejob.FieldActualCost]
  11540. return ok
  11541. }
  11542. // ResetActualCost resets all changes to the "actual_cost" field.
  11543. func (m *BatchImageJobMutation) ResetActualCost() {
  11544. m.actual_cost = nil
  11545. m.addactual_cost = nil
  11546. delete(m.clearedFields, batchimagejob.FieldActualCost)
  11547. }
  11548. // SetCurrency sets the "currency" field.
  11549. func (m *BatchImageJobMutation) SetCurrency(s string) {
  11550. m.currency = &s
  11551. }
  11552. // Currency returns the value of the "currency" field in the mutation.
  11553. func (m *BatchImageJobMutation) Currency() (r string, exists bool) {
  11554. v := m.currency
  11555. if v == nil {
  11556. return
  11557. }
  11558. return *v, true
  11559. }
  11560. // OldCurrency returns the old "currency" field's value of the BatchImageJob entity.
  11561. // If the BatchImageJob object wasn't provided to the builder, the object is fetched from the database.
  11562. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11563. func (m *BatchImageJobMutation) OldCurrency(ctx context.Context) (v string, err error) {
  11564. if !m.op.Is(OpUpdateOne) {
  11565. return v, errors.New("OldCurrency is only allowed on UpdateOne operations")
  11566. }
  11567. if m.id == nil || m.oldValue == nil {
  11568. return v, errors.New("OldCurrency requires an ID field in the mutation")
  11569. }
  11570. oldValue, err := m.oldValue(ctx)
  11571. if err != nil {
  11572. return v, fmt.Errorf("querying old value for OldCurrency: %w", err)
  11573. }
  11574. return oldValue.Currency, nil
  11575. }
  11576. // ResetCurrency resets all changes to the "currency" field.
  11577. func (m *BatchImageJobMutation) ResetCurrency() {
  11578. m.currency = nil
  11579. }
  11580. // SetHoldID sets the "hold_id" field.
  11581. func (m *BatchImageJobMutation) SetHoldID(s string) {
  11582. m.hold_id = &s
  11583. }
  11584. // HoldID returns the value of the "hold_id" field in the mutation.
  11585. func (m *BatchImageJobMutation) HoldID() (r string, exists bool) {
  11586. v := m.hold_id
  11587. if v == nil {
  11588. return
  11589. }
  11590. return *v, true
  11591. }
  11592. // OldHoldID returns the old "hold_id" field's value of the BatchImageJob entity.
  11593. // If the BatchImageJob object wasn't provided to the builder, the object is fetched from the database.
  11594. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11595. func (m *BatchImageJobMutation) OldHoldID(ctx context.Context) (v *string, err error) {
  11596. if !m.op.Is(OpUpdateOne) {
  11597. return v, errors.New("OldHoldID is only allowed on UpdateOne operations")
  11598. }
  11599. if m.id == nil || m.oldValue == nil {
  11600. return v, errors.New("OldHoldID requires an ID field in the mutation")
  11601. }
  11602. oldValue, err := m.oldValue(ctx)
  11603. if err != nil {
  11604. return v, fmt.Errorf("querying old value for OldHoldID: %w", err)
  11605. }
  11606. return oldValue.HoldID, nil
  11607. }
  11608. // ClearHoldID clears the value of the "hold_id" field.
  11609. func (m *BatchImageJobMutation) ClearHoldID() {
  11610. m.hold_id = nil
  11611. m.clearedFields[batchimagejob.FieldHoldID] = struct{}{}
  11612. }
  11613. // HoldIDCleared returns if the "hold_id" field was cleared in this mutation.
  11614. func (m *BatchImageJobMutation) HoldIDCleared() bool {
  11615. _, ok := m.clearedFields[batchimagejob.FieldHoldID]
  11616. return ok
  11617. }
  11618. // ResetHoldID resets all changes to the "hold_id" field.
  11619. func (m *BatchImageJobMutation) ResetHoldID() {
  11620. m.hold_id = nil
  11621. delete(m.clearedFields, batchimagejob.FieldHoldID)
  11622. }
  11623. // SetIdempotencyKey sets the "idempotency_key" field.
  11624. func (m *BatchImageJobMutation) SetIdempotencyKey(s string) {
  11625. m.idempotency_key = &s
  11626. }
  11627. // IdempotencyKey returns the value of the "idempotency_key" field in the mutation.
  11628. func (m *BatchImageJobMutation) IdempotencyKey() (r string, exists bool) {
  11629. v := m.idempotency_key
  11630. if v == nil {
  11631. return
  11632. }
  11633. return *v, true
  11634. }
  11635. // OldIdempotencyKey returns the old "idempotency_key" field's value of the BatchImageJob entity.
  11636. // If the BatchImageJob object wasn't provided to the builder, the object is fetched from the database.
  11637. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11638. func (m *BatchImageJobMutation) OldIdempotencyKey(ctx context.Context) (v *string, err error) {
  11639. if !m.op.Is(OpUpdateOne) {
  11640. return v, errors.New("OldIdempotencyKey is only allowed on UpdateOne operations")
  11641. }
  11642. if m.id == nil || m.oldValue == nil {
  11643. return v, errors.New("OldIdempotencyKey requires an ID field in the mutation")
  11644. }
  11645. oldValue, err := m.oldValue(ctx)
  11646. if err != nil {
  11647. return v, fmt.Errorf("querying old value for OldIdempotencyKey: %w", err)
  11648. }
  11649. return oldValue.IdempotencyKey, nil
  11650. }
  11651. // ClearIdempotencyKey clears the value of the "idempotency_key" field.
  11652. func (m *BatchImageJobMutation) ClearIdempotencyKey() {
  11653. m.idempotency_key = nil
  11654. m.clearedFields[batchimagejob.FieldIdempotencyKey] = struct{}{}
  11655. }
  11656. // IdempotencyKeyCleared returns if the "idempotency_key" field was cleared in this mutation.
  11657. func (m *BatchImageJobMutation) IdempotencyKeyCleared() bool {
  11658. _, ok := m.clearedFields[batchimagejob.FieldIdempotencyKey]
  11659. return ok
  11660. }
  11661. // ResetIdempotencyKey resets all changes to the "idempotency_key" field.
  11662. func (m *BatchImageJobMutation) ResetIdempotencyKey() {
  11663. m.idempotency_key = nil
  11664. delete(m.clearedFields, batchimagejob.FieldIdempotencyKey)
  11665. }
  11666. // SetRequestHash sets the "request_hash" field.
  11667. func (m *BatchImageJobMutation) SetRequestHash(s string) {
  11668. m.request_hash = &s
  11669. }
  11670. // RequestHash returns the value of the "request_hash" field in the mutation.
  11671. func (m *BatchImageJobMutation) RequestHash() (r string, exists bool) {
  11672. v := m.request_hash
  11673. if v == nil {
  11674. return
  11675. }
  11676. return *v, true
  11677. }
  11678. // OldRequestHash returns the old "request_hash" field's value of the BatchImageJob entity.
  11679. // If the BatchImageJob object wasn't provided to the builder, the object is fetched from the database.
  11680. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11681. func (m *BatchImageJobMutation) OldRequestHash(ctx context.Context) (v *string, err error) {
  11682. if !m.op.Is(OpUpdateOne) {
  11683. return v, errors.New("OldRequestHash is only allowed on UpdateOne operations")
  11684. }
  11685. if m.id == nil || m.oldValue == nil {
  11686. return v, errors.New("OldRequestHash requires an ID field in the mutation")
  11687. }
  11688. oldValue, err := m.oldValue(ctx)
  11689. if err != nil {
  11690. return v, fmt.Errorf("querying old value for OldRequestHash: %w", err)
  11691. }
  11692. return oldValue.RequestHash, nil
  11693. }
  11694. // ClearRequestHash clears the value of the "request_hash" field.
  11695. func (m *BatchImageJobMutation) ClearRequestHash() {
  11696. m.request_hash = nil
  11697. m.clearedFields[batchimagejob.FieldRequestHash] = struct{}{}
  11698. }
  11699. // RequestHashCleared returns if the "request_hash" field was cleared in this mutation.
  11700. func (m *BatchImageJobMutation) RequestHashCleared() bool {
  11701. _, ok := m.clearedFields[batchimagejob.FieldRequestHash]
  11702. return ok
  11703. }
  11704. // ResetRequestHash resets all changes to the "request_hash" field.
  11705. func (m *BatchImageJobMutation) ResetRequestHash() {
  11706. m.request_hash = nil
  11707. delete(m.clearedFields, batchimagejob.FieldRequestHash)
  11708. }
  11709. // SetManifestHash sets the "manifest_hash" field.
  11710. func (m *BatchImageJobMutation) SetManifestHash(s string) {
  11711. m.manifest_hash = &s
  11712. }
  11713. // ManifestHash returns the value of the "manifest_hash" field in the mutation.
  11714. func (m *BatchImageJobMutation) ManifestHash() (r string, exists bool) {
  11715. v := m.manifest_hash
  11716. if v == nil {
  11717. return
  11718. }
  11719. return *v, true
  11720. }
  11721. // OldManifestHash returns the old "manifest_hash" field's value of the BatchImageJob entity.
  11722. // If the BatchImageJob object wasn't provided to the builder, the object is fetched from the database.
  11723. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11724. func (m *BatchImageJobMutation) OldManifestHash(ctx context.Context) (v *string, err error) {
  11725. if !m.op.Is(OpUpdateOne) {
  11726. return v, errors.New("OldManifestHash is only allowed on UpdateOne operations")
  11727. }
  11728. if m.id == nil || m.oldValue == nil {
  11729. return v, errors.New("OldManifestHash requires an ID field in the mutation")
  11730. }
  11731. oldValue, err := m.oldValue(ctx)
  11732. if err != nil {
  11733. return v, fmt.Errorf("querying old value for OldManifestHash: %w", err)
  11734. }
  11735. return oldValue.ManifestHash, nil
  11736. }
  11737. // ClearManifestHash clears the value of the "manifest_hash" field.
  11738. func (m *BatchImageJobMutation) ClearManifestHash() {
  11739. m.manifest_hash = nil
  11740. m.clearedFields[batchimagejob.FieldManifestHash] = struct{}{}
  11741. }
  11742. // ManifestHashCleared returns if the "manifest_hash" field was cleared in this mutation.
  11743. func (m *BatchImageJobMutation) ManifestHashCleared() bool {
  11744. _, ok := m.clearedFields[batchimagejob.FieldManifestHash]
  11745. return ok
  11746. }
  11747. // ResetManifestHash resets all changes to the "manifest_hash" field.
  11748. func (m *BatchImageJobMutation) ResetManifestHash() {
  11749. m.manifest_hash = nil
  11750. delete(m.clearedFields, batchimagejob.FieldManifestHash)
  11751. }
  11752. // SetRetryCount sets the "retry_count" field.
  11753. func (m *BatchImageJobMutation) SetRetryCount(i int) {
  11754. m.retry_count = &i
  11755. m.addretry_count = nil
  11756. }
  11757. // RetryCount returns the value of the "retry_count" field in the mutation.
  11758. func (m *BatchImageJobMutation) RetryCount() (r int, exists bool) {
  11759. v := m.retry_count
  11760. if v == nil {
  11761. return
  11762. }
  11763. return *v, true
  11764. }
  11765. // OldRetryCount returns the old "retry_count" field's value of the BatchImageJob entity.
  11766. // If the BatchImageJob object wasn't provided to the builder, the object is fetched from the database.
  11767. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11768. func (m *BatchImageJobMutation) OldRetryCount(ctx context.Context) (v int, err error) {
  11769. if !m.op.Is(OpUpdateOne) {
  11770. return v, errors.New("OldRetryCount is only allowed on UpdateOne operations")
  11771. }
  11772. if m.id == nil || m.oldValue == nil {
  11773. return v, errors.New("OldRetryCount requires an ID field in the mutation")
  11774. }
  11775. oldValue, err := m.oldValue(ctx)
  11776. if err != nil {
  11777. return v, fmt.Errorf("querying old value for OldRetryCount: %w", err)
  11778. }
  11779. return oldValue.RetryCount, nil
  11780. }
  11781. // AddRetryCount adds i to the "retry_count" field.
  11782. func (m *BatchImageJobMutation) AddRetryCount(i int) {
  11783. if m.addretry_count != nil {
  11784. *m.addretry_count += i
  11785. } else {
  11786. m.addretry_count = &i
  11787. }
  11788. }
  11789. // AddedRetryCount returns the value that was added to the "retry_count" field in this mutation.
  11790. func (m *BatchImageJobMutation) AddedRetryCount() (r int, exists bool) {
  11791. v := m.addretry_count
  11792. if v == nil {
  11793. return
  11794. }
  11795. return *v, true
  11796. }
  11797. // ResetRetryCount resets all changes to the "retry_count" field.
  11798. func (m *BatchImageJobMutation) ResetRetryCount() {
  11799. m.retry_count = nil
  11800. m.addretry_count = nil
  11801. }
  11802. // SetVersion sets the "version" field.
  11803. func (m *BatchImageJobMutation) SetVersion(i int) {
  11804. m.version = &i
  11805. m.addversion = nil
  11806. }
  11807. // Version returns the value of the "version" field in the mutation.
  11808. func (m *BatchImageJobMutation) Version() (r int, exists bool) {
  11809. v := m.version
  11810. if v == nil {
  11811. return
  11812. }
  11813. return *v, true
  11814. }
  11815. // OldVersion returns the old "version" field's value of the BatchImageJob entity.
  11816. // If the BatchImageJob object wasn't provided to the builder, the object is fetched from the database.
  11817. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11818. func (m *BatchImageJobMutation) OldVersion(ctx context.Context) (v int, err error) {
  11819. if !m.op.Is(OpUpdateOne) {
  11820. return v, errors.New("OldVersion is only allowed on UpdateOne operations")
  11821. }
  11822. if m.id == nil || m.oldValue == nil {
  11823. return v, errors.New("OldVersion requires an ID field in the mutation")
  11824. }
  11825. oldValue, err := m.oldValue(ctx)
  11826. if err != nil {
  11827. return v, fmt.Errorf("querying old value for OldVersion: %w", err)
  11828. }
  11829. return oldValue.Version, nil
  11830. }
  11831. // AddVersion adds i to the "version" field.
  11832. func (m *BatchImageJobMutation) AddVersion(i int) {
  11833. if m.addversion != nil {
  11834. *m.addversion += i
  11835. } else {
  11836. m.addversion = &i
  11837. }
  11838. }
  11839. // AddedVersion returns the value that was added to the "version" field in this mutation.
  11840. func (m *BatchImageJobMutation) AddedVersion() (r int, exists bool) {
  11841. v := m.addversion
  11842. if v == nil {
  11843. return
  11844. }
  11845. return *v, true
  11846. }
  11847. // ResetVersion resets all changes to the "version" field.
  11848. func (m *BatchImageJobMutation) ResetVersion() {
  11849. m.version = nil
  11850. m.addversion = nil
  11851. }
  11852. // SetOutputExpiresAt sets the "output_expires_at" field.
  11853. func (m *BatchImageJobMutation) SetOutputExpiresAt(t time.Time) {
  11854. m.output_expires_at = &t
  11855. }
  11856. // OutputExpiresAt returns the value of the "output_expires_at" field in the mutation.
  11857. func (m *BatchImageJobMutation) OutputExpiresAt() (r time.Time, exists bool) {
  11858. v := m.output_expires_at
  11859. if v == nil {
  11860. return
  11861. }
  11862. return *v, true
  11863. }
  11864. // OldOutputExpiresAt returns the old "output_expires_at" field's value of the BatchImageJob entity.
  11865. // If the BatchImageJob object wasn't provided to the builder, the object is fetched from the database.
  11866. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11867. func (m *BatchImageJobMutation) OldOutputExpiresAt(ctx context.Context) (v *time.Time, err error) {
  11868. if !m.op.Is(OpUpdateOne) {
  11869. return v, errors.New("OldOutputExpiresAt is only allowed on UpdateOne operations")
  11870. }
  11871. if m.id == nil || m.oldValue == nil {
  11872. return v, errors.New("OldOutputExpiresAt requires an ID field in the mutation")
  11873. }
  11874. oldValue, err := m.oldValue(ctx)
  11875. if err != nil {
  11876. return v, fmt.Errorf("querying old value for OldOutputExpiresAt: %w", err)
  11877. }
  11878. return oldValue.OutputExpiresAt, nil
  11879. }
  11880. // ClearOutputExpiresAt clears the value of the "output_expires_at" field.
  11881. func (m *BatchImageJobMutation) ClearOutputExpiresAt() {
  11882. m.output_expires_at = nil
  11883. m.clearedFields[batchimagejob.FieldOutputExpiresAt] = struct{}{}
  11884. }
  11885. // OutputExpiresAtCleared returns if the "output_expires_at" field was cleared in this mutation.
  11886. func (m *BatchImageJobMutation) OutputExpiresAtCleared() bool {
  11887. _, ok := m.clearedFields[batchimagejob.FieldOutputExpiresAt]
  11888. return ok
  11889. }
  11890. // ResetOutputExpiresAt resets all changes to the "output_expires_at" field.
  11891. func (m *BatchImageJobMutation) ResetOutputExpiresAt() {
  11892. m.output_expires_at = nil
  11893. delete(m.clearedFields, batchimagejob.FieldOutputExpiresAt)
  11894. }
  11895. // SetInputDeletedAt sets the "input_deleted_at" field.
  11896. func (m *BatchImageJobMutation) SetInputDeletedAt(t time.Time) {
  11897. m.input_deleted_at = &t
  11898. }
  11899. // InputDeletedAt returns the value of the "input_deleted_at" field in the mutation.
  11900. func (m *BatchImageJobMutation) InputDeletedAt() (r time.Time, exists bool) {
  11901. v := m.input_deleted_at
  11902. if v == nil {
  11903. return
  11904. }
  11905. return *v, true
  11906. }
  11907. // OldInputDeletedAt returns the old "input_deleted_at" field's value of the BatchImageJob entity.
  11908. // If the BatchImageJob object wasn't provided to the builder, the object is fetched from the database.
  11909. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11910. func (m *BatchImageJobMutation) OldInputDeletedAt(ctx context.Context) (v *time.Time, err error) {
  11911. if !m.op.Is(OpUpdateOne) {
  11912. return v, errors.New("OldInputDeletedAt is only allowed on UpdateOne operations")
  11913. }
  11914. if m.id == nil || m.oldValue == nil {
  11915. return v, errors.New("OldInputDeletedAt requires an ID field in the mutation")
  11916. }
  11917. oldValue, err := m.oldValue(ctx)
  11918. if err != nil {
  11919. return v, fmt.Errorf("querying old value for OldInputDeletedAt: %w", err)
  11920. }
  11921. return oldValue.InputDeletedAt, nil
  11922. }
  11923. // ClearInputDeletedAt clears the value of the "input_deleted_at" field.
  11924. func (m *BatchImageJobMutation) ClearInputDeletedAt() {
  11925. m.input_deleted_at = nil
  11926. m.clearedFields[batchimagejob.FieldInputDeletedAt] = struct{}{}
  11927. }
  11928. // InputDeletedAtCleared returns if the "input_deleted_at" field was cleared in this mutation.
  11929. func (m *BatchImageJobMutation) InputDeletedAtCleared() bool {
  11930. _, ok := m.clearedFields[batchimagejob.FieldInputDeletedAt]
  11931. return ok
  11932. }
  11933. // ResetInputDeletedAt resets all changes to the "input_deleted_at" field.
  11934. func (m *BatchImageJobMutation) ResetInputDeletedAt() {
  11935. m.input_deleted_at = nil
  11936. delete(m.clearedFields, batchimagejob.FieldInputDeletedAt)
  11937. }
  11938. // SetOutputDeletedAt sets the "output_deleted_at" field.
  11939. func (m *BatchImageJobMutation) SetOutputDeletedAt(t time.Time) {
  11940. m.output_deleted_at = &t
  11941. }
  11942. // OutputDeletedAt returns the value of the "output_deleted_at" field in the mutation.
  11943. func (m *BatchImageJobMutation) OutputDeletedAt() (r time.Time, exists bool) {
  11944. v := m.output_deleted_at
  11945. if v == nil {
  11946. return
  11947. }
  11948. return *v, true
  11949. }
  11950. // OldOutputDeletedAt returns the old "output_deleted_at" field's value of the BatchImageJob entity.
  11951. // If the BatchImageJob object wasn't provided to the builder, the object is fetched from the database.
  11952. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11953. func (m *BatchImageJobMutation) OldOutputDeletedAt(ctx context.Context) (v *time.Time, err error) {
  11954. if !m.op.Is(OpUpdateOne) {
  11955. return v, errors.New("OldOutputDeletedAt is only allowed on UpdateOne operations")
  11956. }
  11957. if m.id == nil || m.oldValue == nil {
  11958. return v, errors.New("OldOutputDeletedAt requires an ID field in the mutation")
  11959. }
  11960. oldValue, err := m.oldValue(ctx)
  11961. if err != nil {
  11962. return v, fmt.Errorf("querying old value for OldOutputDeletedAt: %w", err)
  11963. }
  11964. return oldValue.OutputDeletedAt, nil
  11965. }
  11966. // ClearOutputDeletedAt clears the value of the "output_deleted_at" field.
  11967. func (m *BatchImageJobMutation) ClearOutputDeletedAt() {
  11968. m.output_deleted_at = nil
  11969. m.clearedFields[batchimagejob.FieldOutputDeletedAt] = struct{}{}
  11970. }
  11971. // OutputDeletedAtCleared returns if the "output_deleted_at" field was cleared in this mutation.
  11972. func (m *BatchImageJobMutation) OutputDeletedAtCleared() bool {
  11973. _, ok := m.clearedFields[batchimagejob.FieldOutputDeletedAt]
  11974. return ok
  11975. }
  11976. // ResetOutputDeletedAt resets all changes to the "output_deleted_at" field.
  11977. func (m *BatchImageJobMutation) ResetOutputDeletedAt() {
  11978. m.output_deleted_at = nil
  11979. delete(m.clearedFields, batchimagejob.FieldOutputDeletedAt)
  11980. }
  11981. // SetDownloadedAt sets the "downloaded_at" field.
  11982. func (m *BatchImageJobMutation) SetDownloadedAt(t time.Time) {
  11983. m.downloaded_at = &t
  11984. }
  11985. // DownloadedAt returns the value of the "downloaded_at" field in the mutation.
  11986. func (m *BatchImageJobMutation) DownloadedAt() (r time.Time, exists bool) {
  11987. v := m.downloaded_at
  11988. if v == nil {
  11989. return
  11990. }
  11991. return *v, true
  11992. }
  11993. // OldDownloadedAt returns the old "downloaded_at" field's value of the BatchImageJob entity.
  11994. // If the BatchImageJob object wasn't provided to the builder, the object is fetched from the database.
  11995. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11996. func (m *BatchImageJobMutation) OldDownloadedAt(ctx context.Context) (v *time.Time, err error) {
  11997. if !m.op.Is(OpUpdateOne) {
  11998. return v, errors.New("OldDownloadedAt is only allowed on UpdateOne operations")
  11999. }
  12000. if m.id == nil || m.oldValue == nil {
  12001. return v, errors.New("OldDownloadedAt requires an ID field in the mutation")
  12002. }
  12003. oldValue, err := m.oldValue(ctx)
  12004. if err != nil {
  12005. return v, fmt.Errorf("querying old value for OldDownloadedAt: %w", err)
  12006. }
  12007. return oldValue.DownloadedAt, nil
  12008. }
  12009. // ClearDownloadedAt clears the value of the "downloaded_at" field.
  12010. func (m *BatchImageJobMutation) ClearDownloadedAt() {
  12011. m.downloaded_at = nil
  12012. m.clearedFields[batchimagejob.FieldDownloadedAt] = struct{}{}
  12013. }
  12014. // DownloadedAtCleared returns if the "downloaded_at" field was cleared in this mutation.
  12015. func (m *BatchImageJobMutation) DownloadedAtCleared() bool {
  12016. _, ok := m.clearedFields[batchimagejob.FieldDownloadedAt]
  12017. return ok
  12018. }
  12019. // ResetDownloadedAt resets all changes to the "downloaded_at" field.
  12020. func (m *BatchImageJobMutation) ResetDownloadedAt() {
  12021. m.downloaded_at = nil
  12022. delete(m.clearedFields, batchimagejob.FieldDownloadedAt)
  12023. }
  12024. // SetUserDeletedAt sets the "user_deleted_at" field.
  12025. func (m *BatchImageJobMutation) SetUserDeletedAt(t time.Time) {
  12026. m.user_deleted_at = &t
  12027. }
  12028. // UserDeletedAt returns the value of the "user_deleted_at" field in the mutation.
  12029. func (m *BatchImageJobMutation) UserDeletedAt() (r time.Time, exists bool) {
  12030. v := m.user_deleted_at
  12031. if v == nil {
  12032. return
  12033. }
  12034. return *v, true
  12035. }
  12036. // OldUserDeletedAt returns the old "user_deleted_at" field's value of the BatchImageJob entity.
  12037. // If the BatchImageJob object wasn't provided to the builder, the object is fetched from the database.
  12038. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12039. func (m *BatchImageJobMutation) OldUserDeletedAt(ctx context.Context) (v *time.Time, err error) {
  12040. if !m.op.Is(OpUpdateOne) {
  12041. return v, errors.New("OldUserDeletedAt is only allowed on UpdateOne operations")
  12042. }
  12043. if m.id == nil || m.oldValue == nil {
  12044. return v, errors.New("OldUserDeletedAt requires an ID field in the mutation")
  12045. }
  12046. oldValue, err := m.oldValue(ctx)
  12047. if err != nil {
  12048. return v, fmt.Errorf("querying old value for OldUserDeletedAt: %w", err)
  12049. }
  12050. return oldValue.UserDeletedAt, nil
  12051. }
  12052. // ClearUserDeletedAt clears the value of the "user_deleted_at" field.
  12053. func (m *BatchImageJobMutation) ClearUserDeletedAt() {
  12054. m.user_deleted_at = nil
  12055. m.clearedFields[batchimagejob.FieldUserDeletedAt] = struct{}{}
  12056. }
  12057. // UserDeletedAtCleared returns if the "user_deleted_at" field was cleared in this mutation.
  12058. func (m *BatchImageJobMutation) UserDeletedAtCleared() bool {
  12059. _, ok := m.clearedFields[batchimagejob.FieldUserDeletedAt]
  12060. return ok
  12061. }
  12062. // ResetUserDeletedAt resets all changes to the "user_deleted_at" field.
  12063. func (m *BatchImageJobMutation) ResetUserDeletedAt() {
  12064. m.user_deleted_at = nil
  12065. delete(m.clearedFields, batchimagejob.FieldUserDeletedAt)
  12066. }
  12067. // SetLastErrorCode sets the "last_error_code" field.
  12068. func (m *BatchImageJobMutation) SetLastErrorCode(s string) {
  12069. m.last_error_code = &s
  12070. }
  12071. // LastErrorCode returns the value of the "last_error_code" field in the mutation.
  12072. func (m *BatchImageJobMutation) LastErrorCode() (r string, exists bool) {
  12073. v := m.last_error_code
  12074. if v == nil {
  12075. return
  12076. }
  12077. return *v, true
  12078. }
  12079. // OldLastErrorCode returns the old "last_error_code" field's value of the BatchImageJob entity.
  12080. // If the BatchImageJob object wasn't provided to the builder, the object is fetched from the database.
  12081. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12082. func (m *BatchImageJobMutation) OldLastErrorCode(ctx context.Context) (v *string, err error) {
  12083. if !m.op.Is(OpUpdateOne) {
  12084. return v, errors.New("OldLastErrorCode is only allowed on UpdateOne operations")
  12085. }
  12086. if m.id == nil || m.oldValue == nil {
  12087. return v, errors.New("OldLastErrorCode requires an ID field in the mutation")
  12088. }
  12089. oldValue, err := m.oldValue(ctx)
  12090. if err != nil {
  12091. return v, fmt.Errorf("querying old value for OldLastErrorCode: %w", err)
  12092. }
  12093. return oldValue.LastErrorCode, nil
  12094. }
  12095. // ClearLastErrorCode clears the value of the "last_error_code" field.
  12096. func (m *BatchImageJobMutation) ClearLastErrorCode() {
  12097. m.last_error_code = nil
  12098. m.clearedFields[batchimagejob.FieldLastErrorCode] = struct{}{}
  12099. }
  12100. // LastErrorCodeCleared returns if the "last_error_code" field was cleared in this mutation.
  12101. func (m *BatchImageJobMutation) LastErrorCodeCleared() bool {
  12102. _, ok := m.clearedFields[batchimagejob.FieldLastErrorCode]
  12103. return ok
  12104. }
  12105. // ResetLastErrorCode resets all changes to the "last_error_code" field.
  12106. func (m *BatchImageJobMutation) ResetLastErrorCode() {
  12107. m.last_error_code = nil
  12108. delete(m.clearedFields, batchimagejob.FieldLastErrorCode)
  12109. }
  12110. // SetLastErrorMessage sets the "last_error_message" field.
  12111. func (m *BatchImageJobMutation) SetLastErrorMessage(s string) {
  12112. m.last_error_message = &s
  12113. }
  12114. // LastErrorMessage returns the value of the "last_error_message" field in the mutation.
  12115. func (m *BatchImageJobMutation) LastErrorMessage() (r string, exists bool) {
  12116. v := m.last_error_message
  12117. if v == nil {
  12118. return
  12119. }
  12120. return *v, true
  12121. }
  12122. // OldLastErrorMessage returns the old "last_error_message" field's value of the BatchImageJob entity.
  12123. // If the BatchImageJob object wasn't provided to the builder, the object is fetched from the database.
  12124. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12125. func (m *BatchImageJobMutation) OldLastErrorMessage(ctx context.Context) (v *string, err error) {
  12126. if !m.op.Is(OpUpdateOne) {
  12127. return v, errors.New("OldLastErrorMessage is only allowed on UpdateOne operations")
  12128. }
  12129. if m.id == nil || m.oldValue == nil {
  12130. return v, errors.New("OldLastErrorMessage requires an ID field in the mutation")
  12131. }
  12132. oldValue, err := m.oldValue(ctx)
  12133. if err != nil {
  12134. return v, fmt.Errorf("querying old value for OldLastErrorMessage: %w", err)
  12135. }
  12136. return oldValue.LastErrorMessage, nil
  12137. }
  12138. // ClearLastErrorMessage clears the value of the "last_error_message" field.
  12139. func (m *BatchImageJobMutation) ClearLastErrorMessage() {
  12140. m.last_error_message = nil
  12141. m.clearedFields[batchimagejob.FieldLastErrorMessage] = struct{}{}
  12142. }
  12143. // LastErrorMessageCleared returns if the "last_error_message" field was cleared in this mutation.
  12144. func (m *BatchImageJobMutation) LastErrorMessageCleared() bool {
  12145. _, ok := m.clearedFields[batchimagejob.FieldLastErrorMessage]
  12146. return ok
  12147. }
  12148. // ResetLastErrorMessage resets all changes to the "last_error_message" field.
  12149. func (m *BatchImageJobMutation) ResetLastErrorMessage() {
  12150. m.last_error_message = nil
  12151. delete(m.clearedFields, batchimagejob.FieldLastErrorMessage)
  12152. }
  12153. // SetCreatedAt sets the "created_at" field.
  12154. func (m *BatchImageJobMutation) SetCreatedAt(t time.Time) {
  12155. m.created_at = &t
  12156. }
  12157. // CreatedAt returns the value of the "created_at" field in the mutation.
  12158. func (m *BatchImageJobMutation) CreatedAt() (r time.Time, exists bool) {
  12159. v := m.created_at
  12160. if v == nil {
  12161. return
  12162. }
  12163. return *v, true
  12164. }
  12165. // OldCreatedAt returns the old "created_at" field's value of the BatchImageJob entity.
  12166. // If the BatchImageJob object wasn't provided to the builder, the object is fetched from the database.
  12167. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12168. func (m *BatchImageJobMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  12169. if !m.op.Is(OpUpdateOne) {
  12170. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  12171. }
  12172. if m.id == nil || m.oldValue == nil {
  12173. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  12174. }
  12175. oldValue, err := m.oldValue(ctx)
  12176. if err != nil {
  12177. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  12178. }
  12179. return oldValue.CreatedAt, nil
  12180. }
  12181. // ResetCreatedAt resets all changes to the "created_at" field.
  12182. func (m *BatchImageJobMutation) ResetCreatedAt() {
  12183. m.created_at = nil
  12184. }
  12185. // SetUpdatedAt sets the "updated_at" field.
  12186. func (m *BatchImageJobMutation) SetUpdatedAt(t time.Time) {
  12187. m.updated_at = &t
  12188. }
  12189. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  12190. func (m *BatchImageJobMutation) UpdatedAt() (r time.Time, exists bool) {
  12191. v := m.updated_at
  12192. if v == nil {
  12193. return
  12194. }
  12195. return *v, true
  12196. }
  12197. // OldUpdatedAt returns the old "updated_at" field's value of the BatchImageJob entity.
  12198. // If the BatchImageJob object wasn't provided to the builder, the object is fetched from the database.
  12199. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12200. func (m *BatchImageJobMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  12201. if !m.op.Is(OpUpdateOne) {
  12202. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  12203. }
  12204. if m.id == nil || m.oldValue == nil {
  12205. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  12206. }
  12207. oldValue, err := m.oldValue(ctx)
  12208. if err != nil {
  12209. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  12210. }
  12211. return oldValue.UpdatedAt, nil
  12212. }
  12213. // ResetUpdatedAt resets all changes to the "updated_at" field.
  12214. func (m *BatchImageJobMutation) ResetUpdatedAt() {
  12215. m.updated_at = nil
  12216. }
  12217. // SetSubmittedAt sets the "submitted_at" field.
  12218. func (m *BatchImageJobMutation) SetSubmittedAt(t time.Time) {
  12219. m.submitted_at = &t
  12220. }
  12221. // SubmittedAt returns the value of the "submitted_at" field in the mutation.
  12222. func (m *BatchImageJobMutation) SubmittedAt() (r time.Time, exists bool) {
  12223. v := m.submitted_at
  12224. if v == nil {
  12225. return
  12226. }
  12227. return *v, true
  12228. }
  12229. // OldSubmittedAt returns the old "submitted_at" field's value of the BatchImageJob entity.
  12230. // If the BatchImageJob object wasn't provided to the builder, the object is fetched from the database.
  12231. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12232. func (m *BatchImageJobMutation) OldSubmittedAt(ctx context.Context) (v *time.Time, err error) {
  12233. if !m.op.Is(OpUpdateOne) {
  12234. return v, errors.New("OldSubmittedAt is only allowed on UpdateOne operations")
  12235. }
  12236. if m.id == nil || m.oldValue == nil {
  12237. return v, errors.New("OldSubmittedAt requires an ID field in the mutation")
  12238. }
  12239. oldValue, err := m.oldValue(ctx)
  12240. if err != nil {
  12241. return v, fmt.Errorf("querying old value for OldSubmittedAt: %w", err)
  12242. }
  12243. return oldValue.SubmittedAt, nil
  12244. }
  12245. // ClearSubmittedAt clears the value of the "submitted_at" field.
  12246. func (m *BatchImageJobMutation) ClearSubmittedAt() {
  12247. m.submitted_at = nil
  12248. m.clearedFields[batchimagejob.FieldSubmittedAt] = struct{}{}
  12249. }
  12250. // SubmittedAtCleared returns if the "submitted_at" field was cleared in this mutation.
  12251. func (m *BatchImageJobMutation) SubmittedAtCleared() bool {
  12252. _, ok := m.clearedFields[batchimagejob.FieldSubmittedAt]
  12253. return ok
  12254. }
  12255. // ResetSubmittedAt resets all changes to the "submitted_at" field.
  12256. func (m *BatchImageJobMutation) ResetSubmittedAt() {
  12257. m.submitted_at = nil
  12258. delete(m.clearedFields, batchimagejob.FieldSubmittedAt)
  12259. }
  12260. // SetStartedAt sets the "started_at" field.
  12261. func (m *BatchImageJobMutation) SetStartedAt(t time.Time) {
  12262. m.started_at = &t
  12263. }
  12264. // StartedAt returns the value of the "started_at" field in the mutation.
  12265. func (m *BatchImageJobMutation) StartedAt() (r time.Time, exists bool) {
  12266. v := m.started_at
  12267. if v == nil {
  12268. return
  12269. }
  12270. return *v, true
  12271. }
  12272. // OldStartedAt returns the old "started_at" field's value of the BatchImageJob entity.
  12273. // If the BatchImageJob object wasn't provided to the builder, the object is fetched from the database.
  12274. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12275. func (m *BatchImageJobMutation) OldStartedAt(ctx context.Context) (v *time.Time, err error) {
  12276. if !m.op.Is(OpUpdateOne) {
  12277. return v, errors.New("OldStartedAt is only allowed on UpdateOne operations")
  12278. }
  12279. if m.id == nil || m.oldValue == nil {
  12280. return v, errors.New("OldStartedAt requires an ID field in the mutation")
  12281. }
  12282. oldValue, err := m.oldValue(ctx)
  12283. if err != nil {
  12284. return v, fmt.Errorf("querying old value for OldStartedAt: %w", err)
  12285. }
  12286. return oldValue.StartedAt, nil
  12287. }
  12288. // ClearStartedAt clears the value of the "started_at" field.
  12289. func (m *BatchImageJobMutation) ClearStartedAt() {
  12290. m.started_at = nil
  12291. m.clearedFields[batchimagejob.FieldStartedAt] = struct{}{}
  12292. }
  12293. // StartedAtCleared returns if the "started_at" field was cleared in this mutation.
  12294. func (m *BatchImageJobMutation) StartedAtCleared() bool {
  12295. _, ok := m.clearedFields[batchimagejob.FieldStartedAt]
  12296. return ok
  12297. }
  12298. // ResetStartedAt resets all changes to the "started_at" field.
  12299. func (m *BatchImageJobMutation) ResetStartedAt() {
  12300. m.started_at = nil
  12301. delete(m.clearedFields, batchimagejob.FieldStartedAt)
  12302. }
  12303. // SetFinishedAt sets the "finished_at" field.
  12304. func (m *BatchImageJobMutation) SetFinishedAt(t time.Time) {
  12305. m.finished_at = &t
  12306. }
  12307. // FinishedAt returns the value of the "finished_at" field in the mutation.
  12308. func (m *BatchImageJobMutation) FinishedAt() (r time.Time, exists bool) {
  12309. v := m.finished_at
  12310. if v == nil {
  12311. return
  12312. }
  12313. return *v, true
  12314. }
  12315. // OldFinishedAt returns the old "finished_at" field's value of the BatchImageJob entity.
  12316. // If the BatchImageJob object wasn't provided to the builder, the object is fetched from the database.
  12317. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12318. func (m *BatchImageJobMutation) OldFinishedAt(ctx context.Context) (v *time.Time, err error) {
  12319. if !m.op.Is(OpUpdateOne) {
  12320. return v, errors.New("OldFinishedAt is only allowed on UpdateOne operations")
  12321. }
  12322. if m.id == nil || m.oldValue == nil {
  12323. return v, errors.New("OldFinishedAt requires an ID field in the mutation")
  12324. }
  12325. oldValue, err := m.oldValue(ctx)
  12326. if err != nil {
  12327. return v, fmt.Errorf("querying old value for OldFinishedAt: %w", err)
  12328. }
  12329. return oldValue.FinishedAt, nil
  12330. }
  12331. // ClearFinishedAt clears the value of the "finished_at" field.
  12332. func (m *BatchImageJobMutation) ClearFinishedAt() {
  12333. m.finished_at = nil
  12334. m.clearedFields[batchimagejob.FieldFinishedAt] = struct{}{}
  12335. }
  12336. // FinishedAtCleared returns if the "finished_at" field was cleared in this mutation.
  12337. func (m *BatchImageJobMutation) FinishedAtCleared() bool {
  12338. _, ok := m.clearedFields[batchimagejob.FieldFinishedAt]
  12339. return ok
  12340. }
  12341. // ResetFinishedAt resets all changes to the "finished_at" field.
  12342. func (m *BatchImageJobMutation) ResetFinishedAt() {
  12343. m.finished_at = nil
  12344. delete(m.clearedFields, batchimagejob.FieldFinishedAt)
  12345. }
  12346. // SetSettledAt sets the "settled_at" field.
  12347. func (m *BatchImageJobMutation) SetSettledAt(t time.Time) {
  12348. m.settled_at = &t
  12349. }
  12350. // SettledAt returns the value of the "settled_at" field in the mutation.
  12351. func (m *BatchImageJobMutation) SettledAt() (r time.Time, exists bool) {
  12352. v := m.settled_at
  12353. if v == nil {
  12354. return
  12355. }
  12356. return *v, true
  12357. }
  12358. // OldSettledAt returns the old "settled_at" field's value of the BatchImageJob entity.
  12359. // If the BatchImageJob object wasn't provided to the builder, the object is fetched from the database.
  12360. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12361. func (m *BatchImageJobMutation) OldSettledAt(ctx context.Context) (v *time.Time, err error) {
  12362. if !m.op.Is(OpUpdateOne) {
  12363. return v, errors.New("OldSettledAt is only allowed on UpdateOne operations")
  12364. }
  12365. if m.id == nil || m.oldValue == nil {
  12366. return v, errors.New("OldSettledAt requires an ID field in the mutation")
  12367. }
  12368. oldValue, err := m.oldValue(ctx)
  12369. if err != nil {
  12370. return v, fmt.Errorf("querying old value for OldSettledAt: %w", err)
  12371. }
  12372. return oldValue.SettledAt, nil
  12373. }
  12374. // ClearSettledAt clears the value of the "settled_at" field.
  12375. func (m *BatchImageJobMutation) ClearSettledAt() {
  12376. m.settled_at = nil
  12377. m.clearedFields[batchimagejob.FieldSettledAt] = struct{}{}
  12378. }
  12379. // SettledAtCleared returns if the "settled_at" field was cleared in this mutation.
  12380. func (m *BatchImageJobMutation) SettledAtCleared() bool {
  12381. _, ok := m.clearedFields[batchimagejob.FieldSettledAt]
  12382. return ok
  12383. }
  12384. // ResetSettledAt resets all changes to the "settled_at" field.
  12385. func (m *BatchImageJobMutation) ResetSettledAt() {
  12386. m.settled_at = nil
  12387. delete(m.clearedFields, batchimagejob.FieldSettledAt)
  12388. }
  12389. // Where appends a list predicates to the BatchImageJobMutation builder.
  12390. func (m *BatchImageJobMutation) Where(ps ...predicate.BatchImageJob) {
  12391. m.predicates = append(m.predicates, ps...)
  12392. }
  12393. // WhereP appends storage-level predicates to the BatchImageJobMutation builder. Using this method,
  12394. // users can use type-assertion to append predicates that do not depend on any generated package.
  12395. func (m *BatchImageJobMutation) WhereP(ps ...func(*sql.Selector)) {
  12396. p := make([]predicate.BatchImageJob, len(ps))
  12397. for i := range ps {
  12398. p[i] = ps[i]
  12399. }
  12400. m.Where(p...)
  12401. }
  12402. // Op returns the operation name.
  12403. func (m *BatchImageJobMutation) Op() Op {
  12404. return m.op
  12405. }
  12406. // SetOp allows setting the mutation operation.
  12407. func (m *BatchImageJobMutation) SetOp(op Op) {
  12408. m.op = op
  12409. }
  12410. // Type returns the node type of this mutation (BatchImageJob).
  12411. func (m *BatchImageJobMutation) Type() string {
  12412. return m.typ
  12413. }
  12414. // Fields returns all fields that were changed during this mutation. Note that in
  12415. // order to get all numeric fields that were incremented/decremented, call
  12416. // AddedFields().
  12417. func (m *BatchImageJobMutation) Fields() []string {
  12418. fields := make([]string, 0, 40)
  12419. if m.batch_id != nil {
  12420. fields = append(fields, batchimagejob.FieldBatchID)
  12421. }
  12422. if m.user_id != nil {
  12423. fields = append(fields, batchimagejob.FieldUserID)
  12424. }
  12425. if m.api_key_id != nil {
  12426. fields = append(fields, batchimagejob.FieldAPIKeyID)
  12427. }
  12428. if m.account_id != nil {
  12429. fields = append(fields, batchimagejob.FieldAccountID)
  12430. }
  12431. if m.provider != nil {
  12432. fields = append(fields, batchimagejob.FieldProvider)
  12433. }
  12434. if m.model != nil {
  12435. fields = append(fields, batchimagejob.FieldModel)
  12436. }
  12437. if m.task_name != nil {
  12438. fields = append(fields, batchimagejob.FieldTaskName)
  12439. }
  12440. if m.status != nil {
  12441. fields = append(fields, batchimagejob.FieldStatus)
  12442. }
  12443. if m.provider_job_name != nil {
  12444. fields = append(fields, batchimagejob.FieldProviderJobName)
  12445. }
  12446. if m.provider_input_ref != nil {
  12447. fields = append(fields, batchimagejob.FieldProviderInputRef)
  12448. }
  12449. if m.provider_output_ref != nil {
  12450. fields = append(fields, batchimagejob.FieldProviderOutputRef)
  12451. }
  12452. if m.gcs_input_uri != nil {
  12453. fields = append(fields, batchimagejob.FieldGcsInputURI)
  12454. }
  12455. if m.gcs_output_uri != nil {
  12456. fields = append(fields, batchimagejob.FieldGcsOutputURI)
  12457. }
  12458. if m.item_count != nil {
  12459. fields = append(fields, batchimagejob.FieldItemCount)
  12460. }
  12461. if m.success_count != nil {
  12462. fields = append(fields, batchimagejob.FieldSuccessCount)
  12463. }
  12464. if m.fail_count != nil {
  12465. fields = append(fields, batchimagejob.FieldFailCount)
  12466. }
  12467. if m.cancelled_count != nil {
  12468. fields = append(fields, batchimagejob.FieldCancelledCount)
  12469. }
  12470. if m.estimated_cost != nil {
  12471. fields = append(fields, batchimagejob.FieldEstimatedCost)
  12472. }
  12473. if m.hold_amount != nil {
  12474. fields = append(fields, batchimagejob.FieldHoldAmount)
  12475. }
  12476. if m.actual_cost != nil {
  12477. fields = append(fields, batchimagejob.FieldActualCost)
  12478. }
  12479. if m.currency != nil {
  12480. fields = append(fields, batchimagejob.FieldCurrency)
  12481. }
  12482. if m.hold_id != nil {
  12483. fields = append(fields, batchimagejob.FieldHoldID)
  12484. }
  12485. if m.idempotency_key != nil {
  12486. fields = append(fields, batchimagejob.FieldIdempotencyKey)
  12487. }
  12488. if m.request_hash != nil {
  12489. fields = append(fields, batchimagejob.FieldRequestHash)
  12490. }
  12491. if m.manifest_hash != nil {
  12492. fields = append(fields, batchimagejob.FieldManifestHash)
  12493. }
  12494. if m.retry_count != nil {
  12495. fields = append(fields, batchimagejob.FieldRetryCount)
  12496. }
  12497. if m.version != nil {
  12498. fields = append(fields, batchimagejob.FieldVersion)
  12499. }
  12500. if m.output_expires_at != nil {
  12501. fields = append(fields, batchimagejob.FieldOutputExpiresAt)
  12502. }
  12503. if m.input_deleted_at != nil {
  12504. fields = append(fields, batchimagejob.FieldInputDeletedAt)
  12505. }
  12506. if m.output_deleted_at != nil {
  12507. fields = append(fields, batchimagejob.FieldOutputDeletedAt)
  12508. }
  12509. if m.downloaded_at != nil {
  12510. fields = append(fields, batchimagejob.FieldDownloadedAt)
  12511. }
  12512. if m.user_deleted_at != nil {
  12513. fields = append(fields, batchimagejob.FieldUserDeletedAt)
  12514. }
  12515. if m.last_error_code != nil {
  12516. fields = append(fields, batchimagejob.FieldLastErrorCode)
  12517. }
  12518. if m.last_error_message != nil {
  12519. fields = append(fields, batchimagejob.FieldLastErrorMessage)
  12520. }
  12521. if m.created_at != nil {
  12522. fields = append(fields, batchimagejob.FieldCreatedAt)
  12523. }
  12524. if m.updated_at != nil {
  12525. fields = append(fields, batchimagejob.FieldUpdatedAt)
  12526. }
  12527. if m.submitted_at != nil {
  12528. fields = append(fields, batchimagejob.FieldSubmittedAt)
  12529. }
  12530. if m.started_at != nil {
  12531. fields = append(fields, batchimagejob.FieldStartedAt)
  12532. }
  12533. if m.finished_at != nil {
  12534. fields = append(fields, batchimagejob.FieldFinishedAt)
  12535. }
  12536. if m.settled_at != nil {
  12537. fields = append(fields, batchimagejob.FieldSettledAt)
  12538. }
  12539. return fields
  12540. }
  12541. // Field returns the value of a field with the given name. The second boolean
  12542. // return value indicates that this field was not set, or was not defined in the
  12543. // schema.
  12544. func (m *BatchImageJobMutation) Field(name string) (ent.Value, bool) {
  12545. switch name {
  12546. case batchimagejob.FieldBatchID:
  12547. return m.BatchID()
  12548. case batchimagejob.FieldUserID:
  12549. return m.UserID()
  12550. case batchimagejob.FieldAPIKeyID:
  12551. return m.APIKeyID()
  12552. case batchimagejob.FieldAccountID:
  12553. return m.AccountID()
  12554. case batchimagejob.FieldProvider:
  12555. return m.Provider()
  12556. case batchimagejob.FieldModel:
  12557. return m.Model()
  12558. case batchimagejob.FieldTaskName:
  12559. return m.TaskName()
  12560. case batchimagejob.FieldStatus:
  12561. return m.Status()
  12562. case batchimagejob.FieldProviderJobName:
  12563. return m.ProviderJobName()
  12564. case batchimagejob.FieldProviderInputRef:
  12565. return m.ProviderInputRef()
  12566. case batchimagejob.FieldProviderOutputRef:
  12567. return m.ProviderOutputRef()
  12568. case batchimagejob.FieldGcsInputURI:
  12569. return m.GcsInputURI()
  12570. case batchimagejob.FieldGcsOutputURI:
  12571. return m.GcsOutputURI()
  12572. case batchimagejob.FieldItemCount:
  12573. return m.ItemCount()
  12574. case batchimagejob.FieldSuccessCount:
  12575. return m.SuccessCount()
  12576. case batchimagejob.FieldFailCount:
  12577. return m.FailCount()
  12578. case batchimagejob.FieldCancelledCount:
  12579. return m.CancelledCount()
  12580. case batchimagejob.FieldEstimatedCost:
  12581. return m.EstimatedCost()
  12582. case batchimagejob.FieldHoldAmount:
  12583. return m.HoldAmount()
  12584. case batchimagejob.FieldActualCost:
  12585. return m.ActualCost()
  12586. case batchimagejob.FieldCurrency:
  12587. return m.Currency()
  12588. case batchimagejob.FieldHoldID:
  12589. return m.HoldID()
  12590. case batchimagejob.FieldIdempotencyKey:
  12591. return m.IdempotencyKey()
  12592. case batchimagejob.FieldRequestHash:
  12593. return m.RequestHash()
  12594. case batchimagejob.FieldManifestHash:
  12595. return m.ManifestHash()
  12596. case batchimagejob.FieldRetryCount:
  12597. return m.RetryCount()
  12598. case batchimagejob.FieldVersion:
  12599. return m.Version()
  12600. case batchimagejob.FieldOutputExpiresAt:
  12601. return m.OutputExpiresAt()
  12602. case batchimagejob.FieldInputDeletedAt:
  12603. return m.InputDeletedAt()
  12604. case batchimagejob.FieldOutputDeletedAt:
  12605. return m.OutputDeletedAt()
  12606. case batchimagejob.FieldDownloadedAt:
  12607. return m.DownloadedAt()
  12608. case batchimagejob.FieldUserDeletedAt:
  12609. return m.UserDeletedAt()
  12610. case batchimagejob.FieldLastErrorCode:
  12611. return m.LastErrorCode()
  12612. case batchimagejob.FieldLastErrorMessage:
  12613. return m.LastErrorMessage()
  12614. case batchimagejob.FieldCreatedAt:
  12615. return m.CreatedAt()
  12616. case batchimagejob.FieldUpdatedAt:
  12617. return m.UpdatedAt()
  12618. case batchimagejob.FieldSubmittedAt:
  12619. return m.SubmittedAt()
  12620. case batchimagejob.FieldStartedAt:
  12621. return m.StartedAt()
  12622. case batchimagejob.FieldFinishedAt:
  12623. return m.FinishedAt()
  12624. case batchimagejob.FieldSettledAt:
  12625. return m.SettledAt()
  12626. }
  12627. return nil, false
  12628. }
  12629. // OldField returns the old value of the field from the database. An error is
  12630. // returned if the mutation operation is not UpdateOne, or the query to the
  12631. // database failed.
  12632. func (m *BatchImageJobMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  12633. switch name {
  12634. case batchimagejob.FieldBatchID:
  12635. return m.OldBatchID(ctx)
  12636. case batchimagejob.FieldUserID:
  12637. return m.OldUserID(ctx)
  12638. case batchimagejob.FieldAPIKeyID:
  12639. return m.OldAPIKeyID(ctx)
  12640. case batchimagejob.FieldAccountID:
  12641. return m.OldAccountID(ctx)
  12642. case batchimagejob.FieldProvider:
  12643. return m.OldProvider(ctx)
  12644. case batchimagejob.FieldModel:
  12645. return m.OldModel(ctx)
  12646. case batchimagejob.FieldTaskName:
  12647. return m.OldTaskName(ctx)
  12648. case batchimagejob.FieldStatus:
  12649. return m.OldStatus(ctx)
  12650. case batchimagejob.FieldProviderJobName:
  12651. return m.OldProviderJobName(ctx)
  12652. case batchimagejob.FieldProviderInputRef:
  12653. return m.OldProviderInputRef(ctx)
  12654. case batchimagejob.FieldProviderOutputRef:
  12655. return m.OldProviderOutputRef(ctx)
  12656. case batchimagejob.FieldGcsInputURI:
  12657. return m.OldGcsInputURI(ctx)
  12658. case batchimagejob.FieldGcsOutputURI:
  12659. return m.OldGcsOutputURI(ctx)
  12660. case batchimagejob.FieldItemCount:
  12661. return m.OldItemCount(ctx)
  12662. case batchimagejob.FieldSuccessCount:
  12663. return m.OldSuccessCount(ctx)
  12664. case batchimagejob.FieldFailCount:
  12665. return m.OldFailCount(ctx)
  12666. case batchimagejob.FieldCancelledCount:
  12667. return m.OldCancelledCount(ctx)
  12668. case batchimagejob.FieldEstimatedCost:
  12669. return m.OldEstimatedCost(ctx)
  12670. case batchimagejob.FieldHoldAmount:
  12671. return m.OldHoldAmount(ctx)
  12672. case batchimagejob.FieldActualCost:
  12673. return m.OldActualCost(ctx)
  12674. case batchimagejob.FieldCurrency:
  12675. return m.OldCurrency(ctx)
  12676. case batchimagejob.FieldHoldID:
  12677. return m.OldHoldID(ctx)
  12678. case batchimagejob.FieldIdempotencyKey:
  12679. return m.OldIdempotencyKey(ctx)
  12680. case batchimagejob.FieldRequestHash:
  12681. return m.OldRequestHash(ctx)
  12682. case batchimagejob.FieldManifestHash:
  12683. return m.OldManifestHash(ctx)
  12684. case batchimagejob.FieldRetryCount:
  12685. return m.OldRetryCount(ctx)
  12686. case batchimagejob.FieldVersion:
  12687. return m.OldVersion(ctx)
  12688. case batchimagejob.FieldOutputExpiresAt:
  12689. return m.OldOutputExpiresAt(ctx)
  12690. case batchimagejob.FieldInputDeletedAt:
  12691. return m.OldInputDeletedAt(ctx)
  12692. case batchimagejob.FieldOutputDeletedAt:
  12693. return m.OldOutputDeletedAt(ctx)
  12694. case batchimagejob.FieldDownloadedAt:
  12695. return m.OldDownloadedAt(ctx)
  12696. case batchimagejob.FieldUserDeletedAt:
  12697. return m.OldUserDeletedAt(ctx)
  12698. case batchimagejob.FieldLastErrorCode:
  12699. return m.OldLastErrorCode(ctx)
  12700. case batchimagejob.FieldLastErrorMessage:
  12701. return m.OldLastErrorMessage(ctx)
  12702. case batchimagejob.FieldCreatedAt:
  12703. return m.OldCreatedAt(ctx)
  12704. case batchimagejob.FieldUpdatedAt:
  12705. return m.OldUpdatedAt(ctx)
  12706. case batchimagejob.FieldSubmittedAt:
  12707. return m.OldSubmittedAt(ctx)
  12708. case batchimagejob.FieldStartedAt:
  12709. return m.OldStartedAt(ctx)
  12710. case batchimagejob.FieldFinishedAt:
  12711. return m.OldFinishedAt(ctx)
  12712. case batchimagejob.FieldSettledAt:
  12713. return m.OldSettledAt(ctx)
  12714. }
  12715. return nil, fmt.Errorf("unknown BatchImageJob field %s", name)
  12716. }
  12717. // SetField sets the value of a field with the given name. It returns an error if
  12718. // the field is not defined in the schema, or if the type mismatched the field
  12719. // type.
  12720. func (m *BatchImageJobMutation) SetField(name string, value ent.Value) error {
  12721. switch name {
  12722. case batchimagejob.FieldBatchID:
  12723. v, ok := value.(string)
  12724. if !ok {
  12725. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12726. }
  12727. m.SetBatchID(v)
  12728. return nil
  12729. case batchimagejob.FieldUserID:
  12730. v, ok := value.(int64)
  12731. if !ok {
  12732. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12733. }
  12734. m.SetUserID(v)
  12735. return nil
  12736. case batchimagejob.FieldAPIKeyID:
  12737. v, ok := value.(int64)
  12738. if !ok {
  12739. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12740. }
  12741. m.SetAPIKeyID(v)
  12742. return nil
  12743. case batchimagejob.FieldAccountID:
  12744. v, ok := value.(int64)
  12745. if !ok {
  12746. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12747. }
  12748. m.SetAccountID(v)
  12749. return nil
  12750. case batchimagejob.FieldProvider:
  12751. v, ok := value.(string)
  12752. if !ok {
  12753. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12754. }
  12755. m.SetProvider(v)
  12756. return nil
  12757. case batchimagejob.FieldModel:
  12758. v, ok := value.(string)
  12759. if !ok {
  12760. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12761. }
  12762. m.SetModel(v)
  12763. return nil
  12764. case batchimagejob.FieldTaskName:
  12765. v, ok := value.(string)
  12766. if !ok {
  12767. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12768. }
  12769. m.SetTaskName(v)
  12770. return nil
  12771. case batchimagejob.FieldStatus:
  12772. v, ok := value.(string)
  12773. if !ok {
  12774. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12775. }
  12776. m.SetStatus(v)
  12777. return nil
  12778. case batchimagejob.FieldProviderJobName:
  12779. v, ok := value.(string)
  12780. if !ok {
  12781. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12782. }
  12783. m.SetProviderJobName(v)
  12784. return nil
  12785. case batchimagejob.FieldProviderInputRef:
  12786. v, ok := value.(string)
  12787. if !ok {
  12788. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12789. }
  12790. m.SetProviderInputRef(v)
  12791. return nil
  12792. case batchimagejob.FieldProviderOutputRef:
  12793. v, ok := value.(string)
  12794. if !ok {
  12795. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12796. }
  12797. m.SetProviderOutputRef(v)
  12798. return nil
  12799. case batchimagejob.FieldGcsInputURI:
  12800. v, ok := value.(string)
  12801. if !ok {
  12802. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12803. }
  12804. m.SetGcsInputURI(v)
  12805. return nil
  12806. case batchimagejob.FieldGcsOutputURI:
  12807. v, ok := value.(string)
  12808. if !ok {
  12809. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12810. }
  12811. m.SetGcsOutputURI(v)
  12812. return nil
  12813. case batchimagejob.FieldItemCount:
  12814. v, ok := value.(int)
  12815. if !ok {
  12816. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12817. }
  12818. m.SetItemCount(v)
  12819. return nil
  12820. case batchimagejob.FieldSuccessCount:
  12821. v, ok := value.(int)
  12822. if !ok {
  12823. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12824. }
  12825. m.SetSuccessCount(v)
  12826. return nil
  12827. case batchimagejob.FieldFailCount:
  12828. v, ok := value.(int)
  12829. if !ok {
  12830. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12831. }
  12832. m.SetFailCount(v)
  12833. return nil
  12834. case batchimagejob.FieldCancelledCount:
  12835. v, ok := value.(int)
  12836. if !ok {
  12837. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12838. }
  12839. m.SetCancelledCount(v)
  12840. return nil
  12841. case batchimagejob.FieldEstimatedCost:
  12842. v, ok := value.(float64)
  12843. if !ok {
  12844. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12845. }
  12846. m.SetEstimatedCost(v)
  12847. return nil
  12848. case batchimagejob.FieldHoldAmount:
  12849. v, ok := value.(float64)
  12850. if !ok {
  12851. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12852. }
  12853. m.SetHoldAmount(v)
  12854. return nil
  12855. case batchimagejob.FieldActualCost:
  12856. v, ok := value.(float64)
  12857. if !ok {
  12858. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12859. }
  12860. m.SetActualCost(v)
  12861. return nil
  12862. case batchimagejob.FieldCurrency:
  12863. v, ok := value.(string)
  12864. if !ok {
  12865. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12866. }
  12867. m.SetCurrency(v)
  12868. return nil
  12869. case batchimagejob.FieldHoldID:
  12870. v, ok := value.(string)
  12871. if !ok {
  12872. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12873. }
  12874. m.SetHoldID(v)
  12875. return nil
  12876. case batchimagejob.FieldIdempotencyKey:
  12877. v, ok := value.(string)
  12878. if !ok {
  12879. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12880. }
  12881. m.SetIdempotencyKey(v)
  12882. return nil
  12883. case batchimagejob.FieldRequestHash:
  12884. v, ok := value.(string)
  12885. if !ok {
  12886. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12887. }
  12888. m.SetRequestHash(v)
  12889. return nil
  12890. case batchimagejob.FieldManifestHash:
  12891. v, ok := value.(string)
  12892. if !ok {
  12893. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12894. }
  12895. m.SetManifestHash(v)
  12896. return nil
  12897. case batchimagejob.FieldRetryCount:
  12898. v, ok := value.(int)
  12899. if !ok {
  12900. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12901. }
  12902. m.SetRetryCount(v)
  12903. return nil
  12904. case batchimagejob.FieldVersion:
  12905. v, ok := value.(int)
  12906. if !ok {
  12907. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12908. }
  12909. m.SetVersion(v)
  12910. return nil
  12911. case batchimagejob.FieldOutputExpiresAt:
  12912. v, ok := value.(time.Time)
  12913. if !ok {
  12914. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12915. }
  12916. m.SetOutputExpiresAt(v)
  12917. return nil
  12918. case batchimagejob.FieldInputDeletedAt:
  12919. v, ok := value.(time.Time)
  12920. if !ok {
  12921. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12922. }
  12923. m.SetInputDeletedAt(v)
  12924. return nil
  12925. case batchimagejob.FieldOutputDeletedAt:
  12926. v, ok := value.(time.Time)
  12927. if !ok {
  12928. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12929. }
  12930. m.SetOutputDeletedAt(v)
  12931. return nil
  12932. case batchimagejob.FieldDownloadedAt:
  12933. v, ok := value.(time.Time)
  12934. if !ok {
  12935. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12936. }
  12937. m.SetDownloadedAt(v)
  12938. return nil
  12939. case batchimagejob.FieldUserDeletedAt:
  12940. v, ok := value.(time.Time)
  12941. if !ok {
  12942. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12943. }
  12944. m.SetUserDeletedAt(v)
  12945. return nil
  12946. case batchimagejob.FieldLastErrorCode:
  12947. v, ok := value.(string)
  12948. if !ok {
  12949. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12950. }
  12951. m.SetLastErrorCode(v)
  12952. return nil
  12953. case batchimagejob.FieldLastErrorMessage:
  12954. v, ok := value.(string)
  12955. if !ok {
  12956. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12957. }
  12958. m.SetLastErrorMessage(v)
  12959. return nil
  12960. case batchimagejob.FieldCreatedAt:
  12961. v, ok := value.(time.Time)
  12962. if !ok {
  12963. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12964. }
  12965. m.SetCreatedAt(v)
  12966. return nil
  12967. case batchimagejob.FieldUpdatedAt:
  12968. v, ok := value.(time.Time)
  12969. if !ok {
  12970. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12971. }
  12972. m.SetUpdatedAt(v)
  12973. return nil
  12974. case batchimagejob.FieldSubmittedAt:
  12975. v, ok := value.(time.Time)
  12976. if !ok {
  12977. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12978. }
  12979. m.SetSubmittedAt(v)
  12980. return nil
  12981. case batchimagejob.FieldStartedAt:
  12982. v, ok := value.(time.Time)
  12983. if !ok {
  12984. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12985. }
  12986. m.SetStartedAt(v)
  12987. return nil
  12988. case batchimagejob.FieldFinishedAt:
  12989. v, ok := value.(time.Time)
  12990. if !ok {
  12991. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12992. }
  12993. m.SetFinishedAt(v)
  12994. return nil
  12995. case batchimagejob.FieldSettledAt:
  12996. v, ok := value.(time.Time)
  12997. if !ok {
  12998. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12999. }
  13000. m.SetSettledAt(v)
  13001. return nil
  13002. }
  13003. return fmt.Errorf("unknown BatchImageJob field %s", name)
  13004. }
  13005. // AddedFields returns all numeric fields that were incremented/decremented during
  13006. // this mutation.
  13007. func (m *BatchImageJobMutation) AddedFields() []string {
  13008. var fields []string
  13009. if m.adduser_id != nil {
  13010. fields = append(fields, batchimagejob.FieldUserID)
  13011. }
  13012. if m.addapi_key_id != nil {
  13013. fields = append(fields, batchimagejob.FieldAPIKeyID)
  13014. }
  13015. if m.addaccount_id != nil {
  13016. fields = append(fields, batchimagejob.FieldAccountID)
  13017. }
  13018. if m.additem_count != nil {
  13019. fields = append(fields, batchimagejob.FieldItemCount)
  13020. }
  13021. if m.addsuccess_count != nil {
  13022. fields = append(fields, batchimagejob.FieldSuccessCount)
  13023. }
  13024. if m.addfail_count != nil {
  13025. fields = append(fields, batchimagejob.FieldFailCount)
  13026. }
  13027. if m.addcancelled_count != nil {
  13028. fields = append(fields, batchimagejob.FieldCancelledCount)
  13029. }
  13030. if m.addestimated_cost != nil {
  13031. fields = append(fields, batchimagejob.FieldEstimatedCost)
  13032. }
  13033. if m.addhold_amount != nil {
  13034. fields = append(fields, batchimagejob.FieldHoldAmount)
  13035. }
  13036. if m.addactual_cost != nil {
  13037. fields = append(fields, batchimagejob.FieldActualCost)
  13038. }
  13039. if m.addretry_count != nil {
  13040. fields = append(fields, batchimagejob.FieldRetryCount)
  13041. }
  13042. if m.addversion != nil {
  13043. fields = append(fields, batchimagejob.FieldVersion)
  13044. }
  13045. return fields
  13046. }
  13047. // AddedField returns the numeric value that was incremented/decremented on a field
  13048. // with the given name. The second boolean return value indicates that this field
  13049. // was not set, or was not defined in the schema.
  13050. func (m *BatchImageJobMutation) AddedField(name string) (ent.Value, bool) {
  13051. switch name {
  13052. case batchimagejob.FieldUserID:
  13053. return m.AddedUserID()
  13054. case batchimagejob.FieldAPIKeyID:
  13055. return m.AddedAPIKeyID()
  13056. case batchimagejob.FieldAccountID:
  13057. return m.AddedAccountID()
  13058. case batchimagejob.FieldItemCount:
  13059. return m.AddedItemCount()
  13060. case batchimagejob.FieldSuccessCount:
  13061. return m.AddedSuccessCount()
  13062. case batchimagejob.FieldFailCount:
  13063. return m.AddedFailCount()
  13064. case batchimagejob.FieldCancelledCount:
  13065. return m.AddedCancelledCount()
  13066. case batchimagejob.FieldEstimatedCost:
  13067. return m.AddedEstimatedCost()
  13068. case batchimagejob.FieldHoldAmount:
  13069. return m.AddedHoldAmount()
  13070. case batchimagejob.FieldActualCost:
  13071. return m.AddedActualCost()
  13072. case batchimagejob.FieldRetryCount:
  13073. return m.AddedRetryCount()
  13074. case batchimagejob.FieldVersion:
  13075. return m.AddedVersion()
  13076. }
  13077. return nil, false
  13078. }
  13079. // AddField adds the value to the field with the given name. It returns an error if
  13080. // the field is not defined in the schema, or if the type mismatched the field
  13081. // type.
  13082. func (m *BatchImageJobMutation) AddField(name string, value ent.Value) error {
  13083. switch name {
  13084. case batchimagejob.FieldUserID:
  13085. v, ok := value.(int64)
  13086. if !ok {
  13087. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13088. }
  13089. m.AddUserID(v)
  13090. return nil
  13091. case batchimagejob.FieldAPIKeyID:
  13092. v, ok := value.(int64)
  13093. if !ok {
  13094. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13095. }
  13096. m.AddAPIKeyID(v)
  13097. return nil
  13098. case batchimagejob.FieldAccountID:
  13099. v, ok := value.(int64)
  13100. if !ok {
  13101. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13102. }
  13103. m.AddAccountID(v)
  13104. return nil
  13105. case batchimagejob.FieldItemCount:
  13106. v, ok := value.(int)
  13107. if !ok {
  13108. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13109. }
  13110. m.AddItemCount(v)
  13111. return nil
  13112. case batchimagejob.FieldSuccessCount:
  13113. v, ok := value.(int)
  13114. if !ok {
  13115. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13116. }
  13117. m.AddSuccessCount(v)
  13118. return nil
  13119. case batchimagejob.FieldFailCount:
  13120. v, ok := value.(int)
  13121. if !ok {
  13122. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13123. }
  13124. m.AddFailCount(v)
  13125. return nil
  13126. case batchimagejob.FieldCancelledCount:
  13127. v, ok := value.(int)
  13128. if !ok {
  13129. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13130. }
  13131. m.AddCancelledCount(v)
  13132. return nil
  13133. case batchimagejob.FieldEstimatedCost:
  13134. v, ok := value.(float64)
  13135. if !ok {
  13136. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13137. }
  13138. m.AddEstimatedCost(v)
  13139. return nil
  13140. case batchimagejob.FieldHoldAmount:
  13141. v, ok := value.(float64)
  13142. if !ok {
  13143. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13144. }
  13145. m.AddHoldAmount(v)
  13146. return nil
  13147. case batchimagejob.FieldActualCost:
  13148. v, ok := value.(float64)
  13149. if !ok {
  13150. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13151. }
  13152. m.AddActualCost(v)
  13153. return nil
  13154. case batchimagejob.FieldRetryCount:
  13155. v, ok := value.(int)
  13156. if !ok {
  13157. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13158. }
  13159. m.AddRetryCount(v)
  13160. return nil
  13161. case batchimagejob.FieldVersion:
  13162. v, ok := value.(int)
  13163. if !ok {
  13164. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13165. }
  13166. m.AddVersion(v)
  13167. return nil
  13168. }
  13169. return fmt.Errorf("unknown BatchImageJob numeric field %s", name)
  13170. }
  13171. // ClearedFields returns all nullable fields that were cleared during this
  13172. // mutation.
  13173. func (m *BatchImageJobMutation) ClearedFields() []string {
  13174. var fields []string
  13175. if m.FieldCleared(batchimagejob.FieldAPIKeyID) {
  13176. fields = append(fields, batchimagejob.FieldAPIKeyID)
  13177. }
  13178. if m.FieldCleared(batchimagejob.FieldAccountID) {
  13179. fields = append(fields, batchimagejob.FieldAccountID)
  13180. }
  13181. if m.FieldCleared(batchimagejob.FieldProviderJobName) {
  13182. fields = append(fields, batchimagejob.FieldProviderJobName)
  13183. }
  13184. if m.FieldCleared(batchimagejob.FieldProviderInputRef) {
  13185. fields = append(fields, batchimagejob.FieldProviderInputRef)
  13186. }
  13187. if m.FieldCleared(batchimagejob.FieldProviderOutputRef) {
  13188. fields = append(fields, batchimagejob.FieldProviderOutputRef)
  13189. }
  13190. if m.FieldCleared(batchimagejob.FieldGcsInputURI) {
  13191. fields = append(fields, batchimagejob.FieldGcsInputURI)
  13192. }
  13193. if m.FieldCleared(batchimagejob.FieldGcsOutputURI) {
  13194. fields = append(fields, batchimagejob.FieldGcsOutputURI)
  13195. }
  13196. if m.FieldCleared(batchimagejob.FieldHoldAmount) {
  13197. fields = append(fields, batchimagejob.FieldHoldAmount)
  13198. }
  13199. if m.FieldCleared(batchimagejob.FieldActualCost) {
  13200. fields = append(fields, batchimagejob.FieldActualCost)
  13201. }
  13202. if m.FieldCleared(batchimagejob.FieldHoldID) {
  13203. fields = append(fields, batchimagejob.FieldHoldID)
  13204. }
  13205. if m.FieldCleared(batchimagejob.FieldIdempotencyKey) {
  13206. fields = append(fields, batchimagejob.FieldIdempotencyKey)
  13207. }
  13208. if m.FieldCleared(batchimagejob.FieldRequestHash) {
  13209. fields = append(fields, batchimagejob.FieldRequestHash)
  13210. }
  13211. if m.FieldCleared(batchimagejob.FieldManifestHash) {
  13212. fields = append(fields, batchimagejob.FieldManifestHash)
  13213. }
  13214. if m.FieldCleared(batchimagejob.FieldOutputExpiresAt) {
  13215. fields = append(fields, batchimagejob.FieldOutputExpiresAt)
  13216. }
  13217. if m.FieldCleared(batchimagejob.FieldInputDeletedAt) {
  13218. fields = append(fields, batchimagejob.FieldInputDeletedAt)
  13219. }
  13220. if m.FieldCleared(batchimagejob.FieldOutputDeletedAt) {
  13221. fields = append(fields, batchimagejob.FieldOutputDeletedAt)
  13222. }
  13223. if m.FieldCleared(batchimagejob.FieldDownloadedAt) {
  13224. fields = append(fields, batchimagejob.FieldDownloadedAt)
  13225. }
  13226. if m.FieldCleared(batchimagejob.FieldUserDeletedAt) {
  13227. fields = append(fields, batchimagejob.FieldUserDeletedAt)
  13228. }
  13229. if m.FieldCleared(batchimagejob.FieldLastErrorCode) {
  13230. fields = append(fields, batchimagejob.FieldLastErrorCode)
  13231. }
  13232. if m.FieldCleared(batchimagejob.FieldLastErrorMessage) {
  13233. fields = append(fields, batchimagejob.FieldLastErrorMessage)
  13234. }
  13235. if m.FieldCleared(batchimagejob.FieldSubmittedAt) {
  13236. fields = append(fields, batchimagejob.FieldSubmittedAt)
  13237. }
  13238. if m.FieldCleared(batchimagejob.FieldStartedAt) {
  13239. fields = append(fields, batchimagejob.FieldStartedAt)
  13240. }
  13241. if m.FieldCleared(batchimagejob.FieldFinishedAt) {
  13242. fields = append(fields, batchimagejob.FieldFinishedAt)
  13243. }
  13244. if m.FieldCleared(batchimagejob.FieldSettledAt) {
  13245. fields = append(fields, batchimagejob.FieldSettledAt)
  13246. }
  13247. return fields
  13248. }
  13249. // FieldCleared returns a boolean indicating if a field with the given name was
  13250. // cleared in this mutation.
  13251. func (m *BatchImageJobMutation) FieldCleared(name string) bool {
  13252. _, ok := m.clearedFields[name]
  13253. return ok
  13254. }
  13255. // ClearField clears the value of the field with the given name. It returns an
  13256. // error if the field is not defined in the schema.
  13257. func (m *BatchImageJobMutation) ClearField(name string) error {
  13258. switch name {
  13259. case batchimagejob.FieldAPIKeyID:
  13260. m.ClearAPIKeyID()
  13261. return nil
  13262. case batchimagejob.FieldAccountID:
  13263. m.ClearAccountID()
  13264. return nil
  13265. case batchimagejob.FieldProviderJobName:
  13266. m.ClearProviderJobName()
  13267. return nil
  13268. case batchimagejob.FieldProviderInputRef:
  13269. m.ClearProviderInputRef()
  13270. return nil
  13271. case batchimagejob.FieldProviderOutputRef:
  13272. m.ClearProviderOutputRef()
  13273. return nil
  13274. case batchimagejob.FieldGcsInputURI:
  13275. m.ClearGcsInputURI()
  13276. return nil
  13277. case batchimagejob.FieldGcsOutputURI:
  13278. m.ClearGcsOutputURI()
  13279. return nil
  13280. case batchimagejob.FieldHoldAmount:
  13281. m.ClearHoldAmount()
  13282. return nil
  13283. case batchimagejob.FieldActualCost:
  13284. m.ClearActualCost()
  13285. return nil
  13286. case batchimagejob.FieldHoldID:
  13287. m.ClearHoldID()
  13288. return nil
  13289. case batchimagejob.FieldIdempotencyKey:
  13290. m.ClearIdempotencyKey()
  13291. return nil
  13292. case batchimagejob.FieldRequestHash:
  13293. m.ClearRequestHash()
  13294. return nil
  13295. case batchimagejob.FieldManifestHash:
  13296. m.ClearManifestHash()
  13297. return nil
  13298. case batchimagejob.FieldOutputExpiresAt:
  13299. m.ClearOutputExpiresAt()
  13300. return nil
  13301. case batchimagejob.FieldInputDeletedAt:
  13302. m.ClearInputDeletedAt()
  13303. return nil
  13304. case batchimagejob.FieldOutputDeletedAt:
  13305. m.ClearOutputDeletedAt()
  13306. return nil
  13307. case batchimagejob.FieldDownloadedAt:
  13308. m.ClearDownloadedAt()
  13309. return nil
  13310. case batchimagejob.FieldUserDeletedAt:
  13311. m.ClearUserDeletedAt()
  13312. return nil
  13313. case batchimagejob.FieldLastErrorCode:
  13314. m.ClearLastErrorCode()
  13315. return nil
  13316. case batchimagejob.FieldLastErrorMessage:
  13317. m.ClearLastErrorMessage()
  13318. return nil
  13319. case batchimagejob.FieldSubmittedAt:
  13320. m.ClearSubmittedAt()
  13321. return nil
  13322. case batchimagejob.FieldStartedAt:
  13323. m.ClearStartedAt()
  13324. return nil
  13325. case batchimagejob.FieldFinishedAt:
  13326. m.ClearFinishedAt()
  13327. return nil
  13328. case batchimagejob.FieldSettledAt:
  13329. m.ClearSettledAt()
  13330. return nil
  13331. }
  13332. return fmt.Errorf("unknown BatchImageJob nullable field %s", name)
  13333. }
  13334. // ResetField resets all changes in the mutation for the field with the given name.
  13335. // It returns an error if the field is not defined in the schema.
  13336. func (m *BatchImageJobMutation) ResetField(name string) error {
  13337. switch name {
  13338. case batchimagejob.FieldBatchID:
  13339. m.ResetBatchID()
  13340. return nil
  13341. case batchimagejob.FieldUserID:
  13342. m.ResetUserID()
  13343. return nil
  13344. case batchimagejob.FieldAPIKeyID:
  13345. m.ResetAPIKeyID()
  13346. return nil
  13347. case batchimagejob.FieldAccountID:
  13348. m.ResetAccountID()
  13349. return nil
  13350. case batchimagejob.FieldProvider:
  13351. m.ResetProvider()
  13352. return nil
  13353. case batchimagejob.FieldModel:
  13354. m.ResetModel()
  13355. return nil
  13356. case batchimagejob.FieldTaskName:
  13357. m.ResetTaskName()
  13358. return nil
  13359. case batchimagejob.FieldStatus:
  13360. m.ResetStatus()
  13361. return nil
  13362. case batchimagejob.FieldProviderJobName:
  13363. m.ResetProviderJobName()
  13364. return nil
  13365. case batchimagejob.FieldProviderInputRef:
  13366. m.ResetProviderInputRef()
  13367. return nil
  13368. case batchimagejob.FieldProviderOutputRef:
  13369. m.ResetProviderOutputRef()
  13370. return nil
  13371. case batchimagejob.FieldGcsInputURI:
  13372. m.ResetGcsInputURI()
  13373. return nil
  13374. case batchimagejob.FieldGcsOutputURI:
  13375. m.ResetGcsOutputURI()
  13376. return nil
  13377. case batchimagejob.FieldItemCount:
  13378. m.ResetItemCount()
  13379. return nil
  13380. case batchimagejob.FieldSuccessCount:
  13381. m.ResetSuccessCount()
  13382. return nil
  13383. case batchimagejob.FieldFailCount:
  13384. m.ResetFailCount()
  13385. return nil
  13386. case batchimagejob.FieldCancelledCount:
  13387. m.ResetCancelledCount()
  13388. return nil
  13389. case batchimagejob.FieldEstimatedCost:
  13390. m.ResetEstimatedCost()
  13391. return nil
  13392. case batchimagejob.FieldHoldAmount:
  13393. m.ResetHoldAmount()
  13394. return nil
  13395. case batchimagejob.FieldActualCost:
  13396. m.ResetActualCost()
  13397. return nil
  13398. case batchimagejob.FieldCurrency:
  13399. m.ResetCurrency()
  13400. return nil
  13401. case batchimagejob.FieldHoldID:
  13402. m.ResetHoldID()
  13403. return nil
  13404. case batchimagejob.FieldIdempotencyKey:
  13405. m.ResetIdempotencyKey()
  13406. return nil
  13407. case batchimagejob.FieldRequestHash:
  13408. m.ResetRequestHash()
  13409. return nil
  13410. case batchimagejob.FieldManifestHash:
  13411. m.ResetManifestHash()
  13412. return nil
  13413. case batchimagejob.FieldRetryCount:
  13414. m.ResetRetryCount()
  13415. return nil
  13416. case batchimagejob.FieldVersion:
  13417. m.ResetVersion()
  13418. return nil
  13419. case batchimagejob.FieldOutputExpiresAt:
  13420. m.ResetOutputExpiresAt()
  13421. return nil
  13422. case batchimagejob.FieldInputDeletedAt:
  13423. m.ResetInputDeletedAt()
  13424. return nil
  13425. case batchimagejob.FieldOutputDeletedAt:
  13426. m.ResetOutputDeletedAt()
  13427. return nil
  13428. case batchimagejob.FieldDownloadedAt:
  13429. m.ResetDownloadedAt()
  13430. return nil
  13431. case batchimagejob.FieldUserDeletedAt:
  13432. m.ResetUserDeletedAt()
  13433. return nil
  13434. case batchimagejob.FieldLastErrorCode:
  13435. m.ResetLastErrorCode()
  13436. return nil
  13437. case batchimagejob.FieldLastErrorMessage:
  13438. m.ResetLastErrorMessage()
  13439. return nil
  13440. case batchimagejob.FieldCreatedAt:
  13441. m.ResetCreatedAt()
  13442. return nil
  13443. case batchimagejob.FieldUpdatedAt:
  13444. m.ResetUpdatedAt()
  13445. return nil
  13446. case batchimagejob.FieldSubmittedAt:
  13447. m.ResetSubmittedAt()
  13448. return nil
  13449. case batchimagejob.FieldStartedAt:
  13450. m.ResetStartedAt()
  13451. return nil
  13452. case batchimagejob.FieldFinishedAt:
  13453. m.ResetFinishedAt()
  13454. return nil
  13455. case batchimagejob.FieldSettledAt:
  13456. m.ResetSettledAt()
  13457. return nil
  13458. }
  13459. return fmt.Errorf("unknown BatchImageJob field %s", name)
  13460. }
  13461. // AddedEdges returns all edge names that were set/added in this mutation.
  13462. func (m *BatchImageJobMutation) AddedEdges() []string {
  13463. edges := make([]string, 0, 0)
  13464. return edges
  13465. }
  13466. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  13467. // name in this mutation.
  13468. func (m *BatchImageJobMutation) AddedIDs(name string) []ent.Value {
  13469. return nil
  13470. }
  13471. // RemovedEdges returns all edge names that were removed in this mutation.
  13472. func (m *BatchImageJobMutation) RemovedEdges() []string {
  13473. edges := make([]string, 0, 0)
  13474. return edges
  13475. }
  13476. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  13477. // the given name in this mutation.
  13478. func (m *BatchImageJobMutation) RemovedIDs(name string) []ent.Value {
  13479. return nil
  13480. }
  13481. // ClearedEdges returns all edge names that were cleared in this mutation.
  13482. func (m *BatchImageJobMutation) ClearedEdges() []string {
  13483. edges := make([]string, 0, 0)
  13484. return edges
  13485. }
  13486. // EdgeCleared returns a boolean which indicates if the edge with the given name
  13487. // was cleared in this mutation.
  13488. func (m *BatchImageJobMutation) EdgeCleared(name string) bool {
  13489. return false
  13490. }
  13491. // ClearEdge clears the value of the edge with the given name. It returns an error
  13492. // if that edge is not defined in the schema.
  13493. func (m *BatchImageJobMutation) ClearEdge(name string) error {
  13494. return fmt.Errorf("unknown BatchImageJob unique edge %s", name)
  13495. }
  13496. // ResetEdge resets all changes to the edge with the given name in this mutation.
  13497. // It returns an error if the edge is not defined in the schema.
  13498. func (m *BatchImageJobMutation) ResetEdge(name string) error {
  13499. return fmt.Errorf("unknown BatchImageJob edge %s", name)
  13500. }
  13501. // ChannelMonitorMutation represents an operation that mutates the ChannelMonitor nodes in the graph.
  13502. type ChannelMonitorMutation struct {
  13503. config
  13504. op Op
  13505. typ string
  13506. id *int64
  13507. created_at *time.Time
  13508. updated_at *time.Time
  13509. name *string
  13510. provider *channelmonitor.Provider
  13511. check_mode *string
  13512. account_id *int64
  13513. addaccount_id *int64
  13514. api_mode *string
  13515. endpoint *string
  13516. api_key_encrypted *string
  13517. primary_model *string
  13518. extra_models *[]string
  13519. appendextra_models []string
  13520. group_name *string
  13521. enabled *bool
  13522. interval_seconds *int
  13523. addinterval_seconds *int
  13524. jitter_seconds *int
  13525. addjitter_seconds *int
  13526. last_checked_at *time.Time
  13527. created_by *int64
  13528. addcreated_by *int64
  13529. extra_headers *map[string]string
  13530. body_override_mode *string
  13531. body_override *map[string]interface{}
  13532. clearedFields map[string]struct{}
  13533. history map[int64]struct{}
  13534. removedhistory map[int64]struct{}
  13535. clearedhistory bool
  13536. daily_rollups map[int64]struct{}
  13537. removeddaily_rollups map[int64]struct{}
  13538. cleareddaily_rollups bool
  13539. request_template *int64
  13540. clearedrequest_template bool
  13541. done bool
  13542. oldValue func(context.Context) (*ChannelMonitor, error)
  13543. predicates []predicate.ChannelMonitor
  13544. }
  13545. var _ ent.Mutation = (*ChannelMonitorMutation)(nil)
  13546. // channelmonitorOption allows management of the mutation configuration using functional options.
  13547. type channelmonitorOption func(*ChannelMonitorMutation)
  13548. // newChannelMonitorMutation creates new mutation for the ChannelMonitor entity.
  13549. func newChannelMonitorMutation(c config, op Op, opts ...channelmonitorOption) *ChannelMonitorMutation {
  13550. m := &ChannelMonitorMutation{
  13551. config: c,
  13552. op: op,
  13553. typ: TypeChannelMonitor,
  13554. clearedFields: make(map[string]struct{}),
  13555. }
  13556. for _, opt := range opts {
  13557. opt(m)
  13558. }
  13559. return m
  13560. }
  13561. // withChannelMonitorID sets the ID field of the mutation.
  13562. func withChannelMonitorID(id int64) channelmonitorOption {
  13563. return func(m *ChannelMonitorMutation) {
  13564. var (
  13565. err error
  13566. once sync.Once
  13567. value *ChannelMonitor
  13568. )
  13569. m.oldValue = func(ctx context.Context) (*ChannelMonitor, error) {
  13570. once.Do(func() {
  13571. if m.done {
  13572. err = errors.New("querying old values post mutation is not allowed")
  13573. } else {
  13574. value, err = m.Client().ChannelMonitor.Get(ctx, id)
  13575. }
  13576. })
  13577. return value, err
  13578. }
  13579. m.id = &id
  13580. }
  13581. }
  13582. // withChannelMonitor sets the old ChannelMonitor of the mutation.
  13583. func withChannelMonitor(node *ChannelMonitor) channelmonitorOption {
  13584. return func(m *ChannelMonitorMutation) {
  13585. m.oldValue = func(context.Context) (*ChannelMonitor, error) {
  13586. return node, nil
  13587. }
  13588. m.id = &node.ID
  13589. }
  13590. }
  13591. // Client returns a new `ent.Client` from the mutation. If the mutation was
  13592. // executed in a transaction (ent.Tx), a transactional client is returned.
  13593. func (m ChannelMonitorMutation) Client() *Client {
  13594. client := &Client{config: m.config}
  13595. client.init()
  13596. return client
  13597. }
  13598. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  13599. // it returns an error otherwise.
  13600. func (m ChannelMonitorMutation) Tx() (*Tx, error) {
  13601. if _, ok := m.driver.(*txDriver); !ok {
  13602. return nil, errors.New("ent: mutation is not running in a transaction")
  13603. }
  13604. tx := &Tx{config: m.config}
  13605. tx.init()
  13606. return tx, nil
  13607. }
  13608. // ID returns the ID value in the mutation. Note that the ID is only available
  13609. // if it was provided to the builder or after it was returned from the database.
  13610. func (m *ChannelMonitorMutation) ID() (id int64, exists bool) {
  13611. if m.id == nil {
  13612. return
  13613. }
  13614. return *m.id, true
  13615. }
  13616. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  13617. // That means, if the mutation is applied within a transaction with an isolation level such
  13618. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  13619. // or updated by the mutation.
  13620. func (m *ChannelMonitorMutation) IDs(ctx context.Context) ([]int64, error) {
  13621. switch {
  13622. case m.op.Is(OpUpdateOne | OpDeleteOne):
  13623. id, exists := m.ID()
  13624. if exists {
  13625. return []int64{id}, nil
  13626. }
  13627. fallthrough
  13628. case m.op.Is(OpUpdate | OpDelete):
  13629. return m.Client().ChannelMonitor.Query().Where(m.predicates...).IDs(ctx)
  13630. default:
  13631. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  13632. }
  13633. }
  13634. // SetCreatedAt sets the "created_at" field.
  13635. func (m *ChannelMonitorMutation) SetCreatedAt(t time.Time) {
  13636. m.created_at = &t
  13637. }
  13638. // CreatedAt returns the value of the "created_at" field in the mutation.
  13639. func (m *ChannelMonitorMutation) CreatedAt() (r time.Time, exists bool) {
  13640. v := m.created_at
  13641. if v == nil {
  13642. return
  13643. }
  13644. return *v, true
  13645. }
  13646. // OldCreatedAt returns the old "created_at" field's value of the ChannelMonitor entity.
  13647. // If the ChannelMonitor object wasn't provided to the builder, the object is fetched from the database.
  13648. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13649. func (m *ChannelMonitorMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  13650. if !m.op.Is(OpUpdateOne) {
  13651. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  13652. }
  13653. if m.id == nil || m.oldValue == nil {
  13654. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  13655. }
  13656. oldValue, err := m.oldValue(ctx)
  13657. if err != nil {
  13658. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  13659. }
  13660. return oldValue.CreatedAt, nil
  13661. }
  13662. // ResetCreatedAt resets all changes to the "created_at" field.
  13663. func (m *ChannelMonitorMutation) ResetCreatedAt() {
  13664. m.created_at = nil
  13665. }
  13666. // SetUpdatedAt sets the "updated_at" field.
  13667. func (m *ChannelMonitorMutation) SetUpdatedAt(t time.Time) {
  13668. m.updated_at = &t
  13669. }
  13670. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  13671. func (m *ChannelMonitorMutation) UpdatedAt() (r time.Time, exists bool) {
  13672. v := m.updated_at
  13673. if v == nil {
  13674. return
  13675. }
  13676. return *v, true
  13677. }
  13678. // OldUpdatedAt returns the old "updated_at" field's value of the ChannelMonitor entity.
  13679. // If the ChannelMonitor object wasn't provided to the builder, the object is fetched from the database.
  13680. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13681. func (m *ChannelMonitorMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  13682. if !m.op.Is(OpUpdateOne) {
  13683. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  13684. }
  13685. if m.id == nil || m.oldValue == nil {
  13686. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  13687. }
  13688. oldValue, err := m.oldValue(ctx)
  13689. if err != nil {
  13690. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  13691. }
  13692. return oldValue.UpdatedAt, nil
  13693. }
  13694. // ResetUpdatedAt resets all changes to the "updated_at" field.
  13695. func (m *ChannelMonitorMutation) ResetUpdatedAt() {
  13696. m.updated_at = nil
  13697. }
  13698. // SetName sets the "name" field.
  13699. func (m *ChannelMonitorMutation) SetName(s string) {
  13700. m.name = &s
  13701. }
  13702. // Name returns the value of the "name" field in the mutation.
  13703. func (m *ChannelMonitorMutation) Name() (r string, exists bool) {
  13704. v := m.name
  13705. if v == nil {
  13706. return
  13707. }
  13708. return *v, true
  13709. }
  13710. // OldName returns the old "name" field's value of the ChannelMonitor entity.
  13711. // If the ChannelMonitor object wasn't provided to the builder, the object is fetched from the database.
  13712. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13713. func (m *ChannelMonitorMutation) OldName(ctx context.Context) (v string, err error) {
  13714. if !m.op.Is(OpUpdateOne) {
  13715. return v, errors.New("OldName is only allowed on UpdateOne operations")
  13716. }
  13717. if m.id == nil || m.oldValue == nil {
  13718. return v, errors.New("OldName requires an ID field in the mutation")
  13719. }
  13720. oldValue, err := m.oldValue(ctx)
  13721. if err != nil {
  13722. return v, fmt.Errorf("querying old value for OldName: %w", err)
  13723. }
  13724. return oldValue.Name, nil
  13725. }
  13726. // ResetName resets all changes to the "name" field.
  13727. func (m *ChannelMonitorMutation) ResetName() {
  13728. m.name = nil
  13729. }
  13730. // SetProvider sets the "provider" field.
  13731. func (m *ChannelMonitorMutation) SetProvider(c channelmonitor.Provider) {
  13732. m.provider = &c
  13733. }
  13734. // Provider returns the value of the "provider" field in the mutation.
  13735. func (m *ChannelMonitorMutation) Provider() (r channelmonitor.Provider, exists bool) {
  13736. v := m.provider
  13737. if v == nil {
  13738. return
  13739. }
  13740. return *v, true
  13741. }
  13742. // OldProvider returns the old "provider" field's value of the ChannelMonitor entity.
  13743. // If the ChannelMonitor object wasn't provided to the builder, the object is fetched from the database.
  13744. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13745. func (m *ChannelMonitorMutation) OldProvider(ctx context.Context) (v channelmonitor.Provider, err error) {
  13746. if !m.op.Is(OpUpdateOne) {
  13747. return v, errors.New("OldProvider is only allowed on UpdateOne operations")
  13748. }
  13749. if m.id == nil || m.oldValue == nil {
  13750. return v, errors.New("OldProvider requires an ID field in the mutation")
  13751. }
  13752. oldValue, err := m.oldValue(ctx)
  13753. if err != nil {
  13754. return v, fmt.Errorf("querying old value for OldProvider: %w", err)
  13755. }
  13756. return oldValue.Provider, nil
  13757. }
  13758. // ResetProvider resets all changes to the "provider" field.
  13759. func (m *ChannelMonitorMutation) ResetProvider() {
  13760. m.provider = nil
  13761. }
  13762. // SetCheckMode sets the "check_mode" field.
  13763. func (m *ChannelMonitorMutation) SetCheckMode(s string) {
  13764. m.check_mode = &s
  13765. }
  13766. // CheckMode returns the value of the "check_mode" field in the mutation.
  13767. func (m *ChannelMonitorMutation) CheckMode() (r string, exists bool) {
  13768. v := m.check_mode
  13769. if v == nil {
  13770. return
  13771. }
  13772. return *v, true
  13773. }
  13774. // OldCheckMode returns the old "check_mode" field's value of the ChannelMonitor entity.
  13775. // If the ChannelMonitor object wasn't provided to the builder, the object is fetched from the database.
  13776. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13777. func (m *ChannelMonitorMutation) OldCheckMode(ctx context.Context) (v string, err error) {
  13778. if !m.op.Is(OpUpdateOne) {
  13779. return v, errors.New("OldCheckMode is only allowed on UpdateOne operations")
  13780. }
  13781. if m.id == nil || m.oldValue == nil {
  13782. return v, errors.New("OldCheckMode requires an ID field in the mutation")
  13783. }
  13784. oldValue, err := m.oldValue(ctx)
  13785. if err != nil {
  13786. return v, fmt.Errorf("querying old value for OldCheckMode: %w", err)
  13787. }
  13788. return oldValue.CheckMode, nil
  13789. }
  13790. // ResetCheckMode resets all changes to the "check_mode" field.
  13791. func (m *ChannelMonitorMutation) ResetCheckMode() {
  13792. m.check_mode = nil
  13793. }
  13794. // SetAccountID sets the "account_id" field.
  13795. func (m *ChannelMonitorMutation) SetAccountID(i int64) {
  13796. m.account_id = &i
  13797. m.addaccount_id = nil
  13798. }
  13799. // AccountID returns the value of the "account_id" field in the mutation.
  13800. func (m *ChannelMonitorMutation) AccountID() (r int64, exists bool) {
  13801. v := m.account_id
  13802. if v == nil {
  13803. return
  13804. }
  13805. return *v, true
  13806. }
  13807. // OldAccountID returns the old "account_id" field's value of the ChannelMonitor entity.
  13808. // If the ChannelMonitor object wasn't provided to the builder, the object is fetched from the database.
  13809. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13810. func (m *ChannelMonitorMutation) OldAccountID(ctx context.Context) (v *int64, err error) {
  13811. if !m.op.Is(OpUpdateOne) {
  13812. return v, errors.New("OldAccountID is only allowed on UpdateOne operations")
  13813. }
  13814. if m.id == nil || m.oldValue == nil {
  13815. return v, errors.New("OldAccountID requires an ID field in the mutation")
  13816. }
  13817. oldValue, err := m.oldValue(ctx)
  13818. if err != nil {
  13819. return v, fmt.Errorf("querying old value for OldAccountID: %w", err)
  13820. }
  13821. return oldValue.AccountID, nil
  13822. }
  13823. // AddAccountID adds i to the "account_id" field.
  13824. func (m *ChannelMonitorMutation) AddAccountID(i int64) {
  13825. if m.addaccount_id != nil {
  13826. *m.addaccount_id += i
  13827. } else {
  13828. m.addaccount_id = &i
  13829. }
  13830. }
  13831. // AddedAccountID returns the value that was added to the "account_id" field in this mutation.
  13832. func (m *ChannelMonitorMutation) AddedAccountID() (r int64, exists bool) {
  13833. v := m.addaccount_id
  13834. if v == nil {
  13835. return
  13836. }
  13837. return *v, true
  13838. }
  13839. // ClearAccountID clears the value of the "account_id" field.
  13840. func (m *ChannelMonitorMutation) ClearAccountID() {
  13841. m.account_id = nil
  13842. m.addaccount_id = nil
  13843. m.clearedFields[channelmonitor.FieldAccountID] = struct{}{}
  13844. }
  13845. // AccountIDCleared returns if the "account_id" field was cleared in this mutation.
  13846. func (m *ChannelMonitorMutation) AccountIDCleared() bool {
  13847. _, ok := m.clearedFields[channelmonitor.FieldAccountID]
  13848. return ok
  13849. }
  13850. // ResetAccountID resets all changes to the "account_id" field.
  13851. func (m *ChannelMonitorMutation) ResetAccountID() {
  13852. m.account_id = nil
  13853. m.addaccount_id = nil
  13854. delete(m.clearedFields, channelmonitor.FieldAccountID)
  13855. }
  13856. // SetAPIMode sets the "api_mode" field.
  13857. func (m *ChannelMonitorMutation) SetAPIMode(s string) {
  13858. m.api_mode = &s
  13859. }
  13860. // APIMode returns the value of the "api_mode" field in the mutation.
  13861. func (m *ChannelMonitorMutation) APIMode() (r string, exists bool) {
  13862. v := m.api_mode
  13863. if v == nil {
  13864. return
  13865. }
  13866. return *v, true
  13867. }
  13868. // OldAPIMode returns the old "api_mode" field's value of the ChannelMonitor entity.
  13869. // If the ChannelMonitor object wasn't provided to the builder, the object is fetched from the database.
  13870. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13871. func (m *ChannelMonitorMutation) OldAPIMode(ctx context.Context) (v string, err error) {
  13872. if !m.op.Is(OpUpdateOne) {
  13873. return v, errors.New("OldAPIMode is only allowed on UpdateOne operations")
  13874. }
  13875. if m.id == nil || m.oldValue == nil {
  13876. return v, errors.New("OldAPIMode requires an ID field in the mutation")
  13877. }
  13878. oldValue, err := m.oldValue(ctx)
  13879. if err != nil {
  13880. return v, fmt.Errorf("querying old value for OldAPIMode: %w", err)
  13881. }
  13882. return oldValue.APIMode, nil
  13883. }
  13884. // ResetAPIMode resets all changes to the "api_mode" field.
  13885. func (m *ChannelMonitorMutation) ResetAPIMode() {
  13886. m.api_mode = nil
  13887. }
  13888. // SetEndpoint sets the "endpoint" field.
  13889. func (m *ChannelMonitorMutation) SetEndpoint(s string) {
  13890. m.endpoint = &s
  13891. }
  13892. // Endpoint returns the value of the "endpoint" field in the mutation.
  13893. func (m *ChannelMonitorMutation) Endpoint() (r string, exists bool) {
  13894. v := m.endpoint
  13895. if v == nil {
  13896. return
  13897. }
  13898. return *v, true
  13899. }
  13900. // OldEndpoint returns the old "endpoint" field's value of the ChannelMonitor entity.
  13901. // If the ChannelMonitor object wasn't provided to the builder, the object is fetched from the database.
  13902. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13903. func (m *ChannelMonitorMutation) OldEndpoint(ctx context.Context) (v string, err error) {
  13904. if !m.op.Is(OpUpdateOne) {
  13905. return v, errors.New("OldEndpoint is only allowed on UpdateOne operations")
  13906. }
  13907. if m.id == nil || m.oldValue == nil {
  13908. return v, errors.New("OldEndpoint requires an ID field in the mutation")
  13909. }
  13910. oldValue, err := m.oldValue(ctx)
  13911. if err != nil {
  13912. return v, fmt.Errorf("querying old value for OldEndpoint: %w", err)
  13913. }
  13914. return oldValue.Endpoint, nil
  13915. }
  13916. // ResetEndpoint resets all changes to the "endpoint" field.
  13917. func (m *ChannelMonitorMutation) ResetEndpoint() {
  13918. m.endpoint = nil
  13919. }
  13920. // SetAPIKeyEncrypted sets the "api_key_encrypted" field.
  13921. func (m *ChannelMonitorMutation) SetAPIKeyEncrypted(s string) {
  13922. m.api_key_encrypted = &s
  13923. }
  13924. // APIKeyEncrypted returns the value of the "api_key_encrypted" field in the mutation.
  13925. func (m *ChannelMonitorMutation) APIKeyEncrypted() (r string, exists bool) {
  13926. v := m.api_key_encrypted
  13927. if v == nil {
  13928. return
  13929. }
  13930. return *v, true
  13931. }
  13932. // OldAPIKeyEncrypted returns the old "api_key_encrypted" field's value of the ChannelMonitor entity.
  13933. // If the ChannelMonitor object wasn't provided to the builder, the object is fetched from the database.
  13934. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13935. func (m *ChannelMonitorMutation) OldAPIKeyEncrypted(ctx context.Context) (v string, err error) {
  13936. if !m.op.Is(OpUpdateOne) {
  13937. return v, errors.New("OldAPIKeyEncrypted is only allowed on UpdateOne operations")
  13938. }
  13939. if m.id == nil || m.oldValue == nil {
  13940. return v, errors.New("OldAPIKeyEncrypted requires an ID field in the mutation")
  13941. }
  13942. oldValue, err := m.oldValue(ctx)
  13943. if err != nil {
  13944. return v, fmt.Errorf("querying old value for OldAPIKeyEncrypted: %w", err)
  13945. }
  13946. return oldValue.APIKeyEncrypted, nil
  13947. }
  13948. // ResetAPIKeyEncrypted resets all changes to the "api_key_encrypted" field.
  13949. func (m *ChannelMonitorMutation) ResetAPIKeyEncrypted() {
  13950. m.api_key_encrypted = nil
  13951. }
  13952. // SetPrimaryModel sets the "primary_model" field.
  13953. func (m *ChannelMonitorMutation) SetPrimaryModel(s string) {
  13954. m.primary_model = &s
  13955. }
  13956. // PrimaryModel returns the value of the "primary_model" field in the mutation.
  13957. func (m *ChannelMonitorMutation) PrimaryModel() (r string, exists bool) {
  13958. v := m.primary_model
  13959. if v == nil {
  13960. return
  13961. }
  13962. return *v, true
  13963. }
  13964. // OldPrimaryModel returns the old "primary_model" field's value of the ChannelMonitor entity.
  13965. // If the ChannelMonitor object wasn't provided to the builder, the object is fetched from the database.
  13966. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13967. func (m *ChannelMonitorMutation) OldPrimaryModel(ctx context.Context) (v string, err error) {
  13968. if !m.op.Is(OpUpdateOne) {
  13969. return v, errors.New("OldPrimaryModel is only allowed on UpdateOne operations")
  13970. }
  13971. if m.id == nil || m.oldValue == nil {
  13972. return v, errors.New("OldPrimaryModel requires an ID field in the mutation")
  13973. }
  13974. oldValue, err := m.oldValue(ctx)
  13975. if err != nil {
  13976. return v, fmt.Errorf("querying old value for OldPrimaryModel: %w", err)
  13977. }
  13978. return oldValue.PrimaryModel, nil
  13979. }
  13980. // ResetPrimaryModel resets all changes to the "primary_model" field.
  13981. func (m *ChannelMonitorMutation) ResetPrimaryModel() {
  13982. m.primary_model = nil
  13983. }
  13984. // SetExtraModels sets the "extra_models" field.
  13985. func (m *ChannelMonitorMutation) SetExtraModels(s []string) {
  13986. m.extra_models = &s
  13987. m.appendextra_models = nil
  13988. }
  13989. // ExtraModels returns the value of the "extra_models" field in the mutation.
  13990. func (m *ChannelMonitorMutation) ExtraModels() (r []string, exists bool) {
  13991. v := m.extra_models
  13992. if v == nil {
  13993. return
  13994. }
  13995. return *v, true
  13996. }
  13997. // OldExtraModels returns the old "extra_models" field's value of the ChannelMonitor entity.
  13998. // If the ChannelMonitor object wasn't provided to the builder, the object is fetched from the database.
  13999. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14000. func (m *ChannelMonitorMutation) OldExtraModels(ctx context.Context) (v []string, err error) {
  14001. if !m.op.Is(OpUpdateOne) {
  14002. return v, errors.New("OldExtraModels is only allowed on UpdateOne operations")
  14003. }
  14004. if m.id == nil || m.oldValue == nil {
  14005. return v, errors.New("OldExtraModels requires an ID field in the mutation")
  14006. }
  14007. oldValue, err := m.oldValue(ctx)
  14008. if err != nil {
  14009. return v, fmt.Errorf("querying old value for OldExtraModels: %w", err)
  14010. }
  14011. return oldValue.ExtraModels, nil
  14012. }
  14013. // AppendExtraModels adds s to the "extra_models" field.
  14014. func (m *ChannelMonitorMutation) AppendExtraModels(s []string) {
  14015. m.appendextra_models = append(m.appendextra_models, s...)
  14016. }
  14017. // AppendedExtraModels returns the list of values that were appended to the "extra_models" field in this mutation.
  14018. func (m *ChannelMonitorMutation) AppendedExtraModels() ([]string, bool) {
  14019. if len(m.appendextra_models) == 0 {
  14020. return nil, false
  14021. }
  14022. return m.appendextra_models, true
  14023. }
  14024. // ResetExtraModels resets all changes to the "extra_models" field.
  14025. func (m *ChannelMonitorMutation) ResetExtraModels() {
  14026. m.extra_models = nil
  14027. m.appendextra_models = nil
  14028. }
  14029. // SetGroupName sets the "group_name" field.
  14030. func (m *ChannelMonitorMutation) SetGroupName(s string) {
  14031. m.group_name = &s
  14032. }
  14033. // GroupName returns the value of the "group_name" field in the mutation.
  14034. func (m *ChannelMonitorMutation) GroupName() (r string, exists bool) {
  14035. v := m.group_name
  14036. if v == nil {
  14037. return
  14038. }
  14039. return *v, true
  14040. }
  14041. // OldGroupName returns the old "group_name" field's value of the ChannelMonitor entity.
  14042. // If the ChannelMonitor object wasn't provided to the builder, the object is fetched from the database.
  14043. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14044. func (m *ChannelMonitorMutation) OldGroupName(ctx context.Context) (v string, err error) {
  14045. if !m.op.Is(OpUpdateOne) {
  14046. return v, errors.New("OldGroupName is only allowed on UpdateOne operations")
  14047. }
  14048. if m.id == nil || m.oldValue == nil {
  14049. return v, errors.New("OldGroupName requires an ID field in the mutation")
  14050. }
  14051. oldValue, err := m.oldValue(ctx)
  14052. if err != nil {
  14053. return v, fmt.Errorf("querying old value for OldGroupName: %w", err)
  14054. }
  14055. return oldValue.GroupName, nil
  14056. }
  14057. // ClearGroupName clears the value of the "group_name" field.
  14058. func (m *ChannelMonitorMutation) ClearGroupName() {
  14059. m.group_name = nil
  14060. m.clearedFields[channelmonitor.FieldGroupName] = struct{}{}
  14061. }
  14062. // GroupNameCleared returns if the "group_name" field was cleared in this mutation.
  14063. func (m *ChannelMonitorMutation) GroupNameCleared() bool {
  14064. _, ok := m.clearedFields[channelmonitor.FieldGroupName]
  14065. return ok
  14066. }
  14067. // ResetGroupName resets all changes to the "group_name" field.
  14068. func (m *ChannelMonitorMutation) ResetGroupName() {
  14069. m.group_name = nil
  14070. delete(m.clearedFields, channelmonitor.FieldGroupName)
  14071. }
  14072. // SetEnabled sets the "enabled" field.
  14073. func (m *ChannelMonitorMutation) SetEnabled(b bool) {
  14074. m.enabled = &b
  14075. }
  14076. // Enabled returns the value of the "enabled" field in the mutation.
  14077. func (m *ChannelMonitorMutation) Enabled() (r bool, exists bool) {
  14078. v := m.enabled
  14079. if v == nil {
  14080. return
  14081. }
  14082. return *v, true
  14083. }
  14084. // OldEnabled returns the old "enabled" field's value of the ChannelMonitor entity.
  14085. // If the ChannelMonitor object wasn't provided to the builder, the object is fetched from the database.
  14086. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14087. func (m *ChannelMonitorMutation) OldEnabled(ctx context.Context) (v bool, err error) {
  14088. if !m.op.Is(OpUpdateOne) {
  14089. return v, errors.New("OldEnabled is only allowed on UpdateOne operations")
  14090. }
  14091. if m.id == nil || m.oldValue == nil {
  14092. return v, errors.New("OldEnabled requires an ID field in the mutation")
  14093. }
  14094. oldValue, err := m.oldValue(ctx)
  14095. if err != nil {
  14096. return v, fmt.Errorf("querying old value for OldEnabled: %w", err)
  14097. }
  14098. return oldValue.Enabled, nil
  14099. }
  14100. // ResetEnabled resets all changes to the "enabled" field.
  14101. func (m *ChannelMonitorMutation) ResetEnabled() {
  14102. m.enabled = nil
  14103. }
  14104. // SetIntervalSeconds sets the "interval_seconds" field.
  14105. func (m *ChannelMonitorMutation) SetIntervalSeconds(i int) {
  14106. m.interval_seconds = &i
  14107. m.addinterval_seconds = nil
  14108. }
  14109. // IntervalSeconds returns the value of the "interval_seconds" field in the mutation.
  14110. func (m *ChannelMonitorMutation) IntervalSeconds() (r int, exists bool) {
  14111. v := m.interval_seconds
  14112. if v == nil {
  14113. return
  14114. }
  14115. return *v, true
  14116. }
  14117. // OldIntervalSeconds returns the old "interval_seconds" field's value of the ChannelMonitor entity.
  14118. // If the ChannelMonitor object wasn't provided to the builder, the object is fetched from the database.
  14119. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14120. func (m *ChannelMonitorMutation) OldIntervalSeconds(ctx context.Context) (v int, err error) {
  14121. if !m.op.Is(OpUpdateOne) {
  14122. return v, errors.New("OldIntervalSeconds is only allowed on UpdateOne operations")
  14123. }
  14124. if m.id == nil || m.oldValue == nil {
  14125. return v, errors.New("OldIntervalSeconds requires an ID field in the mutation")
  14126. }
  14127. oldValue, err := m.oldValue(ctx)
  14128. if err != nil {
  14129. return v, fmt.Errorf("querying old value for OldIntervalSeconds: %w", err)
  14130. }
  14131. return oldValue.IntervalSeconds, nil
  14132. }
  14133. // AddIntervalSeconds adds i to the "interval_seconds" field.
  14134. func (m *ChannelMonitorMutation) AddIntervalSeconds(i int) {
  14135. if m.addinterval_seconds != nil {
  14136. *m.addinterval_seconds += i
  14137. } else {
  14138. m.addinterval_seconds = &i
  14139. }
  14140. }
  14141. // AddedIntervalSeconds returns the value that was added to the "interval_seconds" field in this mutation.
  14142. func (m *ChannelMonitorMutation) AddedIntervalSeconds() (r int, exists bool) {
  14143. v := m.addinterval_seconds
  14144. if v == nil {
  14145. return
  14146. }
  14147. return *v, true
  14148. }
  14149. // ResetIntervalSeconds resets all changes to the "interval_seconds" field.
  14150. func (m *ChannelMonitorMutation) ResetIntervalSeconds() {
  14151. m.interval_seconds = nil
  14152. m.addinterval_seconds = nil
  14153. }
  14154. // SetJitterSeconds sets the "jitter_seconds" field.
  14155. func (m *ChannelMonitorMutation) SetJitterSeconds(i int) {
  14156. m.jitter_seconds = &i
  14157. m.addjitter_seconds = nil
  14158. }
  14159. // JitterSeconds returns the value of the "jitter_seconds" field in the mutation.
  14160. func (m *ChannelMonitorMutation) JitterSeconds() (r int, exists bool) {
  14161. v := m.jitter_seconds
  14162. if v == nil {
  14163. return
  14164. }
  14165. return *v, true
  14166. }
  14167. // OldJitterSeconds returns the old "jitter_seconds" field's value of the ChannelMonitor entity.
  14168. // If the ChannelMonitor object wasn't provided to the builder, the object is fetched from the database.
  14169. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14170. func (m *ChannelMonitorMutation) OldJitterSeconds(ctx context.Context) (v int, err error) {
  14171. if !m.op.Is(OpUpdateOne) {
  14172. return v, errors.New("OldJitterSeconds is only allowed on UpdateOne operations")
  14173. }
  14174. if m.id == nil || m.oldValue == nil {
  14175. return v, errors.New("OldJitterSeconds requires an ID field in the mutation")
  14176. }
  14177. oldValue, err := m.oldValue(ctx)
  14178. if err != nil {
  14179. return v, fmt.Errorf("querying old value for OldJitterSeconds: %w", err)
  14180. }
  14181. return oldValue.JitterSeconds, nil
  14182. }
  14183. // AddJitterSeconds adds i to the "jitter_seconds" field.
  14184. func (m *ChannelMonitorMutation) AddJitterSeconds(i int) {
  14185. if m.addjitter_seconds != nil {
  14186. *m.addjitter_seconds += i
  14187. } else {
  14188. m.addjitter_seconds = &i
  14189. }
  14190. }
  14191. // AddedJitterSeconds returns the value that was added to the "jitter_seconds" field in this mutation.
  14192. func (m *ChannelMonitorMutation) AddedJitterSeconds() (r int, exists bool) {
  14193. v := m.addjitter_seconds
  14194. if v == nil {
  14195. return
  14196. }
  14197. return *v, true
  14198. }
  14199. // ResetJitterSeconds resets all changes to the "jitter_seconds" field.
  14200. func (m *ChannelMonitorMutation) ResetJitterSeconds() {
  14201. m.jitter_seconds = nil
  14202. m.addjitter_seconds = nil
  14203. }
  14204. // SetLastCheckedAt sets the "last_checked_at" field.
  14205. func (m *ChannelMonitorMutation) SetLastCheckedAt(t time.Time) {
  14206. m.last_checked_at = &t
  14207. }
  14208. // LastCheckedAt returns the value of the "last_checked_at" field in the mutation.
  14209. func (m *ChannelMonitorMutation) LastCheckedAt() (r time.Time, exists bool) {
  14210. v := m.last_checked_at
  14211. if v == nil {
  14212. return
  14213. }
  14214. return *v, true
  14215. }
  14216. // OldLastCheckedAt returns the old "last_checked_at" field's value of the ChannelMonitor entity.
  14217. // If the ChannelMonitor object wasn't provided to the builder, the object is fetched from the database.
  14218. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14219. func (m *ChannelMonitorMutation) OldLastCheckedAt(ctx context.Context) (v *time.Time, err error) {
  14220. if !m.op.Is(OpUpdateOne) {
  14221. return v, errors.New("OldLastCheckedAt is only allowed on UpdateOne operations")
  14222. }
  14223. if m.id == nil || m.oldValue == nil {
  14224. return v, errors.New("OldLastCheckedAt requires an ID field in the mutation")
  14225. }
  14226. oldValue, err := m.oldValue(ctx)
  14227. if err != nil {
  14228. return v, fmt.Errorf("querying old value for OldLastCheckedAt: %w", err)
  14229. }
  14230. return oldValue.LastCheckedAt, nil
  14231. }
  14232. // ClearLastCheckedAt clears the value of the "last_checked_at" field.
  14233. func (m *ChannelMonitorMutation) ClearLastCheckedAt() {
  14234. m.last_checked_at = nil
  14235. m.clearedFields[channelmonitor.FieldLastCheckedAt] = struct{}{}
  14236. }
  14237. // LastCheckedAtCleared returns if the "last_checked_at" field was cleared in this mutation.
  14238. func (m *ChannelMonitorMutation) LastCheckedAtCleared() bool {
  14239. _, ok := m.clearedFields[channelmonitor.FieldLastCheckedAt]
  14240. return ok
  14241. }
  14242. // ResetLastCheckedAt resets all changes to the "last_checked_at" field.
  14243. func (m *ChannelMonitorMutation) ResetLastCheckedAt() {
  14244. m.last_checked_at = nil
  14245. delete(m.clearedFields, channelmonitor.FieldLastCheckedAt)
  14246. }
  14247. // SetCreatedBy sets the "created_by" field.
  14248. func (m *ChannelMonitorMutation) SetCreatedBy(i int64) {
  14249. m.created_by = &i
  14250. m.addcreated_by = nil
  14251. }
  14252. // CreatedBy returns the value of the "created_by" field in the mutation.
  14253. func (m *ChannelMonitorMutation) CreatedBy() (r int64, exists bool) {
  14254. v := m.created_by
  14255. if v == nil {
  14256. return
  14257. }
  14258. return *v, true
  14259. }
  14260. // OldCreatedBy returns the old "created_by" field's value of the ChannelMonitor entity.
  14261. // If the ChannelMonitor object wasn't provided to the builder, the object is fetched from the database.
  14262. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14263. func (m *ChannelMonitorMutation) OldCreatedBy(ctx context.Context) (v int64, err error) {
  14264. if !m.op.Is(OpUpdateOne) {
  14265. return v, errors.New("OldCreatedBy is only allowed on UpdateOne operations")
  14266. }
  14267. if m.id == nil || m.oldValue == nil {
  14268. return v, errors.New("OldCreatedBy requires an ID field in the mutation")
  14269. }
  14270. oldValue, err := m.oldValue(ctx)
  14271. if err != nil {
  14272. return v, fmt.Errorf("querying old value for OldCreatedBy: %w", err)
  14273. }
  14274. return oldValue.CreatedBy, nil
  14275. }
  14276. // AddCreatedBy adds i to the "created_by" field.
  14277. func (m *ChannelMonitorMutation) AddCreatedBy(i int64) {
  14278. if m.addcreated_by != nil {
  14279. *m.addcreated_by += i
  14280. } else {
  14281. m.addcreated_by = &i
  14282. }
  14283. }
  14284. // AddedCreatedBy returns the value that was added to the "created_by" field in this mutation.
  14285. func (m *ChannelMonitorMutation) AddedCreatedBy() (r int64, exists bool) {
  14286. v := m.addcreated_by
  14287. if v == nil {
  14288. return
  14289. }
  14290. return *v, true
  14291. }
  14292. // ResetCreatedBy resets all changes to the "created_by" field.
  14293. func (m *ChannelMonitorMutation) ResetCreatedBy() {
  14294. m.created_by = nil
  14295. m.addcreated_by = nil
  14296. }
  14297. // SetTemplateID sets the "template_id" field.
  14298. func (m *ChannelMonitorMutation) SetTemplateID(i int64) {
  14299. m.request_template = &i
  14300. }
  14301. // TemplateID returns the value of the "template_id" field in the mutation.
  14302. func (m *ChannelMonitorMutation) TemplateID() (r int64, exists bool) {
  14303. v := m.request_template
  14304. if v == nil {
  14305. return
  14306. }
  14307. return *v, true
  14308. }
  14309. // OldTemplateID returns the old "template_id" field's value of the ChannelMonitor entity.
  14310. // If the ChannelMonitor object wasn't provided to the builder, the object is fetched from the database.
  14311. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14312. func (m *ChannelMonitorMutation) OldTemplateID(ctx context.Context) (v *int64, err error) {
  14313. if !m.op.Is(OpUpdateOne) {
  14314. return v, errors.New("OldTemplateID is only allowed on UpdateOne operations")
  14315. }
  14316. if m.id == nil || m.oldValue == nil {
  14317. return v, errors.New("OldTemplateID requires an ID field in the mutation")
  14318. }
  14319. oldValue, err := m.oldValue(ctx)
  14320. if err != nil {
  14321. return v, fmt.Errorf("querying old value for OldTemplateID: %w", err)
  14322. }
  14323. return oldValue.TemplateID, nil
  14324. }
  14325. // ClearTemplateID clears the value of the "template_id" field.
  14326. func (m *ChannelMonitorMutation) ClearTemplateID() {
  14327. m.request_template = nil
  14328. m.clearedFields[channelmonitor.FieldTemplateID] = struct{}{}
  14329. }
  14330. // TemplateIDCleared returns if the "template_id" field was cleared in this mutation.
  14331. func (m *ChannelMonitorMutation) TemplateIDCleared() bool {
  14332. _, ok := m.clearedFields[channelmonitor.FieldTemplateID]
  14333. return ok
  14334. }
  14335. // ResetTemplateID resets all changes to the "template_id" field.
  14336. func (m *ChannelMonitorMutation) ResetTemplateID() {
  14337. m.request_template = nil
  14338. delete(m.clearedFields, channelmonitor.FieldTemplateID)
  14339. }
  14340. // SetExtraHeaders sets the "extra_headers" field.
  14341. func (m *ChannelMonitorMutation) SetExtraHeaders(value map[string]string) {
  14342. m.extra_headers = &value
  14343. }
  14344. // ExtraHeaders returns the value of the "extra_headers" field in the mutation.
  14345. func (m *ChannelMonitorMutation) ExtraHeaders() (r map[string]string, exists bool) {
  14346. v := m.extra_headers
  14347. if v == nil {
  14348. return
  14349. }
  14350. return *v, true
  14351. }
  14352. // OldExtraHeaders returns the old "extra_headers" field's value of the ChannelMonitor entity.
  14353. // If the ChannelMonitor object wasn't provided to the builder, the object is fetched from the database.
  14354. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14355. func (m *ChannelMonitorMutation) OldExtraHeaders(ctx context.Context) (v map[string]string, err error) {
  14356. if !m.op.Is(OpUpdateOne) {
  14357. return v, errors.New("OldExtraHeaders is only allowed on UpdateOne operations")
  14358. }
  14359. if m.id == nil || m.oldValue == nil {
  14360. return v, errors.New("OldExtraHeaders requires an ID field in the mutation")
  14361. }
  14362. oldValue, err := m.oldValue(ctx)
  14363. if err != nil {
  14364. return v, fmt.Errorf("querying old value for OldExtraHeaders: %w", err)
  14365. }
  14366. return oldValue.ExtraHeaders, nil
  14367. }
  14368. // ResetExtraHeaders resets all changes to the "extra_headers" field.
  14369. func (m *ChannelMonitorMutation) ResetExtraHeaders() {
  14370. m.extra_headers = nil
  14371. }
  14372. // SetBodyOverrideMode sets the "body_override_mode" field.
  14373. func (m *ChannelMonitorMutation) SetBodyOverrideMode(s string) {
  14374. m.body_override_mode = &s
  14375. }
  14376. // BodyOverrideMode returns the value of the "body_override_mode" field in the mutation.
  14377. func (m *ChannelMonitorMutation) BodyOverrideMode() (r string, exists bool) {
  14378. v := m.body_override_mode
  14379. if v == nil {
  14380. return
  14381. }
  14382. return *v, true
  14383. }
  14384. // OldBodyOverrideMode returns the old "body_override_mode" field's value of the ChannelMonitor entity.
  14385. // If the ChannelMonitor object wasn't provided to the builder, the object is fetched from the database.
  14386. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14387. func (m *ChannelMonitorMutation) OldBodyOverrideMode(ctx context.Context) (v string, err error) {
  14388. if !m.op.Is(OpUpdateOne) {
  14389. return v, errors.New("OldBodyOverrideMode is only allowed on UpdateOne operations")
  14390. }
  14391. if m.id == nil || m.oldValue == nil {
  14392. return v, errors.New("OldBodyOverrideMode requires an ID field in the mutation")
  14393. }
  14394. oldValue, err := m.oldValue(ctx)
  14395. if err != nil {
  14396. return v, fmt.Errorf("querying old value for OldBodyOverrideMode: %w", err)
  14397. }
  14398. return oldValue.BodyOverrideMode, nil
  14399. }
  14400. // ResetBodyOverrideMode resets all changes to the "body_override_mode" field.
  14401. func (m *ChannelMonitorMutation) ResetBodyOverrideMode() {
  14402. m.body_override_mode = nil
  14403. }
  14404. // SetBodyOverride sets the "body_override" field.
  14405. func (m *ChannelMonitorMutation) SetBodyOverride(value map[string]interface{}) {
  14406. m.body_override = &value
  14407. }
  14408. // BodyOverride returns the value of the "body_override" field in the mutation.
  14409. func (m *ChannelMonitorMutation) BodyOverride() (r map[string]interface{}, exists bool) {
  14410. v := m.body_override
  14411. if v == nil {
  14412. return
  14413. }
  14414. return *v, true
  14415. }
  14416. // OldBodyOverride returns the old "body_override" field's value of the ChannelMonitor entity.
  14417. // If the ChannelMonitor object wasn't provided to the builder, the object is fetched from the database.
  14418. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14419. func (m *ChannelMonitorMutation) OldBodyOverride(ctx context.Context) (v map[string]interface{}, err error) {
  14420. if !m.op.Is(OpUpdateOne) {
  14421. return v, errors.New("OldBodyOverride is only allowed on UpdateOne operations")
  14422. }
  14423. if m.id == nil || m.oldValue == nil {
  14424. return v, errors.New("OldBodyOverride requires an ID field in the mutation")
  14425. }
  14426. oldValue, err := m.oldValue(ctx)
  14427. if err != nil {
  14428. return v, fmt.Errorf("querying old value for OldBodyOverride: %w", err)
  14429. }
  14430. return oldValue.BodyOverride, nil
  14431. }
  14432. // ClearBodyOverride clears the value of the "body_override" field.
  14433. func (m *ChannelMonitorMutation) ClearBodyOverride() {
  14434. m.body_override = nil
  14435. m.clearedFields[channelmonitor.FieldBodyOverride] = struct{}{}
  14436. }
  14437. // BodyOverrideCleared returns if the "body_override" field was cleared in this mutation.
  14438. func (m *ChannelMonitorMutation) BodyOverrideCleared() bool {
  14439. _, ok := m.clearedFields[channelmonitor.FieldBodyOverride]
  14440. return ok
  14441. }
  14442. // ResetBodyOverride resets all changes to the "body_override" field.
  14443. func (m *ChannelMonitorMutation) ResetBodyOverride() {
  14444. m.body_override = nil
  14445. delete(m.clearedFields, channelmonitor.FieldBodyOverride)
  14446. }
  14447. // AddHistoryIDs adds the "history" edge to the ChannelMonitorHistory entity by ids.
  14448. func (m *ChannelMonitorMutation) AddHistoryIDs(ids ...int64) {
  14449. if m.history == nil {
  14450. m.history = make(map[int64]struct{})
  14451. }
  14452. for i := range ids {
  14453. m.history[ids[i]] = struct{}{}
  14454. }
  14455. }
  14456. // ClearHistory clears the "history" edge to the ChannelMonitorHistory entity.
  14457. func (m *ChannelMonitorMutation) ClearHistory() {
  14458. m.clearedhistory = true
  14459. }
  14460. // HistoryCleared reports if the "history" edge to the ChannelMonitorHistory entity was cleared.
  14461. func (m *ChannelMonitorMutation) HistoryCleared() bool {
  14462. return m.clearedhistory
  14463. }
  14464. // RemoveHistoryIDs removes the "history" edge to the ChannelMonitorHistory entity by IDs.
  14465. func (m *ChannelMonitorMutation) RemoveHistoryIDs(ids ...int64) {
  14466. if m.removedhistory == nil {
  14467. m.removedhistory = make(map[int64]struct{})
  14468. }
  14469. for i := range ids {
  14470. delete(m.history, ids[i])
  14471. m.removedhistory[ids[i]] = struct{}{}
  14472. }
  14473. }
  14474. // RemovedHistory returns the removed IDs of the "history" edge to the ChannelMonitorHistory entity.
  14475. func (m *ChannelMonitorMutation) RemovedHistoryIDs() (ids []int64) {
  14476. for id := range m.removedhistory {
  14477. ids = append(ids, id)
  14478. }
  14479. return
  14480. }
  14481. // HistoryIDs returns the "history" edge IDs in the mutation.
  14482. func (m *ChannelMonitorMutation) HistoryIDs() (ids []int64) {
  14483. for id := range m.history {
  14484. ids = append(ids, id)
  14485. }
  14486. return
  14487. }
  14488. // ResetHistory resets all changes to the "history" edge.
  14489. func (m *ChannelMonitorMutation) ResetHistory() {
  14490. m.history = nil
  14491. m.clearedhistory = false
  14492. m.removedhistory = nil
  14493. }
  14494. // AddDailyRollupIDs adds the "daily_rollups" edge to the ChannelMonitorDailyRollup entity by ids.
  14495. func (m *ChannelMonitorMutation) AddDailyRollupIDs(ids ...int64) {
  14496. if m.daily_rollups == nil {
  14497. m.daily_rollups = make(map[int64]struct{})
  14498. }
  14499. for i := range ids {
  14500. m.daily_rollups[ids[i]] = struct{}{}
  14501. }
  14502. }
  14503. // ClearDailyRollups clears the "daily_rollups" edge to the ChannelMonitorDailyRollup entity.
  14504. func (m *ChannelMonitorMutation) ClearDailyRollups() {
  14505. m.cleareddaily_rollups = true
  14506. }
  14507. // DailyRollupsCleared reports if the "daily_rollups" edge to the ChannelMonitorDailyRollup entity was cleared.
  14508. func (m *ChannelMonitorMutation) DailyRollupsCleared() bool {
  14509. return m.cleareddaily_rollups
  14510. }
  14511. // RemoveDailyRollupIDs removes the "daily_rollups" edge to the ChannelMonitorDailyRollup entity by IDs.
  14512. func (m *ChannelMonitorMutation) RemoveDailyRollupIDs(ids ...int64) {
  14513. if m.removeddaily_rollups == nil {
  14514. m.removeddaily_rollups = make(map[int64]struct{})
  14515. }
  14516. for i := range ids {
  14517. delete(m.daily_rollups, ids[i])
  14518. m.removeddaily_rollups[ids[i]] = struct{}{}
  14519. }
  14520. }
  14521. // RemovedDailyRollups returns the removed IDs of the "daily_rollups" edge to the ChannelMonitorDailyRollup entity.
  14522. func (m *ChannelMonitorMutation) RemovedDailyRollupsIDs() (ids []int64) {
  14523. for id := range m.removeddaily_rollups {
  14524. ids = append(ids, id)
  14525. }
  14526. return
  14527. }
  14528. // DailyRollupsIDs returns the "daily_rollups" edge IDs in the mutation.
  14529. func (m *ChannelMonitorMutation) DailyRollupsIDs() (ids []int64) {
  14530. for id := range m.daily_rollups {
  14531. ids = append(ids, id)
  14532. }
  14533. return
  14534. }
  14535. // ResetDailyRollups resets all changes to the "daily_rollups" edge.
  14536. func (m *ChannelMonitorMutation) ResetDailyRollups() {
  14537. m.daily_rollups = nil
  14538. m.cleareddaily_rollups = false
  14539. m.removeddaily_rollups = nil
  14540. }
  14541. // SetRequestTemplateID sets the "request_template" edge to the ChannelMonitorRequestTemplate entity by id.
  14542. func (m *ChannelMonitorMutation) SetRequestTemplateID(id int64) {
  14543. m.request_template = &id
  14544. }
  14545. // ClearRequestTemplate clears the "request_template" edge to the ChannelMonitorRequestTemplate entity.
  14546. func (m *ChannelMonitorMutation) ClearRequestTemplate() {
  14547. m.clearedrequest_template = true
  14548. m.clearedFields[channelmonitor.FieldTemplateID] = struct{}{}
  14549. }
  14550. // RequestTemplateCleared reports if the "request_template" edge to the ChannelMonitorRequestTemplate entity was cleared.
  14551. func (m *ChannelMonitorMutation) RequestTemplateCleared() bool {
  14552. return m.TemplateIDCleared() || m.clearedrequest_template
  14553. }
  14554. // RequestTemplateID returns the "request_template" edge ID in the mutation.
  14555. func (m *ChannelMonitorMutation) RequestTemplateID() (id int64, exists bool) {
  14556. if m.request_template != nil {
  14557. return *m.request_template, true
  14558. }
  14559. return
  14560. }
  14561. // RequestTemplateIDs returns the "request_template" edge IDs in the mutation.
  14562. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  14563. // RequestTemplateID instead. It exists only for internal usage by the builders.
  14564. func (m *ChannelMonitorMutation) RequestTemplateIDs() (ids []int64) {
  14565. if id := m.request_template; id != nil {
  14566. ids = append(ids, *id)
  14567. }
  14568. return
  14569. }
  14570. // ResetRequestTemplate resets all changes to the "request_template" edge.
  14571. func (m *ChannelMonitorMutation) ResetRequestTemplate() {
  14572. m.request_template = nil
  14573. m.clearedrequest_template = false
  14574. }
  14575. // Where appends a list predicates to the ChannelMonitorMutation builder.
  14576. func (m *ChannelMonitorMutation) Where(ps ...predicate.ChannelMonitor) {
  14577. m.predicates = append(m.predicates, ps...)
  14578. }
  14579. // WhereP appends storage-level predicates to the ChannelMonitorMutation builder. Using this method,
  14580. // users can use type-assertion to append predicates that do not depend on any generated package.
  14581. func (m *ChannelMonitorMutation) WhereP(ps ...func(*sql.Selector)) {
  14582. p := make([]predicate.ChannelMonitor, len(ps))
  14583. for i := range ps {
  14584. p[i] = ps[i]
  14585. }
  14586. m.Where(p...)
  14587. }
  14588. // Op returns the operation name.
  14589. func (m *ChannelMonitorMutation) Op() Op {
  14590. return m.op
  14591. }
  14592. // SetOp allows setting the mutation operation.
  14593. func (m *ChannelMonitorMutation) SetOp(op Op) {
  14594. m.op = op
  14595. }
  14596. // Type returns the node type of this mutation (ChannelMonitor).
  14597. func (m *ChannelMonitorMutation) Type() string {
  14598. return m.typ
  14599. }
  14600. // Fields returns all fields that were changed during this mutation. Note that in
  14601. // order to get all numeric fields that were incremented/decremented, call
  14602. // AddedFields().
  14603. func (m *ChannelMonitorMutation) Fields() []string {
  14604. fields := make([]string, 0, 21)
  14605. if m.created_at != nil {
  14606. fields = append(fields, channelmonitor.FieldCreatedAt)
  14607. }
  14608. if m.updated_at != nil {
  14609. fields = append(fields, channelmonitor.FieldUpdatedAt)
  14610. }
  14611. if m.name != nil {
  14612. fields = append(fields, channelmonitor.FieldName)
  14613. }
  14614. if m.provider != nil {
  14615. fields = append(fields, channelmonitor.FieldProvider)
  14616. }
  14617. if m.check_mode != nil {
  14618. fields = append(fields, channelmonitor.FieldCheckMode)
  14619. }
  14620. if m.account_id != nil {
  14621. fields = append(fields, channelmonitor.FieldAccountID)
  14622. }
  14623. if m.api_mode != nil {
  14624. fields = append(fields, channelmonitor.FieldAPIMode)
  14625. }
  14626. if m.endpoint != nil {
  14627. fields = append(fields, channelmonitor.FieldEndpoint)
  14628. }
  14629. if m.api_key_encrypted != nil {
  14630. fields = append(fields, channelmonitor.FieldAPIKeyEncrypted)
  14631. }
  14632. if m.primary_model != nil {
  14633. fields = append(fields, channelmonitor.FieldPrimaryModel)
  14634. }
  14635. if m.extra_models != nil {
  14636. fields = append(fields, channelmonitor.FieldExtraModels)
  14637. }
  14638. if m.group_name != nil {
  14639. fields = append(fields, channelmonitor.FieldGroupName)
  14640. }
  14641. if m.enabled != nil {
  14642. fields = append(fields, channelmonitor.FieldEnabled)
  14643. }
  14644. if m.interval_seconds != nil {
  14645. fields = append(fields, channelmonitor.FieldIntervalSeconds)
  14646. }
  14647. if m.jitter_seconds != nil {
  14648. fields = append(fields, channelmonitor.FieldJitterSeconds)
  14649. }
  14650. if m.last_checked_at != nil {
  14651. fields = append(fields, channelmonitor.FieldLastCheckedAt)
  14652. }
  14653. if m.created_by != nil {
  14654. fields = append(fields, channelmonitor.FieldCreatedBy)
  14655. }
  14656. if m.request_template != nil {
  14657. fields = append(fields, channelmonitor.FieldTemplateID)
  14658. }
  14659. if m.extra_headers != nil {
  14660. fields = append(fields, channelmonitor.FieldExtraHeaders)
  14661. }
  14662. if m.body_override_mode != nil {
  14663. fields = append(fields, channelmonitor.FieldBodyOverrideMode)
  14664. }
  14665. if m.body_override != nil {
  14666. fields = append(fields, channelmonitor.FieldBodyOverride)
  14667. }
  14668. return fields
  14669. }
  14670. // Field returns the value of a field with the given name. The second boolean
  14671. // return value indicates that this field was not set, or was not defined in the
  14672. // schema.
  14673. func (m *ChannelMonitorMutation) Field(name string) (ent.Value, bool) {
  14674. switch name {
  14675. case channelmonitor.FieldCreatedAt:
  14676. return m.CreatedAt()
  14677. case channelmonitor.FieldUpdatedAt:
  14678. return m.UpdatedAt()
  14679. case channelmonitor.FieldName:
  14680. return m.Name()
  14681. case channelmonitor.FieldProvider:
  14682. return m.Provider()
  14683. case channelmonitor.FieldCheckMode:
  14684. return m.CheckMode()
  14685. case channelmonitor.FieldAccountID:
  14686. return m.AccountID()
  14687. case channelmonitor.FieldAPIMode:
  14688. return m.APIMode()
  14689. case channelmonitor.FieldEndpoint:
  14690. return m.Endpoint()
  14691. case channelmonitor.FieldAPIKeyEncrypted:
  14692. return m.APIKeyEncrypted()
  14693. case channelmonitor.FieldPrimaryModel:
  14694. return m.PrimaryModel()
  14695. case channelmonitor.FieldExtraModels:
  14696. return m.ExtraModels()
  14697. case channelmonitor.FieldGroupName:
  14698. return m.GroupName()
  14699. case channelmonitor.FieldEnabled:
  14700. return m.Enabled()
  14701. case channelmonitor.FieldIntervalSeconds:
  14702. return m.IntervalSeconds()
  14703. case channelmonitor.FieldJitterSeconds:
  14704. return m.JitterSeconds()
  14705. case channelmonitor.FieldLastCheckedAt:
  14706. return m.LastCheckedAt()
  14707. case channelmonitor.FieldCreatedBy:
  14708. return m.CreatedBy()
  14709. case channelmonitor.FieldTemplateID:
  14710. return m.TemplateID()
  14711. case channelmonitor.FieldExtraHeaders:
  14712. return m.ExtraHeaders()
  14713. case channelmonitor.FieldBodyOverrideMode:
  14714. return m.BodyOverrideMode()
  14715. case channelmonitor.FieldBodyOverride:
  14716. return m.BodyOverride()
  14717. }
  14718. return nil, false
  14719. }
  14720. // OldField returns the old value of the field from the database. An error is
  14721. // returned if the mutation operation is not UpdateOne, or the query to the
  14722. // database failed.
  14723. func (m *ChannelMonitorMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  14724. switch name {
  14725. case channelmonitor.FieldCreatedAt:
  14726. return m.OldCreatedAt(ctx)
  14727. case channelmonitor.FieldUpdatedAt:
  14728. return m.OldUpdatedAt(ctx)
  14729. case channelmonitor.FieldName:
  14730. return m.OldName(ctx)
  14731. case channelmonitor.FieldProvider:
  14732. return m.OldProvider(ctx)
  14733. case channelmonitor.FieldCheckMode:
  14734. return m.OldCheckMode(ctx)
  14735. case channelmonitor.FieldAccountID:
  14736. return m.OldAccountID(ctx)
  14737. case channelmonitor.FieldAPIMode:
  14738. return m.OldAPIMode(ctx)
  14739. case channelmonitor.FieldEndpoint:
  14740. return m.OldEndpoint(ctx)
  14741. case channelmonitor.FieldAPIKeyEncrypted:
  14742. return m.OldAPIKeyEncrypted(ctx)
  14743. case channelmonitor.FieldPrimaryModel:
  14744. return m.OldPrimaryModel(ctx)
  14745. case channelmonitor.FieldExtraModels:
  14746. return m.OldExtraModels(ctx)
  14747. case channelmonitor.FieldGroupName:
  14748. return m.OldGroupName(ctx)
  14749. case channelmonitor.FieldEnabled:
  14750. return m.OldEnabled(ctx)
  14751. case channelmonitor.FieldIntervalSeconds:
  14752. return m.OldIntervalSeconds(ctx)
  14753. case channelmonitor.FieldJitterSeconds:
  14754. return m.OldJitterSeconds(ctx)
  14755. case channelmonitor.FieldLastCheckedAt:
  14756. return m.OldLastCheckedAt(ctx)
  14757. case channelmonitor.FieldCreatedBy:
  14758. return m.OldCreatedBy(ctx)
  14759. case channelmonitor.FieldTemplateID:
  14760. return m.OldTemplateID(ctx)
  14761. case channelmonitor.FieldExtraHeaders:
  14762. return m.OldExtraHeaders(ctx)
  14763. case channelmonitor.FieldBodyOverrideMode:
  14764. return m.OldBodyOverrideMode(ctx)
  14765. case channelmonitor.FieldBodyOverride:
  14766. return m.OldBodyOverride(ctx)
  14767. }
  14768. return nil, fmt.Errorf("unknown ChannelMonitor field %s", name)
  14769. }
  14770. // SetField sets the value of a field with the given name. It returns an error if
  14771. // the field is not defined in the schema, or if the type mismatched the field
  14772. // type.
  14773. func (m *ChannelMonitorMutation) SetField(name string, value ent.Value) error {
  14774. switch name {
  14775. case channelmonitor.FieldCreatedAt:
  14776. v, ok := value.(time.Time)
  14777. if !ok {
  14778. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14779. }
  14780. m.SetCreatedAt(v)
  14781. return nil
  14782. case channelmonitor.FieldUpdatedAt:
  14783. v, ok := value.(time.Time)
  14784. if !ok {
  14785. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14786. }
  14787. m.SetUpdatedAt(v)
  14788. return nil
  14789. case channelmonitor.FieldName:
  14790. v, ok := value.(string)
  14791. if !ok {
  14792. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14793. }
  14794. m.SetName(v)
  14795. return nil
  14796. case channelmonitor.FieldProvider:
  14797. v, ok := value.(channelmonitor.Provider)
  14798. if !ok {
  14799. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14800. }
  14801. m.SetProvider(v)
  14802. return nil
  14803. case channelmonitor.FieldCheckMode:
  14804. v, ok := value.(string)
  14805. if !ok {
  14806. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14807. }
  14808. m.SetCheckMode(v)
  14809. return nil
  14810. case channelmonitor.FieldAccountID:
  14811. v, ok := value.(int64)
  14812. if !ok {
  14813. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14814. }
  14815. m.SetAccountID(v)
  14816. return nil
  14817. case channelmonitor.FieldAPIMode:
  14818. v, ok := value.(string)
  14819. if !ok {
  14820. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14821. }
  14822. m.SetAPIMode(v)
  14823. return nil
  14824. case channelmonitor.FieldEndpoint:
  14825. v, ok := value.(string)
  14826. if !ok {
  14827. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14828. }
  14829. m.SetEndpoint(v)
  14830. return nil
  14831. case channelmonitor.FieldAPIKeyEncrypted:
  14832. v, ok := value.(string)
  14833. if !ok {
  14834. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14835. }
  14836. m.SetAPIKeyEncrypted(v)
  14837. return nil
  14838. case channelmonitor.FieldPrimaryModel:
  14839. v, ok := value.(string)
  14840. if !ok {
  14841. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14842. }
  14843. m.SetPrimaryModel(v)
  14844. return nil
  14845. case channelmonitor.FieldExtraModels:
  14846. v, ok := value.([]string)
  14847. if !ok {
  14848. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14849. }
  14850. m.SetExtraModels(v)
  14851. return nil
  14852. case channelmonitor.FieldGroupName:
  14853. v, ok := value.(string)
  14854. if !ok {
  14855. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14856. }
  14857. m.SetGroupName(v)
  14858. return nil
  14859. case channelmonitor.FieldEnabled:
  14860. v, ok := value.(bool)
  14861. if !ok {
  14862. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14863. }
  14864. m.SetEnabled(v)
  14865. return nil
  14866. case channelmonitor.FieldIntervalSeconds:
  14867. v, ok := value.(int)
  14868. if !ok {
  14869. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14870. }
  14871. m.SetIntervalSeconds(v)
  14872. return nil
  14873. case channelmonitor.FieldJitterSeconds:
  14874. v, ok := value.(int)
  14875. if !ok {
  14876. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14877. }
  14878. m.SetJitterSeconds(v)
  14879. return nil
  14880. case channelmonitor.FieldLastCheckedAt:
  14881. v, ok := value.(time.Time)
  14882. if !ok {
  14883. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14884. }
  14885. m.SetLastCheckedAt(v)
  14886. return nil
  14887. case channelmonitor.FieldCreatedBy:
  14888. v, ok := value.(int64)
  14889. if !ok {
  14890. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14891. }
  14892. m.SetCreatedBy(v)
  14893. return nil
  14894. case channelmonitor.FieldTemplateID:
  14895. v, ok := value.(int64)
  14896. if !ok {
  14897. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14898. }
  14899. m.SetTemplateID(v)
  14900. return nil
  14901. case channelmonitor.FieldExtraHeaders:
  14902. v, ok := value.(map[string]string)
  14903. if !ok {
  14904. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14905. }
  14906. m.SetExtraHeaders(v)
  14907. return nil
  14908. case channelmonitor.FieldBodyOverrideMode:
  14909. v, ok := value.(string)
  14910. if !ok {
  14911. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14912. }
  14913. m.SetBodyOverrideMode(v)
  14914. return nil
  14915. case channelmonitor.FieldBodyOverride:
  14916. v, ok := value.(map[string]interface{})
  14917. if !ok {
  14918. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14919. }
  14920. m.SetBodyOverride(v)
  14921. return nil
  14922. }
  14923. return fmt.Errorf("unknown ChannelMonitor field %s", name)
  14924. }
  14925. // AddedFields returns all numeric fields that were incremented/decremented during
  14926. // this mutation.
  14927. func (m *ChannelMonitorMutation) AddedFields() []string {
  14928. var fields []string
  14929. if m.addaccount_id != nil {
  14930. fields = append(fields, channelmonitor.FieldAccountID)
  14931. }
  14932. if m.addinterval_seconds != nil {
  14933. fields = append(fields, channelmonitor.FieldIntervalSeconds)
  14934. }
  14935. if m.addjitter_seconds != nil {
  14936. fields = append(fields, channelmonitor.FieldJitterSeconds)
  14937. }
  14938. if m.addcreated_by != nil {
  14939. fields = append(fields, channelmonitor.FieldCreatedBy)
  14940. }
  14941. return fields
  14942. }
  14943. // AddedField returns the numeric value that was incremented/decremented on a field
  14944. // with the given name. The second boolean return value indicates that this field
  14945. // was not set, or was not defined in the schema.
  14946. func (m *ChannelMonitorMutation) AddedField(name string) (ent.Value, bool) {
  14947. switch name {
  14948. case channelmonitor.FieldAccountID:
  14949. return m.AddedAccountID()
  14950. case channelmonitor.FieldIntervalSeconds:
  14951. return m.AddedIntervalSeconds()
  14952. case channelmonitor.FieldJitterSeconds:
  14953. return m.AddedJitterSeconds()
  14954. case channelmonitor.FieldCreatedBy:
  14955. return m.AddedCreatedBy()
  14956. }
  14957. return nil, false
  14958. }
  14959. // AddField adds the value to the field with the given name. It returns an error if
  14960. // the field is not defined in the schema, or if the type mismatched the field
  14961. // type.
  14962. func (m *ChannelMonitorMutation) AddField(name string, value ent.Value) error {
  14963. switch name {
  14964. case channelmonitor.FieldAccountID:
  14965. v, ok := value.(int64)
  14966. if !ok {
  14967. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14968. }
  14969. m.AddAccountID(v)
  14970. return nil
  14971. case channelmonitor.FieldIntervalSeconds:
  14972. v, ok := value.(int)
  14973. if !ok {
  14974. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14975. }
  14976. m.AddIntervalSeconds(v)
  14977. return nil
  14978. case channelmonitor.FieldJitterSeconds:
  14979. v, ok := value.(int)
  14980. if !ok {
  14981. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14982. }
  14983. m.AddJitterSeconds(v)
  14984. return nil
  14985. case channelmonitor.FieldCreatedBy:
  14986. v, ok := value.(int64)
  14987. if !ok {
  14988. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14989. }
  14990. m.AddCreatedBy(v)
  14991. return nil
  14992. }
  14993. return fmt.Errorf("unknown ChannelMonitor numeric field %s", name)
  14994. }
  14995. // ClearedFields returns all nullable fields that were cleared during this
  14996. // mutation.
  14997. func (m *ChannelMonitorMutation) ClearedFields() []string {
  14998. var fields []string
  14999. if m.FieldCleared(channelmonitor.FieldAccountID) {
  15000. fields = append(fields, channelmonitor.FieldAccountID)
  15001. }
  15002. if m.FieldCleared(channelmonitor.FieldGroupName) {
  15003. fields = append(fields, channelmonitor.FieldGroupName)
  15004. }
  15005. if m.FieldCleared(channelmonitor.FieldLastCheckedAt) {
  15006. fields = append(fields, channelmonitor.FieldLastCheckedAt)
  15007. }
  15008. if m.FieldCleared(channelmonitor.FieldTemplateID) {
  15009. fields = append(fields, channelmonitor.FieldTemplateID)
  15010. }
  15011. if m.FieldCleared(channelmonitor.FieldBodyOverride) {
  15012. fields = append(fields, channelmonitor.FieldBodyOverride)
  15013. }
  15014. return fields
  15015. }
  15016. // FieldCleared returns a boolean indicating if a field with the given name was
  15017. // cleared in this mutation.
  15018. func (m *ChannelMonitorMutation) FieldCleared(name string) bool {
  15019. _, ok := m.clearedFields[name]
  15020. return ok
  15021. }
  15022. // ClearField clears the value of the field with the given name. It returns an
  15023. // error if the field is not defined in the schema.
  15024. func (m *ChannelMonitorMutation) ClearField(name string) error {
  15025. switch name {
  15026. case channelmonitor.FieldAccountID:
  15027. m.ClearAccountID()
  15028. return nil
  15029. case channelmonitor.FieldGroupName:
  15030. m.ClearGroupName()
  15031. return nil
  15032. case channelmonitor.FieldLastCheckedAt:
  15033. m.ClearLastCheckedAt()
  15034. return nil
  15035. case channelmonitor.FieldTemplateID:
  15036. m.ClearTemplateID()
  15037. return nil
  15038. case channelmonitor.FieldBodyOverride:
  15039. m.ClearBodyOverride()
  15040. return nil
  15041. }
  15042. return fmt.Errorf("unknown ChannelMonitor nullable field %s", name)
  15043. }
  15044. // ResetField resets all changes in the mutation for the field with the given name.
  15045. // It returns an error if the field is not defined in the schema.
  15046. func (m *ChannelMonitorMutation) ResetField(name string) error {
  15047. switch name {
  15048. case channelmonitor.FieldCreatedAt:
  15049. m.ResetCreatedAt()
  15050. return nil
  15051. case channelmonitor.FieldUpdatedAt:
  15052. m.ResetUpdatedAt()
  15053. return nil
  15054. case channelmonitor.FieldName:
  15055. m.ResetName()
  15056. return nil
  15057. case channelmonitor.FieldProvider:
  15058. m.ResetProvider()
  15059. return nil
  15060. case channelmonitor.FieldCheckMode:
  15061. m.ResetCheckMode()
  15062. return nil
  15063. case channelmonitor.FieldAccountID:
  15064. m.ResetAccountID()
  15065. return nil
  15066. case channelmonitor.FieldAPIMode:
  15067. m.ResetAPIMode()
  15068. return nil
  15069. case channelmonitor.FieldEndpoint:
  15070. m.ResetEndpoint()
  15071. return nil
  15072. case channelmonitor.FieldAPIKeyEncrypted:
  15073. m.ResetAPIKeyEncrypted()
  15074. return nil
  15075. case channelmonitor.FieldPrimaryModel:
  15076. m.ResetPrimaryModel()
  15077. return nil
  15078. case channelmonitor.FieldExtraModels:
  15079. m.ResetExtraModels()
  15080. return nil
  15081. case channelmonitor.FieldGroupName:
  15082. m.ResetGroupName()
  15083. return nil
  15084. case channelmonitor.FieldEnabled:
  15085. m.ResetEnabled()
  15086. return nil
  15087. case channelmonitor.FieldIntervalSeconds:
  15088. m.ResetIntervalSeconds()
  15089. return nil
  15090. case channelmonitor.FieldJitterSeconds:
  15091. m.ResetJitterSeconds()
  15092. return nil
  15093. case channelmonitor.FieldLastCheckedAt:
  15094. m.ResetLastCheckedAt()
  15095. return nil
  15096. case channelmonitor.FieldCreatedBy:
  15097. m.ResetCreatedBy()
  15098. return nil
  15099. case channelmonitor.FieldTemplateID:
  15100. m.ResetTemplateID()
  15101. return nil
  15102. case channelmonitor.FieldExtraHeaders:
  15103. m.ResetExtraHeaders()
  15104. return nil
  15105. case channelmonitor.FieldBodyOverrideMode:
  15106. m.ResetBodyOverrideMode()
  15107. return nil
  15108. case channelmonitor.FieldBodyOverride:
  15109. m.ResetBodyOverride()
  15110. return nil
  15111. }
  15112. return fmt.Errorf("unknown ChannelMonitor field %s", name)
  15113. }
  15114. // AddedEdges returns all edge names that were set/added in this mutation.
  15115. func (m *ChannelMonitorMutation) AddedEdges() []string {
  15116. edges := make([]string, 0, 3)
  15117. if m.history != nil {
  15118. edges = append(edges, channelmonitor.EdgeHistory)
  15119. }
  15120. if m.daily_rollups != nil {
  15121. edges = append(edges, channelmonitor.EdgeDailyRollups)
  15122. }
  15123. if m.request_template != nil {
  15124. edges = append(edges, channelmonitor.EdgeRequestTemplate)
  15125. }
  15126. return edges
  15127. }
  15128. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  15129. // name in this mutation.
  15130. func (m *ChannelMonitorMutation) AddedIDs(name string) []ent.Value {
  15131. switch name {
  15132. case channelmonitor.EdgeHistory:
  15133. ids := make([]ent.Value, 0, len(m.history))
  15134. for id := range m.history {
  15135. ids = append(ids, id)
  15136. }
  15137. return ids
  15138. case channelmonitor.EdgeDailyRollups:
  15139. ids := make([]ent.Value, 0, len(m.daily_rollups))
  15140. for id := range m.daily_rollups {
  15141. ids = append(ids, id)
  15142. }
  15143. return ids
  15144. case channelmonitor.EdgeRequestTemplate:
  15145. if id := m.request_template; id != nil {
  15146. return []ent.Value{*id}
  15147. }
  15148. }
  15149. return nil
  15150. }
  15151. // RemovedEdges returns all edge names that were removed in this mutation.
  15152. func (m *ChannelMonitorMutation) RemovedEdges() []string {
  15153. edges := make([]string, 0, 3)
  15154. if m.removedhistory != nil {
  15155. edges = append(edges, channelmonitor.EdgeHistory)
  15156. }
  15157. if m.removeddaily_rollups != nil {
  15158. edges = append(edges, channelmonitor.EdgeDailyRollups)
  15159. }
  15160. return edges
  15161. }
  15162. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  15163. // the given name in this mutation.
  15164. func (m *ChannelMonitorMutation) RemovedIDs(name string) []ent.Value {
  15165. switch name {
  15166. case channelmonitor.EdgeHistory:
  15167. ids := make([]ent.Value, 0, len(m.removedhistory))
  15168. for id := range m.removedhistory {
  15169. ids = append(ids, id)
  15170. }
  15171. return ids
  15172. case channelmonitor.EdgeDailyRollups:
  15173. ids := make([]ent.Value, 0, len(m.removeddaily_rollups))
  15174. for id := range m.removeddaily_rollups {
  15175. ids = append(ids, id)
  15176. }
  15177. return ids
  15178. }
  15179. return nil
  15180. }
  15181. // ClearedEdges returns all edge names that were cleared in this mutation.
  15182. func (m *ChannelMonitorMutation) ClearedEdges() []string {
  15183. edges := make([]string, 0, 3)
  15184. if m.clearedhistory {
  15185. edges = append(edges, channelmonitor.EdgeHistory)
  15186. }
  15187. if m.cleareddaily_rollups {
  15188. edges = append(edges, channelmonitor.EdgeDailyRollups)
  15189. }
  15190. if m.clearedrequest_template {
  15191. edges = append(edges, channelmonitor.EdgeRequestTemplate)
  15192. }
  15193. return edges
  15194. }
  15195. // EdgeCleared returns a boolean which indicates if the edge with the given name
  15196. // was cleared in this mutation.
  15197. func (m *ChannelMonitorMutation) EdgeCleared(name string) bool {
  15198. switch name {
  15199. case channelmonitor.EdgeHistory:
  15200. return m.clearedhistory
  15201. case channelmonitor.EdgeDailyRollups:
  15202. return m.cleareddaily_rollups
  15203. case channelmonitor.EdgeRequestTemplate:
  15204. return m.clearedrequest_template
  15205. }
  15206. return false
  15207. }
  15208. // ClearEdge clears the value of the edge with the given name. It returns an error
  15209. // if that edge is not defined in the schema.
  15210. func (m *ChannelMonitorMutation) ClearEdge(name string) error {
  15211. switch name {
  15212. case channelmonitor.EdgeRequestTemplate:
  15213. m.ClearRequestTemplate()
  15214. return nil
  15215. }
  15216. return fmt.Errorf("unknown ChannelMonitor unique edge %s", name)
  15217. }
  15218. // ResetEdge resets all changes to the edge with the given name in this mutation.
  15219. // It returns an error if the edge is not defined in the schema.
  15220. func (m *ChannelMonitorMutation) ResetEdge(name string) error {
  15221. switch name {
  15222. case channelmonitor.EdgeHistory:
  15223. m.ResetHistory()
  15224. return nil
  15225. case channelmonitor.EdgeDailyRollups:
  15226. m.ResetDailyRollups()
  15227. return nil
  15228. case channelmonitor.EdgeRequestTemplate:
  15229. m.ResetRequestTemplate()
  15230. return nil
  15231. }
  15232. return fmt.Errorf("unknown ChannelMonitor edge %s", name)
  15233. }
  15234. // ChannelMonitorDailyRollupMutation represents an operation that mutates the ChannelMonitorDailyRollup nodes in the graph.
  15235. type ChannelMonitorDailyRollupMutation struct {
  15236. config
  15237. op Op
  15238. typ string
  15239. id *int64
  15240. model *string
  15241. bucket_date *time.Time
  15242. total_checks *int
  15243. addtotal_checks *int
  15244. ok_count *int
  15245. addok_count *int
  15246. operational_count *int
  15247. addoperational_count *int
  15248. degraded_count *int
  15249. adddegraded_count *int
  15250. failed_count *int
  15251. addfailed_count *int
  15252. error_count *int
  15253. adderror_count *int
  15254. sum_latency_ms *int64
  15255. addsum_latency_ms *int64
  15256. count_latency *int
  15257. addcount_latency *int
  15258. sum_ping_latency_ms *int64
  15259. addsum_ping_latency_ms *int64
  15260. count_ping_latency *int
  15261. addcount_ping_latency *int
  15262. computed_at *time.Time
  15263. clearedFields map[string]struct{}
  15264. monitor *int64
  15265. clearedmonitor bool
  15266. done bool
  15267. oldValue func(context.Context) (*ChannelMonitorDailyRollup, error)
  15268. predicates []predicate.ChannelMonitorDailyRollup
  15269. }
  15270. var _ ent.Mutation = (*ChannelMonitorDailyRollupMutation)(nil)
  15271. // channelmonitordailyrollupOption allows management of the mutation configuration using functional options.
  15272. type channelmonitordailyrollupOption func(*ChannelMonitorDailyRollupMutation)
  15273. // newChannelMonitorDailyRollupMutation creates new mutation for the ChannelMonitorDailyRollup entity.
  15274. func newChannelMonitorDailyRollupMutation(c config, op Op, opts ...channelmonitordailyrollupOption) *ChannelMonitorDailyRollupMutation {
  15275. m := &ChannelMonitorDailyRollupMutation{
  15276. config: c,
  15277. op: op,
  15278. typ: TypeChannelMonitorDailyRollup,
  15279. clearedFields: make(map[string]struct{}),
  15280. }
  15281. for _, opt := range opts {
  15282. opt(m)
  15283. }
  15284. return m
  15285. }
  15286. // withChannelMonitorDailyRollupID sets the ID field of the mutation.
  15287. func withChannelMonitorDailyRollupID(id int64) channelmonitordailyrollupOption {
  15288. return func(m *ChannelMonitorDailyRollupMutation) {
  15289. var (
  15290. err error
  15291. once sync.Once
  15292. value *ChannelMonitorDailyRollup
  15293. )
  15294. m.oldValue = func(ctx context.Context) (*ChannelMonitorDailyRollup, error) {
  15295. once.Do(func() {
  15296. if m.done {
  15297. err = errors.New("querying old values post mutation is not allowed")
  15298. } else {
  15299. value, err = m.Client().ChannelMonitorDailyRollup.Get(ctx, id)
  15300. }
  15301. })
  15302. return value, err
  15303. }
  15304. m.id = &id
  15305. }
  15306. }
  15307. // withChannelMonitorDailyRollup sets the old ChannelMonitorDailyRollup of the mutation.
  15308. func withChannelMonitorDailyRollup(node *ChannelMonitorDailyRollup) channelmonitordailyrollupOption {
  15309. return func(m *ChannelMonitorDailyRollupMutation) {
  15310. m.oldValue = func(context.Context) (*ChannelMonitorDailyRollup, error) {
  15311. return node, nil
  15312. }
  15313. m.id = &node.ID
  15314. }
  15315. }
  15316. // Client returns a new `ent.Client` from the mutation. If the mutation was
  15317. // executed in a transaction (ent.Tx), a transactional client is returned.
  15318. func (m ChannelMonitorDailyRollupMutation) Client() *Client {
  15319. client := &Client{config: m.config}
  15320. client.init()
  15321. return client
  15322. }
  15323. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  15324. // it returns an error otherwise.
  15325. func (m ChannelMonitorDailyRollupMutation) Tx() (*Tx, error) {
  15326. if _, ok := m.driver.(*txDriver); !ok {
  15327. return nil, errors.New("ent: mutation is not running in a transaction")
  15328. }
  15329. tx := &Tx{config: m.config}
  15330. tx.init()
  15331. return tx, nil
  15332. }
  15333. // ID returns the ID value in the mutation. Note that the ID is only available
  15334. // if it was provided to the builder or after it was returned from the database.
  15335. func (m *ChannelMonitorDailyRollupMutation) ID() (id int64, exists bool) {
  15336. if m.id == nil {
  15337. return
  15338. }
  15339. return *m.id, true
  15340. }
  15341. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  15342. // That means, if the mutation is applied within a transaction with an isolation level such
  15343. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  15344. // or updated by the mutation.
  15345. func (m *ChannelMonitorDailyRollupMutation) IDs(ctx context.Context) ([]int64, error) {
  15346. switch {
  15347. case m.op.Is(OpUpdateOne | OpDeleteOne):
  15348. id, exists := m.ID()
  15349. if exists {
  15350. return []int64{id}, nil
  15351. }
  15352. fallthrough
  15353. case m.op.Is(OpUpdate | OpDelete):
  15354. return m.Client().ChannelMonitorDailyRollup.Query().Where(m.predicates...).IDs(ctx)
  15355. default:
  15356. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  15357. }
  15358. }
  15359. // SetMonitorID sets the "monitor_id" field.
  15360. func (m *ChannelMonitorDailyRollupMutation) SetMonitorID(i int64) {
  15361. m.monitor = &i
  15362. }
  15363. // MonitorID returns the value of the "monitor_id" field in the mutation.
  15364. func (m *ChannelMonitorDailyRollupMutation) MonitorID() (r int64, exists bool) {
  15365. v := m.monitor
  15366. if v == nil {
  15367. return
  15368. }
  15369. return *v, true
  15370. }
  15371. // OldMonitorID returns the old "monitor_id" field's value of the ChannelMonitorDailyRollup entity.
  15372. // If the ChannelMonitorDailyRollup object wasn't provided to the builder, the object is fetched from the database.
  15373. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15374. func (m *ChannelMonitorDailyRollupMutation) OldMonitorID(ctx context.Context) (v int64, err error) {
  15375. if !m.op.Is(OpUpdateOne) {
  15376. return v, errors.New("OldMonitorID is only allowed on UpdateOne operations")
  15377. }
  15378. if m.id == nil || m.oldValue == nil {
  15379. return v, errors.New("OldMonitorID requires an ID field in the mutation")
  15380. }
  15381. oldValue, err := m.oldValue(ctx)
  15382. if err != nil {
  15383. return v, fmt.Errorf("querying old value for OldMonitorID: %w", err)
  15384. }
  15385. return oldValue.MonitorID, nil
  15386. }
  15387. // ResetMonitorID resets all changes to the "monitor_id" field.
  15388. func (m *ChannelMonitorDailyRollupMutation) ResetMonitorID() {
  15389. m.monitor = nil
  15390. }
  15391. // SetModel sets the "model" field.
  15392. func (m *ChannelMonitorDailyRollupMutation) SetModel(s string) {
  15393. m.model = &s
  15394. }
  15395. // Model returns the value of the "model" field in the mutation.
  15396. func (m *ChannelMonitorDailyRollupMutation) Model() (r string, exists bool) {
  15397. v := m.model
  15398. if v == nil {
  15399. return
  15400. }
  15401. return *v, true
  15402. }
  15403. // OldModel returns the old "model" field's value of the ChannelMonitorDailyRollup entity.
  15404. // If the ChannelMonitorDailyRollup object wasn't provided to the builder, the object is fetched from the database.
  15405. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15406. func (m *ChannelMonitorDailyRollupMutation) OldModel(ctx context.Context) (v string, err error) {
  15407. if !m.op.Is(OpUpdateOne) {
  15408. return v, errors.New("OldModel is only allowed on UpdateOne operations")
  15409. }
  15410. if m.id == nil || m.oldValue == nil {
  15411. return v, errors.New("OldModel requires an ID field in the mutation")
  15412. }
  15413. oldValue, err := m.oldValue(ctx)
  15414. if err != nil {
  15415. return v, fmt.Errorf("querying old value for OldModel: %w", err)
  15416. }
  15417. return oldValue.Model, nil
  15418. }
  15419. // ResetModel resets all changes to the "model" field.
  15420. func (m *ChannelMonitorDailyRollupMutation) ResetModel() {
  15421. m.model = nil
  15422. }
  15423. // SetBucketDate sets the "bucket_date" field.
  15424. func (m *ChannelMonitorDailyRollupMutation) SetBucketDate(t time.Time) {
  15425. m.bucket_date = &t
  15426. }
  15427. // BucketDate returns the value of the "bucket_date" field in the mutation.
  15428. func (m *ChannelMonitorDailyRollupMutation) BucketDate() (r time.Time, exists bool) {
  15429. v := m.bucket_date
  15430. if v == nil {
  15431. return
  15432. }
  15433. return *v, true
  15434. }
  15435. // OldBucketDate returns the old "bucket_date" field's value of the ChannelMonitorDailyRollup entity.
  15436. // If the ChannelMonitorDailyRollup object wasn't provided to the builder, the object is fetched from the database.
  15437. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15438. func (m *ChannelMonitorDailyRollupMutation) OldBucketDate(ctx context.Context) (v time.Time, err error) {
  15439. if !m.op.Is(OpUpdateOne) {
  15440. return v, errors.New("OldBucketDate is only allowed on UpdateOne operations")
  15441. }
  15442. if m.id == nil || m.oldValue == nil {
  15443. return v, errors.New("OldBucketDate requires an ID field in the mutation")
  15444. }
  15445. oldValue, err := m.oldValue(ctx)
  15446. if err != nil {
  15447. return v, fmt.Errorf("querying old value for OldBucketDate: %w", err)
  15448. }
  15449. return oldValue.BucketDate, nil
  15450. }
  15451. // ResetBucketDate resets all changes to the "bucket_date" field.
  15452. func (m *ChannelMonitorDailyRollupMutation) ResetBucketDate() {
  15453. m.bucket_date = nil
  15454. }
  15455. // SetTotalChecks sets the "total_checks" field.
  15456. func (m *ChannelMonitorDailyRollupMutation) SetTotalChecks(i int) {
  15457. m.total_checks = &i
  15458. m.addtotal_checks = nil
  15459. }
  15460. // TotalChecks returns the value of the "total_checks" field in the mutation.
  15461. func (m *ChannelMonitorDailyRollupMutation) TotalChecks() (r int, exists bool) {
  15462. v := m.total_checks
  15463. if v == nil {
  15464. return
  15465. }
  15466. return *v, true
  15467. }
  15468. // OldTotalChecks returns the old "total_checks" field's value of the ChannelMonitorDailyRollup entity.
  15469. // If the ChannelMonitorDailyRollup object wasn't provided to the builder, the object is fetched from the database.
  15470. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15471. func (m *ChannelMonitorDailyRollupMutation) OldTotalChecks(ctx context.Context) (v int, err error) {
  15472. if !m.op.Is(OpUpdateOne) {
  15473. return v, errors.New("OldTotalChecks is only allowed on UpdateOne operations")
  15474. }
  15475. if m.id == nil || m.oldValue == nil {
  15476. return v, errors.New("OldTotalChecks requires an ID field in the mutation")
  15477. }
  15478. oldValue, err := m.oldValue(ctx)
  15479. if err != nil {
  15480. return v, fmt.Errorf("querying old value for OldTotalChecks: %w", err)
  15481. }
  15482. return oldValue.TotalChecks, nil
  15483. }
  15484. // AddTotalChecks adds i to the "total_checks" field.
  15485. func (m *ChannelMonitorDailyRollupMutation) AddTotalChecks(i int) {
  15486. if m.addtotal_checks != nil {
  15487. *m.addtotal_checks += i
  15488. } else {
  15489. m.addtotal_checks = &i
  15490. }
  15491. }
  15492. // AddedTotalChecks returns the value that was added to the "total_checks" field in this mutation.
  15493. func (m *ChannelMonitorDailyRollupMutation) AddedTotalChecks() (r int, exists bool) {
  15494. v := m.addtotal_checks
  15495. if v == nil {
  15496. return
  15497. }
  15498. return *v, true
  15499. }
  15500. // ResetTotalChecks resets all changes to the "total_checks" field.
  15501. func (m *ChannelMonitorDailyRollupMutation) ResetTotalChecks() {
  15502. m.total_checks = nil
  15503. m.addtotal_checks = nil
  15504. }
  15505. // SetOkCount sets the "ok_count" field.
  15506. func (m *ChannelMonitorDailyRollupMutation) SetOkCount(i int) {
  15507. m.ok_count = &i
  15508. m.addok_count = nil
  15509. }
  15510. // OkCount returns the value of the "ok_count" field in the mutation.
  15511. func (m *ChannelMonitorDailyRollupMutation) OkCount() (r int, exists bool) {
  15512. v := m.ok_count
  15513. if v == nil {
  15514. return
  15515. }
  15516. return *v, true
  15517. }
  15518. // OldOkCount returns the old "ok_count" field's value of the ChannelMonitorDailyRollup entity.
  15519. // If the ChannelMonitorDailyRollup object wasn't provided to the builder, the object is fetched from the database.
  15520. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15521. func (m *ChannelMonitorDailyRollupMutation) OldOkCount(ctx context.Context) (v int, err error) {
  15522. if !m.op.Is(OpUpdateOne) {
  15523. return v, errors.New("OldOkCount is only allowed on UpdateOne operations")
  15524. }
  15525. if m.id == nil || m.oldValue == nil {
  15526. return v, errors.New("OldOkCount requires an ID field in the mutation")
  15527. }
  15528. oldValue, err := m.oldValue(ctx)
  15529. if err != nil {
  15530. return v, fmt.Errorf("querying old value for OldOkCount: %w", err)
  15531. }
  15532. return oldValue.OkCount, nil
  15533. }
  15534. // AddOkCount adds i to the "ok_count" field.
  15535. func (m *ChannelMonitorDailyRollupMutation) AddOkCount(i int) {
  15536. if m.addok_count != nil {
  15537. *m.addok_count += i
  15538. } else {
  15539. m.addok_count = &i
  15540. }
  15541. }
  15542. // AddedOkCount returns the value that was added to the "ok_count" field in this mutation.
  15543. func (m *ChannelMonitorDailyRollupMutation) AddedOkCount() (r int, exists bool) {
  15544. v := m.addok_count
  15545. if v == nil {
  15546. return
  15547. }
  15548. return *v, true
  15549. }
  15550. // ResetOkCount resets all changes to the "ok_count" field.
  15551. func (m *ChannelMonitorDailyRollupMutation) ResetOkCount() {
  15552. m.ok_count = nil
  15553. m.addok_count = nil
  15554. }
  15555. // SetOperationalCount sets the "operational_count" field.
  15556. func (m *ChannelMonitorDailyRollupMutation) SetOperationalCount(i int) {
  15557. m.operational_count = &i
  15558. m.addoperational_count = nil
  15559. }
  15560. // OperationalCount returns the value of the "operational_count" field in the mutation.
  15561. func (m *ChannelMonitorDailyRollupMutation) OperationalCount() (r int, exists bool) {
  15562. v := m.operational_count
  15563. if v == nil {
  15564. return
  15565. }
  15566. return *v, true
  15567. }
  15568. // OldOperationalCount returns the old "operational_count" field's value of the ChannelMonitorDailyRollup entity.
  15569. // If the ChannelMonitorDailyRollup object wasn't provided to the builder, the object is fetched from the database.
  15570. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15571. func (m *ChannelMonitorDailyRollupMutation) OldOperationalCount(ctx context.Context) (v int, err error) {
  15572. if !m.op.Is(OpUpdateOne) {
  15573. return v, errors.New("OldOperationalCount is only allowed on UpdateOne operations")
  15574. }
  15575. if m.id == nil || m.oldValue == nil {
  15576. return v, errors.New("OldOperationalCount requires an ID field in the mutation")
  15577. }
  15578. oldValue, err := m.oldValue(ctx)
  15579. if err != nil {
  15580. return v, fmt.Errorf("querying old value for OldOperationalCount: %w", err)
  15581. }
  15582. return oldValue.OperationalCount, nil
  15583. }
  15584. // AddOperationalCount adds i to the "operational_count" field.
  15585. func (m *ChannelMonitorDailyRollupMutation) AddOperationalCount(i int) {
  15586. if m.addoperational_count != nil {
  15587. *m.addoperational_count += i
  15588. } else {
  15589. m.addoperational_count = &i
  15590. }
  15591. }
  15592. // AddedOperationalCount returns the value that was added to the "operational_count" field in this mutation.
  15593. func (m *ChannelMonitorDailyRollupMutation) AddedOperationalCount() (r int, exists bool) {
  15594. v := m.addoperational_count
  15595. if v == nil {
  15596. return
  15597. }
  15598. return *v, true
  15599. }
  15600. // ResetOperationalCount resets all changes to the "operational_count" field.
  15601. func (m *ChannelMonitorDailyRollupMutation) ResetOperationalCount() {
  15602. m.operational_count = nil
  15603. m.addoperational_count = nil
  15604. }
  15605. // SetDegradedCount sets the "degraded_count" field.
  15606. func (m *ChannelMonitorDailyRollupMutation) SetDegradedCount(i int) {
  15607. m.degraded_count = &i
  15608. m.adddegraded_count = nil
  15609. }
  15610. // DegradedCount returns the value of the "degraded_count" field in the mutation.
  15611. func (m *ChannelMonitorDailyRollupMutation) DegradedCount() (r int, exists bool) {
  15612. v := m.degraded_count
  15613. if v == nil {
  15614. return
  15615. }
  15616. return *v, true
  15617. }
  15618. // OldDegradedCount returns the old "degraded_count" field's value of the ChannelMonitorDailyRollup entity.
  15619. // If the ChannelMonitorDailyRollup object wasn't provided to the builder, the object is fetched from the database.
  15620. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15621. func (m *ChannelMonitorDailyRollupMutation) OldDegradedCount(ctx context.Context) (v int, err error) {
  15622. if !m.op.Is(OpUpdateOne) {
  15623. return v, errors.New("OldDegradedCount is only allowed on UpdateOne operations")
  15624. }
  15625. if m.id == nil || m.oldValue == nil {
  15626. return v, errors.New("OldDegradedCount requires an ID field in the mutation")
  15627. }
  15628. oldValue, err := m.oldValue(ctx)
  15629. if err != nil {
  15630. return v, fmt.Errorf("querying old value for OldDegradedCount: %w", err)
  15631. }
  15632. return oldValue.DegradedCount, nil
  15633. }
  15634. // AddDegradedCount adds i to the "degraded_count" field.
  15635. func (m *ChannelMonitorDailyRollupMutation) AddDegradedCount(i int) {
  15636. if m.adddegraded_count != nil {
  15637. *m.adddegraded_count += i
  15638. } else {
  15639. m.adddegraded_count = &i
  15640. }
  15641. }
  15642. // AddedDegradedCount returns the value that was added to the "degraded_count" field in this mutation.
  15643. func (m *ChannelMonitorDailyRollupMutation) AddedDegradedCount() (r int, exists bool) {
  15644. v := m.adddegraded_count
  15645. if v == nil {
  15646. return
  15647. }
  15648. return *v, true
  15649. }
  15650. // ResetDegradedCount resets all changes to the "degraded_count" field.
  15651. func (m *ChannelMonitorDailyRollupMutation) ResetDegradedCount() {
  15652. m.degraded_count = nil
  15653. m.adddegraded_count = nil
  15654. }
  15655. // SetFailedCount sets the "failed_count" field.
  15656. func (m *ChannelMonitorDailyRollupMutation) SetFailedCount(i int) {
  15657. m.failed_count = &i
  15658. m.addfailed_count = nil
  15659. }
  15660. // FailedCount returns the value of the "failed_count" field in the mutation.
  15661. func (m *ChannelMonitorDailyRollupMutation) FailedCount() (r int, exists bool) {
  15662. v := m.failed_count
  15663. if v == nil {
  15664. return
  15665. }
  15666. return *v, true
  15667. }
  15668. // OldFailedCount returns the old "failed_count" field's value of the ChannelMonitorDailyRollup entity.
  15669. // If the ChannelMonitorDailyRollup object wasn't provided to the builder, the object is fetched from the database.
  15670. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15671. func (m *ChannelMonitorDailyRollupMutation) OldFailedCount(ctx context.Context) (v int, err error) {
  15672. if !m.op.Is(OpUpdateOne) {
  15673. return v, errors.New("OldFailedCount is only allowed on UpdateOne operations")
  15674. }
  15675. if m.id == nil || m.oldValue == nil {
  15676. return v, errors.New("OldFailedCount requires an ID field in the mutation")
  15677. }
  15678. oldValue, err := m.oldValue(ctx)
  15679. if err != nil {
  15680. return v, fmt.Errorf("querying old value for OldFailedCount: %w", err)
  15681. }
  15682. return oldValue.FailedCount, nil
  15683. }
  15684. // AddFailedCount adds i to the "failed_count" field.
  15685. func (m *ChannelMonitorDailyRollupMutation) AddFailedCount(i int) {
  15686. if m.addfailed_count != nil {
  15687. *m.addfailed_count += i
  15688. } else {
  15689. m.addfailed_count = &i
  15690. }
  15691. }
  15692. // AddedFailedCount returns the value that was added to the "failed_count" field in this mutation.
  15693. func (m *ChannelMonitorDailyRollupMutation) AddedFailedCount() (r int, exists bool) {
  15694. v := m.addfailed_count
  15695. if v == nil {
  15696. return
  15697. }
  15698. return *v, true
  15699. }
  15700. // ResetFailedCount resets all changes to the "failed_count" field.
  15701. func (m *ChannelMonitorDailyRollupMutation) ResetFailedCount() {
  15702. m.failed_count = nil
  15703. m.addfailed_count = nil
  15704. }
  15705. // SetErrorCount sets the "error_count" field.
  15706. func (m *ChannelMonitorDailyRollupMutation) SetErrorCount(i int) {
  15707. m.error_count = &i
  15708. m.adderror_count = nil
  15709. }
  15710. // ErrorCount returns the value of the "error_count" field in the mutation.
  15711. func (m *ChannelMonitorDailyRollupMutation) ErrorCount() (r int, exists bool) {
  15712. v := m.error_count
  15713. if v == nil {
  15714. return
  15715. }
  15716. return *v, true
  15717. }
  15718. // OldErrorCount returns the old "error_count" field's value of the ChannelMonitorDailyRollup entity.
  15719. // If the ChannelMonitorDailyRollup object wasn't provided to the builder, the object is fetched from the database.
  15720. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15721. func (m *ChannelMonitorDailyRollupMutation) OldErrorCount(ctx context.Context) (v int, err error) {
  15722. if !m.op.Is(OpUpdateOne) {
  15723. return v, errors.New("OldErrorCount is only allowed on UpdateOne operations")
  15724. }
  15725. if m.id == nil || m.oldValue == nil {
  15726. return v, errors.New("OldErrorCount requires an ID field in the mutation")
  15727. }
  15728. oldValue, err := m.oldValue(ctx)
  15729. if err != nil {
  15730. return v, fmt.Errorf("querying old value for OldErrorCount: %w", err)
  15731. }
  15732. return oldValue.ErrorCount, nil
  15733. }
  15734. // AddErrorCount adds i to the "error_count" field.
  15735. func (m *ChannelMonitorDailyRollupMutation) AddErrorCount(i int) {
  15736. if m.adderror_count != nil {
  15737. *m.adderror_count += i
  15738. } else {
  15739. m.adderror_count = &i
  15740. }
  15741. }
  15742. // AddedErrorCount returns the value that was added to the "error_count" field in this mutation.
  15743. func (m *ChannelMonitorDailyRollupMutation) AddedErrorCount() (r int, exists bool) {
  15744. v := m.adderror_count
  15745. if v == nil {
  15746. return
  15747. }
  15748. return *v, true
  15749. }
  15750. // ResetErrorCount resets all changes to the "error_count" field.
  15751. func (m *ChannelMonitorDailyRollupMutation) ResetErrorCount() {
  15752. m.error_count = nil
  15753. m.adderror_count = nil
  15754. }
  15755. // SetSumLatencyMs sets the "sum_latency_ms" field.
  15756. func (m *ChannelMonitorDailyRollupMutation) SetSumLatencyMs(i int64) {
  15757. m.sum_latency_ms = &i
  15758. m.addsum_latency_ms = nil
  15759. }
  15760. // SumLatencyMs returns the value of the "sum_latency_ms" field in the mutation.
  15761. func (m *ChannelMonitorDailyRollupMutation) SumLatencyMs() (r int64, exists bool) {
  15762. v := m.sum_latency_ms
  15763. if v == nil {
  15764. return
  15765. }
  15766. return *v, true
  15767. }
  15768. // OldSumLatencyMs returns the old "sum_latency_ms" field's value of the ChannelMonitorDailyRollup entity.
  15769. // If the ChannelMonitorDailyRollup object wasn't provided to the builder, the object is fetched from the database.
  15770. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15771. func (m *ChannelMonitorDailyRollupMutation) OldSumLatencyMs(ctx context.Context) (v int64, err error) {
  15772. if !m.op.Is(OpUpdateOne) {
  15773. return v, errors.New("OldSumLatencyMs is only allowed on UpdateOne operations")
  15774. }
  15775. if m.id == nil || m.oldValue == nil {
  15776. return v, errors.New("OldSumLatencyMs requires an ID field in the mutation")
  15777. }
  15778. oldValue, err := m.oldValue(ctx)
  15779. if err != nil {
  15780. return v, fmt.Errorf("querying old value for OldSumLatencyMs: %w", err)
  15781. }
  15782. return oldValue.SumLatencyMs, nil
  15783. }
  15784. // AddSumLatencyMs adds i to the "sum_latency_ms" field.
  15785. func (m *ChannelMonitorDailyRollupMutation) AddSumLatencyMs(i int64) {
  15786. if m.addsum_latency_ms != nil {
  15787. *m.addsum_latency_ms += i
  15788. } else {
  15789. m.addsum_latency_ms = &i
  15790. }
  15791. }
  15792. // AddedSumLatencyMs returns the value that was added to the "sum_latency_ms" field in this mutation.
  15793. func (m *ChannelMonitorDailyRollupMutation) AddedSumLatencyMs() (r int64, exists bool) {
  15794. v := m.addsum_latency_ms
  15795. if v == nil {
  15796. return
  15797. }
  15798. return *v, true
  15799. }
  15800. // ResetSumLatencyMs resets all changes to the "sum_latency_ms" field.
  15801. func (m *ChannelMonitorDailyRollupMutation) ResetSumLatencyMs() {
  15802. m.sum_latency_ms = nil
  15803. m.addsum_latency_ms = nil
  15804. }
  15805. // SetCountLatency sets the "count_latency" field.
  15806. func (m *ChannelMonitorDailyRollupMutation) SetCountLatency(i int) {
  15807. m.count_latency = &i
  15808. m.addcount_latency = nil
  15809. }
  15810. // CountLatency returns the value of the "count_latency" field in the mutation.
  15811. func (m *ChannelMonitorDailyRollupMutation) CountLatency() (r int, exists bool) {
  15812. v := m.count_latency
  15813. if v == nil {
  15814. return
  15815. }
  15816. return *v, true
  15817. }
  15818. // OldCountLatency returns the old "count_latency" field's value of the ChannelMonitorDailyRollup entity.
  15819. // If the ChannelMonitorDailyRollup object wasn't provided to the builder, the object is fetched from the database.
  15820. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15821. func (m *ChannelMonitorDailyRollupMutation) OldCountLatency(ctx context.Context) (v int, err error) {
  15822. if !m.op.Is(OpUpdateOne) {
  15823. return v, errors.New("OldCountLatency is only allowed on UpdateOne operations")
  15824. }
  15825. if m.id == nil || m.oldValue == nil {
  15826. return v, errors.New("OldCountLatency requires an ID field in the mutation")
  15827. }
  15828. oldValue, err := m.oldValue(ctx)
  15829. if err != nil {
  15830. return v, fmt.Errorf("querying old value for OldCountLatency: %w", err)
  15831. }
  15832. return oldValue.CountLatency, nil
  15833. }
  15834. // AddCountLatency adds i to the "count_latency" field.
  15835. func (m *ChannelMonitorDailyRollupMutation) AddCountLatency(i int) {
  15836. if m.addcount_latency != nil {
  15837. *m.addcount_latency += i
  15838. } else {
  15839. m.addcount_latency = &i
  15840. }
  15841. }
  15842. // AddedCountLatency returns the value that was added to the "count_latency" field in this mutation.
  15843. func (m *ChannelMonitorDailyRollupMutation) AddedCountLatency() (r int, exists bool) {
  15844. v := m.addcount_latency
  15845. if v == nil {
  15846. return
  15847. }
  15848. return *v, true
  15849. }
  15850. // ResetCountLatency resets all changes to the "count_latency" field.
  15851. func (m *ChannelMonitorDailyRollupMutation) ResetCountLatency() {
  15852. m.count_latency = nil
  15853. m.addcount_latency = nil
  15854. }
  15855. // SetSumPingLatencyMs sets the "sum_ping_latency_ms" field.
  15856. func (m *ChannelMonitorDailyRollupMutation) SetSumPingLatencyMs(i int64) {
  15857. m.sum_ping_latency_ms = &i
  15858. m.addsum_ping_latency_ms = nil
  15859. }
  15860. // SumPingLatencyMs returns the value of the "sum_ping_latency_ms" field in the mutation.
  15861. func (m *ChannelMonitorDailyRollupMutation) SumPingLatencyMs() (r int64, exists bool) {
  15862. v := m.sum_ping_latency_ms
  15863. if v == nil {
  15864. return
  15865. }
  15866. return *v, true
  15867. }
  15868. // OldSumPingLatencyMs returns the old "sum_ping_latency_ms" field's value of the ChannelMonitorDailyRollup entity.
  15869. // If the ChannelMonitorDailyRollup object wasn't provided to the builder, the object is fetched from the database.
  15870. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15871. func (m *ChannelMonitorDailyRollupMutation) OldSumPingLatencyMs(ctx context.Context) (v int64, err error) {
  15872. if !m.op.Is(OpUpdateOne) {
  15873. return v, errors.New("OldSumPingLatencyMs is only allowed on UpdateOne operations")
  15874. }
  15875. if m.id == nil || m.oldValue == nil {
  15876. return v, errors.New("OldSumPingLatencyMs requires an ID field in the mutation")
  15877. }
  15878. oldValue, err := m.oldValue(ctx)
  15879. if err != nil {
  15880. return v, fmt.Errorf("querying old value for OldSumPingLatencyMs: %w", err)
  15881. }
  15882. return oldValue.SumPingLatencyMs, nil
  15883. }
  15884. // AddSumPingLatencyMs adds i to the "sum_ping_latency_ms" field.
  15885. func (m *ChannelMonitorDailyRollupMutation) AddSumPingLatencyMs(i int64) {
  15886. if m.addsum_ping_latency_ms != nil {
  15887. *m.addsum_ping_latency_ms += i
  15888. } else {
  15889. m.addsum_ping_latency_ms = &i
  15890. }
  15891. }
  15892. // AddedSumPingLatencyMs returns the value that was added to the "sum_ping_latency_ms" field in this mutation.
  15893. func (m *ChannelMonitorDailyRollupMutation) AddedSumPingLatencyMs() (r int64, exists bool) {
  15894. v := m.addsum_ping_latency_ms
  15895. if v == nil {
  15896. return
  15897. }
  15898. return *v, true
  15899. }
  15900. // ResetSumPingLatencyMs resets all changes to the "sum_ping_latency_ms" field.
  15901. func (m *ChannelMonitorDailyRollupMutation) ResetSumPingLatencyMs() {
  15902. m.sum_ping_latency_ms = nil
  15903. m.addsum_ping_latency_ms = nil
  15904. }
  15905. // SetCountPingLatency sets the "count_ping_latency" field.
  15906. func (m *ChannelMonitorDailyRollupMutation) SetCountPingLatency(i int) {
  15907. m.count_ping_latency = &i
  15908. m.addcount_ping_latency = nil
  15909. }
  15910. // CountPingLatency returns the value of the "count_ping_latency" field in the mutation.
  15911. func (m *ChannelMonitorDailyRollupMutation) CountPingLatency() (r int, exists bool) {
  15912. v := m.count_ping_latency
  15913. if v == nil {
  15914. return
  15915. }
  15916. return *v, true
  15917. }
  15918. // OldCountPingLatency returns the old "count_ping_latency" field's value of the ChannelMonitorDailyRollup entity.
  15919. // If the ChannelMonitorDailyRollup object wasn't provided to the builder, the object is fetched from the database.
  15920. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15921. func (m *ChannelMonitorDailyRollupMutation) OldCountPingLatency(ctx context.Context) (v int, err error) {
  15922. if !m.op.Is(OpUpdateOne) {
  15923. return v, errors.New("OldCountPingLatency is only allowed on UpdateOne operations")
  15924. }
  15925. if m.id == nil || m.oldValue == nil {
  15926. return v, errors.New("OldCountPingLatency requires an ID field in the mutation")
  15927. }
  15928. oldValue, err := m.oldValue(ctx)
  15929. if err != nil {
  15930. return v, fmt.Errorf("querying old value for OldCountPingLatency: %w", err)
  15931. }
  15932. return oldValue.CountPingLatency, nil
  15933. }
  15934. // AddCountPingLatency adds i to the "count_ping_latency" field.
  15935. func (m *ChannelMonitorDailyRollupMutation) AddCountPingLatency(i int) {
  15936. if m.addcount_ping_latency != nil {
  15937. *m.addcount_ping_latency += i
  15938. } else {
  15939. m.addcount_ping_latency = &i
  15940. }
  15941. }
  15942. // AddedCountPingLatency returns the value that was added to the "count_ping_latency" field in this mutation.
  15943. func (m *ChannelMonitorDailyRollupMutation) AddedCountPingLatency() (r int, exists bool) {
  15944. v := m.addcount_ping_latency
  15945. if v == nil {
  15946. return
  15947. }
  15948. return *v, true
  15949. }
  15950. // ResetCountPingLatency resets all changes to the "count_ping_latency" field.
  15951. func (m *ChannelMonitorDailyRollupMutation) ResetCountPingLatency() {
  15952. m.count_ping_latency = nil
  15953. m.addcount_ping_latency = nil
  15954. }
  15955. // SetComputedAt sets the "computed_at" field.
  15956. func (m *ChannelMonitorDailyRollupMutation) SetComputedAt(t time.Time) {
  15957. m.computed_at = &t
  15958. }
  15959. // ComputedAt returns the value of the "computed_at" field in the mutation.
  15960. func (m *ChannelMonitorDailyRollupMutation) ComputedAt() (r time.Time, exists bool) {
  15961. v := m.computed_at
  15962. if v == nil {
  15963. return
  15964. }
  15965. return *v, true
  15966. }
  15967. // OldComputedAt returns the old "computed_at" field's value of the ChannelMonitorDailyRollup entity.
  15968. // If the ChannelMonitorDailyRollup object wasn't provided to the builder, the object is fetched from the database.
  15969. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15970. func (m *ChannelMonitorDailyRollupMutation) OldComputedAt(ctx context.Context) (v time.Time, err error) {
  15971. if !m.op.Is(OpUpdateOne) {
  15972. return v, errors.New("OldComputedAt is only allowed on UpdateOne operations")
  15973. }
  15974. if m.id == nil || m.oldValue == nil {
  15975. return v, errors.New("OldComputedAt requires an ID field in the mutation")
  15976. }
  15977. oldValue, err := m.oldValue(ctx)
  15978. if err != nil {
  15979. return v, fmt.Errorf("querying old value for OldComputedAt: %w", err)
  15980. }
  15981. return oldValue.ComputedAt, nil
  15982. }
  15983. // ResetComputedAt resets all changes to the "computed_at" field.
  15984. func (m *ChannelMonitorDailyRollupMutation) ResetComputedAt() {
  15985. m.computed_at = nil
  15986. }
  15987. // ClearMonitor clears the "monitor" edge to the ChannelMonitor entity.
  15988. func (m *ChannelMonitorDailyRollupMutation) ClearMonitor() {
  15989. m.clearedmonitor = true
  15990. m.clearedFields[channelmonitordailyrollup.FieldMonitorID] = struct{}{}
  15991. }
  15992. // MonitorCleared reports if the "monitor" edge to the ChannelMonitor entity was cleared.
  15993. func (m *ChannelMonitorDailyRollupMutation) MonitorCleared() bool {
  15994. return m.clearedmonitor
  15995. }
  15996. // MonitorIDs returns the "monitor" edge IDs in the mutation.
  15997. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  15998. // MonitorID instead. It exists only for internal usage by the builders.
  15999. func (m *ChannelMonitorDailyRollupMutation) MonitorIDs() (ids []int64) {
  16000. if id := m.monitor; id != nil {
  16001. ids = append(ids, *id)
  16002. }
  16003. return
  16004. }
  16005. // ResetMonitor resets all changes to the "monitor" edge.
  16006. func (m *ChannelMonitorDailyRollupMutation) ResetMonitor() {
  16007. m.monitor = nil
  16008. m.clearedmonitor = false
  16009. }
  16010. // Where appends a list predicates to the ChannelMonitorDailyRollupMutation builder.
  16011. func (m *ChannelMonitorDailyRollupMutation) Where(ps ...predicate.ChannelMonitorDailyRollup) {
  16012. m.predicates = append(m.predicates, ps...)
  16013. }
  16014. // WhereP appends storage-level predicates to the ChannelMonitorDailyRollupMutation builder. Using this method,
  16015. // users can use type-assertion to append predicates that do not depend on any generated package.
  16016. func (m *ChannelMonitorDailyRollupMutation) WhereP(ps ...func(*sql.Selector)) {
  16017. p := make([]predicate.ChannelMonitorDailyRollup, len(ps))
  16018. for i := range ps {
  16019. p[i] = ps[i]
  16020. }
  16021. m.Where(p...)
  16022. }
  16023. // Op returns the operation name.
  16024. func (m *ChannelMonitorDailyRollupMutation) Op() Op {
  16025. return m.op
  16026. }
  16027. // SetOp allows setting the mutation operation.
  16028. func (m *ChannelMonitorDailyRollupMutation) SetOp(op Op) {
  16029. m.op = op
  16030. }
  16031. // Type returns the node type of this mutation (ChannelMonitorDailyRollup).
  16032. func (m *ChannelMonitorDailyRollupMutation) Type() string {
  16033. return m.typ
  16034. }
  16035. // Fields returns all fields that were changed during this mutation. Note that in
  16036. // order to get all numeric fields that were incremented/decremented, call
  16037. // AddedFields().
  16038. func (m *ChannelMonitorDailyRollupMutation) Fields() []string {
  16039. fields := make([]string, 0, 14)
  16040. if m.monitor != nil {
  16041. fields = append(fields, channelmonitordailyrollup.FieldMonitorID)
  16042. }
  16043. if m.model != nil {
  16044. fields = append(fields, channelmonitordailyrollup.FieldModel)
  16045. }
  16046. if m.bucket_date != nil {
  16047. fields = append(fields, channelmonitordailyrollup.FieldBucketDate)
  16048. }
  16049. if m.total_checks != nil {
  16050. fields = append(fields, channelmonitordailyrollup.FieldTotalChecks)
  16051. }
  16052. if m.ok_count != nil {
  16053. fields = append(fields, channelmonitordailyrollup.FieldOkCount)
  16054. }
  16055. if m.operational_count != nil {
  16056. fields = append(fields, channelmonitordailyrollup.FieldOperationalCount)
  16057. }
  16058. if m.degraded_count != nil {
  16059. fields = append(fields, channelmonitordailyrollup.FieldDegradedCount)
  16060. }
  16061. if m.failed_count != nil {
  16062. fields = append(fields, channelmonitordailyrollup.FieldFailedCount)
  16063. }
  16064. if m.error_count != nil {
  16065. fields = append(fields, channelmonitordailyrollup.FieldErrorCount)
  16066. }
  16067. if m.sum_latency_ms != nil {
  16068. fields = append(fields, channelmonitordailyrollup.FieldSumLatencyMs)
  16069. }
  16070. if m.count_latency != nil {
  16071. fields = append(fields, channelmonitordailyrollup.FieldCountLatency)
  16072. }
  16073. if m.sum_ping_latency_ms != nil {
  16074. fields = append(fields, channelmonitordailyrollup.FieldSumPingLatencyMs)
  16075. }
  16076. if m.count_ping_latency != nil {
  16077. fields = append(fields, channelmonitordailyrollup.FieldCountPingLatency)
  16078. }
  16079. if m.computed_at != nil {
  16080. fields = append(fields, channelmonitordailyrollup.FieldComputedAt)
  16081. }
  16082. return fields
  16083. }
  16084. // Field returns the value of a field with the given name. The second boolean
  16085. // return value indicates that this field was not set, or was not defined in the
  16086. // schema.
  16087. func (m *ChannelMonitorDailyRollupMutation) Field(name string) (ent.Value, bool) {
  16088. switch name {
  16089. case channelmonitordailyrollup.FieldMonitorID:
  16090. return m.MonitorID()
  16091. case channelmonitordailyrollup.FieldModel:
  16092. return m.Model()
  16093. case channelmonitordailyrollup.FieldBucketDate:
  16094. return m.BucketDate()
  16095. case channelmonitordailyrollup.FieldTotalChecks:
  16096. return m.TotalChecks()
  16097. case channelmonitordailyrollup.FieldOkCount:
  16098. return m.OkCount()
  16099. case channelmonitordailyrollup.FieldOperationalCount:
  16100. return m.OperationalCount()
  16101. case channelmonitordailyrollup.FieldDegradedCount:
  16102. return m.DegradedCount()
  16103. case channelmonitordailyrollup.FieldFailedCount:
  16104. return m.FailedCount()
  16105. case channelmonitordailyrollup.FieldErrorCount:
  16106. return m.ErrorCount()
  16107. case channelmonitordailyrollup.FieldSumLatencyMs:
  16108. return m.SumLatencyMs()
  16109. case channelmonitordailyrollup.FieldCountLatency:
  16110. return m.CountLatency()
  16111. case channelmonitordailyrollup.FieldSumPingLatencyMs:
  16112. return m.SumPingLatencyMs()
  16113. case channelmonitordailyrollup.FieldCountPingLatency:
  16114. return m.CountPingLatency()
  16115. case channelmonitordailyrollup.FieldComputedAt:
  16116. return m.ComputedAt()
  16117. }
  16118. return nil, false
  16119. }
  16120. // OldField returns the old value of the field from the database. An error is
  16121. // returned if the mutation operation is not UpdateOne, or the query to the
  16122. // database failed.
  16123. func (m *ChannelMonitorDailyRollupMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  16124. switch name {
  16125. case channelmonitordailyrollup.FieldMonitorID:
  16126. return m.OldMonitorID(ctx)
  16127. case channelmonitordailyrollup.FieldModel:
  16128. return m.OldModel(ctx)
  16129. case channelmonitordailyrollup.FieldBucketDate:
  16130. return m.OldBucketDate(ctx)
  16131. case channelmonitordailyrollup.FieldTotalChecks:
  16132. return m.OldTotalChecks(ctx)
  16133. case channelmonitordailyrollup.FieldOkCount:
  16134. return m.OldOkCount(ctx)
  16135. case channelmonitordailyrollup.FieldOperationalCount:
  16136. return m.OldOperationalCount(ctx)
  16137. case channelmonitordailyrollup.FieldDegradedCount:
  16138. return m.OldDegradedCount(ctx)
  16139. case channelmonitordailyrollup.FieldFailedCount:
  16140. return m.OldFailedCount(ctx)
  16141. case channelmonitordailyrollup.FieldErrorCount:
  16142. return m.OldErrorCount(ctx)
  16143. case channelmonitordailyrollup.FieldSumLatencyMs:
  16144. return m.OldSumLatencyMs(ctx)
  16145. case channelmonitordailyrollup.FieldCountLatency:
  16146. return m.OldCountLatency(ctx)
  16147. case channelmonitordailyrollup.FieldSumPingLatencyMs:
  16148. return m.OldSumPingLatencyMs(ctx)
  16149. case channelmonitordailyrollup.FieldCountPingLatency:
  16150. return m.OldCountPingLatency(ctx)
  16151. case channelmonitordailyrollup.FieldComputedAt:
  16152. return m.OldComputedAt(ctx)
  16153. }
  16154. return nil, fmt.Errorf("unknown ChannelMonitorDailyRollup field %s", name)
  16155. }
  16156. // SetField sets the value of a field with the given name. It returns an error if
  16157. // the field is not defined in the schema, or if the type mismatched the field
  16158. // type.
  16159. func (m *ChannelMonitorDailyRollupMutation) SetField(name string, value ent.Value) error {
  16160. switch name {
  16161. case channelmonitordailyrollup.FieldMonitorID:
  16162. v, ok := value.(int64)
  16163. if !ok {
  16164. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16165. }
  16166. m.SetMonitorID(v)
  16167. return nil
  16168. case channelmonitordailyrollup.FieldModel:
  16169. v, ok := value.(string)
  16170. if !ok {
  16171. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16172. }
  16173. m.SetModel(v)
  16174. return nil
  16175. case channelmonitordailyrollup.FieldBucketDate:
  16176. v, ok := value.(time.Time)
  16177. if !ok {
  16178. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16179. }
  16180. m.SetBucketDate(v)
  16181. return nil
  16182. case channelmonitordailyrollup.FieldTotalChecks:
  16183. v, ok := value.(int)
  16184. if !ok {
  16185. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16186. }
  16187. m.SetTotalChecks(v)
  16188. return nil
  16189. case channelmonitordailyrollup.FieldOkCount:
  16190. v, ok := value.(int)
  16191. if !ok {
  16192. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16193. }
  16194. m.SetOkCount(v)
  16195. return nil
  16196. case channelmonitordailyrollup.FieldOperationalCount:
  16197. v, ok := value.(int)
  16198. if !ok {
  16199. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16200. }
  16201. m.SetOperationalCount(v)
  16202. return nil
  16203. case channelmonitordailyrollup.FieldDegradedCount:
  16204. v, ok := value.(int)
  16205. if !ok {
  16206. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16207. }
  16208. m.SetDegradedCount(v)
  16209. return nil
  16210. case channelmonitordailyrollup.FieldFailedCount:
  16211. v, ok := value.(int)
  16212. if !ok {
  16213. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16214. }
  16215. m.SetFailedCount(v)
  16216. return nil
  16217. case channelmonitordailyrollup.FieldErrorCount:
  16218. v, ok := value.(int)
  16219. if !ok {
  16220. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16221. }
  16222. m.SetErrorCount(v)
  16223. return nil
  16224. case channelmonitordailyrollup.FieldSumLatencyMs:
  16225. v, ok := value.(int64)
  16226. if !ok {
  16227. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16228. }
  16229. m.SetSumLatencyMs(v)
  16230. return nil
  16231. case channelmonitordailyrollup.FieldCountLatency:
  16232. v, ok := value.(int)
  16233. if !ok {
  16234. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16235. }
  16236. m.SetCountLatency(v)
  16237. return nil
  16238. case channelmonitordailyrollup.FieldSumPingLatencyMs:
  16239. v, ok := value.(int64)
  16240. if !ok {
  16241. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16242. }
  16243. m.SetSumPingLatencyMs(v)
  16244. return nil
  16245. case channelmonitordailyrollup.FieldCountPingLatency:
  16246. v, ok := value.(int)
  16247. if !ok {
  16248. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16249. }
  16250. m.SetCountPingLatency(v)
  16251. return nil
  16252. case channelmonitordailyrollup.FieldComputedAt:
  16253. v, ok := value.(time.Time)
  16254. if !ok {
  16255. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16256. }
  16257. m.SetComputedAt(v)
  16258. return nil
  16259. }
  16260. return fmt.Errorf("unknown ChannelMonitorDailyRollup field %s", name)
  16261. }
  16262. // AddedFields returns all numeric fields that were incremented/decremented during
  16263. // this mutation.
  16264. func (m *ChannelMonitorDailyRollupMutation) AddedFields() []string {
  16265. var fields []string
  16266. if m.addtotal_checks != nil {
  16267. fields = append(fields, channelmonitordailyrollup.FieldTotalChecks)
  16268. }
  16269. if m.addok_count != nil {
  16270. fields = append(fields, channelmonitordailyrollup.FieldOkCount)
  16271. }
  16272. if m.addoperational_count != nil {
  16273. fields = append(fields, channelmonitordailyrollup.FieldOperationalCount)
  16274. }
  16275. if m.adddegraded_count != nil {
  16276. fields = append(fields, channelmonitordailyrollup.FieldDegradedCount)
  16277. }
  16278. if m.addfailed_count != nil {
  16279. fields = append(fields, channelmonitordailyrollup.FieldFailedCount)
  16280. }
  16281. if m.adderror_count != nil {
  16282. fields = append(fields, channelmonitordailyrollup.FieldErrorCount)
  16283. }
  16284. if m.addsum_latency_ms != nil {
  16285. fields = append(fields, channelmonitordailyrollup.FieldSumLatencyMs)
  16286. }
  16287. if m.addcount_latency != nil {
  16288. fields = append(fields, channelmonitordailyrollup.FieldCountLatency)
  16289. }
  16290. if m.addsum_ping_latency_ms != nil {
  16291. fields = append(fields, channelmonitordailyrollup.FieldSumPingLatencyMs)
  16292. }
  16293. if m.addcount_ping_latency != nil {
  16294. fields = append(fields, channelmonitordailyrollup.FieldCountPingLatency)
  16295. }
  16296. return fields
  16297. }
  16298. // AddedField returns the numeric value that was incremented/decremented on a field
  16299. // with the given name. The second boolean return value indicates that this field
  16300. // was not set, or was not defined in the schema.
  16301. func (m *ChannelMonitorDailyRollupMutation) AddedField(name string) (ent.Value, bool) {
  16302. switch name {
  16303. case channelmonitordailyrollup.FieldTotalChecks:
  16304. return m.AddedTotalChecks()
  16305. case channelmonitordailyrollup.FieldOkCount:
  16306. return m.AddedOkCount()
  16307. case channelmonitordailyrollup.FieldOperationalCount:
  16308. return m.AddedOperationalCount()
  16309. case channelmonitordailyrollup.FieldDegradedCount:
  16310. return m.AddedDegradedCount()
  16311. case channelmonitordailyrollup.FieldFailedCount:
  16312. return m.AddedFailedCount()
  16313. case channelmonitordailyrollup.FieldErrorCount:
  16314. return m.AddedErrorCount()
  16315. case channelmonitordailyrollup.FieldSumLatencyMs:
  16316. return m.AddedSumLatencyMs()
  16317. case channelmonitordailyrollup.FieldCountLatency:
  16318. return m.AddedCountLatency()
  16319. case channelmonitordailyrollup.FieldSumPingLatencyMs:
  16320. return m.AddedSumPingLatencyMs()
  16321. case channelmonitordailyrollup.FieldCountPingLatency:
  16322. return m.AddedCountPingLatency()
  16323. }
  16324. return nil, false
  16325. }
  16326. // AddField adds the value to the field with the given name. It returns an error if
  16327. // the field is not defined in the schema, or if the type mismatched the field
  16328. // type.
  16329. func (m *ChannelMonitorDailyRollupMutation) AddField(name string, value ent.Value) error {
  16330. switch name {
  16331. case channelmonitordailyrollup.FieldTotalChecks:
  16332. v, ok := value.(int)
  16333. if !ok {
  16334. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16335. }
  16336. m.AddTotalChecks(v)
  16337. return nil
  16338. case channelmonitordailyrollup.FieldOkCount:
  16339. v, ok := value.(int)
  16340. if !ok {
  16341. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16342. }
  16343. m.AddOkCount(v)
  16344. return nil
  16345. case channelmonitordailyrollup.FieldOperationalCount:
  16346. v, ok := value.(int)
  16347. if !ok {
  16348. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16349. }
  16350. m.AddOperationalCount(v)
  16351. return nil
  16352. case channelmonitordailyrollup.FieldDegradedCount:
  16353. v, ok := value.(int)
  16354. if !ok {
  16355. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16356. }
  16357. m.AddDegradedCount(v)
  16358. return nil
  16359. case channelmonitordailyrollup.FieldFailedCount:
  16360. v, ok := value.(int)
  16361. if !ok {
  16362. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16363. }
  16364. m.AddFailedCount(v)
  16365. return nil
  16366. case channelmonitordailyrollup.FieldErrorCount:
  16367. v, ok := value.(int)
  16368. if !ok {
  16369. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16370. }
  16371. m.AddErrorCount(v)
  16372. return nil
  16373. case channelmonitordailyrollup.FieldSumLatencyMs:
  16374. v, ok := value.(int64)
  16375. if !ok {
  16376. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16377. }
  16378. m.AddSumLatencyMs(v)
  16379. return nil
  16380. case channelmonitordailyrollup.FieldCountLatency:
  16381. v, ok := value.(int)
  16382. if !ok {
  16383. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16384. }
  16385. m.AddCountLatency(v)
  16386. return nil
  16387. case channelmonitordailyrollup.FieldSumPingLatencyMs:
  16388. v, ok := value.(int64)
  16389. if !ok {
  16390. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16391. }
  16392. m.AddSumPingLatencyMs(v)
  16393. return nil
  16394. case channelmonitordailyrollup.FieldCountPingLatency:
  16395. v, ok := value.(int)
  16396. if !ok {
  16397. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16398. }
  16399. m.AddCountPingLatency(v)
  16400. return nil
  16401. }
  16402. return fmt.Errorf("unknown ChannelMonitorDailyRollup numeric field %s", name)
  16403. }
  16404. // ClearedFields returns all nullable fields that were cleared during this
  16405. // mutation.
  16406. func (m *ChannelMonitorDailyRollupMutation) ClearedFields() []string {
  16407. return nil
  16408. }
  16409. // FieldCleared returns a boolean indicating if a field with the given name was
  16410. // cleared in this mutation.
  16411. func (m *ChannelMonitorDailyRollupMutation) FieldCleared(name string) bool {
  16412. _, ok := m.clearedFields[name]
  16413. return ok
  16414. }
  16415. // ClearField clears the value of the field with the given name. It returns an
  16416. // error if the field is not defined in the schema.
  16417. func (m *ChannelMonitorDailyRollupMutation) ClearField(name string) error {
  16418. return fmt.Errorf("unknown ChannelMonitorDailyRollup nullable field %s", name)
  16419. }
  16420. // ResetField resets all changes in the mutation for the field with the given name.
  16421. // It returns an error if the field is not defined in the schema.
  16422. func (m *ChannelMonitorDailyRollupMutation) ResetField(name string) error {
  16423. switch name {
  16424. case channelmonitordailyrollup.FieldMonitorID:
  16425. m.ResetMonitorID()
  16426. return nil
  16427. case channelmonitordailyrollup.FieldModel:
  16428. m.ResetModel()
  16429. return nil
  16430. case channelmonitordailyrollup.FieldBucketDate:
  16431. m.ResetBucketDate()
  16432. return nil
  16433. case channelmonitordailyrollup.FieldTotalChecks:
  16434. m.ResetTotalChecks()
  16435. return nil
  16436. case channelmonitordailyrollup.FieldOkCount:
  16437. m.ResetOkCount()
  16438. return nil
  16439. case channelmonitordailyrollup.FieldOperationalCount:
  16440. m.ResetOperationalCount()
  16441. return nil
  16442. case channelmonitordailyrollup.FieldDegradedCount:
  16443. m.ResetDegradedCount()
  16444. return nil
  16445. case channelmonitordailyrollup.FieldFailedCount:
  16446. m.ResetFailedCount()
  16447. return nil
  16448. case channelmonitordailyrollup.FieldErrorCount:
  16449. m.ResetErrorCount()
  16450. return nil
  16451. case channelmonitordailyrollup.FieldSumLatencyMs:
  16452. m.ResetSumLatencyMs()
  16453. return nil
  16454. case channelmonitordailyrollup.FieldCountLatency:
  16455. m.ResetCountLatency()
  16456. return nil
  16457. case channelmonitordailyrollup.FieldSumPingLatencyMs:
  16458. m.ResetSumPingLatencyMs()
  16459. return nil
  16460. case channelmonitordailyrollup.FieldCountPingLatency:
  16461. m.ResetCountPingLatency()
  16462. return nil
  16463. case channelmonitordailyrollup.FieldComputedAt:
  16464. m.ResetComputedAt()
  16465. return nil
  16466. }
  16467. return fmt.Errorf("unknown ChannelMonitorDailyRollup field %s", name)
  16468. }
  16469. // AddedEdges returns all edge names that were set/added in this mutation.
  16470. func (m *ChannelMonitorDailyRollupMutation) AddedEdges() []string {
  16471. edges := make([]string, 0, 1)
  16472. if m.monitor != nil {
  16473. edges = append(edges, channelmonitordailyrollup.EdgeMonitor)
  16474. }
  16475. return edges
  16476. }
  16477. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  16478. // name in this mutation.
  16479. func (m *ChannelMonitorDailyRollupMutation) AddedIDs(name string) []ent.Value {
  16480. switch name {
  16481. case channelmonitordailyrollup.EdgeMonitor:
  16482. if id := m.monitor; id != nil {
  16483. return []ent.Value{*id}
  16484. }
  16485. }
  16486. return nil
  16487. }
  16488. // RemovedEdges returns all edge names that were removed in this mutation.
  16489. func (m *ChannelMonitorDailyRollupMutation) RemovedEdges() []string {
  16490. edges := make([]string, 0, 1)
  16491. return edges
  16492. }
  16493. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  16494. // the given name in this mutation.
  16495. func (m *ChannelMonitorDailyRollupMutation) RemovedIDs(name string) []ent.Value {
  16496. return nil
  16497. }
  16498. // ClearedEdges returns all edge names that were cleared in this mutation.
  16499. func (m *ChannelMonitorDailyRollupMutation) ClearedEdges() []string {
  16500. edges := make([]string, 0, 1)
  16501. if m.clearedmonitor {
  16502. edges = append(edges, channelmonitordailyrollup.EdgeMonitor)
  16503. }
  16504. return edges
  16505. }
  16506. // EdgeCleared returns a boolean which indicates if the edge with the given name
  16507. // was cleared in this mutation.
  16508. func (m *ChannelMonitorDailyRollupMutation) EdgeCleared(name string) bool {
  16509. switch name {
  16510. case channelmonitordailyrollup.EdgeMonitor:
  16511. return m.clearedmonitor
  16512. }
  16513. return false
  16514. }
  16515. // ClearEdge clears the value of the edge with the given name. It returns an error
  16516. // if that edge is not defined in the schema.
  16517. func (m *ChannelMonitorDailyRollupMutation) ClearEdge(name string) error {
  16518. switch name {
  16519. case channelmonitordailyrollup.EdgeMonitor:
  16520. m.ClearMonitor()
  16521. return nil
  16522. }
  16523. return fmt.Errorf("unknown ChannelMonitorDailyRollup unique edge %s", name)
  16524. }
  16525. // ResetEdge resets all changes to the edge with the given name in this mutation.
  16526. // It returns an error if the edge is not defined in the schema.
  16527. func (m *ChannelMonitorDailyRollupMutation) ResetEdge(name string) error {
  16528. switch name {
  16529. case channelmonitordailyrollup.EdgeMonitor:
  16530. m.ResetMonitor()
  16531. return nil
  16532. }
  16533. return fmt.Errorf("unknown ChannelMonitorDailyRollup edge %s", name)
  16534. }
  16535. // ChannelMonitorHistoryMutation represents an operation that mutates the ChannelMonitorHistory nodes in the graph.
  16536. type ChannelMonitorHistoryMutation struct {
  16537. config
  16538. op Op
  16539. typ string
  16540. id *int64
  16541. model *string
  16542. status *channelmonitorhistory.Status
  16543. latency_ms *int
  16544. addlatency_ms *int
  16545. ping_latency_ms *int
  16546. addping_latency_ms *int
  16547. message *string
  16548. quota **domain.MonitorQuotaSnapshot
  16549. checked_at *time.Time
  16550. clearedFields map[string]struct{}
  16551. monitor *int64
  16552. clearedmonitor bool
  16553. done bool
  16554. oldValue func(context.Context) (*ChannelMonitorHistory, error)
  16555. predicates []predicate.ChannelMonitorHistory
  16556. }
  16557. var _ ent.Mutation = (*ChannelMonitorHistoryMutation)(nil)
  16558. // channelmonitorhistoryOption allows management of the mutation configuration using functional options.
  16559. type channelmonitorhistoryOption func(*ChannelMonitorHistoryMutation)
  16560. // newChannelMonitorHistoryMutation creates new mutation for the ChannelMonitorHistory entity.
  16561. func newChannelMonitorHistoryMutation(c config, op Op, opts ...channelmonitorhistoryOption) *ChannelMonitorHistoryMutation {
  16562. m := &ChannelMonitorHistoryMutation{
  16563. config: c,
  16564. op: op,
  16565. typ: TypeChannelMonitorHistory,
  16566. clearedFields: make(map[string]struct{}),
  16567. }
  16568. for _, opt := range opts {
  16569. opt(m)
  16570. }
  16571. return m
  16572. }
  16573. // withChannelMonitorHistoryID sets the ID field of the mutation.
  16574. func withChannelMonitorHistoryID(id int64) channelmonitorhistoryOption {
  16575. return func(m *ChannelMonitorHistoryMutation) {
  16576. var (
  16577. err error
  16578. once sync.Once
  16579. value *ChannelMonitorHistory
  16580. )
  16581. m.oldValue = func(ctx context.Context) (*ChannelMonitorHistory, error) {
  16582. once.Do(func() {
  16583. if m.done {
  16584. err = errors.New("querying old values post mutation is not allowed")
  16585. } else {
  16586. value, err = m.Client().ChannelMonitorHistory.Get(ctx, id)
  16587. }
  16588. })
  16589. return value, err
  16590. }
  16591. m.id = &id
  16592. }
  16593. }
  16594. // withChannelMonitorHistory sets the old ChannelMonitorHistory of the mutation.
  16595. func withChannelMonitorHistory(node *ChannelMonitorHistory) channelmonitorhistoryOption {
  16596. return func(m *ChannelMonitorHistoryMutation) {
  16597. m.oldValue = func(context.Context) (*ChannelMonitorHistory, error) {
  16598. return node, nil
  16599. }
  16600. m.id = &node.ID
  16601. }
  16602. }
  16603. // Client returns a new `ent.Client` from the mutation. If the mutation was
  16604. // executed in a transaction (ent.Tx), a transactional client is returned.
  16605. func (m ChannelMonitorHistoryMutation) Client() *Client {
  16606. client := &Client{config: m.config}
  16607. client.init()
  16608. return client
  16609. }
  16610. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  16611. // it returns an error otherwise.
  16612. func (m ChannelMonitorHistoryMutation) Tx() (*Tx, error) {
  16613. if _, ok := m.driver.(*txDriver); !ok {
  16614. return nil, errors.New("ent: mutation is not running in a transaction")
  16615. }
  16616. tx := &Tx{config: m.config}
  16617. tx.init()
  16618. return tx, nil
  16619. }
  16620. // ID returns the ID value in the mutation. Note that the ID is only available
  16621. // if it was provided to the builder or after it was returned from the database.
  16622. func (m *ChannelMonitorHistoryMutation) ID() (id int64, exists bool) {
  16623. if m.id == nil {
  16624. return
  16625. }
  16626. return *m.id, true
  16627. }
  16628. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  16629. // That means, if the mutation is applied within a transaction with an isolation level such
  16630. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  16631. // or updated by the mutation.
  16632. func (m *ChannelMonitorHistoryMutation) IDs(ctx context.Context) ([]int64, error) {
  16633. switch {
  16634. case m.op.Is(OpUpdateOne | OpDeleteOne):
  16635. id, exists := m.ID()
  16636. if exists {
  16637. return []int64{id}, nil
  16638. }
  16639. fallthrough
  16640. case m.op.Is(OpUpdate | OpDelete):
  16641. return m.Client().ChannelMonitorHistory.Query().Where(m.predicates...).IDs(ctx)
  16642. default:
  16643. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  16644. }
  16645. }
  16646. // SetMonitorID sets the "monitor_id" field.
  16647. func (m *ChannelMonitorHistoryMutation) SetMonitorID(i int64) {
  16648. m.monitor = &i
  16649. }
  16650. // MonitorID returns the value of the "monitor_id" field in the mutation.
  16651. func (m *ChannelMonitorHistoryMutation) MonitorID() (r int64, exists bool) {
  16652. v := m.monitor
  16653. if v == nil {
  16654. return
  16655. }
  16656. return *v, true
  16657. }
  16658. // OldMonitorID returns the old "monitor_id" field's value of the ChannelMonitorHistory entity.
  16659. // If the ChannelMonitorHistory object wasn't provided to the builder, the object is fetched from the database.
  16660. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16661. func (m *ChannelMonitorHistoryMutation) OldMonitorID(ctx context.Context) (v int64, err error) {
  16662. if !m.op.Is(OpUpdateOne) {
  16663. return v, errors.New("OldMonitorID is only allowed on UpdateOne operations")
  16664. }
  16665. if m.id == nil || m.oldValue == nil {
  16666. return v, errors.New("OldMonitorID requires an ID field in the mutation")
  16667. }
  16668. oldValue, err := m.oldValue(ctx)
  16669. if err != nil {
  16670. return v, fmt.Errorf("querying old value for OldMonitorID: %w", err)
  16671. }
  16672. return oldValue.MonitorID, nil
  16673. }
  16674. // ResetMonitorID resets all changes to the "monitor_id" field.
  16675. func (m *ChannelMonitorHistoryMutation) ResetMonitorID() {
  16676. m.monitor = nil
  16677. }
  16678. // SetModel sets the "model" field.
  16679. func (m *ChannelMonitorHistoryMutation) SetModel(s string) {
  16680. m.model = &s
  16681. }
  16682. // Model returns the value of the "model" field in the mutation.
  16683. func (m *ChannelMonitorHistoryMutation) Model() (r string, exists bool) {
  16684. v := m.model
  16685. if v == nil {
  16686. return
  16687. }
  16688. return *v, true
  16689. }
  16690. // OldModel returns the old "model" field's value of the ChannelMonitorHistory entity.
  16691. // If the ChannelMonitorHistory object wasn't provided to the builder, the object is fetched from the database.
  16692. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16693. func (m *ChannelMonitorHistoryMutation) OldModel(ctx context.Context) (v string, err error) {
  16694. if !m.op.Is(OpUpdateOne) {
  16695. return v, errors.New("OldModel is only allowed on UpdateOne operations")
  16696. }
  16697. if m.id == nil || m.oldValue == nil {
  16698. return v, errors.New("OldModel requires an ID field in the mutation")
  16699. }
  16700. oldValue, err := m.oldValue(ctx)
  16701. if err != nil {
  16702. return v, fmt.Errorf("querying old value for OldModel: %w", err)
  16703. }
  16704. return oldValue.Model, nil
  16705. }
  16706. // ResetModel resets all changes to the "model" field.
  16707. func (m *ChannelMonitorHistoryMutation) ResetModel() {
  16708. m.model = nil
  16709. }
  16710. // SetStatus sets the "status" field.
  16711. func (m *ChannelMonitorHistoryMutation) SetStatus(c channelmonitorhistory.Status) {
  16712. m.status = &c
  16713. }
  16714. // Status returns the value of the "status" field in the mutation.
  16715. func (m *ChannelMonitorHistoryMutation) Status() (r channelmonitorhistory.Status, exists bool) {
  16716. v := m.status
  16717. if v == nil {
  16718. return
  16719. }
  16720. return *v, true
  16721. }
  16722. // OldStatus returns the old "status" field's value of the ChannelMonitorHistory entity.
  16723. // If the ChannelMonitorHistory object wasn't provided to the builder, the object is fetched from the database.
  16724. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16725. func (m *ChannelMonitorHistoryMutation) OldStatus(ctx context.Context) (v channelmonitorhistory.Status, err error) {
  16726. if !m.op.Is(OpUpdateOne) {
  16727. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  16728. }
  16729. if m.id == nil || m.oldValue == nil {
  16730. return v, errors.New("OldStatus requires an ID field in the mutation")
  16731. }
  16732. oldValue, err := m.oldValue(ctx)
  16733. if err != nil {
  16734. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  16735. }
  16736. return oldValue.Status, nil
  16737. }
  16738. // ResetStatus resets all changes to the "status" field.
  16739. func (m *ChannelMonitorHistoryMutation) ResetStatus() {
  16740. m.status = nil
  16741. }
  16742. // SetLatencyMs sets the "latency_ms" field.
  16743. func (m *ChannelMonitorHistoryMutation) SetLatencyMs(i int) {
  16744. m.latency_ms = &i
  16745. m.addlatency_ms = nil
  16746. }
  16747. // LatencyMs returns the value of the "latency_ms" field in the mutation.
  16748. func (m *ChannelMonitorHistoryMutation) LatencyMs() (r int, exists bool) {
  16749. v := m.latency_ms
  16750. if v == nil {
  16751. return
  16752. }
  16753. return *v, true
  16754. }
  16755. // OldLatencyMs returns the old "latency_ms" field's value of the ChannelMonitorHistory entity.
  16756. // If the ChannelMonitorHistory object wasn't provided to the builder, the object is fetched from the database.
  16757. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16758. func (m *ChannelMonitorHistoryMutation) OldLatencyMs(ctx context.Context) (v *int, err error) {
  16759. if !m.op.Is(OpUpdateOne) {
  16760. return v, errors.New("OldLatencyMs is only allowed on UpdateOne operations")
  16761. }
  16762. if m.id == nil || m.oldValue == nil {
  16763. return v, errors.New("OldLatencyMs requires an ID field in the mutation")
  16764. }
  16765. oldValue, err := m.oldValue(ctx)
  16766. if err != nil {
  16767. return v, fmt.Errorf("querying old value for OldLatencyMs: %w", err)
  16768. }
  16769. return oldValue.LatencyMs, nil
  16770. }
  16771. // AddLatencyMs adds i to the "latency_ms" field.
  16772. func (m *ChannelMonitorHistoryMutation) AddLatencyMs(i int) {
  16773. if m.addlatency_ms != nil {
  16774. *m.addlatency_ms += i
  16775. } else {
  16776. m.addlatency_ms = &i
  16777. }
  16778. }
  16779. // AddedLatencyMs returns the value that was added to the "latency_ms" field in this mutation.
  16780. func (m *ChannelMonitorHistoryMutation) AddedLatencyMs() (r int, exists bool) {
  16781. v := m.addlatency_ms
  16782. if v == nil {
  16783. return
  16784. }
  16785. return *v, true
  16786. }
  16787. // ClearLatencyMs clears the value of the "latency_ms" field.
  16788. func (m *ChannelMonitorHistoryMutation) ClearLatencyMs() {
  16789. m.latency_ms = nil
  16790. m.addlatency_ms = nil
  16791. m.clearedFields[channelmonitorhistory.FieldLatencyMs] = struct{}{}
  16792. }
  16793. // LatencyMsCleared returns if the "latency_ms" field was cleared in this mutation.
  16794. func (m *ChannelMonitorHistoryMutation) LatencyMsCleared() bool {
  16795. _, ok := m.clearedFields[channelmonitorhistory.FieldLatencyMs]
  16796. return ok
  16797. }
  16798. // ResetLatencyMs resets all changes to the "latency_ms" field.
  16799. func (m *ChannelMonitorHistoryMutation) ResetLatencyMs() {
  16800. m.latency_ms = nil
  16801. m.addlatency_ms = nil
  16802. delete(m.clearedFields, channelmonitorhistory.FieldLatencyMs)
  16803. }
  16804. // SetPingLatencyMs sets the "ping_latency_ms" field.
  16805. func (m *ChannelMonitorHistoryMutation) SetPingLatencyMs(i int) {
  16806. m.ping_latency_ms = &i
  16807. m.addping_latency_ms = nil
  16808. }
  16809. // PingLatencyMs returns the value of the "ping_latency_ms" field in the mutation.
  16810. func (m *ChannelMonitorHistoryMutation) PingLatencyMs() (r int, exists bool) {
  16811. v := m.ping_latency_ms
  16812. if v == nil {
  16813. return
  16814. }
  16815. return *v, true
  16816. }
  16817. // OldPingLatencyMs returns the old "ping_latency_ms" field's value of the ChannelMonitorHistory entity.
  16818. // If the ChannelMonitorHistory object wasn't provided to the builder, the object is fetched from the database.
  16819. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16820. func (m *ChannelMonitorHistoryMutation) OldPingLatencyMs(ctx context.Context) (v *int, err error) {
  16821. if !m.op.Is(OpUpdateOne) {
  16822. return v, errors.New("OldPingLatencyMs is only allowed on UpdateOne operations")
  16823. }
  16824. if m.id == nil || m.oldValue == nil {
  16825. return v, errors.New("OldPingLatencyMs requires an ID field in the mutation")
  16826. }
  16827. oldValue, err := m.oldValue(ctx)
  16828. if err != nil {
  16829. return v, fmt.Errorf("querying old value for OldPingLatencyMs: %w", err)
  16830. }
  16831. return oldValue.PingLatencyMs, nil
  16832. }
  16833. // AddPingLatencyMs adds i to the "ping_latency_ms" field.
  16834. func (m *ChannelMonitorHistoryMutation) AddPingLatencyMs(i int) {
  16835. if m.addping_latency_ms != nil {
  16836. *m.addping_latency_ms += i
  16837. } else {
  16838. m.addping_latency_ms = &i
  16839. }
  16840. }
  16841. // AddedPingLatencyMs returns the value that was added to the "ping_latency_ms" field in this mutation.
  16842. func (m *ChannelMonitorHistoryMutation) AddedPingLatencyMs() (r int, exists bool) {
  16843. v := m.addping_latency_ms
  16844. if v == nil {
  16845. return
  16846. }
  16847. return *v, true
  16848. }
  16849. // ClearPingLatencyMs clears the value of the "ping_latency_ms" field.
  16850. func (m *ChannelMonitorHistoryMutation) ClearPingLatencyMs() {
  16851. m.ping_latency_ms = nil
  16852. m.addping_latency_ms = nil
  16853. m.clearedFields[channelmonitorhistory.FieldPingLatencyMs] = struct{}{}
  16854. }
  16855. // PingLatencyMsCleared returns if the "ping_latency_ms" field was cleared in this mutation.
  16856. func (m *ChannelMonitorHistoryMutation) PingLatencyMsCleared() bool {
  16857. _, ok := m.clearedFields[channelmonitorhistory.FieldPingLatencyMs]
  16858. return ok
  16859. }
  16860. // ResetPingLatencyMs resets all changes to the "ping_latency_ms" field.
  16861. func (m *ChannelMonitorHistoryMutation) ResetPingLatencyMs() {
  16862. m.ping_latency_ms = nil
  16863. m.addping_latency_ms = nil
  16864. delete(m.clearedFields, channelmonitorhistory.FieldPingLatencyMs)
  16865. }
  16866. // SetMessage sets the "message" field.
  16867. func (m *ChannelMonitorHistoryMutation) SetMessage(s string) {
  16868. m.message = &s
  16869. }
  16870. // Message returns the value of the "message" field in the mutation.
  16871. func (m *ChannelMonitorHistoryMutation) Message() (r string, exists bool) {
  16872. v := m.message
  16873. if v == nil {
  16874. return
  16875. }
  16876. return *v, true
  16877. }
  16878. // OldMessage returns the old "message" field's value of the ChannelMonitorHistory entity.
  16879. // If the ChannelMonitorHistory object wasn't provided to the builder, the object is fetched from the database.
  16880. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16881. func (m *ChannelMonitorHistoryMutation) OldMessage(ctx context.Context) (v string, err error) {
  16882. if !m.op.Is(OpUpdateOne) {
  16883. return v, errors.New("OldMessage is only allowed on UpdateOne operations")
  16884. }
  16885. if m.id == nil || m.oldValue == nil {
  16886. return v, errors.New("OldMessage requires an ID field in the mutation")
  16887. }
  16888. oldValue, err := m.oldValue(ctx)
  16889. if err != nil {
  16890. return v, fmt.Errorf("querying old value for OldMessage: %w", err)
  16891. }
  16892. return oldValue.Message, nil
  16893. }
  16894. // ClearMessage clears the value of the "message" field.
  16895. func (m *ChannelMonitorHistoryMutation) ClearMessage() {
  16896. m.message = nil
  16897. m.clearedFields[channelmonitorhistory.FieldMessage] = struct{}{}
  16898. }
  16899. // MessageCleared returns if the "message" field was cleared in this mutation.
  16900. func (m *ChannelMonitorHistoryMutation) MessageCleared() bool {
  16901. _, ok := m.clearedFields[channelmonitorhistory.FieldMessage]
  16902. return ok
  16903. }
  16904. // ResetMessage resets all changes to the "message" field.
  16905. func (m *ChannelMonitorHistoryMutation) ResetMessage() {
  16906. m.message = nil
  16907. delete(m.clearedFields, channelmonitorhistory.FieldMessage)
  16908. }
  16909. // SetQuota sets the "quota" field.
  16910. func (m *ChannelMonitorHistoryMutation) SetQuota(dqs *domain.MonitorQuotaSnapshot) {
  16911. m.quota = &dqs
  16912. }
  16913. // Quota returns the value of the "quota" field in the mutation.
  16914. func (m *ChannelMonitorHistoryMutation) Quota() (r *domain.MonitorQuotaSnapshot, exists bool) {
  16915. v := m.quota
  16916. if v == nil {
  16917. return
  16918. }
  16919. return *v, true
  16920. }
  16921. // OldQuota returns the old "quota" field's value of the ChannelMonitorHistory entity.
  16922. // If the ChannelMonitorHistory object wasn't provided to the builder, the object is fetched from the database.
  16923. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16924. func (m *ChannelMonitorHistoryMutation) OldQuota(ctx context.Context) (v *domain.MonitorQuotaSnapshot, err error) {
  16925. if !m.op.Is(OpUpdateOne) {
  16926. return v, errors.New("OldQuota is only allowed on UpdateOne operations")
  16927. }
  16928. if m.id == nil || m.oldValue == nil {
  16929. return v, errors.New("OldQuota requires an ID field in the mutation")
  16930. }
  16931. oldValue, err := m.oldValue(ctx)
  16932. if err != nil {
  16933. return v, fmt.Errorf("querying old value for OldQuota: %w", err)
  16934. }
  16935. return oldValue.Quota, nil
  16936. }
  16937. // ClearQuota clears the value of the "quota" field.
  16938. func (m *ChannelMonitorHistoryMutation) ClearQuota() {
  16939. m.quota = nil
  16940. m.clearedFields[channelmonitorhistory.FieldQuota] = struct{}{}
  16941. }
  16942. // QuotaCleared returns if the "quota" field was cleared in this mutation.
  16943. func (m *ChannelMonitorHistoryMutation) QuotaCleared() bool {
  16944. _, ok := m.clearedFields[channelmonitorhistory.FieldQuota]
  16945. return ok
  16946. }
  16947. // ResetQuota resets all changes to the "quota" field.
  16948. func (m *ChannelMonitorHistoryMutation) ResetQuota() {
  16949. m.quota = nil
  16950. delete(m.clearedFields, channelmonitorhistory.FieldQuota)
  16951. }
  16952. // SetCheckedAt sets the "checked_at" field.
  16953. func (m *ChannelMonitorHistoryMutation) SetCheckedAt(t time.Time) {
  16954. m.checked_at = &t
  16955. }
  16956. // CheckedAt returns the value of the "checked_at" field in the mutation.
  16957. func (m *ChannelMonitorHistoryMutation) CheckedAt() (r time.Time, exists bool) {
  16958. v := m.checked_at
  16959. if v == nil {
  16960. return
  16961. }
  16962. return *v, true
  16963. }
  16964. // OldCheckedAt returns the old "checked_at" field's value of the ChannelMonitorHistory entity.
  16965. // If the ChannelMonitorHistory object wasn't provided to the builder, the object is fetched from the database.
  16966. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16967. func (m *ChannelMonitorHistoryMutation) OldCheckedAt(ctx context.Context) (v time.Time, err error) {
  16968. if !m.op.Is(OpUpdateOne) {
  16969. return v, errors.New("OldCheckedAt is only allowed on UpdateOne operations")
  16970. }
  16971. if m.id == nil || m.oldValue == nil {
  16972. return v, errors.New("OldCheckedAt requires an ID field in the mutation")
  16973. }
  16974. oldValue, err := m.oldValue(ctx)
  16975. if err != nil {
  16976. return v, fmt.Errorf("querying old value for OldCheckedAt: %w", err)
  16977. }
  16978. return oldValue.CheckedAt, nil
  16979. }
  16980. // ResetCheckedAt resets all changes to the "checked_at" field.
  16981. func (m *ChannelMonitorHistoryMutation) ResetCheckedAt() {
  16982. m.checked_at = nil
  16983. }
  16984. // ClearMonitor clears the "monitor" edge to the ChannelMonitor entity.
  16985. func (m *ChannelMonitorHistoryMutation) ClearMonitor() {
  16986. m.clearedmonitor = true
  16987. m.clearedFields[channelmonitorhistory.FieldMonitorID] = struct{}{}
  16988. }
  16989. // MonitorCleared reports if the "monitor" edge to the ChannelMonitor entity was cleared.
  16990. func (m *ChannelMonitorHistoryMutation) MonitorCleared() bool {
  16991. return m.clearedmonitor
  16992. }
  16993. // MonitorIDs returns the "monitor" edge IDs in the mutation.
  16994. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  16995. // MonitorID instead. It exists only for internal usage by the builders.
  16996. func (m *ChannelMonitorHistoryMutation) MonitorIDs() (ids []int64) {
  16997. if id := m.monitor; id != nil {
  16998. ids = append(ids, *id)
  16999. }
  17000. return
  17001. }
  17002. // ResetMonitor resets all changes to the "monitor" edge.
  17003. func (m *ChannelMonitorHistoryMutation) ResetMonitor() {
  17004. m.monitor = nil
  17005. m.clearedmonitor = false
  17006. }
  17007. // Where appends a list predicates to the ChannelMonitorHistoryMutation builder.
  17008. func (m *ChannelMonitorHistoryMutation) Where(ps ...predicate.ChannelMonitorHistory) {
  17009. m.predicates = append(m.predicates, ps...)
  17010. }
  17011. // WhereP appends storage-level predicates to the ChannelMonitorHistoryMutation builder. Using this method,
  17012. // users can use type-assertion to append predicates that do not depend on any generated package.
  17013. func (m *ChannelMonitorHistoryMutation) WhereP(ps ...func(*sql.Selector)) {
  17014. p := make([]predicate.ChannelMonitorHistory, len(ps))
  17015. for i := range ps {
  17016. p[i] = ps[i]
  17017. }
  17018. m.Where(p...)
  17019. }
  17020. // Op returns the operation name.
  17021. func (m *ChannelMonitorHistoryMutation) Op() Op {
  17022. return m.op
  17023. }
  17024. // SetOp allows setting the mutation operation.
  17025. func (m *ChannelMonitorHistoryMutation) SetOp(op Op) {
  17026. m.op = op
  17027. }
  17028. // Type returns the node type of this mutation (ChannelMonitorHistory).
  17029. func (m *ChannelMonitorHistoryMutation) Type() string {
  17030. return m.typ
  17031. }
  17032. // Fields returns all fields that were changed during this mutation. Note that in
  17033. // order to get all numeric fields that were incremented/decremented, call
  17034. // AddedFields().
  17035. func (m *ChannelMonitorHistoryMutation) Fields() []string {
  17036. fields := make([]string, 0, 8)
  17037. if m.monitor != nil {
  17038. fields = append(fields, channelmonitorhistory.FieldMonitorID)
  17039. }
  17040. if m.model != nil {
  17041. fields = append(fields, channelmonitorhistory.FieldModel)
  17042. }
  17043. if m.status != nil {
  17044. fields = append(fields, channelmonitorhistory.FieldStatus)
  17045. }
  17046. if m.latency_ms != nil {
  17047. fields = append(fields, channelmonitorhistory.FieldLatencyMs)
  17048. }
  17049. if m.ping_latency_ms != nil {
  17050. fields = append(fields, channelmonitorhistory.FieldPingLatencyMs)
  17051. }
  17052. if m.message != nil {
  17053. fields = append(fields, channelmonitorhistory.FieldMessage)
  17054. }
  17055. if m.quota != nil {
  17056. fields = append(fields, channelmonitorhistory.FieldQuota)
  17057. }
  17058. if m.checked_at != nil {
  17059. fields = append(fields, channelmonitorhistory.FieldCheckedAt)
  17060. }
  17061. return fields
  17062. }
  17063. // Field returns the value of a field with the given name. The second boolean
  17064. // return value indicates that this field was not set, or was not defined in the
  17065. // schema.
  17066. func (m *ChannelMonitorHistoryMutation) Field(name string) (ent.Value, bool) {
  17067. switch name {
  17068. case channelmonitorhistory.FieldMonitorID:
  17069. return m.MonitorID()
  17070. case channelmonitorhistory.FieldModel:
  17071. return m.Model()
  17072. case channelmonitorhistory.FieldStatus:
  17073. return m.Status()
  17074. case channelmonitorhistory.FieldLatencyMs:
  17075. return m.LatencyMs()
  17076. case channelmonitorhistory.FieldPingLatencyMs:
  17077. return m.PingLatencyMs()
  17078. case channelmonitorhistory.FieldMessage:
  17079. return m.Message()
  17080. case channelmonitorhistory.FieldQuota:
  17081. return m.Quota()
  17082. case channelmonitorhistory.FieldCheckedAt:
  17083. return m.CheckedAt()
  17084. }
  17085. return nil, false
  17086. }
  17087. // OldField returns the old value of the field from the database. An error is
  17088. // returned if the mutation operation is not UpdateOne, or the query to the
  17089. // database failed.
  17090. func (m *ChannelMonitorHistoryMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  17091. switch name {
  17092. case channelmonitorhistory.FieldMonitorID:
  17093. return m.OldMonitorID(ctx)
  17094. case channelmonitorhistory.FieldModel:
  17095. return m.OldModel(ctx)
  17096. case channelmonitorhistory.FieldStatus:
  17097. return m.OldStatus(ctx)
  17098. case channelmonitorhistory.FieldLatencyMs:
  17099. return m.OldLatencyMs(ctx)
  17100. case channelmonitorhistory.FieldPingLatencyMs:
  17101. return m.OldPingLatencyMs(ctx)
  17102. case channelmonitorhistory.FieldMessage:
  17103. return m.OldMessage(ctx)
  17104. case channelmonitorhistory.FieldQuota:
  17105. return m.OldQuota(ctx)
  17106. case channelmonitorhistory.FieldCheckedAt:
  17107. return m.OldCheckedAt(ctx)
  17108. }
  17109. return nil, fmt.Errorf("unknown ChannelMonitorHistory field %s", name)
  17110. }
  17111. // SetField sets the value of a field with the given name. It returns an error if
  17112. // the field is not defined in the schema, or if the type mismatched the field
  17113. // type.
  17114. func (m *ChannelMonitorHistoryMutation) SetField(name string, value ent.Value) error {
  17115. switch name {
  17116. case channelmonitorhistory.FieldMonitorID:
  17117. v, ok := value.(int64)
  17118. if !ok {
  17119. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17120. }
  17121. m.SetMonitorID(v)
  17122. return nil
  17123. case channelmonitorhistory.FieldModel:
  17124. v, ok := value.(string)
  17125. if !ok {
  17126. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17127. }
  17128. m.SetModel(v)
  17129. return nil
  17130. case channelmonitorhistory.FieldStatus:
  17131. v, ok := value.(channelmonitorhistory.Status)
  17132. if !ok {
  17133. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17134. }
  17135. m.SetStatus(v)
  17136. return nil
  17137. case channelmonitorhistory.FieldLatencyMs:
  17138. v, ok := value.(int)
  17139. if !ok {
  17140. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17141. }
  17142. m.SetLatencyMs(v)
  17143. return nil
  17144. case channelmonitorhistory.FieldPingLatencyMs:
  17145. v, ok := value.(int)
  17146. if !ok {
  17147. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17148. }
  17149. m.SetPingLatencyMs(v)
  17150. return nil
  17151. case channelmonitorhistory.FieldMessage:
  17152. v, ok := value.(string)
  17153. if !ok {
  17154. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17155. }
  17156. m.SetMessage(v)
  17157. return nil
  17158. case channelmonitorhistory.FieldQuota:
  17159. v, ok := value.(*domain.MonitorQuotaSnapshot)
  17160. if !ok {
  17161. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17162. }
  17163. m.SetQuota(v)
  17164. return nil
  17165. case channelmonitorhistory.FieldCheckedAt:
  17166. v, ok := value.(time.Time)
  17167. if !ok {
  17168. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17169. }
  17170. m.SetCheckedAt(v)
  17171. return nil
  17172. }
  17173. return fmt.Errorf("unknown ChannelMonitorHistory field %s", name)
  17174. }
  17175. // AddedFields returns all numeric fields that were incremented/decremented during
  17176. // this mutation.
  17177. func (m *ChannelMonitorHistoryMutation) AddedFields() []string {
  17178. var fields []string
  17179. if m.addlatency_ms != nil {
  17180. fields = append(fields, channelmonitorhistory.FieldLatencyMs)
  17181. }
  17182. if m.addping_latency_ms != nil {
  17183. fields = append(fields, channelmonitorhistory.FieldPingLatencyMs)
  17184. }
  17185. return fields
  17186. }
  17187. // AddedField returns the numeric value that was incremented/decremented on a field
  17188. // with the given name. The second boolean return value indicates that this field
  17189. // was not set, or was not defined in the schema.
  17190. func (m *ChannelMonitorHistoryMutation) AddedField(name string) (ent.Value, bool) {
  17191. switch name {
  17192. case channelmonitorhistory.FieldLatencyMs:
  17193. return m.AddedLatencyMs()
  17194. case channelmonitorhistory.FieldPingLatencyMs:
  17195. return m.AddedPingLatencyMs()
  17196. }
  17197. return nil, false
  17198. }
  17199. // AddField adds the value to the field with the given name. It returns an error if
  17200. // the field is not defined in the schema, or if the type mismatched the field
  17201. // type.
  17202. func (m *ChannelMonitorHistoryMutation) AddField(name string, value ent.Value) error {
  17203. switch name {
  17204. case channelmonitorhistory.FieldLatencyMs:
  17205. v, ok := value.(int)
  17206. if !ok {
  17207. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17208. }
  17209. m.AddLatencyMs(v)
  17210. return nil
  17211. case channelmonitorhistory.FieldPingLatencyMs:
  17212. v, ok := value.(int)
  17213. if !ok {
  17214. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17215. }
  17216. m.AddPingLatencyMs(v)
  17217. return nil
  17218. }
  17219. return fmt.Errorf("unknown ChannelMonitorHistory numeric field %s", name)
  17220. }
  17221. // ClearedFields returns all nullable fields that were cleared during this
  17222. // mutation.
  17223. func (m *ChannelMonitorHistoryMutation) ClearedFields() []string {
  17224. var fields []string
  17225. if m.FieldCleared(channelmonitorhistory.FieldLatencyMs) {
  17226. fields = append(fields, channelmonitorhistory.FieldLatencyMs)
  17227. }
  17228. if m.FieldCleared(channelmonitorhistory.FieldPingLatencyMs) {
  17229. fields = append(fields, channelmonitorhistory.FieldPingLatencyMs)
  17230. }
  17231. if m.FieldCleared(channelmonitorhistory.FieldMessage) {
  17232. fields = append(fields, channelmonitorhistory.FieldMessage)
  17233. }
  17234. if m.FieldCleared(channelmonitorhistory.FieldQuota) {
  17235. fields = append(fields, channelmonitorhistory.FieldQuota)
  17236. }
  17237. return fields
  17238. }
  17239. // FieldCleared returns a boolean indicating if a field with the given name was
  17240. // cleared in this mutation.
  17241. func (m *ChannelMonitorHistoryMutation) FieldCleared(name string) bool {
  17242. _, ok := m.clearedFields[name]
  17243. return ok
  17244. }
  17245. // ClearField clears the value of the field with the given name. It returns an
  17246. // error if the field is not defined in the schema.
  17247. func (m *ChannelMonitorHistoryMutation) ClearField(name string) error {
  17248. switch name {
  17249. case channelmonitorhistory.FieldLatencyMs:
  17250. m.ClearLatencyMs()
  17251. return nil
  17252. case channelmonitorhistory.FieldPingLatencyMs:
  17253. m.ClearPingLatencyMs()
  17254. return nil
  17255. case channelmonitorhistory.FieldMessage:
  17256. m.ClearMessage()
  17257. return nil
  17258. case channelmonitorhistory.FieldQuota:
  17259. m.ClearQuota()
  17260. return nil
  17261. }
  17262. return fmt.Errorf("unknown ChannelMonitorHistory nullable field %s", name)
  17263. }
  17264. // ResetField resets all changes in the mutation for the field with the given name.
  17265. // It returns an error if the field is not defined in the schema.
  17266. func (m *ChannelMonitorHistoryMutation) ResetField(name string) error {
  17267. switch name {
  17268. case channelmonitorhistory.FieldMonitorID:
  17269. m.ResetMonitorID()
  17270. return nil
  17271. case channelmonitorhistory.FieldModel:
  17272. m.ResetModel()
  17273. return nil
  17274. case channelmonitorhistory.FieldStatus:
  17275. m.ResetStatus()
  17276. return nil
  17277. case channelmonitorhistory.FieldLatencyMs:
  17278. m.ResetLatencyMs()
  17279. return nil
  17280. case channelmonitorhistory.FieldPingLatencyMs:
  17281. m.ResetPingLatencyMs()
  17282. return nil
  17283. case channelmonitorhistory.FieldMessage:
  17284. m.ResetMessage()
  17285. return nil
  17286. case channelmonitorhistory.FieldQuota:
  17287. m.ResetQuota()
  17288. return nil
  17289. case channelmonitorhistory.FieldCheckedAt:
  17290. m.ResetCheckedAt()
  17291. return nil
  17292. }
  17293. return fmt.Errorf("unknown ChannelMonitorHistory field %s", name)
  17294. }
  17295. // AddedEdges returns all edge names that were set/added in this mutation.
  17296. func (m *ChannelMonitorHistoryMutation) AddedEdges() []string {
  17297. edges := make([]string, 0, 1)
  17298. if m.monitor != nil {
  17299. edges = append(edges, channelmonitorhistory.EdgeMonitor)
  17300. }
  17301. return edges
  17302. }
  17303. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  17304. // name in this mutation.
  17305. func (m *ChannelMonitorHistoryMutation) AddedIDs(name string) []ent.Value {
  17306. switch name {
  17307. case channelmonitorhistory.EdgeMonitor:
  17308. if id := m.monitor; id != nil {
  17309. return []ent.Value{*id}
  17310. }
  17311. }
  17312. return nil
  17313. }
  17314. // RemovedEdges returns all edge names that were removed in this mutation.
  17315. func (m *ChannelMonitorHistoryMutation) RemovedEdges() []string {
  17316. edges := make([]string, 0, 1)
  17317. return edges
  17318. }
  17319. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  17320. // the given name in this mutation.
  17321. func (m *ChannelMonitorHistoryMutation) RemovedIDs(name string) []ent.Value {
  17322. return nil
  17323. }
  17324. // ClearedEdges returns all edge names that were cleared in this mutation.
  17325. func (m *ChannelMonitorHistoryMutation) ClearedEdges() []string {
  17326. edges := make([]string, 0, 1)
  17327. if m.clearedmonitor {
  17328. edges = append(edges, channelmonitorhistory.EdgeMonitor)
  17329. }
  17330. return edges
  17331. }
  17332. // EdgeCleared returns a boolean which indicates if the edge with the given name
  17333. // was cleared in this mutation.
  17334. func (m *ChannelMonitorHistoryMutation) EdgeCleared(name string) bool {
  17335. switch name {
  17336. case channelmonitorhistory.EdgeMonitor:
  17337. return m.clearedmonitor
  17338. }
  17339. return false
  17340. }
  17341. // ClearEdge clears the value of the edge with the given name. It returns an error
  17342. // if that edge is not defined in the schema.
  17343. func (m *ChannelMonitorHistoryMutation) ClearEdge(name string) error {
  17344. switch name {
  17345. case channelmonitorhistory.EdgeMonitor:
  17346. m.ClearMonitor()
  17347. return nil
  17348. }
  17349. return fmt.Errorf("unknown ChannelMonitorHistory unique edge %s", name)
  17350. }
  17351. // ResetEdge resets all changes to the edge with the given name in this mutation.
  17352. // It returns an error if the edge is not defined in the schema.
  17353. func (m *ChannelMonitorHistoryMutation) ResetEdge(name string) error {
  17354. switch name {
  17355. case channelmonitorhistory.EdgeMonitor:
  17356. m.ResetMonitor()
  17357. return nil
  17358. }
  17359. return fmt.Errorf("unknown ChannelMonitorHistory edge %s", name)
  17360. }
  17361. // ChannelMonitorRequestTemplateMutation represents an operation that mutates the ChannelMonitorRequestTemplate nodes in the graph.
  17362. type ChannelMonitorRequestTemplateMutation struct {
  17363. config
  17364. op Op
  17365. typ string
  17366. id *int64
  17367. created_at *time.Time
  17368. updated_at *time.Time
  17369. name *string
  17370. provider *channelmonitorrequesttemplate.Provider
  17371. api_mode *string
  17372. description *string
  17373. extra_headers *map[string]string
  17374. body_override_mode *string
  17375. body_override *map[string]interface{}
  17376. clearedFields map[string]struct{}
  17377. monitors map[int64]struct{}
  17378. removedmonitors map[int64]struct{}
  17379. clearedmonitors bool
  17380. done bool
  17381. oldValue func(context.Context) (*ChannelMonitorRequestTemplate, error)
  17382. predicates []predicate.ChannelMonitorRequestTemplate
  17383. }
  17384. var _ ent.Mutation = (*ChannelMonitorRequestTemplateMutation)(nil)
  17385. // channelmonitorrequesttemplateOption allows management of the mutation configuration using functional options.
  17386. type channelmonitorrequesttemplateOption func(*ChannelMonitorRequestTemplateMutation)
  17387. // newChannelMonitorRequestTemplateMutation creates new mutation for the ChannelMonitorRequestTemplate entity.
  17388. func newChannelMonitorRequestTemplateMutation(c config, op Op, opts ...channelmonitorrequesttemplateOption) *ChannelMonitorRequestTemplateMutation {
  17389. m := &ChannelMonitorRequestTemplateMutation{
  17390. config: c,
  17391. op: op,
  17392. typ: TypeChannelMonitorRequestTemplate,
  17393. clearedFields: make(map[string]struct{}),
  17394. }
  17395. for _, opt := range opts {
  17396. opt(m)
  17397. }
  17398. return m
  17399. }
  17400. // withChannelMonitorRequestTemplateID sets the ID field of the mutation.
  17401. func withChannelMonitorRequestTemplateID(id int64) channelmonitorrequesttemplateOption {
  17402. return func(m *ChannelMonitorRequestTemplateMutation) {
  17403. var (
  17404. err error
  17405. once sync.Once
  17406. value *ChannelMonitorRequestTemplate
  17407. )
  17408. m.oldValue = func(ctx context.Context) (*ChannelMonitorRequestTemplate, error) {
  17409. once.Do(func() {
  17410. if m.done {
  17411. err = errors.New("querying old values post mutation is not allowed")
  17412. } else {
  17413. value, err = m.Client().ChannelMonitorRequestTemplate.Get(ctx, id)
  17414. }
  17415. })
  17416. return value, err
  17417. }
  17418. m.id = &id
  17419. }
  17420. }
  17421. // withChannelMonitorRequestTemplate sets the old ChannelMonitorRequestTemplate of the mutation.
  17422. func withChannelMonitorRequestTemplate(node *ChannelMonitorRequestTemplate) channelmonitorrequesttemplateOption {
  17423. return func(m *ChannelMonitorRequestTemplateMutation) {
  17424. m.oldValue = func(context.Context) (*ChannelMonitorRequestTemplate, error) {
  17425. return node, nil
  17426. }
  17427. m.id = &node.ID
  17428. }
  17429. }
  17430. // Client returns a new `ent.Client` from the mutation. If the mutation was
  17431. // executed in a transaction (ent.Tx), a transactional client is returned.
  17432. func (m ChannelMonitorRequestTemplateMutation) Client() *Client {
  17433. client := &Client{config: m.config}
  17434. client.init()
  17435. return client
  17436. }
  17437. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  17438. // it returns an error otherwise.
  17439. func (m ChannelMonitorRequestTemplateMutation) Tx() (*Tx, error) {
  17440. if _, ok := m.driver.(*txDriver); !ok {
  17441. return nil, errors.New("ent: mutation is not running in a transaction")
  17442. }
  17443. tx := &Tx{config: m.config}
  17444. tx.init()
  17445. return tx, nil
  17446. }
  17447. // ID returns the ID value in the mutation. Note that the ID is only available
  17448. // if it was provided to the builder or after it was returned from the database.
  17449. func (m *ChannelMonitorRequestTemplateMutation) ID() (id int64, exists bool) {
  17450. if m.id == nil {
  17451. return
  17452. }
  17453. return *m.id, true
  17454. }
  17455. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  17456. // That means, if the mutation is applied within a transaction with an isolation level such
  17457. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  17458. // or updated by the mutation.
  17459. func (m *ChannelMonitorRequestTemplateMutation) IDs(ctx context.Context) ([]int64, error) {
  17460. switch {
  17461. case m.op.Is(OpUpdateOne | OpDeleteOne):
  17462. id, exists := m.ID()
  17463. if exists {
  17464. return []int64{id}, nil
  17465. }
  17466. fallthrough
  17467. case m.op.Is(OpUpdate | OpDelete):
  17468. return m.Client().ChannelMonitorRequestTemplate.Query().Where(m.predicates...).IDs(ctx)
  17469. default:
  17470. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  17471. }
  17472. }
  17473. // SetCreatedAt sets the "created_at" field.
  17474. func (m *ChannelMonitorRequestTemplateMutation) SetCreatedAt(t time.Time) {
  17475. m.created_at = &t
  17476. }
  17477. // CreatedAt returns the value of the "created_at" field in the mutation.
  17478. func (m *ChannelMonitorRequestTemplateMutation) CreatedAt() (r time.Time, exists bool) {
  17479. v := m.created_at
  17480. if v == nil {
  17481. return
  17482. }
  17483. return *v, true
  17484. }
  17485. // OldCreatedAt returns the old "created_at" field's value of the ChannelMonitorRequestTemplate entity.
  17486. // If the ChannelMonitorRequestTemplate object wasn't provided to the builder, the object is fetched from the database.
  17487. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17488. func (m *ChannelMonitorRequestTemplateMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  17489. if !m.op.Is(OpUpdateOne) {
  17490. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  17491. }
  17492. if m.id == nil || m.oldValue == nil {
  17493. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  17494. }
  17495. oldValue, err := m.oldValue(ctx)
  17496. if err != nil {
  17497. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  17498. }
  17499. return oldValue.CreatedAt, nil
  17500. }
  17501. // ResetCreatedAt resets all changes to the "created_at" field.
  17502. func (m *ChannelMonitorRequestTemplateMutation) ResetCreatedAt() {
  17503. m.created_at = nil
  17504. }
  17505. // SetUpdatedAt sets the "updated_at" field.
  17506. func (m *ChannelMonitorRequestTemplateMutation) SetUpdatedAt(t time.Time) {
  17507. m.updated_at = &t
  17508. }
  17509. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  17510. func (m *ChannelMonitorRequestTemplateMutation) UpdatedAt() (r time.Time, exists bool) {
  17511. v := m.updated_at
  17512. if v == nil {
  17513. return
  17514. }
  17515. return *v, true
  17516. }
  17517. // OldUpdatedAt returns the old "updated_at" field's value of the ChannelMonitorRequestTemplate entity.
  17518. // If the ChannelMonitorRequestTemplate object wasn't provided to the builder, the object is fetched from the database.
  17519. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17520. func (m *ChannelMonitorRequestTemplateMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  17521. if !m.op.Is(OpUpdateOne) {
  17522. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  17523. }
  17524. if m.id == nil || m.oldValue == nil {
  17525. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  17526. }
  17527. oldValue, err := m.oldValue(ctx)
  17528. if err != nil {
  17529. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  17530. }
  17531. return oldValue.UpdatedAt, nil
  17532. }
  17533. // ResetUpdatedAt resets all changes to the "updated_at" field.
  17534. func (m *ChannelMonitorRequestTemplateMutation) ResetUpdatedAt() {
  17535. m.updated_at = nil
  17536. }
  17537. // SetName sets the "name" field.
  17538. func (m *ChannelMonitorRequestTemplateMutation) SetName(s string) {
  17539. m.name = &s
  17540. }
  17541. // Name returns the value of the "name" field in the mutation.
  17542. func (m *ChannelMonitorRequestTemplateMutation) Name() (r string, exists bool) {
  17543. v := m.name
  17544. if v == nil {
  17545. return
  17546. }
  17547. return *v, true
  17548. }
  17549. // OldName returns the old "name" field's value of the ChannelMonitorRequestTemplate entity.
  17550. // If the ChannelMonitorRequestTemplate object wasn't provided to the builder, the object is fetched from the database.
  17551. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17552. func (m *ChannelMonitorRequestTemplateMutation) OldName(ctx context.Context) (v string, err error) {
  17553. if !m.op.Is(OpUpdateOne) {
  17554. return v, errors.New("OldName is only allowed on UpdateOne operations")
  17555. }
  17556. if m.id == nil || m.oldValue == nil {
  17557. return v, errors.New("OldName requires an ID field in the mutation")
  17558. }
  17559. oldValue, err := m.oldValue(ctx)
  17560. if err != nil {
  17561. return v, fmt.Errorf("querying old value for OldName: %w", err)
  17562. }
  17563. return oldValue.Name, nil
  17564. }
  17565. // ResetName resets all changes to the "name" field.
  17566. func (m *ChannelMonitorRequestTemplateMutation) ResetName() {
  17567. m.name = nil
  17568. }
  17569. // SetProvider sets the "provider" field.
  17570. func (m *ChannelMonitorRequestTemplateMutation) SetProvider(c channelmonitorrequesttemplate.Provider) {
  17571. m.provider = &c
  17572. }
  17573. // Provider returns the value of the "provider" field in the mutation.
  17574. func (m *ChannelMonitorRequestTemplateMutation) Provider() (r channelmonitorrequesttemplate.Provider, exists bool) {
  17575. v := m.provider
  17576. if v == nil {
  17577. return
  17578. }
  17579. return *v, true
  17580. }
  17581. // OldProvider returns the old "provider" field's value of the ChannelMonitorRequestTemplate entity.
  17582. // If the ChannelMonitorRequestTemplate object wasn't provided to the builder, the object is fetched from the database.
  17583. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17584. func (m *ChannelMonitorRequestTemplateMutation) OldProvider(ctx context.Context) (v channelmonitorrequesttemplate.Provider, err error) {
  17585. if !m.op.Is(OpUpdateOne) {
  17586. return v, errors.New("OldProvider is only allowed on UpdateOne operations")
  17587. }
  17588. if m.id == nil || m.oldValue == nil {
  17589. return v, errors.New("OldProvider requires an ID field in the mutation")
  17590. }
  17591. oldValue, err := m.oldValue(ctx)
  17592. if err != nil {
  17593. return v, fmt.Errorf("querying old value for OldProvider: %w", err)
  17594. }
  17595. return oldValue.Provider, nil
  17596. }
  17597. // ResetProvider resets all changes to the "provider" field.
  17598. func (m *ChannelMonitorRequestTemplateMutation) ResetProvider() {
  17599. m.provider = nil
  17600. }
  17601. // SetAPIMode sets the "api_mode" field.
  17602. func (m *ChannelMonitorRequestTemplateMutation) SetAPIMode(s string) {
  17603. m.api_mode = &s
  17604. }
  17605. // APIMode returns the value of the "api_mode" field in the mutation.
  17606. func (m *ChannelMonitorRequestTemplateMutation) APIMode() (r string, exists bool) {
  17607. v := m.api_mode
  17608. if v == nil {
  17609. return
  17610. }
  17611. return *v, true
  17612. }
  17613. // OldAPIMode returns the old "api_mode" field's value of the ChannelMonitorRequestTemplate entity.
  17614. // If the ChannelMonitorRequestTemplate object wasn't provided to the builder, the object is fetched from the database.
  17615. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17616. func (m *ChannelMonitorRequestTemplateMutation) OldAPIMode(ctx context.Context) (v string, err error) {
  17617. if !m.op.Is(OpUpdateOne) {
  17618. return v, errors.New("OldAPIMode is only allowed on UpdateOne operations")
  17619. }
  17620. if m.id == nil || m.oldValue == nil {
  17621. return v, errors.New("OldAPIMode requires an ID field in the mutation")
  17622. }
  17623. oldValue, err := m.oldValue(ctx)
  17624. if err != nil {
  17625. return v, fmt.Errorf("querying old value for OldAPIMode: %w", err)
  17626. }
  17627. return oldValue.APIMode, nil
  17628. }
  17629. // ResetAPIMode resets all changes to the "api_mode" field.
  17630. func (m *ChannelMonitorRequestTemplateMutation) ResetAPIMode() {
  17631. m.api_mode = nil
  17632. }
  17633. // SetDescription sets the "description" field.
  17634. func (m *ChannelMonitorRequestTemplateMutation) SetDescription(s string) {
  17635. m.description = &s
  17636. }
  17637. // Description returns the value of the "description" field in the mutation.
  17638. func (m *ChannelMonitorRequestTemplateMutation) Description() (r string, exists bool) {
  17639. v := m.description
  17640. if v == nil {
  17641. return
  17642. }
  17643. return *v, true
  17644. }
  17645. // OldDescription returns the old "description" field's value of the ChannelMonitorRequestTemplate entity.
  17646. // If the ChannelMonitorRequestTemplate object wasn't provided to the builder, the object is fetched from the database.
  17647. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17648. func (m *ChannelMonitorRequestTemplateMutation) OldDescription(ctx context.Context) (v string, err error) {
  17649. if !m.op.Is(OpUpdateOne) {
  17650. return v, errors.New("OldDescription is only allowed on UpdateOne operations")
  17651. }
  17652. if m.id == nil || m.oldValue == nil {
  17653. return v, errors.New("OldDescription requires an ID field in the mutation")
  17654. }
  17655. oldValue, err := m.oldValue(ctx)
  17656. if err != nil {
  17657. return v, fmt.Errorf("querying old value for OldDescription: %w", err)
  17658. }
  17659. return oldValue.Description, nil
  17660. }
  17661. // ClearDescription clears the value of the "description" field.
  17662. func (m *ChannelMonitorRequestTemplateMutation) ClearDescription() {
  17663. m.description = nil
  17664. m.clearedFields[channelmonitorrequesttemplate.FieldDescription] = struct{}{}
  17665. }
  17666. // DescriptionCleared returns if the "description" field was cleared in this mutation.
  17667. func (m *ChannelMonitorRequestTemplateMutation) DescriptionCleared() bool {
  17668. _, ok := m.clearedFields[channelmonitorrequesttemplate.FieldDescription]
  17669. return ok
  17670. }
  17671. // ResetDescription resets all changes to the "description" field.
  17672. func (m *ChannelMonitorRequestTemplateMutation) ResetDescription() {
  17673. m.description = nil
  17674. delete(m.clearedFields, channelmonitorrequesttemplate.FieldDescription)
  17675. }
  17676. // SetExtraHeaders sets the "extra_headers" field.
  17677. func (m *ChannelMonitorRequestTemplateMutation) SetExtraHeaders(value map[string]string) {
  17678. m.extra_headers = &value
  17679. }
  17680. // ExtraHeaders returns the value of the "extra_headers" field in the mutation.
  17681. func (m *ChannelMonitorRequestTemplateMutation) ExtraHeaders() (r map[string]string, exists bool) {
  17682. v := m.extra_headers
  17683. if v == nil {
  17684. return
  17685. }
  17686. return *v, true
  17687. }
  17688. // OldExtraHeaders returns the old "extra_headers" field's value of the ChannelMonitorRequestTemplate entity.
  17689. // If the ChannelMonitorRequestTemplate object wasn't provided to the builder, the object is fetched from the database.
  17690. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17691. func (m *ChannelMonitorRequestTemplateMutation) OldExtraHeaders(ctx context.Context) (v map[string]string, err error) {
  17692. if !m.op.Is(OpUpdateOne) {
  17693. return v, errors.New("OldExtraHeaders is only allowed on UpdateOne operations")
  17694. }
  17695. if m.id == nil || m.oldValue == nil {
  17696. return v, errors.New("OldExtraHeaders requires an ID field in the mutation")
  17697. }
  17698. oldValue, err := m.oldValue(ctx)
  17699. if err != nil {
  17700. return v, fmt.Errorf("querying old value for OldExtraHeaders: %w", err)
  17701. }
  17702. return oldValue.ExtraHeaders, nil
  17703. }
  17704. // ResetExtraHeaders resets all changes to the "extra_headers" field.
  17705. func (m *ChannelMonitorRequestTemplateMutation) ResetExtraHeaders() {
  17706. m.extra_headers = nil
  17707. }
  17708. // SetBodyOverrideMode sets the "body_override_mode" field.
  17709. func (m *ChannelMonitorRequestTemplateMutation) SetBodyOverrideMode(s string) {
  17710. m.body_override_mode = &s
  17711. }
  17712. // BodyOverrideMode returns the value of the "body_override_mode" field in the mutation.
  17713. func (m *ChannelMonitorRequestTemplateMutation) BodyOverrideMode() (r string, exists bool) {
  17714. v := m.body_override_mode
  17715. if v == nil {
  17716. return
  17717. }
  17718. return *v, true
  17719. }
  17720. // OldBodyOverrideMode returns the old "body_override_mode" field's value of the ChannelMonitorRequestTemplate entity.
  17721. // If the ChannelMonitorRequestTemplate object wasn't provided to the builder, the object is fetched from the database.
  17722. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17723. func (m *ChannelMonitorRequestTemplateMutation) OldBodyOverrideMode(ctx context.Context) (v string, err error) {
  17724. if !m.op.Is(OpUpdateOne) {
  17725. return v, errors.New("OldBodyOverrideMode is only allowed on UpdateOne operations")
  17726. }
  17727. if m.id == nil || m.oldValue == nil {
  17728. return v, errors.New("OldBodyOverrideMode requires an ID field in the mutation")
  17729. }
  17730. oldValue, err := m.oldValue(ctx)
  17731. if err != nil {
  17732. return v, fmt.Errorf("querying old value for OldBodyOverrideMode: %w", err)
  17733. }
  17734. return oldValue.BodyOverrideMode, nil
  17735. }
  17736. // ResetBodyOverrideMode resets all changes to the "body_override_mode" field.
  17737. func (m *ChannelMonitorRequestTemplateMutation) ResetBodyOverrideMode() {
  17738. m.body_override_mode = nil
  17739. }
  17740. // SetBodyOverride sets the "body_override" field.
  17741. func (m *ChannelMonitorRequestTemplateMutation) SetBodyOverride(value map[string]interface{}) {
  17742. m.body_override = &value
  17743. }
  17744. // BodyOverride returns the value of the "body_override" field in the mutation.
  17745. func (m *ChannelMonitorRequestTemplateMutation) BodyOverride() (r map[string]interface{}, exists bool) {
  17746. v := m.body_override
  17747. if v == nil {
  17748. return
  17749. }
  17750. return *v, true
  17751. }
  17752. // OldBodyOverride returns the old "body_override" field's value of the ChannelMonitorRequestTemplate entity.
  17753. // If the ChannelMonitorRequestTemplate object wasn't provided to the builder, the object is fetched from the database.
  17754. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17755. func (m *ChannelMonitorRequestTemplateMutation) OldBodyOverride(ctx context.Context) (v map[string]interface{}, err error) {
  17756. if !m.op.Is(OpUpdateOne) {
  17757. return v, errors.New("OldBodyOverride is only allowed on UpdateOne operations")
  17758. }
  17759. if m.id == nil || m.oldValue == nil {
  17760. return v, errors.New("OldBodyOverride requires an ID field in the mutation")
  17761. }
  17762. oldValue, err := m.oldValue(ctx)
  17763. if err != nil {
  17764. return v, fmt.Errorf("querying old value for OldBodyOverride: %w", err)
  17765. }
  17766. return oldValue.BodyOverride, nil
  17767. }
  17768. // ClearBodyOverride clears the value of the "body_override" field.
  17769. func (m *ChannelMonitorRequestTemplateMutation) ClearBodyOverride() {
  17770. m.body_override = nil
  17771. m.clearedFields[channelmonitorrequesttemplate.FieldBodyOverride] = struct{}{}
  17772. }
  17773. // BodyOverrideCleared returns if the "body_override" field was cleared in this mutation.
  17774. func (m *ChannelMonitorRequestTemplateMutation) BodyOverrideCleared() bool {
  17775. _, ok := m.clearedFields[channelmonitorrequesttemplate.FieldBodyOverride]
  17776. return ok
  17777. }
  17778. // ResetBodyOverride resets all changes to the "body_override" field.
  17779. func (m *ChannelMonitorRequestTemplateMutation) ResetBodyOverride() {
  17780. m.body_override = nil
  17781. delete(m.clearedFields, channelmonitorrequesttemplate.FieldBodyOverride)
  17782. }
  17783. // AddMonitorIDs adds the "monitors" edge to the ChannelMonitor entity by ids.
  17784. func (m *ChannelMonitorRequestTemplateMutation) AddMonitorIDs(ids ...int64) {
  17785. if m.monitors == nil {
  17786. m.monitors = make(map[int64]struct{})
  17787. }
  17788. for i := range ids {
  17789. m.monitors[ids[i]] = struct{}{}
  17790. }
  17791. }
  17792. // ClearMonitors clears the "monitors" edge to the ChannelMonitor entity.
  17793. func (m *ChannelMonitorRequestTemplateMutation) ClearMonitors() {
  17794. m.clearedmonitors = true
  17795. }
  17796. // MonitorsCleared reports if the "monitors" edge to the ChannelMonitor entity was cleared.
  17797. func (m *ChannelMonitorRequestTemplateMutation) MonitorsCleared() bool {
  17798. return m.clearedmonitors
  17799. }
  17800. // RemoveMonitorIDs removes the "monitors" edge to the ChannelMonitor entity by IDs.
  17801. func (m *ChannelMonitorRequestTemplateMutation) RemoveMonitorIDs(ids ...int64) {
  17802. if m.removedmonitors == nil {
  17803. m.removedmonitors = make(map[int64]struct{})
  17804. }
  17805. for i := range ids {
  17806. delete(m.monitors, ids[i])
  17807. m.removedmonitors[ids[i]] = struct{}{}
  17808. }
  17809. }
  17810. // RemovedMonitors returns the removed IDs of the "monitors" edge to the ChannelMonitor entity.
  17811. func (m *ChannelMonitorRequestTemplateMutation) RemovedMonitorsIDs() (ids []int64) {
  17812. for id := range m.removedmonitors {
  17813. ids = append(ids, id)
  17814. }
  17815. return
  17816. }
  17817. // MonitorsIDs returns the "monitors" edge IDs in the mutation.
  17818. func (m *ChannelMonitorRequestTemplateMutation) MonitorsIDs() (ids []int64) {
  17819. for id := range m.monitors {
  17820. ids = append(ids, id)
  17821. }
  17822. return
  17823. }
  17824. // ResetMonitors resets all changes to the "monitors" edge.
  17825. func (m *ChannelMonitorRequestTemplateMutation) ResetMonitors() {
  17826. m.monitors = nil
  17827. m.clearedmonitors = false
  17828. m.removedmonitors = nil
  17829. }
  17830. // Where appends a list predicates to the ChannelMonitorRequestTemplateMutation builder.
  17831. func (m *ChannelMonitorRequestTemplateMutation) Where(ps ...predicate.ChannelMonitorRequestTemplate) {
  17832. m.predicates = append(m.predicates, ps...)
  17833. }
  17834. // WhereP appends storage-level predicates to the ChannelMonitorRequestTemplateMutation builder. Using this method,
  17835. // users can use type-assertion to append predicates that do not depend on any generated package.
  17836. func (m *ChannelMonitorRequestTemplateMutation) WhereP(ps ...func(*sql.Selector)) {
  17837. p := make([]predicate.ChannelMonitorRequestTemplate, len(ps))
  17838. for i := range ps {
  17839. p[i] = ps[i]
  17840. }
  17841. m.Where(p...)
  17842. }
  17843. // Op returns the operation name.
  17844. func (m *ChannelMonitorRequestTemplateMutation) Op() Op {
  17845. return m.op
  17846. }
  17847. // SetOp allows setting the mutation operation.
  17848. func (m *ChannelMonitorRequestTemplateMutation) SetOp(op Op) {
  17849. m.op = op
  17850. }
  17851. // Type returns the node type of this mutation (ChannelMonitorRequestTemplate).
  17852. func (m *ChannelMonitorRequestTemplateMutation) Type() string {
  17853. return m.typ
  17854. }
  17855. // Fields returns all fields that were changed during this mutation. Note that in
  17856. // order to get all numeric fields that were incremented/decremented, call
  17857. // AddedFields().
  17858. func (m *ChannelMonitorRequestTemplateMutation) Fields() []string {
  17859. fields := make([]string, 0, 9)
  17860. if m.created_at != nil {
  17861. fields = append(fields, channelmonitorrequesttemplate.FieldCreatedAt)
  17862. }
  17863. if m.updated_at != nil {
  17864. fields = append(fields, channelmonitorrequesttemplate.FieldUpdatedAt)
  17865. }
  17866. if m.name != nil {
  17867. fields = append(fields, channelmonitorrequesttemplate.FieldName)
  17868. }
  17869. if m.provider != nil {
  17870. fields = append(fields, channelmonitorrequesttemplate.FieldProvider)
  17871. }
  17872. if m.api_mode != nil {
  17873. fields = append(fields, channelmonitorrequesttemplate.FieldAPIMode)
  17874. }
  17875. if m.description != nil {
  17876. fields = append(fields, channelmonitorrequesttemplate.FieldDescription)
  17877. }
  17878. if m.extra_headers != nil {
  17879. fields = append(fields, channelmonitorrequesttemplate.FieldExtraHeaders)
  17880. }
  17881. if m.body_override_mode != nil {
  17882. fields = append(fields, channelmonitorrequesttemplate.FieldBodyOverrideMode)
  17883. }
  17884. if m.body_override != nil {
  17885. fields = append(fields, channelmonitorrequesttemplate.FieldBodyOverride)
  17886. }
  17887. return fields
  17888. }
  17889. // Field returns the value of a field with the given name. The second boolean
  17890. // return value indicates that this field was not set, or was not defined in the
  17891. // schema.
  17892. func (m *ChannelMonitorRequestTemplateMutation) Field(name string) (ent.Value, bool) {
  17893. switch name {
  17894. case channelmonitorrequesttemplate.FieldCreatedAt:
  17895. return m.CreatedAt()
  17896. case channelmonitorrequesttemplate.FieldUpdatedAt:
  17897. return m.UpdatedAt()
  17898. case channelmonitorrequesttemplate.FieldName:
  17899. return m.Name()
  17900. case channelmonitorrequesttemplate.FieldProvider:
  17901. return m.Provider()
  17902. case channelmonitorrequesttemplate.FieldAPIMode:
  17903. return m.APIMode()
  17904. case channelmonitorrequesttemplate.FieldDescription:
  17905. return m.Description()
  17906. case channelmonitorrequesttemplate.FieldExtraHeaders:
  17907. return m.ExtraHeaders()
  17908. case channelmonitorrequesttemplate.FieldBodyOverrideMode:
  17909. return m.BodyOverrideMode()
  17910. case channelmonitorrequesttemplate.FieldBodyOverride:
  17911. return m.BodyOverride()
  17912. }
  17913. return nil, false
  17914. }
  17915. // OldField returns the old value of the field from the database. An error is
  17916. // returned if the mutation operation is not UpdateOne, or the query to the
  17917. // database failed.
  17918. func (m *ChannelMonitorRequestTemplateMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  17919. switch name {
  17920. case channelmonitorrequesttemplate.FieldCreatedAt:
  17921. return m.OldCreatedAt(ctx)
  17922. case channelmonitorrequesttemplate.FieldUpdatedAt:
  17923. return m.OldUpdatedAt(ctx)
  17924. case channelmonitorrequesttemplate.FieldName:
  17925. return m.OldName(ctx)
  17926. case channelmonitorrequesttemplate.FieldProvider:
  17927. return m.OldProvider(ctx)
  17928. case channelmonitorrequesttemplate.FieldAPIMode:
  17929. return m.OldAPIMode(ctx)
  17930. case channelmonitorrequesttemplate.FieldDescription:
  17931. return m.OldDescription(ctx)
  17932. case channelmonitorrequesttemplate.FieldExtraHeaders:
  17933. return m.OldExtraHeaders(ctx)
  17934. case channelmonitorrequesttemplate.FieldBodyOverrideMode:
  17935. return m.OldBodyOverrideMode(ctx)
  17936. case channelmonitorrequesttemplate.FieldBodyOverride:
  17937. return m.OldBodyOverride(ctx)
  17938. }
  17939. return nil, fmt.Errorf("unknown ChannelMonitorRequestTemplate field %s", name)
  17940. }
  17941. // SetField sets the value of a field with the given name. It returns an error if
  17942. // the field is not defined in the schema, or if the type mismatched the field
  17943. // type.
  17944. func (m *ChannelMonitorRequestTemplateMutation) SetField(name string, value ent.Value) error {
  17945. switch name {
  17946. case channelmonitorrequesttemplate.FieldCreatedAt:
  17947. v, ok := value.(time.Time)
  17948. if !ok {
  17949. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17950. }
  17951. m.SetCreatedAt(v)
  17952. return nil
  17953. case channelmonitorrequesttemplate.FieldUpdatedAt:
  17954. v, ok := value.(time.Time)
  17955. if !ok {
  17956. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17957. }
  17958. m.SetUpdatedAt(v)
  17959. return nil
  17960. case channelmonitorrequesttemplate.FieldName:
  17961. v, ok := value.(string)
  17962. if !ok {
  17963. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17964. }
  17965. m.SetName(v)
  17966. return nil
  17967. case channelmonitorrequesttemplate.FieldProvider:
  17968. v, ok := value.(channelmonitorrequesttemplate.Provider)
  17969. if !ok {
  17970. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17971. }
  17972. m.SetProvider(v)
  17973. return nil
  17974. case channelmonitorrequesttemplate.FieldAPIMode:
  17975. v, ok := value.(string)
  17976. if !ok {
  17977. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17978. }
  17979. m.SetAPIMode(v)
  17980. return nil
  17981. case channelmonitorrequesttemplate.FieldDescription:
  17982. v, ok := value.(string)
  17983. if !ok {
  17984. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17985. }
  17986. m.SetDescription(v)
  17987. return nil
  17988. case channelmonitorrequesttemplate.FieldExtraHeaders:
  17989. v, ok := value.(map[string]string)
  17990. if !ok {
  17991. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17992. }
  17993. m.SetExtraHeaders(v)
  17994. return nil
  17995. case channelmonitorrequesttemplate.FieldBodyOverrideMode:
  17996. v, ok := value.(string)
  17997. if !ok {
  17998. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17999. }
  18000. m.SetBodyOverrideMode(v)
  18001. return nil
  18002. case channelmonitorrequesttemplate.FieldBodyOverride:
  18003. v, ok := value.(map[string]interface{})
  18004. if !ok {
  18005. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18006. }
  18007. m.SetBodyOverride(v)
  18008. return nil
  18009. }
  18010. return fmt.Errorf("unknown ChannelMonitorRequestTemplate field %s", name)
  18011. }
  18012. // AddedFields returns all numeric fields that were incremented/decremented during
  18013. // this mutation.
  18014. func (m *ChannelMonitorRequestTemplateMutation) AddedFields() []string {
  18015. return nil
  18016. }
  18017. // AddedField returns the numeric value that was incremented/decremented on a field
  18018. // with the given name. The second boolean return value indicates that this field
  18019. // was not set, or was not defined in the schema.
  18020. func (m *ChannelMonitorRequestTemplateMutation) AddedField(name string) (ent.Value, bool) {
  18021. return nil, false
  18022. }
  18023. // AddField adds the value to the field with the given name. It returns an error if
  18024. // the field is not defined in the schema, or if the type mismatched the field
  18025. // type.
  18026. func (m *ChannelMonitorRequestTemplateMutation) AddField(name string, value ent.Value) error {
  18027. switch name {
  18028. }
  18029. return fmt.Errorf("unknown ChannelMonitorRequestTemplate numeric field %s", name)
  18030. }
  18031. // ClearedFields returns all nullable fields that were cleared during this
  18032. // mutation.
  18033. func (m *ChannelMonitorRequestTemplateMutation) ClearedFields() []string {
  18034. var fields []string
  18035. if m.FieldCleared(channelmonitorrequesttemplate.FieldDescription) {
  18036. fields = append(fields, channelmonitorrequesttemplate.FieldDescription)
  18037. }
  18038. if m.FieldCleared(channelmonitorrequesttemplate.FieldBodyOverride) {
  18039. fields = append(fields, channelmonitorrequesttemplate.FieldBodyOverride)
  18040. }
  18041. return fields
  18042. }
  18043. // FieldCleared returns a boolean indicating if a field with the given name was
  18044. // cleared in this mutation.
  18045. func (m *ChannelMonitorRequestTemplateMutation) FieldCleared(name string) bool {
  18046. _, ok := m.clearedFields[name]
  18047. return ok
  18048. }
  18049. // ClearField clears the value of the field with the given name. It returns an
  18050. // error if the field is not defined in the schema.
  18051. func (m *ChannelMonitorRequestTemplateMutation) ClearField(name string) error {
  18052. switch name {
  18053. case channelmonitorrequesttemplate.FieldDescription:
  18054. m.ClearDescription()
  18055. return nil
  18056. case channelmonitorrequesttemplate.FieldBodyOverride:
  18057. m.ClearBodyOverride()
  18058. return nil
  18059. }
  18060. return fmt.Errorf("unknown ChannelMonitorRequestTemplate nullable field %s", name)
  18061. }
  18062. // ResetField resets all changes in the mutation for the field with the given name.
  18063. // It returns an error if the field is not defined in the schema.
  18064. func (m *ChannelMonitorRequestTemplateMutation) ResetField(name string) error {
  18065. switch name {
  18066. case channelmonitorrequesttemplate.FieldCreatedAt:
  18067. m.ResetCreatedAt()
  18068. return nil
  18069. case channelmonitorrequesttemplate.FieldUpdatedAt:
  18070. m.ResetUpdatedAt()
  18071. return nil
  18072. case channelmonitorrequesttemplate.FieldName:
  18073. m.ResetName()
  18074. return nil
  18075. case channelmonitorrequesttemplate.FieldProvider:
  18076. m.ResetProvider()
  18077. return nil
  18078. case channelmonitorrequesttemplate.FieldAPIMode:
  18079. m.ResetAPIMode()
  18080. return nil
  18081. case channelmonitorrequesttemplate.FieldDescription:
  18082. m.ResetDescription()
  18083. return nil
  18084. case channelmonitorrequesttemplate.FieldExtraHeaders:
  18085. m.ResetExtraHeaders()
  18086. return nil
  18087. case channelmonitorrequesttemplate.FieldBodyOverrideMode:
  18088. m.ResetBodyOverrideMode()
  18089. return nil
  18090. case channelmonitorrequesttemplate.FieldBodyOverride:
  18091. m.ResetBodyOverride()
  18092. return nil
  18093. }
  18094. return fmt.Errorf("unknown ChannelMonitorRequestTemplate field %s", name)
  18095. }
  18096. // AddedEdges returns all edge names that were set/added in this mutation.
  18097. func (m *ChannelMonitorRequestTemplateMutation) AddedEdges() []string {
  18098. edges := make([]string, 0, 1)
  18099. if m.monitors != nil {
  18100. edges = append(edges, channelmonitorrequesttemplate.EdgeMonitors)
  18101. }
  18102. return edges
  18103. }
  18104. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  18105. // name in this mutation.
  18106. func (m *ChannelMonitorRequestTemplateMutation) AddedIDs(name string) []ent.Value {
  18107. switch name {
  18108. case channelmonitorrequesttemplate.EdgeMonitors:
  18109. ids := make([]ent.Value, 0, len(m.monitors))
  18110. for id := range m.monitors {
  18111. ids = append(ids, id)
  18112. }
  18113. return ids
  18114. }
  18115. return nil
  18116. }
  18117. // RemovedEdges returns all edge names that were removed in this mutation.
  18118. func (m *ChannelMonitorRequestTemplateMutation) RemovedEdges() []string {
  18119. edges := make([]string, 0, 1)
  18120. if m.removedmonitors != nil {
  18121. edges = append(edges, channelmonitorrequesttemplate.EdgeMonitors)
  18122. }
  18123. return edges
  18124. }
  18125. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  18126. // the given name in this mutation.
  18127. func (m *ChannelMonitorRequestTemplateMutation) RemovedIDs(name string) []ent.Value {
  18128. switch name {
  18129. case channelmonitorrequesttemplate.EdgeMonitors:
  18130. ids := make([]ent.Value, 0, len(m.removedmonitors))
  18131. for id := range m.removedmonitors {
  18132. ids = append(ids, id)
  18133. }
  18134. return ids
  18135. }
  18136. return nil
  18137. }
  18138. // ClearedEdges returns all edge names that were cleared in this mutation.
  18139. func (m *ChannelMonitorRequestTemplateMutation) ClearedEdges() []string {
  18140. edges := make([]string, 0, 1)
  18141. if m.clearedmonitors {
  18142. edges = append(edges, channelmonitorrequesttemplate.EdgeMonitors)
  18143. }
  18144. return edges
  18145. }
  18146. // EdgeCleared returns a boolean which indicates if the edge with the given name
  18147. // was cleared in this mutation.
  18148. func (m *ChannelMonitorRequestTemplateMutation) EdgeCleared(name string) bool {
  18149. switch name {
  18150. case channelmonitorrequesttemplate.EdgeMonitors:
  18151. return m.clearedmonitors
  18152. }
  18153. return false
  18154. }
  18155. // ClearEdge clears the value of the edge with the given name. It returns an error
  18156. // if that edge is not defined in the schema.
  18157. func (m *ChannelMonitorRequestTemplateMutation) ClearEdge(name string) error {
  18158. switch name {
  18159. }
  18160. return fmt.Errorf("unknown ChannelMonitorRequestTemplate unique edge %s", name)
  18161. }
  18162. // ResetEdge resets all changes to the edge with the given name in this mutation.
  18163. // It returns an error if the edge is not defined in the schema.
  18164. func (m *ChannelMonitorRequestTemplateMutation) ResetEdge(name string) error {
  18165. switch name {
  18166. case channelmonitorrequesttemplate.EdgeMonitors:
  18167. m.ResetMonitors()
  18168. return nil
  18169. }
  18170. return fmt.Errorf("unknown ChannelMonitorRequestTemplate edge %s", name)
  18171. }
  18172. // CompositeModelRouteMutation represents an operation that mutates the CompositeModelRoute nodes in the graph.
  18173. type CompositeModelRouteMutation struct {
  18174. config
  18175. op Op
  18176. typ string
  18177. id *int64
  18178. created_at *time.Time
  18179. updated_at *time.Time
  18180. deleted_at *time.Time
  18181. public_model *string
  18182. match_type *string
  18183. target_platform *string
  18184. upstream_model *string
  18185. endpoint *string
  18186. priority *int
  18187. addpriority *int
  18188. enabled *bool
  18189. notes *string
  18190. clearedFields map[string]struct{}
  18191. group *int64
  18192. clearedgroup bool
  18193. done bool
  18194. oldValue func(context.Context) (*CompositeModelRoute, error)
  18195. predicates []predicate.CompositeModelRoute
  18196. }
  18197. var _ ent.Mutation = (*CompositeModelRouteMutation)(nil)
  18198. // compositemodelrouteOption allows management of the mutation configuration using functional options.
  18199. type compositemodelrouteOption func(*CompositeModelRouteMutation)
  18200. // newCompositeModelRouteMutation creates new mutation for the CompositeModelRoute entity.
  18201. func newCompositeModelRouteMutation(c config, op Op, opts ...compositemodelrouteOption) *CompositeModelRouteMutation {
  18202. m := &CompositeModelRouteMutation{
  18203. config: c,
  18204. op: op,
  18205. typ: TypeCompositeModelRoute,
  18206. clearedFields: make(map[string]struct{}),
  18207. }
  18208. for _, opt := range opts {
  18209. opt(m)
  18210. }
  18211. return m
  18212. }
  18213. // withCompositeModelRouteID sets the ID field of the mutation.
  18214. func withCompositeModelRouteID(id int64) compositemodelrouteOption {
  18215. return func(m *CompositeModelRouteMutation) {
  18216. var (
  18217. err error
  18218. once sync.Once
  18219. value *CompositeModelRoute
  18220. )
  18221. m.oldValue = func(ctx context.Context) (*CompositeModelRoute, error) {
  18222. once.Do(func() {
  18223. if m.done {
  18224. err = errors.New("querying old values post mutation is not allowed")
  18225. } else {
  18226. value, err = m.Client().CompositeModelRoute.Get(ctx, id)
  18227. }
  18228. })
  18229. return value, err
  18230. }
  18231. m.id = &id
  18232. }
  18233. }
  18234. // withCompositeModelRoute sets the old CompositeModelRoute of the mutation.
  18235. func withCompositeModelRoute(node *CompositeModelRoute) compositemodelrouteOption {
  18236. return func(m *CompositeModelRouteMutation) {
  18237. m.oldValue = func(context.Context) (*CompositeModelRoute, error) {
  18238. return node, nil
  18239. }
  18240. m.id = &node.ID
  18241. }
  18242. }
  18243. // Client returns a new `ent.Client` from the mutation. If the mutation was
  18244. // executed in a transaction (ent.Tx), a transactional client is returned.
  18245. func (m CompositeModelRouteMutation) Client() *Client {
  18246. client := &Client{config: m.config}
  18247. client.init()
  18248. return client
  18249. }
  18250. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  18251. // it returns an error otherwise.
  18252. func (m CompositeModelRouteMutation) Tx() (*Tx, error) {
  18253. if _, ok := m.driver.(*txDriver); !ok {
  18254. return nil, errors.New("ent: mutation is not running in a transaction")
  18255. }
  18256. tx := &Tx{config: m.config}
  18257. tx.init()
  18258. return tx, nil
  18259. }
  18260. // ID returns the ID value in the mutation. Note that the ID is only available
  18261. // if it was provided to the builder or after it was returned from the database.
  18262. func (m *CompositeModelRouteMutation) ID() (id int64, exists bool) {
  18263. if m.id == nil {
  18264. return
  18265. }
  18266. return *m.id, true
  18267. }
  18268. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  18269. // That means, if the mutation is applied within a transaction with an isolation level such
  18270. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  18271. // or updated by the mutation.
  18272. func (m *CompositeModelRouteMutation) IDs(ctx context.Context) ([]int64, error) {
  18273. switch {
  18274. case m.op.Is(OpUpdateOne | OpDeleteOne):
  18275. id, exists := m.ID()
  18276. if exists {
  18277. return []int64{id}, nil
  18278. }
  18279. fallthrough
  18280. case m.op.Is(OpUpdate | OpDelete):
  18281. return m.Client().CompositeModelRoute.Query().Where(m.predicates...).IDs(ctx)
  18282. default:
  18283. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  18284. }
  18285. }
  18286. // SetCreatedAt sets the "created_at" field.
  18287. func (m *CompositeModelRouteMutation) SetCreatedAt(t time.Time) {
  18288. m.created_at = &t
  18289. }
  18290. // CreatedAt returns the value of the "created_at" field in the mutation.
  18291. func (m *CompositeModelRouteMutation) CreatedAt() (r time.Time, exists bool) {
  18292. v := m.created_at
  18293. if v == nil {
  18294. return
  18295. }
  18296. return *v, true
  18297. }
  18298. // OldCreatedAt returns the old "created_at" field's value of the CompositeModelRoute entity.
  18299. // If the CompositeModelRoute object wasn't provided to the builder, the object is fetched from the database.
  18300. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18301. func (m *CompositeModelRouteMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  18302. if !m.op.Is(OpUpdateOne) {
  18303. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  18304. }
  18305. if m.id == nil || m.oldValue == nil {
  18306. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  18307. }
  18308. oldValue, err := m.oldValue(ctx)
  18309. if err != nil {
  18310. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  18311. }
  18312. return oldValue.CreatedAt, nil
  18313. }
  18314. // ResetCreatedAt resets all changes to the "created_at" field.
  18315. func (m *CompositeModelRouteMutation) ResetCreatedAt() {
  18316. m.created_at = nil
  18317. }
  18318. // SetUpdatedAt sets the "updated_at" field.
  18319. func (m *CompositeModelRouteMutation) SetUpdatedAt(t time.Time) {
  18320. m.updated_at = &t
  18321. }
  18322. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  18323. func (m *CompositeModelRouteMutation) UpdatedAt() (r time.Time, exists bool) {
  18324. v := m.updated_at
  18325. if v == nil {
  18326. return
  18327. }
  18328. return *v, true
  18329. }
  18330. // OldUpdatedAt returns the old "updated_at" field's value of the CompositeModelRoute entity.
  18331. // If the CompositeModelRoute object wasn't provided to the builder, the object is fetched from the database.
  18332. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18333. func (m *CompositeModelRouteMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  18334. if !m.op.Is(OpUpdateOne) {
  18335. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  18336. }
  18337. if m.id == nil || m.oldValue == nil {
  18338. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  18339. }
  18340. oldValue, err := m.oldValue(ctx)
  18341. if err != nil {
  18342. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  18343. }
  18344. return oldValue.UpdatedAt, nil
  18345. }
  18346. // ResetUpdatedAt resets all changes to the "updated_at" field.
  18347. func (m *CompositeModelRouteMutation) ResetUpdatedAt() {
  18348. m.updated_at = nil
  18349. }
  18350. // SetDeletedAt sets the "deleted_at" field.
  18351. func (m *CompositeModelRouteMutation) SetDeletedAt(t time.Time) {
  18352. m.deleted_at = &t
  18353. }
  18354. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  18355. func (m *CompositeModelRouteMutation) DeletedAt() (r time.Time, exists bool) {
  18356. v := m.deleted_at
  18357. if v == nil {
  18358. return
  18359. }
  18360. return *v, true
  18361. }
  18362. // OldDeletedAt returns the old "deleted_at" field's value of the CompositeModelRoute entity.
  18363. // If the CompositeModelRoute object wasn't provided to the builder, the object is fetched from the database.
  18364. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18365. func (m *CompositeModelRouteMutation) OldDeletedAt(ctx context.Context) (v *time.Time, err error) {
  18366. if !m.op.Is(OpUpdateOne) {
  18367. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  18368. }
  18369. if m.id == nil || m.oldValue == nil {
  18370. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  18371. }
  18372. oldValue, err := m.oldValue(ctx)
  18373. if err != nil {
  18374. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  18375. }
  18376. return oldValue.DeletedAt, nil
  18377. }
  18378. // ClearDeletedAt clears the value of the "deleted_at" field.
  18379. func (m *CompositeModelRouteMutation) ClearDeletedAt() {
  18380. m.deleted_at = nil
  18381. m.clearedFields[compositemodelroute.FieldDeletedAt] = struct{}{}
  18382. }
  18383. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  18384. func (m *CompositeModelRouteMutation) DeletedAtCleared() bool {
  18385. _, ok := m.clearedFields[compositemodelroute.FieldDeletedAt]
  18386. return ok
  18387. }
  18388. // ResetDeletedAt resets all changes to the "deleted_at" field.
  18389. func (m *CompositeModelRouteMutation) ResetDeletedAt() {
  18390. m.deleted_at = nil
  18391. delete(m.clearedFields, compositemodelroute.FieldDeletedAt)
  18392. }
  18393. // SetGroupID sets the "group_id" field.
  18394. func (m *CompositeModelRouteMutation) SetGroupID(i int64) {
  18395. m.group = &i
  18396. }
  18397. // GroupID returns the value of the "group_id" field in the mutation.
  18398. func (m *CompositeModelRouteMutation) GroupID() (r int64, exists bool) {
  18399. v := m.group
  18400. if v == nil {
  18401. return
  18402. }
  18403. return *v, true
  18404. }
  18405. // OldGroupID returns the old "group_id" field's value of the CompositeModelRoute entity.
  18406. // If the CompositeModelRoute object wasn't provided to the builder, the object is fetched from the database.
  18407. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18408. func (m *CompositeModelRouteMutation) OldGroupID(ctx context.Context) (v int64, err error) {
  18409. if !m.op.Is(OpUpdateOne) {
  18410. return v, errors.New("OldGroupID is only allowed on UpdateOne operations")
  18411. }
  18412. if m.id == nil || m.oldValue == nil {
  18413. return v, errors.New("OldGroupID requires an ID field in the mutation")
  18414. }
  18415. oldValue, err := m.oldValue(ctx)
  18416. if err != nil {
  18417. return v, fmt.Errorf("querying old value for OldGroupID: %w", err)
  18418. }
  18419. return oldValue.GroupID, nil
  18420. }
  18421. // ResetGroupID resets all changes to the "group_id" field.
  18422. func (m *CompositeModelRouteMutation) ResetGroupID() {
  18423. m.group = nil
  18424. }
  18425. // SetPublicModel sets the "public_model" field.
  18426. func (m *CompositeModelRouteMutation) SetPublicModel(s string) {
  18427. m.public_model = &s
  18428. }
  18429. // PublicModel returns the value of the "public_model" field in the mutation.
  18430. func (m *CompositeModelRouteMutation) PublicModel() (r string, exists bool) {
  18431. v := m.public_model
  18432. if v == nil {
  18433. return
  18434. }
  18435. return *v, true
  18436. }
  18437. // OldPublicModel returns the old "public_model" field's value of the CompositeModelRoute entity.
  18438. // If the CompositeModelRoute object wasn't provided to the builder, the object is fetched from the database.
  18439. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18440. func (m *CompositeModelRouteMutation) OldPublicModel(ctx context.Context) (v string, err error) {
  18441. if !m.op.Is(OpUpdateOne) {
  18442. return v, errors.New("OldPublicModel is only allowed on UpdateOne operations")
  18443. }
  18444. if m.id == nil || m.oldValue == nil {
  18445. return v, errors.New("OldPublicModel requires an ID field in the mutation")
  18446. }
  18447. oldValue, err := m.oldValue(ctx)
  18448. if err != nil {
  18449. return v, fmt.Errorf("querying old value for OldPublicModel: %w", err)
  18450. }
  18451. return oldValue.PublicModel, nil
  18452. }
  18453. // ResetPublicModel resets all changes to the "public_model" field.
  18454. func (m *CompositeModelRouteMutation) ResetPublicModel() {
  18455. m.public_model = nil
  18456. }
  18457. // SetMatchType sets the "match_type" field.
  18458. func (m *CompositeModelRouteMutation) SetMatchType(s string) {
  18459. m.match_type = &s
  18460. }
  18461. // MatchType returns the value of the "match_type" field in the mutation.
  18462. func (m *CompositeModelRouteMutation) MatchType() (r string, exists bool) {
  18463. v := m.match_type
  18464. if v == nil {
  18465. return
  18466. }
  18467. return *v, true
  18468. }
  18469. // OldMatchType returns the old "match_type" field's value of the CompositeModelRoute entity.
  18470. // If the CompositeModelRoute object wasn't provided to the builder, the object is fetched from the database.
  18471. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18472. func (m *CompositeModelRouteMutation) OldMatchType(ctx context.Context) (v string, err error) {
  18473. if !m.op.Is(OpUpdateOne) {
  18474. return v, errors.New("OldMatchType is only allowed on UpdateOne operations")
  18475. }
  18476. if m.id == nil || m.oldValue == nil {
  18477. return v, errors.New("OldMatchType requires an ID field in the mutation")
  18478. }
  18479. oldValue, err := m.oldValue(ctx)
  18480. if err != nil {
  18481. return v, fmt.Errorf("querying old value for OldMatchType: %w", err)
  18482. }
  18483. return oldValue.MatchType, nil
  18484. }
  18485. // ResetMatchType resets all changes to the "match_type" field.
  18486. func (m *CompositeModelRouteMutation) ResetMatchType() {
  18487. m.match_type = nil
  18488. }
  18489. // SetTargetPlatform sets the "target_platform" field.
  18490. func (m *CompositeModelRouteMutation) SetTargetPlatform(s string) {
  18491. m.target_platform = &s
  18492. }
  18493. // TargetPlatform returns the value of the "target_platform" field in the mutation.
  18494. func (m *CompositeModelRouteMutation) TargetPlatform() (r string, exists bool) {
  18495. v := m.target_platform
  18496. if v == nil {
  18497. return
  18498. }
  18499. return *v, true
  18500. }
  18501. // OldTargetPlatform returns the old "target_platform" field's value of the CompositeModelRoute entity.
  18502. // If the CompositeModelRoute object wasn't provided to the builder, the object is fetched from the database.
  18503. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18504. func (m *CompositeModelRouteMutation) OldTargetPlatform(ctx context.Context) (v string, err error) {
  18505. if !m.op.Is(OpUpdateOne) {
  18506. return v, errors.New("OldTargetPlatform is only allowed on UpdateOne operations")
  18507. }
  18508. if m.id == nil || m.oldValue == nil {
  18509. return v, errors.New("OldTargetPlatform requires an ID field in the mutation")
  18510. }
  18511. oldValue, err := m.oldValue(ctx)
  18512. if err != nil {
  18513. return v, fmt.Errorf("querying old value for OldTargetPlatform: %w", err)
  18514. }
  18515. return oldValue.TargetPlatform, nil
  18516. }
  18517. // ResetTargetPlatform resets all changes to the "target_platform" field.
  18518. func (m *CompositeModelRouteMutation) ResetTargetPlatform() {
  18519. m.target_platform = nil
  18520. }
  18521. // SetUpstreamModel sets the "upstream_model" field.
  18522. func (m *CompositeModelRouteMutation) SetUpstreamModel(s string) {
  18523. m.upstream_model = &s
  18524. }
  18525. // UpstreamModel returns the value of the "upstream_model" field in the mutation.
  18526. func (m *CompositeModelRouteMutation) UpstreamModel() (r string, exists bool) {
  18527. v := m.upstream_model
  18528. if v == nil {
  18529. return
  18530. }
  18531. return *v, true
  18532. }
  18533. // OldUpstreamModel returns the old "upstream_model" field's value of the CompositeModelRoute entity.
  18534. // If the CompositeModelRoute object wasn't provided to the builder, the object is fetched from the database.
  18535. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18536. func (m *CompositeModelRouteMutation) OldUpstreamModel(ctx context.Context) (v string, err error) {
  18537. if !m.op.Is(OpUpdateOne) {
  18538. return v, errors.New("OldUpstreamModel is only allowed on UpdateOne operations")
  18539. }
  18540. if m.id == nil || m.oldValue == nil {
  18541. return v, errors.New("OldUpstreamModel requires an ID field in the mutation")
  18542. }
  18543. oldValue, err := m.oldValue(ctx)
  18544. if err != nil {
  18545. return v, fmt.Errorf("querying old value for OldUpstreamModel: %w", err)
  18546. }
  18547. return oldValue.UpstreamModel, nil
  18548. }
  18549. // ResetUpstreamModel resets all changes to the "upstream_model" field.
  18550. func (m *CompositeModelRouteMutation) ResetUpstreamModel() {
  18551. m.upstream_model = nil
  18552. }
  18553. // SetEndpoint sets the "endpoint" field.
  18554. func (m *CompositeModelRouteMutation) SetEndpoint(s string) {
  18555. m.endpoint = &s
  18556. }
  18557. // Endpoint returns the value of the "endpoint" field in the mutation.
  18558. func (m *CompositeModelRouteMutation) Endpoint() (r string, exists bool) {
  18559. v := m.endpoint
  18560. if v == nil {
  18561. return
  18562. }
  18563. return *v, true
  18564. }
  18565. // OldEndpoint returns the old "endpoint" field's value of the CompositeModelRoute entity.
  18566. // If the CompositeModelRoute object wasn't provided to the builder, the object is fetched from the database.
  18567. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18568. func (m *CompositeModelRouteMutation) OldEndpoint(ctx context.Context) (v string, err error) {
  18569. if !m.op.Is(OpUpdateOne) {
  18570. return v, errors.New("OldEndpoint is only allowed on UpdateOne operations")
  18571. }
  18572. if m.id == nil || m.oldValue == nil {
  18573. return v, errors.New("OldEndpoint requires an ID field in the mutation")
  18574. }
  18575. oldValue, err := m.oldValue(ctx)
  18576. if err != nil {
  18577. return v, fmt.Errorf("querying old value for OldEndpoint: %w", err)
  18578. }
  18579. return oldValue.Endpoint, nil
  18580. }
  18581. // ResetEndpoint resets all changes to the "endpoint" field.
  18582. func (m *CompositeModelRouteMutation) ResetEndpoint() {
  18583. m.endpoint = nil
  18584. }
  18585. // SetPriority sets the "priority" field.
  18586. func (m *CompositeModelRouteMutation) SetPriority(i int) {
  18587. m.priority = &i
  18588. m.addpriority = nil
  18589. }
  18590. // Priority returns the value of the "priority" field in the mutation.
  18591. func (m *CompositeModelRouteMutation) Priority() (r int, exists bool) {
  18592. v := m.priority
  18593. if v == nil {
  18594. return
  18595. }
  18596. return *v, true
  18597. }
  18598. // OldPriority returns the old "priority" field's value of the CompositeModelRoute entity.
  18599. // If the CompositeModelRoute object wasn't provided to the builder, the object is fetched from the database.
  18600. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18601. func (m *CompositeModelRouteMutation) OldPriority(ctx context.Context) (v int, err error) {
  18602. if !m.op.Is(OpUpdateOne) {
  18603. return v, errors.New("OldPriority is only allowed on UpdateOne operations")
  18604. }
  18605. if m.id == nil || m.oldValue == nil {
  18606. return v, errors.New("OldPriority requires an ID field in the mutation")
  18607. }
  18608. oldValue, err := m.oldValue(ctx)
  18609. if err != nil {
  18610. return v, fmt.Errorf("querying old value for OldPriority: %w", err)
  18611. }
  18612. return oldValue.Priority, nil
  18613. }
  18614. // AddPriority adds i to the "priority" field.
  18615. func (m *CompositeModelRouteMutation) AddPriority(i int) {
  18616. if m.addpriority != nil {
  18617. *m.addpriority += i
  18618. } else {
  18619. m.addpriority = &i
  18620. }
  18621. }
  18622. // AddedPriority returns the value that was added to the "priority" field in this mutation.
  18623. func (m *CompositeModelRouteMutation) AddedPriority() (r int, exists bool) {
  18624. v := m.addpriority
  18625. if v == nil {
  18626. return
  18627. }
  18628. return *v, true
  18629. }
  18630. // ResetPriority resets all changes to the "priority" field.
  18631. func (m *CompositeModelRouteMutation) ResetPriority() {
  18632. m.priority = nil
  18633. m.addpriority = nil
  18634. }
  18635. // SetEnabled sets the "enabled" field.
  18636. func (m *CompositeModelRouteMutation) SetEnabled(b bool) {
  18637. m.enabled = &b
  18638. }
  18639. // Enabled returns the value of the "enabled" field in the mutation.
  18640. func (m *CompositeModelRouteMutation) Enabled() (r bool, exists bool) {
  18641. v := m.enabled
  18642. if v == nil {
  18643. return
  18644. }
  18645. return *v, true
  18646. }
  18647. // OldEnabled returns the old "enabled" field's value of the CompositeModelRoute entity.
  18648. // If the CompositeModelRoute object wasn't provided to the builder, the object is fetched from the database.
  18649. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18650. func (m *CompositeModelRouteMutation) OldEnabled(ctx context.Context) (v bool, err error) {
  18651. if !m.op.Is(OpUpdateOne) {
  18652. return v, errors.New("OldEnabled is only allowed on UpdateOne operations")
  18653. }
  18654. if m.id == nil || m.oldValue == nil {
  18655. return v, errors.New("OldEnabled requires an ID field in the mutation")
  18656. }
  18657. oldValue, err := m.oldValue(ctx)
  18658. if err != nil {
  18659. return v, fmt.Errorf("querying old value for OldEnabled: %w", err)
  18660. }
  18661. return oldValue.Enabled, nil
  18662. }
  18663. // ResetEnabled resets all changes to the "enabled" field.
  18664. func (m *CompositeModelRouteMutation) ResetEnabled() {
  18665. m.enabled = nil
  18666. }
  18667. // SetNotes sets the "notes" field.
  18668. func (m *CompositeModelRouteMutation) SetNotes(s string) {
  18669. m.notes = &s
  18670. }
  18671. // Notes returns the value of the "notes" field in the mutation.
  18672. func (m *CompositeModelRouteMutation) Notes() (r string, exists bool) {
  18673. v := m.notes
  18674. if v == nil {
  18675. return
  18676. }
  18677. return *v, true
  18678. }
  18679. // OldNotes returns the old "notes" field's value of the CompositeModelRoute entity.
  18680. // If the CompositeModelRoute object wasn't provided to the builder, the object is fetched from the database.
  18681. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18682. func (m *CompositeModelRouteMutation) OldNotes(ctx context.Context) (v *string, err error) {
  18683. if !m.op.Is(OpUpdateOne) {
  18684. return v, errors.New("OldNotes is only allowed on UpdateOne operations")
  18685. }
  18686. if m.id == nil || m.oldValue == nil {
  18687. return v, errors.New("OldNotes requires an ID field in the mutation")
  18688. }
  18689. oldValue, err := m.oldValue(ctx)
  18690. if err != nil {
  18691. return v, fmt.Errorf("querying old value for OldNotes: %w", err)
  18692. }
  18693. return oldValue.Notes, nil
  18694. }
  18695. // ClearNotes clears the value of the "notes" field.
  18696. func (m *CompositeModelRouteMutation) ClearNotes() {
  18697. m.notes = nil
  18698. m.clearedFields[compositemodelroute.FieldNotes] = struct{}{}
  18699. }
  18700. // NotesCleared returns if the "notes" field was cleared in this mutation.
  18701. func (m *CompositeModelRouteMutation) NotesCleared() bool {
  18702. _, ok := m.clearedFields[compositemodelroute.FieldNotes]
  18703. return ok
  18704. }
  18705. // ResetNotes resets all changes to the "notes" field.
  18706. func (m *CompositeModelRouteMutation) ResetNotes() {
  18707. m.notes = nil
  18708. delete(m.clearedFields, compositemodelroute.FieldNotes)
  18709. }
  18710. // ClearGroup clears the "group" edge to the Group entity.
  18711. func (m *CompositeModelRouteMutation) ClearGroup() {
  18712. m.clearedgroup = true
  18713. m.clearedFields[compositemodelroute.FieldGroupID] = struct{}{}
  18714. }
  18715. // GroupCleared reports if the "group" edge to the Group entity was cleared.
  18716. func (m *CompositeModelRouteMutation) GroupCleared() bool {
  18717. return m.clearedgroup
  18718. }
  18719. // GroupIDs returns the "group" edge IDs in the mutation.
  18720. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  18721. // GroupID instead. It exists only for internal usage by the builders.
  18722. func (m *CompositeModelRouteMutation) GroupIDs() (ids []int64) {
  18723. if id := m.group; id != nil {
  18724. ids = append(ids, *id)
  18725. }
  18726. return
  18727. }
  18728. // ResetGroup resets all changes to the "group" edge.
  18729. func (m *CompositeModelRouteMutation) ResetGroup() {
  18730. m.group = nil
  18731. m.clearedgroup = false
  18732. }
  18733. // Where appends a list predicates to the CompositeModelRouteMutation builder.
  18734. func (m *CompositeModelRouteMutation) Where(ps ...predicate.CompositeModelRoute) {
  18735. m.predicates = append(m.predicates, ps...)
  18736. }
  18737. // WhereP appends storage-level predicates to the CompositeModelRouteMutation builder. Using this method,
  18738. // users can use type-assertion to append predicates that do not depend on any generated package.
  18739. func (m *CompositeModelRouteMutation) WhereP(ps ...func(*sql.Selector)) {
  18740. p := make([]predicate.CompositeModelRoute, len(ps))
  18741. for i := range ps {
  18742. p[i] = ps[i]
  18743. }
  18744. m.Where(p...)
  18745. }
  18746. // Op returns the operation name.
  18747. func (m *CompositeModelRouteMutation) Op() Op {
  18748. return m.op
  18749. }
  18750. // SetOp allows setting the mutation operation.
  18751. func (m *CompositeModelRouteMutation) SetOp(op Op) {
  18752. m.op = op
  18753. }
  18754. // Type returns the node type of this mutation (CompositeModelRoute).
  18755. func (m *CompositeModelRouteMutation) Type() string {
  18756. return m.typ
  18757. }
  18758. // Fields returns all fields that were changed during this mutation. Note that in
  18759. // order to get all numeric fields that were incremented/decremented, call
  18760. // AddedFields().
  18761. func (m *CompositeModelRouteMutation) Fields() []string {
  18762. fields := make([]string, 0, 12)
  18763. if m.created_at != nil {
  18764. fields = append(fields, compositemodelroute.FieldCreatedAt)
  18765. }
  18766. if m.updated_at != nil {
  18767. fields = append(fields, compositemodelroute.FieldUpdatedAt)
  18768. }
  18769. if m.deleted_at != nil {
  18770. fields = append(fields, compositemodelroute.FieldDeletedAt)
  18771. }
  18772. if m.group != nil {
  18773. fields = append(fields, compositemodelroute.FieldGroupID)
  18774. }
  18775. if m.public_model != nil {
  18776. fields = append(fields, compositemodelroute.FieldPublicModel)
  18777. }
  18778. if m.match_type != nil {
  18779. fields = append(fields, compositemodelroute.FieldMatchType)
  18780. }
  18781. if m.target_platform != nil {
  18782. fields = append(fields, compositemodelroute.FieldTargetPlatform)
  18783. }
  18784. if m.upstream_model != nil {
  18785. fields = append(fields, compositemodelroute.FieldUpstreamModel)
  18786. }
  18787. if m.endpoint != nil {
  18788. fields = append(fields, compositemodelroute.FieldEndpoint)
  18789. }
  18790. if m.priority != nil {
  18791. fields = append(fields, compositemodelroute.FieldPriority)
  18792. }
  18793. if m.enabled != nil {
  18794. fields = append(fields, compositemodelroute.FieldEnabled)
  18795. }
  18796. if m.notes != nil {
  18797. fields = append(fields, compositemodelroute.FieldNotes)
  18798. }
  18799. return fields
  18800. }
  18801. // Field returns the value of a field with the given name. The second boolean
  18802. // return value indicates that this field was not set, or was not defined in the
  18803. // schema.
  18804. func (m *CompositeModelRouteMutation) Field(name string) (ent.Value, bool) {
  18805. switch name {
  18806. case compositemodelroute.FieldCreatedAt:
  18807. return m.CreatedAt()
  18808. case compositemodelroute.FieldUpdatedAt:
  18809. return m.UpdatedAt()
  18810. case compositemodelroute.FieldDeletedAt:
  18811. return m.DeletedAt()
  18812. case compositemodelroute.FieldGroupID:
  18813. return m.GroupID()
  18814. case compositemodelroute.FieldPublicModel:
  18815. return m.PublicModel()
  18816. case compositemodelroute.FieldMatchType:
  18817. return m.MatchType()
  18818. case compositemodelroute.FieldTargetPlatform:
  18819. return m.TargetPlatform()
  18820. case compositemodelroute.FieldUpstreamModel:
  18821. return m.UpstreamModel()
  18822. case compositemodelroute.FieldEndpoint:
  18823. return m.Endpoint()
  18824. case compositemodelroute.FieldPriority:
  18825. return m.Priority()
  18826. case compositemodelroute.FieldEnabled:
  18827. return m.Enabled()
  18828. case compositemodelroute.FieldNotes:
  18829. return m.Notes()
  18830. }
  18831. return nil, false
  18832. }
  18833. // OldField returns the old value of the field from the database. An error is
  18834. // returned if the mutation operation is not UpdateOne, or the query to the
  18835. // database failed.
  18836. func (m *CompositeModelRouteMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  18837. switch name {
  18838. case compositemodelroute.FieldCreatedAt:
  18839. return m.OldCreatedAt(ctx)
  18840. case compositemodelroute.FieldUpdatedAt:
  18841. return m.OldUpdatedAt(ctx)
  18842. case compositemodelroute.FieldDeletedAt:
  18843. return m.OldDeletedAt(ctx)
  18844. case compositemodelroute.FieldGroupID:
  18845. return m.OldGroupID(ctx)
  18846. case compositemodelroute.FieldPublicModel:
  18847. return m.OldPublicModel(ctx)
  18848. case compositemodelroute.FieldMatchType:
  18849. return m.OldMatchType(ctx)
  18850. case compositemodelroute.FieldTargetPlatform:
  18851. return m.OldTargetPlatform(ctx)
  18852. case compositemodelroute.FieldUpstreamModel:
  18853. return m.OldUpstreamModel(ctx)
  18854. case compositemodelroute.FieldEndpoint:
  18855. return m.OldEndpoint(ctx)
  18856. case compositemodelroute.FieldPriority:
  18857. return m.OldPriority(ctx)
  18858. case compositemodelroute.FieldEnabled:
  18859. return m.OldEnabled(ctx)
  18860. case compositemodelroute.FieldNotes:
  18861. return m.OldNotes(ctx)
  18862. }
  18863. return nil, fmt.Errorf("unknown CompositeModelRoute field %s", name)
  18864. }
  18865. // SetField sets the value of a field with the given name. It returns an error if
  18866. // the field is not defined in the schema, or if the type mismatched the field
  18867. // type.
  18868. func (m *CompositeModelRouteMutation) SetField(name string, value ent.Value) error {
  18869. switch name {
  18870. case compositemodelroute.FieldCreatedAt:
  18871. v, ok := value.(time.Time)
  18872. if !ok {
  18873. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18874. }
  18875. m.SetCreatedAt(v)
  18876. return nil
  18877. case compositemodelroute.FieldUpdatedAt:
  18878. v, ok := value.(time.Time)
  18879. if !ok {
  18880. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18881. }
  18882. m.SetUpdatedAt(v)
  18883. return nil
  18884. case compositemodelroute.FieldDeletedAt:
  18885. v, ok := value.(time.Time)
  18886. if !ok {
  18887. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18888. }
  18889. m.SetDeletedAt(v)
  18890. return nil
  18891. case compositemodelroute.FieldGroupID:
  18892. v, ok := value.(int64)
  18893. if !ok {
  18894. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18895. }
  18896. m.SetGroupID(v)
  18897. return nil
  18898. case compositemodelroute.FieldPublicModel:
  18899. v, ok := value.(string)
  18900. if !ok {
  18901. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18902. }
  18903. m.SetPublicModel(v)
  18904. return nil
  18905. case compositemodelroute.FieldMatchType:
  18906. v, ok := value.(string)
  18907. if !ok {
  18908. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18909. }
  18910. m.SetMatchType(v)
  18911. return nil
  18912. case compositemodelroute.FieldTargetPlatform:
  18913. v, ok := value.(string)
  18914. if !ok {
  18915. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18916. }
  18917. m.SetTargetPlatform(v)
  18918. return nil
  18919. case compositemodelroute.FieldUpstreamModel:
  18920. v, ok := value.(string)
  18921. if !ok {
  18922. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18923. }
  18924. m.SetUpstreamModel(v)
  18925. return nil
  18926. case compositemodelroute.FieldEndpoint:
  18927. v, ok := value.(string)
  18928. if !ok {
  18929. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18930. }
  18931. m.SetEndpoint(v)
  18932. return nil
  18933. case compositemodelroute.FieldPriority:
  18934. v, ok := value.(int)
  18935. if !ok {
  18936. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18937. }
  18938. m.SetPriority(v)
  18939. return nil
  18940. case compositemodelroute.FieldEnabled:
  18941. v, ok := value.(bool)
  18942. if !ok {
  18943. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18944. }
  18945. m.SetEnabled(v)
  18946. return nil
  18947. case compositemodelroute.FieldNotes:
  18948. v, ok := value.(string)
  18949. if !ok {
  18950. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18951. }
  18952. m.SetNotes(v)
  18953. return nil
  18954. }
  18955. return fmt.Errorf("unknown CompositeModelRoute field %s", name)
  18956. }
  18957. // AddedFields returns all numeric fields that were incremented/decremented during
  18958. // this mutation.
  18959. func (m *CompositeModelRouteMutation) AddedFields() []string {
  18960. var fields []string
  18961. if m.addpriority != nil {
  18962. fields = append(fields, compositemodelroute.FieldPriority)
  18963. }
  18964. return fields
  18965. }
  18966. // AddedField returns the numeric value that was incremented/decremented on a field
  18967. // with the given name. The second boolean return value indicates that this field
  18968. // was not set, or was not defined in the schema.
  18969. func (m *CompositeModelRouteMutation) AddedField(name string) (ent.Value, bool) {
  18970. switch name {
  18971. case compositemodelroute.FieldPriority:
  18972. return m.AddedPriority()
  18973. }
  18974. return nil, false
  18975. }
  18976. // AddField adds the value to the field with the given name. It returns an error if
  18977. // the field is not defined in the schema, or if the type mismatched the field
  18978. // type.
  18979. func (m *CompositeModelRouteMutation) AddField(name string, value ent.Value) error {
  18980. switch name {
  18981. case compositemodelroute.FieldPriority:
  18982. v, ok := value.(int)
  18983. if !ok {
  18984. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18985. }
  18986. m.AddPriority(v)
  18987. return nil
  18988. }
  18989. return fmt.Errorf("unknown CompositeModelRoute numeric field %s", name)
  18990. }
  18991. // ClearedFields returns all nullable fields that were cleared during this
  18992. // mutation.
  18993. func (m *CompositeModelRouteMutation) ClearedFields() []string {
  18994. var fields []string
  18995. if m.FieldCleared(compositemodelroute.FieldDeletedAt) {
  18996. fields = append(fields, compositemodelroute.FieldDeletedAt)
  18997. }
  18998. if m.FieldCleared(compositemodelroute.FieldNotes) {
  18999. fields = append(fields, compositemodelroute.FieldNotes)
  19000. }
  19001. return fields
  19002. }
  19003. // FieldCleared returns a boolean indicating if a field with the given name was
  19004. // cleared in this mutation.
  19005. func (m *CompositeModelRouteMutation) FieldCleared(name string) bool {
  19006. _, ok := m.clearedFields[name]
  19007. return ok
  19008. }
  19009. // ClearField clears the value of the field with the given name. It returns an
  19010. // error if the field is not defined in the schema.
  19011. func (m *CompositeModelRouteMutation) ClearField(name string) error {
  19012. switch name {
  19013. case compositemodelroute.FieldDeletedAt:
  19014. m.ClearDeletedAt()
  19015. return nil
  19016. case compositemodelroute.FieldNotes:
  19017. m.ClearNotes()
  19018. return nil
  19019. }
  19020. return fmt.Errorf("unknown CompositeModelRoute nullable field %s", name)
  19021. }
  19022. // ResetField resets all changes in the mutation for the field with the given name.
  19023. // It returns an error if the field is not defined in the schema.
  19024. func (m *CompositeModelRouteMutation) ResetField(name string) error {
  19025. switch name {
  19026. case compositemodelroute.FieldCreatedAt:
  19027. m.ResetCreatedAt()
  19028. return nil
  19029. case compositemodelroute.FieldUpdatedAt:
  19030. m.ResetUpdatedAt()
  19031. return nil
  19032. case compositemodelroute.FieldDeletedAt:
  19033. m.ResetDeletedAt()
  19034. return nil
  19035. case compositemodelroute.FieldGroupID:
  19036. m.ResetGroupID()
  19037. return nil
  19038. case compositemodelroute.FieldPublicModel:
  19039. m.ResetPublicModel()
  19040. return nil
  19041. case compositemodelroute.FieldMatchType:
  19042. m.ResetMatchType()
  19043. return nil
  19044. case compositemodelroute.FieldTargetPlatform:
  19045. m.ResetTargetPlatform()
  19046. return nil
  19047. case compositemodelroute.FieldUpstreamModel:
  19048. m.ResetUpstreamModel()
  19049. return nil
  19050. case compositemodelroute.FieldEndpoint:
  19051. m.ResetEndpoint()
  19052. return nil
  19053. case compositemodelroute.FieldPriority:
  19054. m.ResetPriority()
  19055. return nil
  19056. case compositemodelroute.FieldEnabled:
  19057. m.ResetEnabled()
  19058. return nil
  19059. case compositemodelroute.FieldNotes:
  19060. m.ResetNotes()
  19061. return nil
  19062. }
  19063. return fmt.Errorf("unknown CompositeModelRoute field %s", name)
  19064. }
  19065. // AddedEdges returns all edge names that were set/added in this mutation.
  19066. func (m *CompositeModelRouteMutation) AddedEdges() []string {
  19067. edges := make([]string, 0, 1)
  19068. if m.group != nil {
  19069. edges = append(edges, compositemodelroute.EdgeGroup)
  19070. }
  19071. return edges
  19072. }
  19073. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  19074. // name in this mutation.
  19075. func (m *CompositeModelRouteMutation) AddedIDs(name string) []ent.Value {
  19076. switch name {
  19077. case compositemodelroute.EdgeGroup:
  19078. if id := m.group; id != nil {
  19079. return []ent.Value{*id}
  19080. }
  19081. }
  19082. return nil
  19083. }
  19084. // RemovedEdges returns all edge names that were removed in this mutation.
  19085. func (m *CompositeModelRouteMutation) RemovedEdges() []string {
  19086. edges := make([]string, 0, 1)
  19087. return edges
  19088. }
  19089. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  19090. // the given name in this mutation.
  19091. func (m *CompositeModelRouteMutation) RemovedIDs(name string) []ent.Value {
  19092. return nil
  19093. }
  19094. // ClearedEdges returns all edge names that were cleared in this mutation.
  19095. func (m *CompositeModelRouteMutation) ClearedEdges() []string {
  19096. edges := make([]string, 0, 1)
  19097. if m.clearedgroup {
  19098. edges = append(edges, compositemodelroute.EdgeGroup)
  19099. }
  19100. return edges
  19101. }
  19102. // EdgeCleared returns a boolean which indicates if the edge with the given name
  19103. // was cleared in this mutation.
  19104. func (m *CompositeModelRouteMutation) EdgeCleared(name string) bool {
  19105. switch name {
  19106. case compositemodelroute.EdgeGroup:
  19107. return m.clearedgroup
  19108. }
  19109. return false
  19110. }
  19111. // ClearEdge clears the value of the edge with the given name. It returns an error
  19112. // if that edge is not defined in the schema.
  19113. func (m *CompositeModelRouteMutation) ClearEdge(name string) error {
  19114. switch name {
  19115. case compositemodelroute.EdgeGroup:
  19116. m.ClearGroup()
  19117. return nil
  19118. }
  19119. return fmt.Errorf("unknown CompositeModelRoute unique edge %s", name)
  19120. }
  19121. // ResetEdge resets all changes to the edge with the given name in this mutation.
  19122. // It returns an error if the edge is not defined in the schema.
  19123. func (m *CompositeModelRouteMutation) ResetEdge(name string) error {
  19124. switch name {
  19125. case compositemodelroute.EdgeGroup:
  19126. m.ResetGroup()
  19127. return nil
  19128. }
  19129. return fmt.Errorf("unknown CompositeModelRoute edge %s", name)
  19130. }
  19131. // ErrorPassthroughRuleMutation represents an operation that mutates the ErrorPassthroughRule nodes in the graph.
  19132. type ErrorPassthroughRuleMutation struct {
  19133. config
  19134. op Op
  19135. typ string
  19136. id *int64
  19137. created_at *time.Time
  19138. updated_at *time.Time
  19139. name *string
  19140. enabled *bool
  19141. priority *int
  19142. addpriority *int
  19143. error_codes *[]int
  19144. appenderror_codes []int
  19145. keywords *[]string
  19146. appendkeywords []string
  19147. match_mode *string
  19148. platforms *[]string
  19149. appendplatforms []string
  19150. passthrough_code *bool
  19151. response_code *int
  19152. addresponse_code *int
  19153. passthrough_body *bool
  19154. custom_message *string
  19155. skip_monitoring *bool
  19156. description *string
  19157. clearedFields map[string]struct{}
  19158. done bool
  19159. oldValue func(context.Context) (*ErrorPassthroughRule, error)
  19160. predicates []predicate.ErrorPassthroughRule
  19161. }
  19162. var _ ent.Mutation = (*ErrorPassthroughRuleMutation)(nil)
  19163. // errorpassthroughruleOption allows management of the mutation configuration using functional options.
  19164. type errorpassthroughruleOption func(*ErrorPassthroughRuleMutation)
  19165. // newErrorPassthroughRuleMutation creates new mutation for the ErrorPassthroughRule entity.
  19166. func newErrorPassthroughRuleMutation(c config, op Op, opts ...errorpassthroughruleOption) *ErrorPassthroughRuleMutation {
  19167. m := &ErrorPassthroughRuleMutation{
  19168. config: c,
  19169. op: op,
  19170. typ: TypeErrorPassthroughRule,
  19171. clearedFields: make(map[string]struct{}),
  19172. }
  19173. for _, opt := range opts {
  19174. opt(m)
  19175. }
  19176. return m
  19177. }
  19178. // withErrorPassthroughRuleID sets the ID field of the mutation.
  19179. func withErrorPassthroughRuleID(id int64) errorpassthroughruleOption {
  19180. return func(m *ErrorPassthroughRuleMutation) {
  19181. var (
  19182. err error
  19183. once sync.Once
  19184. value *ErrorPassthroughRule
  19185. )
  19186. m.oldValue = func(ctx context.Context) (*ErrorPassthroughRule, error) {
  19187. once.Do(func() {
  19188. if m.done {
  19189. err = errors.New("querying old values post mutation is not allowed")
  19190. } else {
  19191. value, err = m.Client().ErrorPassthroughRule.Get(ctx, id)
  19192. }
  19193. })
  19194. return value, err
  19195. }
  19196. m.id = &id
  19197. }
  19198. }
  19199. // withErrorPassthroughRule sets the old ErrorPassthroughRule of the mutation.
  19200. func withErrorPassthroughRule(node *ErrorPassthroughRule) errorpassthroughruleOption {
  19201. return func(m *ErrorPassthroughRuleMutation) {
  19202. m.oldValue = func(context.Context) (*ErrorPassthroughRule, error) {
  19203. return node, nil
  19204. }
  19205. m.id = &node.ID
  19206. }
  19207. }
  19208. // Client returns a new `ent.Client` from the mutation. If the mutation was
  19209. // executed in a transaction (ent.Tx), a transactional client is returned.
  19210. func (m ErrorPassthroughRuleMutation) Client() *Client {
  19211. client := &Client{config: m.config}
  19212. client.init()
  19213. return client
  19214. }
  19215. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  19216. // it returns an error otherwise.
  19217. func (m ErrorPassthroughRuleMutation) Tx() (*Tx, error) {
  19218. if _, ok := m.driver.(*txDriver); !ok {
  19219. return nil, errors.New("ent: mutation is not running in a transaction")
  19220. }
  19221. tx := &Tx{config: m.config}
  19222. tx.init()
  19223. return tx, nil
  19224. }
  19225. // ID returns the ID value in the mutation. Note that the ID is only available
  19226. // if it was provided to the builder or after it was returned from the database.
  19227. func (m *ErrorPassthroughRuleMutation) ID() (id int64, exists bool) {
  19228. if m.id == nil {
  19229. return
  19230. }
  19231. return *m.id, true
  19232. }
  19233. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  19234. // That means, if the mutation is applied within a transaction with an isolation level such
  19235. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  19236. // or updated by the mutation.
  19237. func (m *ErrorPassthroughRuleMutation) IDs(ctx context.Context) ([]int64, error) {
  19238. switch {
  19239. case m.op.Is(OpUpdateOne | OpDeleteOne):
  19240. id, exists := m.ID()
  19241. if exists {
  19242. return []int64{id}, nil
  19243. }
  19244. fallthrough
  19245. case m.op.Is(OpUpdate | OpDelete):
  19246. return m.Client().ErrorPassthroughRule.Query().Where(m.predicates...).IDs(ctx)
  19247. default:
  19248. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  19249. }
  19250. }
  19251. // SetCreatedAt sets the "created_at" field.
  19252. func (m *ErrorPassthroughRuleMutation) SetCreatedAt(t time.Time) {
  19253. m.created_at = &t
  19254. }
  19255. // CreatedAt returns the value of the "created_at" field in the mutation.
  19256. func (m *ErrorPassthroughRuleMutation) CreatedAt() (r time.Time, exists bool) {
  19257. v := m.created_at
  19258. if v == nil {
  19259. return
  19260. }
  19261. return *v, true
  19262. }
  19263. // OldCreatedAt returns the old "created_at" field's value of the ErrorPassthroughRule entity.
  19264. // If the ErrorPassthroughRule object wasn't provided to the builder, the object is fetched from the database.
  19265. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19266. func (m *ErrorPassthroughRuleMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  19267. if !m.op.Is(OpUpdateOne) {
  19268. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  19269. }
  19270. if m.id == nil || m.oldValue == nil {
  19271. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  19272. }
  19273. oldValue, err := m.oldValue(ctx)
  19274. if err != nil {
  19275. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  19276. }
  19277. return oldValue.CreatedAt, nil
  19278. }
  19279. // ResetCreatedAt resets all changes to the "created_at" field.
  19280. func (m *ErrorPassthroughRuleMutation) ResetCreatedAt() {
  19281. m.created_at = nil
  19282. }
  19283. // SetUpdatedAt sets the "updated_at" field.
  19284. func (m *ErrorPassthroughRuleMutation) SetUpdatedAt(t time.Time) {
  19285. m.updated_at = &t
  19286. }
  19287. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  19288. func (m *ErrorPassthroughRuleMutation) UpdatedAt() (r time.Time, exists bool) {
  19289. v := m.updated_at
  19290. if v == nil {
  19291. return
  19292. }
  19293. return *v, true
  19294. }
  19295. // OldUpdatedAt returns the old "updated_at" field's value of the ErrorPassthroughRule entity.
  19296. // If the ErrorPassthroughRule object wasn't provided to the builder, the object is fetched from the database.
  19297. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19298. func (m *ErrorPassthroughRuleMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  19299. if !m.op.Is(OpUpdateOne) {
  19300. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  19301. }
  19302. if m.id == nil || m.oldValue == nil {
  19303. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  19304. }
  19305. oldValue, err := m.oldValue(ctx)
  19306. if err != nil {
  19307. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  19308. }
  19309. return oldValue.UpdatedAt, nil
  19310. }
  19311. // ResetUpdatedAt resets all changes to the "updated_at" field.
  19312. func (m *ErrorPassthroughRuleMutation) ResetUpdatedAt() {
  19313. m.updated_at = nil
  19314. }
  19315. // SetName sets the "name" field.
  19316. func (m *ErrorPassthroughRuleMutation) SetName(s string) {
  19317. m.name = &s
  19318. }
  19319. // Name returns the value of the "name" field in the mutation.
  19320. func (m *ErrorPassthroughRuleMutation) Name() (r string, exists bool) {
  19321. v := m.name
  19322. if v == nil {
  19323. return
  19324. }
  19325. return *v, true
  19326. }
  19327. // OldName returns the old "name" field's value of the ErrorPassthroughRule entity.
  19328. // If the ErrorPassthroughRule object wasn't provided to the builder, the object is fetched from the database.
  19329. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19330. func (m *ErrorPassthroughRuleMutation) OldName(ctx context.Context) (v string, err error) {
  19331. if !m.op.Is(OpUpdateOne) {
  19332. return v, errors.New("OldName is only allowed on UpdateOne operations")
  19333. }
  19334. if m.id == nil || m.oldValue == nil {
  19335. return v, errors.New("OldName requires an ID field in the mutation")
  19336. }
  19337. oldValue, err := m.oldValue(ctx)
  19338. if err != nil {
  19339. return v, fmt.Errorf("querying old value for OldName: %w", err)
  19340. }
  19341. return oldValue.Name, nil
  19342. }
  19343. // ResetName resets all changes to the "name" field.
  19344. func (m *ErrorPassthroughRuleMutation) ResetName() {
  19345. m.name = nil
  19346. }
  19347. // SetEnabled sets the "enabled" field.
  19348. func (m *ErrorPassthroughRuleMutation) SetEnabled(b bool) {
  19349. m.enabled = &b
  19350. }
  19351. // Enabled returns the value of the "enabled" field in the mutation.
  19352. func (m *ErrorPassthroughRuleMutation) Enabled() (r bool, exists bool) {
  19353. v := m.enabled
  19354. if v == nil {
  19355. return
  19356. }
  19357. return *v, true
  19358. }
  19359. // OldEnabled returns the old "enabled" field's value of the ErrorPassthroughRule entity.
  19360. // If the ErrorPassthroughRule object wasn't provided to the builder, the object is fetched from the database.
  19361. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19362. func (m *ErrorPassthroughRuleMutation) OldEnabled(ctx context.Context) (v bool, err error) {
  19363. if !m.op.Is(OpUpdateOne) {
  19364. return v, errors.New("OldEnabled is only allowed on UpdateOne operations")
  19365. }
  19366. if m.id == nil || m.oldValue == nil {
  19367. return v, errors.New("OldEnabled requires an ID field in the mutation")
  19368. }
  19369. oldValue, err := m.oldValue(ctx)
  19370. if err != nil {
  19371. return v, fmt.Errorf("querying old value for OldEnabled: %w", err)
  19372. }
  19373. return oldValue.Enabled, nil
  19374. }
  19375. // ResetEnabled resets all changes to the "enabled" field.
  19376. func (m *ErrorPassthroughRuleMutation) ResetEnabled() {
  19377. m.enabled = nil
  19378. }
  19379. // SetPriority sets the "priority" field.
  19380. func (m *ErrorPassthroughRuleMutation) SetPriority(i int) {
  19381. m.priority = &i
  19382. m.addpriority = nil
  19383. }
  19384. // Priority returns the value of the "priority" field in the mutation.
  19385. func (m *ErrorPassthroughRuleMutation) Priority() (r int, exists bool) {
  19386. v := m.priority
  19387. if v == nil {
  19388. return
  19389. }
  19390. return *v, true
  19391. }
  19392. // OldPriority returns the old "priority" field's value of the ErrorPassthroughRule entity.
  19393. // If the ErrorPassthroughRule object wasn't provided to the builder, the object is fetched from the database.
  19394. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19395. func (m *ErrorPassthroughRuleMutation) OldPriority(ctx context.Context) (v int, err error) {
  19396. if !m.op.Is(OpUpdateOne) {
  19397. return v, errors.New("OldPriority is only allowed on UpdateOne operations")
  19398. }
  19399. if m.id == nil || m.oldValue == nil {
  19400. return v, errors.New("OldPriority requires an ID field in the mutation")
  19401. }
  19402. oldValue, err := m.oldValue(ctx)
  19403. if err != nil {
  19404. return v, fmt.Errorf("querying old value for OldPriority: %w", err)
  19405. }
  19406. return oldValue.Priority, nil
  19407. }
  19408. // AddPriority adds i to the "priority" field.
  19409. func (m *ErrorPassthroughRuleMutation) AddPriority(i int) {
  19410. if m.addpriority != nil {
  19411. *m.addpriority += i
  19412. } else {
  19413. m.addpriority = &i
  19414. }
  19415. }
  19416. // AddedPriority returns the value that was added to the "priority" field in this mutation.
  19417. func (m *ErrorPassthroughRuleMutation) AddedPriority() (r int, exists bool) {
  19418. v := m.addpriority
  19419. if v == nil {
  19420. return
  19421. }
  19422. return *v, true
  19423. }
  19424. // ResetPriority resets all changes to the "priority" field.
  19425. func (m *ErrorPassthroughRuleMutation) ResetPriority() {
  19426. m.priority = nil
  19427. m.addpriority = nil
  19428. }
  19429. // SetErrorCodes sets the "error_codes" field.
  19430. func (m *ErrorPassthroughRuleMutation) SetErrorCodes(i []int) {
  19431. m.error_codes = &i
  19432. m.appenderror_codes = nil
  19433. }
  19434. // ErrorCodes returns the value of the "error_codes" field in the mutation.
  19435. func (m *ErrorPassthroughRuleMutation) ErrorCodes() (r []int, exists bool) {
  19436. v := m.error_codes
  19437. if v == nil {
  19438. return
  19439. }
  19440. return *v, true
  19441. }
  19442. // OldErrorCodes returns the old "error_codes" field's value of the ErrorPassthroughRule entity.
  19443. // If the ErrorPassthroughRule object wasn't provided to the builder, the object is fetched from the database.
  19444. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19445. func (m *ErrorPassthroughRuleMutation) OldErrorCodes(ctx context.Context) (v []int, err error) {
  19446. if !m.op.Is(OpUpdateOne) {
  19447. return v, errors.New("OldErrorCodes is only allowed on UpdateOne operations")
  19448. }
  19449. if m.id == nil || m.oldValue == nil {
  19450. return v, errors.New("OldErrorCodes requires an ID field in the mutation")
  19451. }
  19452. oldValue, err := m.oldValue(ctx)
  19453. if err != nil {
  19454. return v, fmt.Errorf("querying old value for OldErrorCodes: %w", err)
  19455. }
  19456. return oldValue.ErrorCodes, nil
  19457. }
  19458. // AppendErrorCodes adds i to the "error_codes" field.
  19459. func (m *ErrorPassthroughRuleMutation) AppendErrorCodes(i []int) {
  19460. m.appenderror_codes = append(m.appenderror_codes, i...)
  19461. }
  19462. // AppendedErrorCodes returns the list of values that were appended to the "error_codes" field in this mutation.
  19463. func (m *ErrorPassthroughRuleMutation) AppendedErrorCodes() ([]int, bool) {
  19464. if len(m.appenderror_codes) == 0 {
  19465. return nil, false
  19466. }
  19467. return m.appenderror_codes, true
  19468. }
  19469. // ClearErrorCodes clears the value of the "error_codes" field.
  19470. func (m *ErrorPassthroughRuleMutation) ClearErrorCodes() {
  19471. m.error_codes = nil
  19472. m.appenderror_codes = nil
  19473. m.clearedFields[errorpassthroughrule.FieldErrorCodes] = struct{}{}
  19474. }
  19475. // ErrorCodesCleared returns if the "error_codes" field was cleared in this mutation.
  19476. func (m *ErrorPassthroughRuleMutation) ErrorCodesCleared() bool {
  19477. _, ok := m.clearedFields[errorpassthroughrule.FieldErrorCodes]
  19478. return ok
  19479. }
  19480. // ResetErrorCodes resets all changes to the "error_codes" field.
  19481. func (m *ErrorPassthroughRuleMutation) ResetErrorCodes() {
  19482. m.error_codes = nil
  19483. m.appenderror_codes = nil
  19484. delete(m.clearedFields, errorpassthroughrule.FieldErrorCodes)
  19485. }
  19486. // SetKeywords sets the "keywords" field.
  19487. func (m *ErrorPassthroughRuleMutation) SetKeywords(s []string) {
  19488. m.keywords = &s
  19489. m.appendkeywords = nil
  19490. }
  19491. // Keywords returns the value of the "keywords" field in the mutation.
  19492. func (m *ErrorPassthroughRuleMutation) Keywords() (r []string, exists bool) {
  19493. v := m.keywords
  19494. if v == nil {
  19495. return
  19496. }
  19497. return *v, true
  19498. }
  19499. // OldKeywords returns the old "keywords" field's value of the ErrorPassthroughRule entity.
  19500. // If the ErrorPassthroughRule object wasn't provided to the builder, the object is fetched from the database.
  19501. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19502. func (m *ErrorPassthroughRuleMutation) OldKeywords(ctx context.Context) (v []string, err error) {
  19503. if !m.op.Is(OpUpdateOne) {
  19504. return v, errors.New("OldKeywords is only allowed on UpdateOne operations")
  19505. }
  19506. if m.id == nil || m.oldValue == nil {
  19507. return v, errors.New("OldKeywords requires an ID field in the mutation")
  19508. }
  19509. oldValue, err := m.oldValue(ctx)
  19510. if err != nil {
  19511. return v, fmt.Errorf("querying old value for OldKeywords: %w", err)
  19512. }
  19513. return oldValue.Keywords, nil
  19514. }
  19515. // AppendKeywords adds s to the "keywords" field.
  19516. func (m *ErrorPassthroughRuleMutation) AppendKeywords(s []string) {
  19517. m.appendkeywords = append(m.appendkeywords, s...)
  19518. }
  19519. // AppendedKeywords returns the list of values that were appended to the "keywords" field in this mutation.
  19520. func (m *ErrorPassthroughRuleMutation) AppendedKeywords() ([]string, bool) {
  19521. if len(m.appendkeywords) == 0 {
  19522. return nil, false
  19523. }
  19524. return m.appendkeywords, true
  19525. }
  19526. // ClearKeywords clears the value of the "keywords" field.
  19527. func (m *ErrorPassthroughRuleMutation) ClearKeywords() {
  19528. m.keywords = nil
  19529. m.appendkeywords = nil
  19530. m.clearedFields[errorpassthroughrule.FieldKeywords] = struct{}{}
  19531. }
  19532. // KeywordsCleared returns if the "keywords" field was cleared in this mutation.
  19533. func (m *ErrorPassthroughRuleMutation) KeywordsCleared() bool {
  19534. _, ok := m.clearedFields[errorpassthroughrule.FieldKeywords]
  19535. return ok
  19536. }
  19537. // ResetKeywords resets all changes to the "keywords" field.
  19538. func (m *ErrorPassthroughRuleMutation) ResetKeywords() {
  19539. m.keywords = nil
  19540. m.appendkeywords = nil
  19541. delete(m.clearedFields, errorpassthroughrule.FieldKeywords)
  19542. }
  19543. // SetMatchMode sets the "match_mode" field.
  19544. func (m *ErrorPassthroughRuleMutation) SetMatchMode(s string) {
  19545. m.match_mode = &s
  19546. }
  19547. // MatchMode returns the value of the "match_mode" field in the mutation.
  19548. func (m *ErrorPassthroughRuleMutation) MatchMode() (r string, exists bool) {
  19549. v := m.match_mode
  19550. if v == nil {
  19551. return
  19552. }
  19553. return *v, true
  19554. }
  19555. // OldMatchMode returns the old "match_mode" field's value of the ErrorPassthroughRule entity.
  19556. // If the ErrorPassthroughRule object wasn't provided to the builder, the object is fetched from the database.
  19557. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19558. func (m *ErrorPassthroughRuleMutation) OldMatchMode(ctx context.Context) (v string, err error) {
  19559. if !m.op.Is(OpUpdateOne) {
  19560. return v, errors.New("OldMatchMode is only allowed on UpdateOne operations")
  19561. }
  19562. if m.id == nil || m.oldValue == nil {
  19563. return v, errors.New("OldMatchMode requires an ID field in the mutation")
  19564. }
  19565. oldValue, err := m.oldValue(ctx)
  19566. if err != nil {
  19567. return v, fmt.Errorf("querying old value for OldMatchMode: %w", err)
  19568. }
  19569. return oldValue.MatchMode, nil
  19570. }
  19571. // ResetMatchMode resets all changes to the "match_mode" field.
  19572. func (m *ErrorPassthroughRuleMutation) ResetMatchMode() {
  19573. m.match_mode = nil
  19574. }
  19575. // SetPlatforms sets the "platforms" field.
  19576. func (m *ErrorPassthroughRuleMutation) SetPlatforms(s []string) {
  19577. m.platforms = &s
  19578. m.appendplatforms = nil
  19579. }
  19580. // Platforms returns the value of the "platforms" field in the mutation.
  19581. func (m *ErrorPassthroughRuleMutation) Platforms() (r []string, exists bool) {
  19582. v := m.platforms
  19583. if v == nil {
  19584. return
  19585. }
  19586. return *v, true
  19587. }
  19588. // OldPlatforms returns the old "platforms" field's value of the ErrorPassthroughRule entity.
  19589. // If the ErrorPassthroughRule object wasn't provided to the builder, the object is fetched from the database.
  19590. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19591. func (m *ErrorPassthroughRuleMutation) OldPlatforms(ctx context.Context) (v []string, err error) {
  19592. if !m.op.Is(OpUpdateOne) {
  19593. return v, errors.New("OldPlatforms is only allowed on UpdateOne operations")
  19594. }
  19595. if m.id == nil || m.oldValue == nil {
  19596. return v, errors.New("OldPlatforms requires an ID field in the mutation")
  19597. }
  19598. oldValue, err := m.oldValue(ctx)
  19599. if err != nil {
  19600. return v, fmt.Errorf("querying old value for OldPlatforms: %w", err)
  19601. }
  19602. return oldValue.Platforms, nil
  19603. }
  19604. // AppendPlatforms adds s to the "platforms" field.
  19605. func (m *ErrorPassthroughRuleMutation) AppendPlatforms(s []string) {
  19606. m.appendplatforms = append(m.appendplatforms, s...)
  19607. }
  19608. // AppendedPlatforms returns the list of values that were appended to the "platforms" field in this mutation.
  19609. func (m *ErrorPassthroughRuleMutation) AppendedPlatforms() ([]string, bool) {
  19610. if len(m.appendplatforms) == 0 {
  19611. return nil, false
  19612. }
  19613. return m.appendplatforms, true
  19614. }
  19615. // ClearPlatforms clears the value of the "platforms" field.
  19616. func (m *ErrorPassthroughRuleMutation) ClearPlatforms() {
  19617. m.platforms = nil
  19618. m.appendplatforms = nil
  19619. m.clearedFields[errorpassthroughrule.FieldPlatforms] = struct{}{}
  19620. }
  19621. // PlatformsCleared returns if the "platforms" field was cleared in this mutation.
  19622. func (m *ErrorPassthroughRuleMutation) PlatformsCleared() bool {
  19623. _, ok := m.clearedFields[errorpassthroughrule.FieldPlatforms]
  19624. return ok
  19625. }
  19626. // ResetPlatforms resets all changes to the "platforms" field.
  19627. func (m *ErrorPassthroughRuleMutation) ResetPlatforms() {
  19628. m.platforms = nil
  19629. m.appendplatforms = nil
  19630. delete(m.clearedFields, errorpassthroughrule.FieldPlatforms)
  19631. }
  19632. // SetPassthroughCode sets the "passthrough_code" field.
  19633. func (m *ErrorPassthroughRuleMutation) SetPassthroughCode(b bool) {
  19634. m.passthrough_code = &b
  19635. }
  19636. // PassthroughCode returns the value of the "passthrough_code" field in the mutation.
  19637. func (m *ErrorPassthroughRuleMutation) PassthroughCode() (r bool, exists bool) {
  19638. v := m.passthrough_code
  19639. if v == nil {
  19640. return
  19641. }
  19642. return *v, true
  19643. }
  19644. // OldPassthroughCode returns the old "passthrough_code" field's value of the ErrorPassthroughRule entity.
  19645. // If the ErrorPassthroughRule object wasn't provided to the builder, the object is fetched from the database.
  19646. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19647. func (m *ErrorPassthroughRuleMutation) OldPassthroughCode(ctx context.Context) (v bool, err error) {
  19648. if !m.op.Is(OpUpdateOne) {
  19649. return v, errors.New("OldPassthroughCode is only allowed on UpdateOne operations")
  19650. }
  19651. if m.id == nil || m.oldValue == nil {
  19652. return v, errors.New("OldPassthroughCode requires an ID field in the mutation")
  19653. }
  19654. oldValue, err := m.oldValue(ctx)
  19655. if err != nil {
  19656. return v, fmt.Errorf("querying old value for OldPassthroughCode: %w", err)
  19657. }
  19658. return oldValue.PassthroughCode, nil
  19659. }
  19660. // ResetPassthroughCode resets all changes to the "passthrough_code" field.
  19661. func (m *ErrorPassthroughRuleMutation) ResetPassthroughCode() {
  19662. m.passthrough_code = nil
  19663. }
  19664. // SetResponseCode sets the "response_code" field.
  19665. func (m *ErrorPassthroughRuleMutation) SetResponseCode(i int) {
  19666. m.response_code = &i
  19667. m.addresponse_code = nil
  19668. }
  19669. // ResponseCode returns the value of the "response_code" field in the mutation.
  19670. func (m *ErrorPassthroughRuleMutation) ResponseCode() (r int, exists bool) {
  19671. v := m.response_code
  19672. if v == nil {
  19673. return
  19674. }
  19675. return *v, true
  19676. }
  19677. // OldResponseCode returns the old "response_code" field's value of the ErrorPassthroughRule entity.
  19678. // If the ErrorPassthroughRule object wasn't provided to the builder, the object is fetched from the database.
  19679. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19680. func (m *ErrorPassthroughRuleMutation) OldResponseCode(ctx context.Context) (v *int, err error) {
  19681. if !m.op.Is(OpUpdateOne) {
  19682. return v, errors.New("OldResponseCode is only allowed on UpdateOne operations")
  19683. }
  19684. if m.id == nil || m.oldValue == nil {
  19685. return v, errors.New("OldResponseCode requires an ID field in the mutation")
  19686. }
  19687. oldValue, err := m.oldValue(ctx)
  19688. if err != nil {
  19689. return v, fmt.Errorf("querying old value for OldResponseCode: %w", err)
  19690. }
  19691. return oldValue.ResponseCode, nil
  19692. }
  19693. // AddResponseCode adds i to the "response_code" field.
  19694. func (m *ErrorPassthroughRuleMutation) AddResponseCode(i int) {
  19695. if m.addresponse_code != nil {
  19696. *m.addresponse_code += i
  19697. } else {
  19698. m.addresponse_code = &i
  19699. }
  19700. }
  19701. // AddedResponseCode returns the value that was added to the "response_code" field in this mutation.
  19702. func (m *ErrorPassthroughRuleMutation) AddedResponseCode() (r int, exists bool) {
  19703. v := m.addresponse_code
  19704. if v == nil {
  19705. return
  19706. }
  19707. return *v, true
  19708. }
  19709. // ClearResponseCode clears the value of the "response_code" field.
  19710. func (m *ErrorPassthroughRuleMutation) ClearResponseCode() {
  19711. m.response_code = nil
  19712. m.addresponse_code = nil
  19713. m.clearedFields[errorpassthroughrule.FieldResponseCode] = struct{}{}
  19714. }
  19715. // ResponseCodeCleared returns if the "response_code" field was cleared in this mutation.
  19716. func (m *ErrorPassthroughRuleMutation) ResponseCodeCleared() bool {
  19717. _, ok := m.clearedFields[errorpassthroughrule.FieldResponseCode]
  19718. return ok
  19719. }
  19720. // ResetResponseCode resets all changes to the "response_code" field.
  19721. func (m *ErrorPassthroughRuleMutation) ResetResponseCode() {
  19722. m.response_code = nil
  19723. m.addresponse_code = nil
  19724. delete(m.clearedFields, errorpassthroughrule.FieldResponseCode)
  19725. }
  19726. // SetPassthroughBody sets the "passthrough_body" field.
  19727. func (m *ErrorPassthroughRuleMutation) SetPassthroughBody(b bool) {
  19728. m.passthrough_body = &b
  19729. }
  19730. // PassthroughBody returns the value of the "passthrough_body" field in the mutation.
  19731. func (m *ErrorPassthroughRuleMutation) PassthroughBody() (r bool, exists bool) {
  19732. v := m.passthrough_body
  19733. if v == nil {
  19734. return
  19735. }
  19736. return *v, true
  19737. }
  19738. // OldPassthroughBody returns the old "passthrough_body" field's value of the ErrorPassthroughRule entity.
  19739. // If the ErrorPassthroughRule object wasn't provided to the builder, the object is fetched from the database.
  19740. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19741. func (m *ErrorPassthroughRuleMutation) OldPassthroughBody(ctx context.Context) (v bool, err error) {
  19742. if !m.op.Is(OpUpdateOne) {
  19743. return v, errors.New("OldPassthroughBody is only allowed on UpdateOne operations")
  19744. }
  19745. if m.id == nil || m.oldValue == nil {
  19746. return v, errors.New("OldPassthroughBody requires an ID field in the mutation")
  19747. }
  19748. oldValue, err := m.oldValue(ctx)
  19749. if err != nil {
  19750. return v, fmt.Errorf("querying old value for OldPassthroughBody: %w", err)
  19751. }
  19752. return oldValue.PassthroughBody, nil
  19753. }
  19754. // ResetPassthroughBody resets all changes to the "passthrough_body" field.
  19755. func (m *ErrorPassthroughRuleMutation) ResetPassthroughBody() {
  19756. m.passthrough_body = nil
  19757. }
  19758. // SetCustomMessage sets the "custom_message" field.
  19759. func (m *ErrorPassthroughRuleMutation) SetCustomMessage(s string) {
  19760. m.custom_message = &s
  19761. }
  19762. // CustomMessage returns the value of the "custom_message" field in the mutation.
  19763. func (m *ErrorPassthroughRuleMutation) CustomMessage() (r string, exists bool) {
  19764. v := m.custom_message
  19765. if v == nil {
  19766. return
  19767. }
  19768. return *v, true
  19769. }
  19770. // OldCustomMessage returns the old "custom_message" field's value of the ErrorPassthroughRule entity.
  19771. // If the ErrorPassthroughRule object wasn't provided to the builder, the object is fetched from the database.
  19772. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19773. func (m *ErrorPassthroughRuleMutation) OldCustomMessage(ctx context.Context) (v *string, err error) {
  19774. if !m.op.Is(OpUpdateOne) {
  19775. return v, errors.New("OldCustomMessage is only allowed on UpdateOne operations")
  19776. }
  19777. if m.id == nil || m.oldValue == nil {
  19778. return v, errors.New("OldCustomMessage requires an ID field in the mutation")
  19779. }
  19780. oldValue, err := m.oldValue(ctx)
  19781. if err != nil {
  19782. return v, fmt.Errorf("querying old value for OldCustomMessage: %w", err)
  19783. }
  19784. return oldValue.CustomMessage, nil
  19785. }
  19786. // ClearCustomMessage clears the value of the "custom_message" field.
  19787. func (m *ErrorPassthroughRuleMutation) ClearCustomMessage() {
  19788. m.custom_message = nil
  19789. m.clearedFields[errorpassthroughrule.FieldCustomMessage] = struct{}{}
  19790. }
  19791. // CustomMessageCleared returns if the "custom_message" field was cleared in this mutation.
  19792. func (m *ErrorPassthroughRuleMutation) CustomMessageCleared() bool {
  19793. _, ok := m.clearedFields[errorpassthroughrule.FieldCustomMessage]
  19794. return ok
  19795. }
  19796. // ResetCustomMessage resets all changes to the "custom_message" field.
  19797. func (m *ErrorPassthroughRuleMutation) ResetCustomMessage() {
  19798. m.custom_message = nil
  19799. delete(m.clearedFields, errorpassthroughrule.FieldCustomMessage)
  19800. }
  19801. // SetSkipMonitoring sets the "skip_monitoring" field.
  19802. func (m *ErrorPassthroughRuleMutation) SetSkipMonitoring(b bool) {
  19803. m.skip_monitoring = &b
  19804. }
  19805. // SkipMonitoring returns the value of the "skip_monitoring" field in the mutation.
  19806. func (m *ErrorPassthroughRuleMutation) SkipMonitoring() (r bool, exists bool) {
  19807. v := m.skip_monitoring
  19808. if v == nil {
  19809. return
  19810. }
  19811. return *v, true
  19812. }
  19813. // OldSkipMonitoring returns the old "skip_monitoring" field's value of the ErrorPassthroughRule entity.
  19814. // If the ErrorPassthroughRule object wasn't provided to the builder, the object is fetched from the database.
  19815. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19816. func (m *ErrorPassthroughRuleMutation) OldSkipMonitoring(ctx context.Context) (v bool, err error) {
  19817. if !m.op.Is(OpUpdateOne) {
  19818. return v, errors.New("OldSkipMonitoring is only allowed on UpdateOne operations")
  19819. }
  19820. if m.id == nil || m.oldValue == nil {
  19821. return v, errors.New("OldSkipMonitoring requires an ID field in the mutation")
  19822. }
  19823. oldValue, err := m.oldValue(ctx)
  19824. if err != nil {
  19825. return v, fmt.Errorf("querying old value for OldSkipMonitoring: %w", err)
  19826. }
  19827. return oldValue.SkipMonitoring, nil
  19828. }
  19829. // ResetSkipMonitoring resets all changes to the "skip_monitoring" field.
  19830. func (m *ErrorPassthroughRuleMutation) ResetSkipMonitoring() {
  19831. m.skip_monitoring = nil
  19832. }
  19833. // SetDescription sets the "description" field.
  19834. func (m *ErrorPassthroughRuleMutation) SetDescription(s string) {
  19835. m.description = &s
  19836. }
  19837. // Description returns the value of the "description" field in the mutation.
  19838. func (m *ErrorPassthroughRuleMutation) Description() (r string, exists bool) {
  19839. v := m.description
  19840. if v == nil {
  19841. return
  19842. }
  19843. return *v, true
  19844. }
  19845. // OldDescription returns the old "description" field's value of the ErrorPassthroughRule entity.
  19846. // If the ErrorPassthroughRule object wasn't provided to the builder, the object is fetched from the database.
  19847. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19848. func (m *ErrorPassthroughRuleMutation) OldDescription(ctx context.Context) (v *string, err error) {
  19849. if !m.op.Is(OpUpdateOne) {
  19850. return v, errors.New("OldDescription is only allowed on UpdateOne operations")
  19851. }
  19852. if m.id == nil || m.oldValue == nil {
  19853. return v, errors.New("OldDescription requires an ID field in the mutation")
  19854. }
  19855. oldValue, err := m.oldValue(ctx)
  19856. if err != nil {
  19857. return v, fmt.Errorf("querying old value for OldDescription: %w", err)
  19858. }
  19859. return oldValue.Description, nil
  19860. }
  19861. // ClearDescription clears the value of the "description" field.
  19862. func (m *ErrorPassthroughRuleMutation) ClearDescription() {
  19863. m.description = nil
  19864. m.clearedFields[errorpassthroughrule.FieldDescription] = struct{}{}
  19865. }
  19866. // DescriptionCleared returns if the "description" field was cleared in this mutation.
  19867. func (m *ErrorPassthroughRuleMutation) DescriptionCleared() bool {
  19868. _, ok := m.clearedFields[errorpassthroughrule.FieldDescription]
  19869. return ok
  19870. }
  19871. // ResetDescription resets all changes to the "description" field.
  19872. func (m *ErrorPassthroughRuleMutation) ResetDescription() {
  19873. m.description = nil
  19874. delete(m.clearedFields, errorpassthroughrule.FieldDescription)
  19875. }
  19876. // Where appends a list predicates to the ErrorPassthroughRuleMutation builder.
  19877. func (m *ErrorPassthroughRuleMutation) Where(ps ...predicate.ErrorPassthroughRule) {
  19878. m.predicates = append(m.predicates, ps...)
  19879. }
  19880. // WhereP appends storage-level predicates to the ErrorPassthroughRuleMutation builder. Using this method,
  19881. // users can use type-assertion to append predicates that do not depend on any generated package.
  19882. func (m *ErrorPassthroughRuleMutation) WhereP(ps ...func(*sql.Selector)) {
  19883. p := make([]predicate.ErrorPassthroughRule, len(ps))
  19884. for i := range ps {
  19885. p[i] = ps[i]
  19886. }
  19887. m.Where(p...)
  19888. }
  19889. // Op returns the operation name.
  19890. func (m *ErrorPassthroughRuleMutation) Op() Op {
  19891. return m.op
  19892. }
  19893. // SetOp allows setting the mutation operation.
  19894. func (m *ErrorPassthroughRuleMutation) SetOp(op Op) {
  19895. m.op = op
  19896. }
  19897. // Type returns the node type of this mutation (ErrorPassthroughRule).
  19898. func (m *ErrorPassthroughRuleMutation) Type() string {
  19899. return m.typ
  19900. }
  19901. // Fields returns all fields that were changed during this mutation. Note that in
  19902. // order to get all numeric fields that were incremented/decremented, call
  19903. // AddedFields().
  19904. func (m *ErrorPassthroughRuleMutation) Fields() []string {
  19905. fields := make([]string, 0, 15)
  19906. if m.created_at != nil {
  19907. fields = append(fields, errorpassthroughrule.FieldCreatedAt)
  19908. }
  19909. if m.updated_at != nil {
  19910. fields = append(fields, errorpassthroughrule.FieldUpdatedAt)
  19911. }
  19912. if m.name != nil {
  19913. fields = append(fields, errorpassthroughrule.FieldName)
  19914. }
  19915. if m.enabled != nil {
  19916. fields = append(fields, errorpassthroughrule.FieldEnabled)
  19917. }
  19918. if m.priority != nil {
  19919. fields = append(fields, errorpassthroughrule.FieldPriority)
  19920. }
  19921. if m.error_codes != nil {
  19922. fields = append(fields, errorpassthroughrule.FieldErrorCodes)
  19923. }
  19924. if m.keywords != nil {
  19925. fields = append(fields, errorpassthroughrule.FieldKeywords)
  19926. }
  19927. if m.match_mode != nil {
  19928. fields = append(fields, errorpassthroughrule.FieldMatchMode)
  19929. }
  19930. if m.platforms != nil {
  19931. fields = append(fields, errorpassthroughrule.FieldPlatforms)
  19932. }
  19933. if m.passthrough_code != nil {
  19934. fields = append(fields, errorpassthroughrule.FieldPassthroughCode)
  19935. }
  19936. if m.response_code != nil {
  19937. fields = append(fields, errorpassthroughrule.FieldResponseCode)
  19938. }
  19939. if m.passthrough_body != nil {
  19940. fields = append(fields, errorpassthroughrule.FieldPassthroughBody)
  19941. }
  19942. if m.custom_message != nil {
  19943. fields = append(fields, errorpassthroughrule.FieldCustomMessage)
  19944. }
  19945. if m.skip_monitoring != nil {
  19946. fields = append(fields, errorpassthroughrule.FieldSkipMonitoring)
  19947. }
  19948. if m.description != nil {
  19949. fields = append(fields, errorpassthroughrule.FieldDescription)
  19950. }
  19951. return fields
  19952. }
  19953. // Field returns the value of a field with the given name. The second boolean
  19954. // return value indicates that this field was not set, or was not defined in the
  19955. // schema.
  19956. func (m *ErrorPassthroughRuleMutation) Field(name string) (ent.Value, bool) {
  19957. switch name {
  19958. case errorpassthroughrule.FieldCreatedAt:
  19959. return m.CreatedAt()
  19960. case errorpassthroughrule.FieldUpdatedAt:
  19961. return m.UpdatedAt()
  19962. case errorpassthroughrule.FieldName:
  19963. return m.Name()
  19964. case errorpassthroughrule.FieldEnabled:
  19965. return m.Enabled()
  19966. case errorpassthroughrule.FieldPriority:
  19967. return m.Priority()
  19968. case errorpassthroughrule.FieldErrorCodes:
  19969. return m.ErrorCodes()
  19970. case errorpassthroughrule.FieldKeywords:
  19971. return m.Keywords()
  19972. case errorpassthroughrule.FieldMatchMode:
  19973. return m.MatchMode()
  19974. case errorpassthroughrule.FieldPlatforms:
  19975. return m.Platforms()
  19976. case errorpassthroughrule.FieldPassthroughCode:
  19977. return m.PassthroughCode()
  19978. case errorpassthroughrule.FieldResponseCode:
  19979. return m.ResponseCode()
  19980. case errorpassthroughrule.FieldPassthroughBody:
  19981. return m.PassthroughBody()
  19982. case errorpassthroughrule.FieldCustomMessage:
  19983. return m.CustomMessage()
  19984. case errorpassthroughrule.FieldSkipMonitoring:
  19985. return m.SkipMonitoring()
  19986. case errorpassthroughrule.FieldDescription:
  19987. return m.Description()
  19988. }
  19989. return nil, false
  19990. }
  19991. // OldField returns the old value of the field from the database. An error is
  19992. // returned if the mutation operation is not UpdateOne, or the query to the
  19993. // database failed.
  19994. func (m *ErrorPassthroughRuleMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  19995. switch name {
  19996. case errorpassthroughrule.FieldCreatedAt:
  19997. return m.OldCreatedAt(ctx)
  19998. case errorpassthroughrule.FieldUpdatedAt:
  19999. return m.OldUpdatedAt(ctx)
  20000. case errorpassthroughrule.FieldName:
  20001. return m.OldName(ctx)
  20002. case errorpassthroughrule.FieldEnabled:
  20003. return m.OldEnabled(ctx)
  20004. case errorpassthroughrule.FieldPriority:
  20005. return m.OldPriority(ctx)
  20006. case errorpassthroughrule.FieldErrorCodes:
  20007. return m.OldErrorCodes(ctx)
  20008. case errorpassthroughrule.FieldKeywords:
  20009. return m.OldKeywords(ctx)
  20010. case errorpassthroughrule.FieldMatchMode:
  20011. return m.OldMatchMode(ctx)
  20012. case errorpassthroughrule.FieldPlatforms:
  20013. return m.OldPlatforms(ctx)
  20014. case errorpassthroughrule.FieldPassthroughCode:
  20015. return m.OldPassthroughCode(ctx)
  20016. case errorpassthroughrule.FieldResponseCode:
  20017. return m.OldResponseCode(ctx)
  20018. case errorpassthroughrule.FieldPassthroughBody:
  20019. return m.OldPassthroughBody(ctx)
  20020. case errorpassthroughrule.FieldCustomMessage:
  20021. return m.OldCustomMessage(ctx)
  20022. case errorpassthroughrule.FieldSkipMonitoring:
  20023. return m.OldSkipMonitoring(ctx)
  20024. case errorpassthroughrule.FieldDescription:
  20025. return m.OldDescription(ctx)
  20026. }
  20027. return nil, fmt.Errorf("unknown ErrorPassthroughRule field %s", name)
  20028. }
  20029. // SetField sets the value of a field with the given name. It returns an error if
  20030. // the field is not defined in the schema, or if the type mismatched the field
  20031. // type.
  20032. func (m *ErrorPassthroughRuleMutation) SetField(name string, value ent.Value) error {
  20033. switch name {
  20034. case errorpassthroughrule.FieldCreatedAt:
  20035. v, ok := value.(time.Time)
  20036. if !ok {
  20037. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20038. }
  20039. m.SetCreatedAt(v)
  20040. return nil
  20041. case errorpassthroughrule.FieldUpdatedAt:
  20042. v, ok := value.(time.Time)
  20043. if !ok {
  20044. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20045. }
  20046. m.SetUpdatedAt(v)
  20047. return nil
  20048. case errorpassthroughrule.FieldName:
  20049. v, ok := value.(string)
  20050. if !ok {
  20051. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20052. }
  20053. m.SetName(v)
  20054. return nil
  20055. case errorpassthroughrule.FieldEnabled:
  20056. v, ok := value.(bool)
  20057. if !ok {
  20058. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20059. }
  20060. m.SetEnabled(v)
  20061. return nil
  20062. case errorpassthroughrule.FieldPriority:
  20063. v, ok := value.(int)
  20064. if !ok {
  20065. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20066. }
  20067. m.SetPriority(v)
  20068. return nil
  20069. case errorpassthroughrule.FieldErrorCodes:
  20070. v, ok := value.([]int)
  20071. if !ok {
  20072. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20073. }
  20074. m.SetErrorCodes(v)
  20075. return nil
  20076. case errorpassthroughrule.FieldKeywords:
  20077. v, ok := value.([]string)
  20078. if !ok {
  20079. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20080. }
  20081. m.SetKeywords(v)
  20082. return nil
  20083. case errorpassthroughrule.FieldMatchMode:
  20084. v, ok := value.(string)
  20085. if !ok {
  20086. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20087. }
  20088. m.SetMatchMode(v)
  20089. return nil
  20090. case errorpassthroughrule.FieldPlatforms:
  20091. v, ok := value.([]string)
  20092. if !ok {
  20093. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20094. }
  20095. m.SetPlatforms(v)
  20096. return nil
  20097. case errorpassthroughrule.FieldPassthroughCode:
  20098. v, ok := value.(bool)
  20099. if !ok {
  20100. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20101. }
  20102. m.SetPassthroughCode(v)
  20103. return nil
  20104. case errorpassthroughrule.FieldResponseCode:
  20105. v, ok := value.(int)
  20106. if !ok {
  20107. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20108. }
  20109. m.SetResponseCode(v)
  20110. return nil
  20111. case errorpassthroughrule.FieldPassthroughBody:
  20112. v, ok := value.(bool)
  20113. if !ok {
  20114. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20115. }
  20116. m.SetPassthroughBody(v)
  20117. return nil
  20118. case errorpassthroughrule.FieldCustomMessage:
  20119. v, ok := value.(string)
  20120. if !ok {
  20121. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20122. }
  20123. m.SetCustomMessage(v)
  20124. return nil
  20125. case errorpassthroughrule.FieldSkipMonitoring:
  20126. v, ok := value.(bool)
  20127. if !ok {
  20128. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20129. }
  20130. m.SetSkipMonitoring(v)
  20131. return nil
  20132. case errorpassthroughrule.FieldDescription:
  20133. v, ok := value.(string)
  20134. if !ok {
  20135. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20136. }
  20137. m.SetDescription(v)
  20138. return nil
  20139. }
  20140. return fmt.Errorf("unknown ErrorPassthroughRule field %s", name)
  20141. }
  20142. // AddedFields returns all numeric fields that were incremented/decremented during
  20143. // this mutation.
  20144. func (m *ErrorPassthroughRuleMutation) AddedFields() []string {
  20145. var fields []string
  20146. if m.addpriority != nil {
  20147. fields = append(fields, errorpassthroughrule.FieldPriority)
  20148. }
  20149. if m.addresponse_code != nil {
  20150. fields = append(fields, errorpassthroughrule.FieldResponseCode)
  20151. }
  20152. return fields
  20153. }
  20154. // AddedField returns the numeric value that was incremented/decremented on a field
  20155. // with the given name. The second boolean return value indicates that this field
  20156. // was not set, or was not defined in the schema.
  20157. func (m *ErrorPassthroughRuleMutation) AddedField(name string) (ent.Value, bool) {
  20158. switch name {
  20159. case errorpassthroughrule.FieldPriority:
  20160. return m.AddedPriority()
  20161. case errorpassthroughrule.FieldResponseCode:
  20162. return m.AddedResponseCode()
  20163. }
  20164. return nil, false
  20165. }
  20166. // AddField adds the value to the field with the given name. It returns an error if
  20167. // the field is not defined in the schema, or if the type mismatched the field
  20168. // type.
  20169. func (m *ErrorPassthroughRuleMutation) AddField(name string, value ent.Value) error {
  20170. switch name {
  20171. case errorpassthroughrule.FieldPriority:
  20172. v, ok := value.(int)
  20173. if !ok {
  20174. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20175. }
  20176. m.AddPriority(v)
  20177. return nil
  20178. case errorpassthroughrule.FieldResponseCode:
  20179. v, ok := value.(int)
  20180. if !ok {
  20181. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20182. }
  20183. m.AddResponseCode(v)
  20184. return nil
  20185. }
  20186. return fmt.Errorf("unknown ErrorPassthroughRule numeric field %s", name)
  20187. }
  20188. // ClearedFields returns all nullable fields that were cleared during this
  20189. // mutation.
  20190. func (m *ErrorPassthroughRuleMutation) ClearedFields() []string {
  20191. var fields []string
  20192. if m.FieldCleared(errorpassthroughrule.FieldErrorCodes) {
  20193. fields = append(fields, errorpassthroughrule.FieldErrorCodes)
  20194. }
  20195. if m.FieldCleared(errorpassthroughrule.FieldKeywords) {
  20196. fields = append(fields, errorpassthroughrule.FieldKeywords)
  20197. }
  20198. if m.FieldCleared(errorpassthroughrule.FieldPlatforms) {
  20199. fields = append(fields, errorpassthroughrule.FieldPlatforms)
  20200. }
  20201. if m.FieldCleared(errorpassthroughrule.FieldResponseCode) {
  20202. fields = append(fields, errorpassthroughrule.FieldResponseCode)
  20203. }
  20204. if m.FieldCleared(errorpassthroughrule.FieldCustomMessage) {
  20205. fields = append(fields, errorpassthroughrule.FieldCustomMessage)
  20206. }
  20207. if m.FieldCleared(errorpassthroughrule.FieldDescription) {
  20208. fields = append(fields, errorpassthroughrule.FieldDescription)
  20209. }
  20210. return fields
  20211. }
  20212. // FieldCleared returns a boolean indicating if a field with the given name was
  20213. // cleared in this mutation.
  20214. func (m *ErrorPassthroughRuleMutation) FieldCleared(name string) bool {
  20215. _, ok := m.clearedFields[name]
  20216. return ok
  20217. }
  20218. // ClearField clears the value of the field with the given name. It returns an
  20219. // error if the field is not defined in the schema.
  20220. func (m *ErrorPassthroughRuleMutation) ClearField(name string) error {
  20221. switch name {
  20222. case errorpassthroughrule.FieldErrorCodes:
  20223. m.ClearErrorCodes()
  20224. return nil
  20225. case errorpassthroughrule.FieldKeywords:
  20226. m.ClearKeywords()
  20227. return nil
  20228. case errorpassthroughrule.FieldPlatforms:
  20229. m.ClearPlatforms()
  20230. return nil
  20231. case errorpassthroughrule.FieldResponseCode:
  20232. m.ClearResponseCode()
  20233. return nil
  20234. case errorpassthroughrule.FieldCustomMessage:
  20235. m.ClearCustomMessage()
  20236. return nil
  20237. case errorpassthroughrule.FieldDescription:
  20238. m.ClearDescription()
  20239. return nil
  20240. }
  20241. return fmt.Errorf("unknown ErrorPassthroughRule nullable field %s", name)
  20242. }
  20243. // ResetField resets all changes in the mutation for the field with the given name.
  20244. // It returns an error if the field is not defined in the schema.
  20245. func (m *ErrorPassthroughRuleMutation) ResetField(name string) error {
  20246. switch name {
  20247. case errorpassthroughrule.FieldCreatedAt:
  20248. m.ResetCreatedAt()
  20249. return nil
  20250. case errorpassthroughrule.FieldUpdatedAt:
  20251. m.ResetUpdatedAt()
  20252. return nil
  20253. case errorpassthroughrule.FieldName:
  20254. m.ResetName()
  20255. return nil
  20256. case errorpassthroughrule.FieldEnabled:
  20257. m.ResetEnabled()
  20258. return nil
  20259. case errorpassthroughrule.FieldPriority:
  20260. m.ResetPriority()
  20261. return nil
  20262. case errorpassthroughrule.FieldErrorCodes:
  20263. m.ResetErrorCodes()
  20264. return nil
  20265. case errorpassthroughrule.FieldKeywords:
  20266. m.ResetKeywords()
  20267. return nil
  20268. case errorpassthroughrule.FieldMatchMode:
  20269. m.ResetMatchMode()
  20270. return nil
  20271. case errorpassthroughrule.FieldPlatforms:
  20272. m.ResetPlatforms()
  20273. return nil
  20274. case errorpassthroughrule.FieldPassthroughCode:
  20275. m.ResetPassthroughCode()
  20276. return nil
  20277. case errorpassthroughrule.FieldResponseCode:
  20278. m.ResetResponseCode()
  20279. return nil
  20280. case errorpassthroughrule.FieldPassthroughBody:
  20281. m.ResetPassthroughBody()
  20282. return nil
  20283. case errorpassthroughrule.FieldCustomMessage:
  20284. m.ResetCustomMessage()
  20285. return nil
  20286. case errorpassthroughrule.FieldSkipMonitoring:
  20287. m.ResetSkipMonitoring()
  20288. return nil
  20289. case errorpassthroughrule.FieldDescription:
  20290. m.ResetDescription()
  20291. return nil
  20292. }
  20293. return fmt.Errorf("unknown ErrorPassthroughRule field %s", name)
  20294. }
  20295. // AddedEdges returns all edge names that were set/added in this mutation.
  20296. func (m *ErrorPassthroughRuleMutation) AddedEdges() []string {
  20297. edges := make([]string, 0, 0)
  20298. return edges
  20299. }
  20300. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  20301. // name in this mutation.
  20302. func (m *ErrorPassthroughRuleMutation) AddedIDs(name string) []ent.Value {
  20303. return nil
  20304. }
  20305. // RemovedEdges returns all edge names that were removed in this mutation.
  20306. func (m *ErrorPassthroughRuleMutation) RemovedEdges() []string {
  20307. edges := make([]string, 0, 0)
  20308. return edges
  20309. }
  20310. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  20311. // the given name in this mutation.
  20312. func (m *ErrorPassthroughRuleMutation) RemovedIDs(name string) []ent.Value {
  20313. return nil
  20314. }
  20315. // ClearedEdges returns all edge names that were cleared in this mutation.
  20316. func (m *ErrorPassthroughRuleMutation) ClearedEdges() []string {
  20317. edges := make([]string, 0, 0)
  20318. return edges
  20319. }
  20320. // EdgeCleared returns a boolean which indicates if the edge with the given name
  20321. // was cleared in this mutation.
  20322. func (m *ErrorPassthroughRuleMutation) EdgeCleared(name string) bool {
  20323. return false
  20324. }
  20325. // ClearEdge clears the value of the edge with the given name. It returns an error
  20326. // if that edge is not defined in the schema.
  20327. func (m *ErrorPassthroughRuleMutation) ClearEdge(name string) error {
  20328. return fmt.Errorf("unknown ErrorPassthroughRule unique edge %s", name)
  20329. }
  20330. // ResetEdge resets all changes to the edge with the given name in this mutation.
  20331. // It returns an error if the edge is not defined in the schema.
  20332. func (m *ErrorPassthroughRuleMutation) ResetEdge(name string) error {
  20333. return fmt.Errorf("unknown ErrorPassthroughRule edge %s", name)
  20334. }
  20335. // GroupMutation represents an operation that mutates the Group nodes in the graph.
  20336. type GroupMutation struct {
  20337. config
  20338. op Op
  20339. typ string
  20340. id *int64
  20341. created_at *time.Time
  20342. updated_at *time.Time
  20343. deleted_at *time.Time
  20344. name *string
  20345. description *string
  20346. rate_multiplier *float64
  20347. addrate_multiplier *float64
  20348. peak_rate_enabled *bool
  20349. peak_start *string
  20350. peak_end *string
  20351. peak_rate_multiplier *float64
  20352. addpeak_rate_multiplier *float64
  20353. is_exclusive *bool
  20354. security_policy_enabled *bool
  20355. security_policy_mode *string
  20356. security_policy_email_enabled *bool
  20357. status *string
  20358. duplicate_operation_id *string
  20359. platform *string
  20360. subscription_type *string
  20361. daily_limit_usd *float64
  20362. adddaily_limit_usd *float64
  20363. weekly_limit_usd *float64
  20364. addweekly_limit_usd *float64
  20365. monthly_limit_usd *float64
  20366. addmonthly_limit_usd *float64
  20367. default_validity_days *int
  20368. adddefault_validity_days *int
  20369. allow_image_generation *bool
  20370. allow_batch_image_generation *bool
  20371. image_rate_independent *bool
  20372. image_rate_multiplier *float64
  20373. addimage_rate_multiplier *float64
  20374. image_price_1k *float64
  20375. addimage_price_1k *float64
  20376. image_price_2k *float64
  20377. addimage_price_2k *float64
  20378. image_price_4k *float64
  20379. addimage_price_4k *float64
  20380. batch_image_discount_multiplier *float64
  20381. addbatch_image_discount_multiplier *float64
  20382. batch_image_hold_multiplier *float64
  20383. addbatch_image_hold_multiplier *float64
  20384. video_rate_independent *bool
  20385. video_rate_multiplier *float64
  20386. addvideo_rate_multiplier *float64
  20387. video_price_480p *float64
  20388. addvideo_price_480p *float64
  20389. video_price_720p *float64
  20390. addvideo_price_720p *float64
  20391. video_price_1080p *float64
  20392. addvideo_price_1080p *float64
  20393. video_model_prices *map[string]map[string]float64
  20394. web_search_price_per_call *float64
  20395. addweb_search_price_per_call *float64
  20396. search_price_per_1k *float64
  20397. addsearch_price_per_1k *float64
  20398. audio_realtime_price_per_min *float64
  20399. addaudio_realtime_price_per_min *float64
  20400. audio_tts_price_per_million_chars *float64
  20401. addaudio_tts_price_per_million_chars *float64
  20402. audio_stt_price_per_hour *float64
  20403. addaudio_stt_price_per_hour *float64
  20404. long_context_pricing_enabled *bool
  20405. model_pricing *jsontext.Value
  20406. appendmodel_pricing jsontext.Value
  20407. claude_code_only *bool
  20408. fallback_group_id *int64
  20409. addfallback_group_id *int64
  20410. fallback_group_id_on_invalid_request *int64
  20411. addfallback_group_id_on_invalid_request *int64
  20412. model_routing *map[string][]int64
  20413. model_routing_enabled *bool
  20414. mcp_xml_inject *bool
  20415. supported_model_scopes *[]string
  20416. appendsupported_model_scopes []string
  20417. sort_order *int
  20418. addsort_order *int
  20419. allow_messages_dispatch *bool
  20420. allow_live *bool
  20421. force_openai_fast *bool
  20422. free_openai_fast *bool
  20423. require_oauth_only *bool
  20424. require_privacy_set *bool
  20425. default_mapped_model *string
  20426. messages_dispatch_model_config *domain.OpenAIMessagesDispatchModelConfig
  20427. model_allowlist *domain.GroupModelAllowlist
  20428. codex_models_manifest_config *domain.GroupCodexModelsManifestConfig
  20429. rpm_limit *int
  20430. addrpm_limit *int
  20431. max_reasoning_effort *string
  20432. max_reasoning_effort_over_limit *string
  20433. reasoning_effort_mappings *[]domain.ReasoningEffortMapping
  20434. appendreasoning_effort_mappings []domain.ReasoningEffortMapping
  20435. profit_control_enabled *bool
  20436. profit_min_margin *float64
  20437. addprofit_min_margin *float64
  20438. profit_safety_buffer *float64
  20439. addprofit_safety_buffer *float64
  20440. clearedFields map[string]struct{}
  20441. api_keys map[int64]struct{}
  20442. removedapi_keys map[int64]struct{}
  20443. clearedapi_keys bool
  20444. redeem_codes map[int64]struct{}
  20445. removedredeem_codes map[int64]struct{}
  20446. clearedredeem_codes bool
  20447. subscriptions map[int64]struct{}
  20448. removedsubscriptions map[int64]struct{}
  20449. clearedsubscriptions bool
  20450. usage_logs map[int64]struct{}
  20451. removedusage_logs map[int64]struct{}
  20452. clearedusage_logs bool
  20453. accounts map[int64]struct{}
  20454. removedaccounts map[int64]struct{}
  20455. clearedaccounts bool
  20456. allowed_users map[int64]struct{}
  20457. removedallowed_users map[int64]struct{}
  20458. clearedallowed_users bool
  20459. done bool
  20460. oldValue func(context.Context) (*Group, error)
  20461. predicates []predicate.Group
  20462. }
  20463. var _ ent.Mutation = (*GroupMutation)(nil)
  20464. // groupOption allows management of the mutation configuration using functional options.
  20465. type groupOption func(*GroupMutation)
  20466. // newGroupMutation creates new mutation for the Group entity.
  20467. func newGroupMutation(c config, op Op, opts ...groupOption) *GroupMutation {
  20468. m := &GroupMutation{
  20469. config: c,
  20470. op: op,
  20471. typ: TypeGroup,
  20472. clearedFields: make(map[string]struct{}),
  20473. }
  20474. for _, opt := range opts {
  20475. opt(m)
  20476. }
  20477. return m
  20478. }
  20479. // withGroupID sets the ID field of the mutation.
  20480. func withGroupID(id int64) groupOption {
  20481. return func(m *GroupMutation) {
  20482. var (
  20483. err error
  20484. once sync.Once
  20485. value *Group
  20486. )
  20487. m.oldValue = func(ctx context.Context) (*Group, error) {
  20488. once.Do(func() {
  20489. if m.done {
  20490. err = errors.New("querying old values post mutation is not allowed")
  20491. } else {
  20492. value, err = m.Client().Group.Get(ctx, id)
  20493. }
  20494. })
  20495. return value, err
  20496. }
  20497. m.id = &id
  20498. }
  20499. }
  20500. // withGroup sets the old Group of the mutation.
  20501. func withGroup(node *Group) groupOption {
  20502. return func(m *GroupMutation) {
  20503. m.oldValue = func(context.Context) (*Group, error) {
  20504. return node, nil
  20505. }
  20506. m.id = &node.ID
  20507. }
  20508. }
  20509. // Client returns a new `ent.Client` from the mutation. If the mutation was
  20510. // executed in a transaction (ent.Tx), a transactional client is returned.
  20511. func (m GroupMutation) Client() *Client {
  20512. client := &Client{config: m.config}
  20513. client.init()
  20514. return client
  20515. }
  20516. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  20517. // it returns an error otherwise.
  20518. func (m GroupMutation) Tx() (*Tx, error) {
  20519. if _, ok := m.driver.(*txDriver); !ok {
  20520. return nil, errors.New("ent: mutation is not running in a transaction")
  20521. }
  20522. tx := &Tx{config: m.config}
  20523. tx.init()
  20524. return tx, nil
  20525. }
  20526. // ID returns the ID value in the mutation. Note that the ID is only available
  20527. // if it was provided to the builder or after it was returned from the database.
  20528. func (m *GroupMutation) ID() (id int64, exists bool) {
  20529. if m.id == nil {
  20530. return
  20531. }
  20532. return *m.id, true
  20533. }
  20534. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  20535. // That means, if the mutation is applied within a transaction with an isolation level such
  20536. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  20537. // or updated by the mutation.
  20538. func (m *GroupMutation) IDs(ctx context.Context) ([]int64, error) {
  20539. switch {
  20540. case m.op.Is(OpUpdateOne | OpDeleteOne):
  20541. id, exists := m.ID()
  20542. if exists {
  20543. return []int64{id}, nil
  20544. }
  20545. fallthrough
  20546. case m.op.Is(OpUpdate | OpDelete):
  20547. return m.Client().Group.Query().Where(m.predicates...).IDs(ctx)
  20548. default:
  20549. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  20550. }
  20551. }
  20552. // SetCreatedAt sets the "created_at" field.
  20553. func (m *GroupMutation) SetCreatedAt(t time.Time) {
  20554. m.created_at = &t
  20555. }
  20556. // CreatedAt returns the value of the "created_at" field in the mutation.
  20557. func (m *GroupMutation) CreatedAt() (r time.Time, exists bool) {
  20558. v := m.created_at
  20559. if v == nil {
  20560. return
  20561. }
  20562. return *v, true
  20563. }
  20564. // OldCreatedAt returns the old "created_at" field's value of the Group entity.
  20565. // If the Group object wasn't provided to the builder, the object is fetched from the database.
  20566. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20567. func (m *GroupMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  20568. if !m.op.Is(OpUpdateOne) {
  20569. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  20570. }
  20571. if m.id == nil || m.oldValue == nil {
  20572. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  20573. }
  20574. oldValue, err := m.oldValue(ctx)
  20575. if err != nil {
  20576. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  20577. }
  20578. return oldValue.CreatedAt, nil
  20579. }
  20580. // ResetCreatedAt resets all changes to the "created_at" field.
  20581. func (m *GroupMutation) ResetCreatedAt() {
  20582. m.created_at = nil
  20583. }
  20584. // SetUpdatedAt sets the "updated_at" field.
  20585. func (m *GroupMutation) SetUpdatedAt(t time.Time) {
  20586. m.updated_at = &t
  20587. }
  20588. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  20589. func (m *GroupMutation) UpdatedAt() (r time.Time, exists bool) {
  20590. v := m.updated_at
  20591. if v == nil {
  20592. return
  20593. }
  20594. return *v, true
  20595. }
  20596. // OldUpdatedAt returns the old "updated_at" field's value of the Group entity.
  20597. // If the Group object wasn't provided to the builder, the object is fetched from the database.
  20598. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20599. func (m *GroupMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  20600. if !m.op.Is(OpUpdateOne) {
  20601. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  20602. }
  20603. if m.id == nil || m.oldValue == nil {
  20604. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  20605. }
  20606. oldValue, err := m.oldValue(ctx)
  20607. if err != nil {
  20608. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  20609. }
  20610. return oldValue.UpdatedAt, nil
  20611. }
  20612. // ResetUpdatedAt resets all changes to the "updated_at" field.
  20613. func (m *GroupMutation) ResetUpdatedAt() {
  20614. m.updated_at = nil
  20615. }
  20616. // SetDeletedAt sets the "deleted_at" field.
  20617. func (m *GroupMutation) SetDeletedAt(t time.Time) {
  20618. m.deleted_at = &t
  20619. }
  20620. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  20621. func (m *GroupMutation) DeletedAt() (r time.Time, exists bool) {
  20622. v := m.deleted_at
  20623. if v == nil {
  20624. return
  20625. }
  20626. return *v, true
  20627. }
  20628. // OldDeletedAt returns the old "deleted_at" field's value of the Group entity.
  20629. // If the Group object wasn't provided to the builder, the object is fetched from the database.
  20630. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20631. func (m *GroupMutation) OldDeletedAt(ctx context.Context) (v *time.Time, err error) {
  20632. if !m.op.Is(OpUpdateOne) {
  20633. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  20634. }
  20635. if m.id == nil || m.oldValue == nil {
  20636. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  20637. }
  20638. oldValue, err := m.oldValue(ctx)
  20639. if err != nil {
  20640. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  20641. }
  20642. return oldValue.DeletedAt, nil
  20643. }
  20644. // ClearDeletedAt clears the value of the "deleted_at" field.
  20645. func (m *GroupMutation) ClearDeletedAt() {
  20646. m.deleted_at = nil
  20647. m.clearedFields[group.FieldDeletedAt] = struct{}{}
  20648. }
  20649. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  20650. func (m *GroupMutation) DeletedAtCleared() bool {
  20651. _, ok := m.clearedFields[group.FieldDeletedAt]
  20652. return ok
  20653. }
  20654. // ResetDeletedAt resets all changes to the "deleted_at" field.
  20655. func (m *GroupMutation) ResetDeletedAt() {
  20656. m.deleted_at = nil
  20657. delete(m.clearedFields, group.FieldDeletedAt)
  20658. }
  20659. // SetName sets the "name" field.
  20660. func (m *GroupMutation) SetName(s string) {
  20661. m.name = &s
  20662. }
  20663. // Name returns the value of the "name" field in the mutation.
  20664. func (m *GroupMutation) Name() (r string, exists bool) {
  20665. v := m.name
  20666. if v == nil {
  20667. return
  20668. }
  20669. return *v, true
  20670. }
  20671. // OldName returns the old "name" field's value of the Group entity.
  20672. // If the Group object wasn't provided to the builder, the object is fetched from the database.
  20673. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20674. func (m *GroupMutation) OldName(ctx context.Context) (v string, err error) {
  20675. if !m.op.Is(OpUpdateOne) {
  20676. return v, errors.New("OldName is only allowed on UpdateOne operations")
  20677. }
  20678. if m.id == nil || m.oldValue == nil {
  20679. return v, errors.New("OldName requires an ID field in the mutation")
  20680. }
  20681. oldValue, err := m.oldValue(ctx)
  20682. if err != nil {
  20683. return v, fmt.Errorf("querying old value for OldName: %w", err)
  20684. }
  20685. return oldValue.Name, nil
  20686. }
  20687. // ResetName resets all changes to the "name" field.
  20688. func (m *GroupMutation) ResetName() {
  20689. m.name = nil
  20690. }
  20691. // SetDescription sets the "description" field.
  20692. func (m *GroupMutation) SetDescription(s string) {
  20693. m.description = &s
  20694. }
  20695. // Description returns the value of the "description" field in the mutation.
  20696. func (m *GroupMutation) Description() (r string, exists bool) {
  20697. v := m.description
  20698. if v == nil {
  20699. return
  20700. }
  20701. return *v, true
  20702. }
  20703. // OldDescription returns the old "description" field's value of the Group entity.
  20704. // If the Group object wasn't provided to the builder, the object is fetched from the database.
  20705. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20706. func (m *GroupMutation) OldDescription(ctx context.Context) (v *string, err error) {
  20707. if !m.op.Is(OpUpdateOne) {
  20708. return v, errors.New("OldDescription is only allowed on UpdateOne operations")
  20709. }
  20710. if m.id == nil || m.oldValue == nil {
  20711. return v, errors.New("OldDescription requires an ID field in the mutation")
  20712. }
  20713. oldValue, err := m.oldValue(ctx)
  20714. if err != nil {
  20715. return v, fmt.Errorf("querying old value for OldDescription: %w", err)
  20716. }
  20717. return oldValue.Description, nil
  20718. }
  20719. // ClearDescription clears the value of the "description" field.
  20720. func (m *GroupMutation) ClearDescription() {
  20721. m.description = nil
  20722. m.clearedFields[group.FieldDescription] = struct{}{}
  20723. }
  20724. // DescriptionCleared returns if the "description" field was cleared in this mutation.
  20725. func (m *GroupMutation) DescriptionCleared() bool {
  20726. _, ok := m.clearedFields[group.FieldDescription]
  20727. return ok
  20728. }
  20729. // ResetDescription resets all changes to the "description" field.
  20730. func (m *GroupMutation) ResetDescription() {
  20731. m.description = nil
  20732. delete(m.clearedFields, group.FieldDescription)
  20733. }
  20734. // SetRateMultiplier sets the "rate_multiplier" field.
  20735. func (m *GroupMutation) SetRateMultiplier(f float64) {
  20736. m.rate_multiplier = &f
  20737. m.addrate_multiplier = nil
  20738. }
  20739. // RateMultiplier returns the value of the "rate_multiplier" field in the mutation.
  20740. func (m *GroupMutation) RateMultiplier() (r float64, exists bool) {
  20741. v := m.rate_multiplier
  20742. if v == nil {
  20743. return
  20744. }
  20745. return *v, true
  20746. }
  20747. // OldRateMultiplier returns the old "rate_multiplier" field's value of the Group entity.
  20748. // If the Group object wasn't provided to the builder, the object is fetched from the database.
  20749. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20750. func (m *GroupMutation) OldRateMultiplier(ctx context.Context) (v float64, err error) {
  20751. if !m.op.Is(OpUpdateOne) {
  20752. return v, errors.New("OldRateMultiplier is only allowed on UpdateOne operations")
  20753. }
  20754. if m.id == nil || m.oldValue == nil {
  20755. return v, errors.New("OldRateMultiplier requires an ID field in the mutation")
  20756. }
  20757. oldValue, err := m.oldValue(ctx)
  20758. if err != nil {
  20759. return v, fmt.Errorf("querying old value for OldRateMultiplier: %w", err)
  20760. }
  20761. return oldValue.RateMultiplier, nil
  20762. }
  20763. // AddRateMultiplier adds f to the "rate_multiplier" field.
  20764. func (m *GroupMutation) AddRateMultiplier(f float64) {
  20765. if m.addrate_multiplier != nil {
  20766. *m.addrate_multiplier += f
  20767. } else {
  20768. m.addrate_multiplier = &f
  20769. }
  20770. }
  20771. // AddedRateMultiplier returns the value that was added to the "rate_multiplier" field in this mutation.
  20772. func (m *GroupMutation) AddedRateMultiplier() (r float64, exists bool) {
  20773. v := m.addrate_multiplier
  20774. if v == nil {
  20775. return
  20776. }
  20777. return *v, true
  20778. }
  20779. // ResetRateMultiplier resets all changes to the "rate_multiplier" field.
  20780. func (m *GroupMutation) ResetRateMultiplier() {
  20781. m.rate_multiplier = nil
  20782. m.addrate_multiplier = nil
  20783. }
  20784. // SetPeakRateEnabled sets the "peak_rate_enabled" field.
  20785. func (m *GroupMutation) SetPeakRateEnabled(b bool) {
  20786. m.peak_rate_enabled = &b
  20787. }
  20788. // PeakRateEnabled returns the value of the "peak_rate_enabled" field in the mutation.
  20789. func (m *GroupMutation) PeakRateEnabled() (r bool, exists bool) {
  20790. v := m.peak_rate_enabled
  20791. if v == nil {
  20792. return
  20793. }
  20794. return *v, true
  20795. }
  20796. // OldPeakRateEnabled returns the old "peak_rate_enabled" field's value of the Group entity.
  20797. // If the Group object wasn't provided to the builder, the object is fetched from the database.
  20798. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20799. func (m *GroupMutation) OldPeakRateEnabled(ctx context.Context) (v bool, err error) {
  20800. if !m.op.Is(OpUpdateOne) {
  20801. return v, errors.New("OldPeakRateEnabled is only allowed on UpdateOne operations")
  20802. }
  20803. if m.id == nil || m.oldValue == nil {
  20804. return v, errors.New("OldPeakRateEnabled requires an ID field in the mutation")
  20805. }
  20806. oldValue, err := m.oldValue(ctx)
  20807. if err != nil {
  20808. return v, fmt.Errorf("querying old value for OldPeakRateEnabled: %w", err)
  20809. }
  20810. return oldValue.PeakRateEnabled, nil
  20811. }
  20812. // ResetPeakRateEnabled resets all changes to the "peak_rate_enabled" field.
  20813. func (m *GroupMutation) ResetPeakRateEnabled() {
  20814. m.peak_rate_enabled = nil
  20815. }
  20816. // SetPeakStart sets the "peak_start" field.
  20817. func (m *GroupMutation) SetPeakStart(s string) {
  20818. m.peak_start = &s
  20819. }
  20820. // PeakStart returns the value of the "peak_start" field in the mutation.
  20821. func (m *GroupMutation) PeakStart() (r string, exists bool) {
  20822. v := m.peak_start
  20823. if v == nil {
  20824. return
  20825. }
  20826. return *v, true
  20827. }
  20828. // OldPeakStart returns the old "peak_start" field's value of the Group entity.
  20829. // If the Group object wasn't provided to the builder, the object is fetched from the database.
  20830. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20831. func (m *GroupMutation) OldPeakStart(ctx context.Context) (v string, err error) {
  20832. if !m.op.Is(OpUpdateOne) {
  20833. return v, errors.New("OldPeakStart is only allowed on UpdateOne operations")
  20834. }
  20835. if m.id == nil || m.oldValue == nil {
  20836. return v, errors.New("OldPeakStart requires an ID field in the mutation")
  20837. }
  20838. oldValue, err := m.oldValue(ctx)
  20839. if err != nil {
  20840. return v, fmt.Errorf("querying old value for OldPeakStart: %w", err)
  20841. }
  20842. return oldValue.PeakStart, nil
  20843. }
  20844. // ResetPeakStart resets all changes to the "peak_start" field.
  20845. func (m *GroupMutation) ResetPeakStart() {
  20846. m.peak_start = nil
  20847. }
  20848. // SetPeakEnd sets the "peak_end" field.
  20849. func (m *GroupMutation) SetPeakEnd(s string) {
  20850. m.peak_end = &s
  20851. }
  20852. // PeakEnd returns the value of the "peak_end" field in the mutation.
  20853. func (m *GroupMutation) PeakEnd() (r string, exists bool) {
  20854. v := m.peak_end
  20855. if v == nil {
  20856. return
  20857. }
  20858. return *v, true
  20859. }
  20860. // OldPeakEnd returns the old "peak_end" field's value of the Group entity.
  20861. // If the Group object wasn't provided to the builder, the object is fetched from the database.
  20862. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20863. func (m *GroupMutation) OldPeakEnd(ctx context.Context) (v string, err error) {
  20864. if !m.op.Is(OpUpdateOne) {
  20865. return v, errors.New("OldPeakEnd is only allowed on UpdateOne operations")
  20866. }
  20867. if m.id == nil || m.oldValue == nil {
  20868. return v, errors.New("OldPeakEnd requires an ID field in the mutation")
  20869. }
  20870. oldValue, err := m.oldValue(ctx)
  20871. if err != nil {
  20872. return v, fmt.Errorf("querying old value for OldPeakEnd: %w", err)
  20873. }
  20874. return oldValue.PeakEnd, nil
  20875. }
  20876. // ResetPeakEnd resets all changes to the "peak_end" field.
  20877. func (m *GroupMutation) ResetPeakEnd() {
  20878. m.peak_end = nil
  20879. }
  20880. // SetPeakRateMultiplier sets the "peak_rate_multiplier" field.
  20881. func (m *GroupMutation) SetPeakRateMultiplier(f float64) {
  20882. m.peak_rate_multiplier = &f
  20883. m.addpeak_rate_multiplier = nil
  20884. }
  20885. // PeakRateMultiplier returns the value of the "peak_rate_multiplier" field in the mutation.
  20886. func (m *GroupMutation) PeakRateMultiplier() (r float64, exists bool) {
  20887. v := m.peak_rate_multiplier
  20888. if v == nil {
  20889. return
  20890. }
  20891. return *v, true
  20892. }
  20893. // OldPeakRateMultiplier returns the old "peak_rate_multiplier" field's value of the Group entity.
  20894. // If the Group object wasn't provided to the builder, the object is fetched from the database.
  20895. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20896. func (m *GroupMutation) OldPeakRateMultiplier(ctx context.Context) (v float64, err error) {
  20897. if !m.op.Is(OpUpdateOne) {
  20898. return v, errors.New("OldPeakRateMultiplier is only allowed on UpdateOne operations")
  20899. }
  20900. if m.id == nil || m.oldValue == nil {
  20901. return v, errors.New("OldPeakRateMultiplier requires an ID field in the mutation")
  20902. }
  20903. oldValue, err := m.oldValue(ctx)
  20904. if err != nil {
  20905. return v, fmt.Errorf("querying old value for OldPeakRateMultiplier: %w", err)
  20906. }
  20907. return oldValue.PeakRateMultiplier, nil
  20908. }
  20909. // AddPeakRateMultiplier adds f to the "peak_rate_multiplier" field.
  20910. func (m *GroupMutation) AddPeakRateMultiplier(f float64) {
  20911. if m.addpeak_rate_multiplier != nil {
  20912. *m.addpeak_rate_multiplier += f
  20913. } else {
  20914. m.addpeak_rate_multiplier = &f
  20915. }
  20916. }
  20917. // AddedPeakRateMultiplier returns the value that was added to the "peak_rate_multiplier" field in this mutation.
  20918. func (m *GroupMutation) AddedPeakRateMultiplier() (r float64, exists bool) {
  20919. v := m.addpeak_rate_multiplier
  20920. if v == nil {
  20921. return
  20922. }
  20923. return *v, true
  20924. }
  20925. // ResetPeakRateMultiplier resets all changes to the "peak_rate_multiplier" field.
  20926. func (m *GroupMutation) ResetPeakRateMultiplier() {
  20927. m.peak_rate_multiplier = nil
  20928. m.addpeak_rate_multiplier = nil
  20929. }
  20930. // SetIsExclusive sets the "is_exclusive" field.
  20931. func (m *GroupMutation) SetIsExclusive(b bool) {
  20932. m.is_exclusive = &b
  20933. }
  20934. // IsExclusive returns the value of the "is_exclusive" field in the mutation.
  20935. func (m *GroupMutation) IsExclusive() (r bool, exists bool) {
  20936. v := m.is_exclusive
  20937. if v == nil {
  20938. return
  20939. }
  20940. return *v, true
  20941. }
  20942. // OldIsExclusive returns the old "is_exclusive" field's value of the Group entity.
  20943. // If the Group object wasn't provided to the builder, the object is fetched from the database.
  20944. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20945. func (m *GroupMutation) OldIsExclusive(ctx context.Context) (v bool, err error) {
  20946. if !m.op.Is(OpUpdateOne) {
  20947. return v, errors.New("OldIsExclusive is only allowed on UpdateOne operations")
  20948. }
  20949. if m.id == nil || m.oldValue == nil {
  20950. return v, errors.New("OldIsExclusive requires an ID field in the mutation")
  20951. }
  20952. oldValue, err := m.oldValue(ctx)
  20953. if err != nil {
  20954. return v, fmt.Errorf("querying old value for OldIsExclusive: %w", err)
  20955. }
  20956. return oldValue.IsExclusive, nil
  20957. }
  20958. // ResetIsExclusive resets all changes to the "is_exclusive" field.
  20959. func (m *GroupMutation) ResetIsExclusive() {
  20960. m.is_exclusive = nil
  20961. }
  20962. // SetSecurityPolicyEnabled sets the "security_policy_enabled" field.
  20963. func (m *GroupMutation) SetSecurityPolicyEnabled(b bool) {
  20964. m.security_policy_enabled = &b
  20965. }
  20966. // SecurityPolicyEnabled returns the value of the "security_policy_enabled" field in the mutation.
  20967. func (m *GroupMutation) SecurityPolicyEnabled() (r bool, exists bool) {
  20968. v := m.security_policy_enabled
  20969. if v == nil {
  20970. return
  20971. }
  20972. return *v, true
  20973. }
  20974. // OldSecurityPolicyEnabled returns the old "security_policy_enabled" field's value of the Group entity.
  20975. // If the Group object wasn't provided to the builder, the object is fetched from the database.
  20976. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20977. func (m *GroupMutation) OldSecurityPolicyEnabled(ctx context.Context) (v bool, err error) {
  20978. if !m.op.Is(OpUpdateOne) {
  20979. return v, errors.New("OldSecurityPolicyEnabled is only allowed on UpdateOne operations")
  20980. }
  20981. if m.id == nil || m.oldValue == nil {
  20982. return v, errors.New("OldSecurityPolicyEnabled requires an ID field in the mutation")
  20983. }
  20984. oldValue, err := m.oldValue(ctx)
  20985. if err != nil {
  20986. return v, fmt.Errorf("querying old value for OldSecurityPolicyEnabled: %w", err)
  20987. }
  20988. return oldValue.SecurityPolicyEnabled, nil
  20989. }
  20990. // ResetSecurityPolicyEnabled resets all changes to the "security_policy_enabled" field.
  20991. func (m *GroupMutation) ResetSecurityPolicyEnabled() {
  20992. m.security_policy_enabled = nil
  20993. }
  20994. // SetSecurityPolicyMode sets the "security_policy_mode" field.
  20995. func (m *GroupMutation) SetSecurityPolicyMode(s string) {
  20996. m.security_policy_mode = &s
  20997. }
  20998. // SecurityPolicyMode returns the value of the "security_policy_mode" field in the mutation.
  20999. func (m *GroupMutation) SecurityPolicyMode() (r string, exists bool) {
  21000. v := m.security_policy_mode
  21001. if v == nil {
  21002. return
  21003. }
  21004. return *v, true
  21005. }
  21006. // OldSecurityPolicyMode returns the old "security_policy_mode" field's value of the Group entity.
  21007. // If the Group object wasn't provided to the builder, the object is fetched from the database.
  21008. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21009. func (m *GroupMutation) OldSecurityPolicyMode(ctx context.Context) (v string, err error) {
  21010. if !m.op.Is(OpUpdateOne) {
  21011. return v, errors.New("OldSecurityPolicyMode is only allowed on UpdateOne operations")
  21012. }
  21013. if m.id == nil || m.oldValue == nil {
  21014. return v, errors.New("OldSecurityPolicyMode requires an ID field in the mutation")
  21015. }
  21016. oldValue, err := m.oldValue(ctx)
  21017. if err != nil {
  21018. return v, fmt.Errorf("querying old value for OldSecurityPolicyMode: %w", err)
  21019. }
  21020. return oldValue.SecurityPolicyMode, nil
  21021. }
  21022. // ResetSecurityPolicyMode resets all changes to the "security_policy_mode" field.
  21023. func (m *GroupMutation) ResetSecurityPolicyMode() {
  21024. m.security_policy_mode = nil
  21025. }
  21026. // SetSecurityPolicyEmailEnabled sets the "security_policy_email_enabled" field.
  21027. func (m *GroupMutation) SetSecurityPolicyEmailEnabled(b bool) {
  21028. m.security_policy_email_enabled = &b
  21029. }
  21030. // SecurityPolicyEmailEnabled returns the value of the "security_policy_email_enabled" field in the mutation.
  21031. func (m *GroupMutation) SecurityPolicyEmailEnabled() (r bool, exists bool) {
  21032. v := m.security_policy_email_enabled
  21033. if v == nil {
  21034. return
  21035. }
  21036. return *v, true
  21037. }
  21038. // OldSecurityPolicyEmailEnabled returns the old "security_policy_email_enabled" field's value of the Group entity.
  21039. // If the Group object wasn't provided to the builder, the object is fetched from the database.
  21040. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21041. func (m *GroupMutation) OldSecurityPolicyEmailEnabled(ctx context.Context) (v bool, err error) {
  21042. if !m.op.Is(OpUpdateOne) {
  21043. return v, errors.New("OldSecurityPolicyEmailEnabled is only allowed on UpdateOne operations")
  21044. }
  21045. if m.id == nil || m.oldValue == nil {
  21046. return v, errors.New("OldSecurityPolicyEmailEnabled requires an ID field in the mutation")
  21047. }
  21048. oldValue, err := m.oldValue(ctx)
  21049. if err != nil {
  21050. return v, fmt.Errorf("querying old value for OldSecurityPolicyEmailEnabled: %w", err)
  21051. }
  21052. return oldValue.SecurityPolicyEmailEnabled, nil
  21053. }
  21054. // ResetSecurityPolicyEmailEnabled resets all changes to the "security_policy_email_enabled" field.
  21055. func (m *GroupMutation) ResetSecurityPolicyEmailEnabled() {
  21056. m.security_policy_email_enabled = nil
  21057. }
  21058. // SetStatus sets the "status" field.
  21059. func (m *GroupMutation) SetStatus(s string) {
  21060. m.status = &s
  21061. }
  21062. // Status returns the value of the "status" field in the mutation.
  21063. func (m *GroupMutation) Status() (r string, exists bool) {
  21064. v := m.status
  21065. if v == nil {
  21066. return
  21067. }
  21068. return *v, true
  21069. }
  21070. // OldStatus returns the old "status" field's value of the Group entity.
  21071. // If the Group object wasn't provided to the builder, the object is fetched from the database.
  21072. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21073. func (m *GroupMutation) OldStatus(ctx context.Context) (v string, err error) {
  21074. if !m.op.Is(OpUpdateOne) {
  21075. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  21076. }
  21077. if m.id == nil || m.oldValue == nil {
  21078. return v, errors.New("OldStatus requires an ID field in the mutation")
  21079. }
  21080. oldValue, err := m.oldValue(ctx)
  21081. if err != nil {
  21082. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  21083. }
  21084. return oldValue.Status, nil
  21085. }
  21086. // ResetStatus resets all changes to the "status" field.
  21087. func (m *GroupMutation) ResetStatus() {
  21088. m.status = nil
  21089. }
  21090. // SetDuplicateOperationID sets the "duplicate_operation_id" field.
  21091. func (m *GroupMutation) SetDuplicateOperationID(s string) {
  21092. m.duplicate_operation_id = &s
  21093. }
  21094. // DuplicateOperationID returns the value of the "duplicate_operation_id" field in the mutation.
  21095. func (m *GroupMutation) DuplicateOperationID() (r string, exists bool) {
  21096. v := m.duplicate_operation_id
  21097. if v == nil {
  21098. return
  21099. }
  21100. return *v, true
  21101. }
  21102. // OldDuplicateOperationID returns the old "duplicate_operation_id" field's value of the Group entity.
  21103. // If the Group object wasn't provided to the builder, the object is fetched from the database.
  21104. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21105. func (m *GroupMutation) OldDuplicateOperationID(ctx context.Context) (v *string, err error) {
  21106. if !m.op.Is(OpUpdateOne) {
  21107. return v, errors.New("OldDuplicateOperationID is only allowed on UpdateOne operations")
  21108. }
  21109. if m.id == nil || m.oldValue == nil {
  21110. return v, errors.New("OldDuplicateOperationID requires an ID field in the mutation")
  21111. }
  21112. oldValue, err := m.oldValue(ctx)
  21113. if err != nil {
  21114. return v, fmt.Errorf("querying old value for OldDuplicateOperationID: %w", err)
  21115. }
  21116. return oldValue.DuplicateOperationID, nil
  21117. }
  21118. // ClearDuplicateOperationID clears the value of the "duplicate_operation_id" field.
  21119. func (m *GroupMutation) ClearDuplicateOperationID() {
  21120. m.duplicate_operation_id = nil
  21121. m.clearedFields[group.FieldDuplicateOperationID] = struct{}{}
  21122. }
  21123. // DuplicateOperationIDCleared returns if the "duplicate_operation_id" field was cleared in this mutation.
  21124. func (m *GroupMutation) DuplicateOperationIDCleared() bool {
  21125. _, ok := m.clearedFields[group.FieldDuplicateOperationID]
  21126. return ok
  21127. }
  21128. // ResetDuplicateOperationID resets all changes to the "duplicate_operation_id" field.
  21129. func (m *GroupMutation) ResetDuplicateOperationID() {
  21130. m.duplicate_operation_id = nil
  21131. delete(m.clearedFields, group.FieldDuplicateOperationID)
  21132. }
  21133. // SetPlatform sets the "platform" field.
  21134. func (m *GroupMutation) SetPlatform(s string) {
  21135. m.platform = &s
  21136. }
  21137. // Platform returns the value of the "platform" field in the mutation.
  21138. func (m *GroupMutation) Platform() (r string, exists bool) {
  21139. v := m.platform
  21140. if v == nil {
  21141. return
  21142. }
  21143. return *v, true
  21144. }
  21145. // OldPlatform returns the old "platform" field's value of the Group entity.
  21146. // If the Group object wasn't provided to the builder, the object is fetched from the database.
  21147. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21148. func (m *GroupMutation) OldPlatform(ctx context.Context) (v string, err error) {
  21149. if !m.op.Is(OpUpdateOne) {
  21150. return v, errors.New("OldPlatform is only allowed on UpdateOne operations")
  21151. }
  21152. if m.id == nil || m.oldValue == nil {
  21153. return v, errors.New("OldPlatform requires an ID field in the mutation")
  21154. }
  21155. oldValue, err := m.oldValue(ctx)
  21156. if err != nil {
  21157. return v, fmt.Errorf("querying old value for OldPlatform: %w", err)
  21158. }
  21159. return oldValue.Platform, nil
  21160. }
  21161. // ResetPlatform resets all changes to the "platform" field.
  21162. func (m *GroupMutation) ResetPlatform() {
  21163. m.platform = nil
  21164. }
  21165. // SetSubscriptionType sets the "subscription_type" field.
  21166. func (m *GroupMutation) SetSubscriptionType(s string) {
  21167. m.subscription_type = &s
  21168. }
  21169. // SubscriptionType returns the value of the "subscription_type" field in the mutation.
  21170. func (m *GroupMutation) SubscriptionType() (r string, exists bool) {
  21171. v := m.subscription_type
  21172. if v == nil {
  21173. return
  21174. }
  21175. return *v, true
  21176. }
  21177. // OldSubscriptionType returns the old "subscription_type" field's value of the Group entity.
  21178. // If the Group object wasn't provided to the builder, the object is fetched from the database.
  21179. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21180. func (m *GroupMutation) OldSubscriptionType(ctx context.Context) (v string, err error) {
  21181. if !m.op.Is(OpUpdateOne) {
  21182. return v, errors.New("OldSubscriptionType is only allowed on UpdateOne operations")
  21183. }
  21184. if m.id == nil || m.oldValue == nil {
  21185. return v, errors.New("OldSubscriptionType requires an ID field in the mutation")
  21186. }
  21187. oldValue, err := m.oldValue(ctx)
  21188. if err != nil {
  21189. return v, fmt.Errorf("querying old value for OldSubscriptionType: %w", err)
  21190. }
  21191. return oldValue.SubscriptionType, nil
  21192. }
  21193. // ResetSubscriptionType resets all changes to the "subscription_type" field.
  21194. func (m *GroupMutation) ResetSubscriptionType() {
  21195. m.subscription_type = nil
  21196. }
  21197. // SetDailyLimitUsd sets the "daily_limit_usd" field.
  21198. func (m *GroupMutation) SetDailyLimitUsd(f float64) {
  21199. m.daily_limit_usd = &f
  21200. m.adddaily_limit_usd = nil
  21201. }
  21202. // DailyLimitUsd returns the value of the "daily_limit_usd" field in the mutation.
  21203. func (m *GroupMutation) DailyLimitUsd() (r float64, exists bool) {
  21204. v := m.daily_limit_usd
  21205. if v == nil {
  21206. return
  21207. }
  21208. return *v, true
  21209. }
  21210. // OldDailyLimitUsd returns the old "daily_limit_usd" field's value of the Group entity.
  21211. // If the Group object wasn't provided to the builder, the object is fetched from the database.
  21212. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21213. func (m *GroupMutation) OldDailyLimitUsd(ctx context.Context) (v *float64, err error) {
  21214. if !m.op.Is(OpUpdateOne) {
  21215. return v, errors.New("OldDailyLimitUsd is only allowed on UpdateOne operations")
  21216. }
  21217. if m.id == nil || m.oldValue == nil {
  21218. return v, errors.New("OldDailyLimitUsd requires an ID field in the mutation")
  21219. }
  21220. oldValue, err := m.oldValue(ctx)
  21221. if err != nil {
  21222. return v, fmt.Errorf("querying old value for OldDailyLimitUsd: %w", err)
  21223. }
  21224. return oldValue.DailyLimitUsd, nil
  21225. }
  21226. // AddDailyLimitUsd adds f to the "daily_limit_usd" field.
  21227. func (m *GroupMutation) AddDailyLimitUsd(f float64) {
  21228. if m.adddaily_limit_usd != nil {
  21229. *m.adddaily_limit_usd += f
  21230. } else {
  21231. m.adddaily_limit_usd = &f
  21232. }
  21233. }
  21234. // AddedDailyLimitUsd returns the value that was added to the "daily_limit_usd" field in this mutation.
  21235. func (m *GroupMutation) AddedDailyLimitUsd() (r float64, exists bool) {
  21236. v := m.adddaily_limit_usd
  21237. if v == nil {
  21238. return
  21239. }
  21240. return *v, true
  21241. }
  21242. // ClearDailyLimitUsd clears the value of the "daily_limit_usd" field.
  21243. func (m *GroupMutation) ClearDailyLimitUsd() {
  21244. m.daily_limit_usd = nil
  21245. m.adddaily_limit_usd = nil
  21246. m.clearedFields[group.FieldDailyLimitUsd] = struct{}{}
  21247. }
  21248. // DailyLimitUsdCleared returns if the "daily_limit_usd" field was cleared in this mutation.
  21249. func (m *GroupMutation) DailyLimitUsdCleared() bool {
  21250. _, ok := m.clearedFields[group.FieldDailyLimitUsd]
  21251. return ok
  21252. }
  21253. // ResetDailyLimitUsd resets all changes to the "daily_limit_usd" field.
  21254. func (m *GroupMutation) ResetDailyLimitUsd() {
  21255. m.daily_limit_usd = nil
  21256. m.adddaily_limit_usd = nil
  21257. delete(m.clearedFields, group.FieldDailyLimitUsd)
  21258. }
  21259. // SetWeeklyLimitUsd sets the "weekly_limit_usd" field.
  21260. func (m *GroupMutation) SetWeeklyLimitUsd(f float64) {
  21261. m.weekly_limit_usd = &f
  21262. m.addweekly_limit_usd = nil
  21263. }
  21264. // WeeklyLimitUsd returns the value of the "weekly_limit_usd" field in the mutation.
  21265. func (m *GroupMutation) WeeklyLimitUsd() (r float64, exists bool) {
  21266. v := m.weekly_limit_usd
  21267. if v == nil {
  21268. return
  21269. }
  21270. return *v, true
  21271. }
  21272. // OldWeeklyLimitUsd returns the old "weekly_limit_usd" field's value of the Group entity.
  21273. // If the Group object wasn't provided to the builder, the object is fetched from the database.
  21274. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21275. func (m *GroupMutation) OldWeeklyLimitUsd(ctx context.Context) (v *float64, err error) {
  21276. if !m.op.Is(OpUpdateOne) {
  21277. return v, errors.New("OldWeeklyLimitUsd is only allowed on UpdateOne operations")
  21278. }
  21279. if m.id == nil || m.oldValue == nil {
  21280. return v, errors.New("OldWeeklyLimitUsd requires an ID field in the mutation")
  21281. }
  21282. oldValue, err := m.oldValue(ctx)
  21283. if err != nil {
  21284. return v, fmt.Errorf("querying old value for OldWeeklyLimitUsd: %w", err)
  21285. }
  21286. return oldValue.WeeklyLimitUsd, nil
  21287. }
  21288. // AddWeeklyLimitUsd adds f to the "weekly_limit_usd" field.
  21289. func (m *GroupMutation) AddWeeklyLimitUsd(f float64) {
  21290. if m.addweekly_limit_usd != nil {
  21291. *m.addweekly_limit_usd += f
  21292. } else {
  21293. m.addweekly_limit_usd = &f
  21294. }
  21295. }
  21296. // AddedWeeklyLimitUsd returns the value that was added to the "weekly_limit_usd" field in this mutation.
  21297. func (m *GroupMutation) AddedWeeklyLimitUsd() (r float64, exists bool) {
  21298. v := m.addweekly_limit_usd
  21299. if v == nil {
  21300. return
  21301. }
  21302. return *v, true
  21303. }
  21304. // ClearWeeklyLimitUsd clears the value of the "weekly_limit_usd" field.
  21305. func (m *GroupMutation) ClearWeeklyLimitUsd() {
  21306. m.weekly_limit_usd = nil
  21307. m.addweekly_limit_usd = nil
  21308. m.clearedFields[group.FieldWeeklyLimitUsd] = struct{}{}
  21309. }
  21310. // WeeklyLimitUsdCleared returns if the "weekly_limit_usd" field was cleared in this mutation.
  21311. func (m *GroupMutation) WeeklyLimitUsdCleared() bool {
  21312. _, ok := m.clearedFields[group.FieldWeeklyLimitUsd]
  21313. return ok
  21314. }
  21315. // ResetWeeklyLimitUsd resets all changes to the "weekly_limit_usd" field.
  21316. func (m *GroupMutation) ResetWeeklyLimitUsd() {
  21317. m.weekly_limit_usd = nil
  21318. m.addweekly_limit_usd = nil
  21319. delete(m.clearedFields, group.FieldWeeklyLimitUsd)
  21320. }
  21321. // SetMonthlyLimitUsd sets the "monthly_limit_usd" field.
  21322. func (m *GroupMutation) SetMonthlyLimitUsd(f float64) {
  21323. m.monthly_limit_usd = &f
  21324. m.addmonthly_limit_usd = nil
  21325. }
  21326. // MonthlyLimitUsd returns the value of the "monthly_limit_usd" field in the mutation.
  21327. func (m *GroupMutation) MonthlyLimitUsd() (r float64, exists bool) {
  21328. v := m.monthly_limit_usd
  21329. if v == nil {
  21330. return
  21331. }
  21332. return *v, true
  21333. }
  21334. // OldMonthlyLimitUsd returns the old "monthly_limit_usd" field's value of the Group entity.
  21335. // If the Group object wasn't provided to the builder, the object is fetched from the database.
  21336. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21337. func (m *GroupMutation) OldMonthlyLimitUsd(ctx context.Context) (v *float64, err error) {
  21338. if !m.op.Is(OpUpdateOne) {
  21339. return v, errors.New("OldMonthlyLimitUsd is only allowed on UpdateOne operations")
  21340. }
  21341. if m.id == nil || m.oldValue == nil {
  21342. return v, errors.New("OldMonthlyLimitUsd requires an ID field in the mutation")
  21343. }
  21344. oldValue, err := m.oldValue(ctx)
  21345. if err != nil {
  21346. return v, fmt.Errorf("querying old value for OldMonthlyLimitUsd: %w", err)
  21347. }
  21348. return oldValue.MonthlyLimitUsd, nil
  21349. }
  21350. // AddMonthlyLimitUsd adds f to the "monthly_limit_usd" field.
  21351. func (m *GroupMutation) AddMonthlyLimitUsd(f float64) {
  21352. if m.addmonthly_limit_usd != nil {
  21353. *m.addmonthly_limit_usd += f
  21354. } else {
  21355. m.addmonthly_limit_usd = &f
  21356. }
  21357. }
  21358. // AddedMonthlyLimitUsd returns the value that was added to the "monthly_limit_usd" field in this mutation.
  21359. func (m *GroupMutation) AddedMonthlyLimitUsd() (r float64, exists bool) {
  21360. v := m.addmonthly_limit_usd
  21361. if v == nil {
  21362. return
  21363. }
  21364. return *v, true
  21365. }
  21366. // ClearMonthlyLimitUsd clears the value of the "monthly_limit_usd" field.
  21367. func (m *GroupMutation) ClearMonthlyLimitUsd() {
  21368. m.monthly_limit_usd = nil
  21369. m.addmonthly_limit_usd = nil
  21370. m.clearedFields[group.FieldMonthlyLimitUsd] = struct{}{}
  21371. }
  21372. // MonthlyLimitUsdCleared returns if the "monthly_limit_usd" field was cleared in this mutation.
  21373. func (m *GroupMutation) MonthlyLimitUsdCleared() bool {
  21374. _, ok := m.clearedFields[group.FieldMonthlyLimitUsd]
  21375. return ok
  21376. }
  21377. // ResetMonthlyLimitUsd resets all changes to the "monthly_limit_usd" field.
  21378. func (m *GroupMutation) ResetMonthlyLimitUsd() {
  21379. m.monthly_limit_usd = nil
  21380. m.addmonthly_limit_usd = nil
  21381. delete(m.clearedFields, group.FieldMonthlyLimitUsd)
  21382. }
  21383. // SetDefaultValidityDays sets the "default_validity_days" field.
  21384. func (m *GroupMutation) SetDefaultValidityDays(i int) {
  21385. m.default_validity_days = &i
  21386. m.adddefault_validity_days = nil
  21387. }
  21388. // DefaultValidityDays returns the value of the "default_validity_days" field in the mutation.
  21389. func (m *GroupMutation) DefaultValidityDays() (r int, exists bool) {
  21390. v := m.default_validity_days
  21391. if v == nil {
  21392. return
  21393. }
  21394. return *v, true
  21395. }
  21396. // OldDefaultValidityDays returns the old "default_validity_days" field's value of the Group entity.
  21397. // If the Group object wasn't provided to the builder, the object is fetched from the database.
  21398. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21399. func (m *GroupMutation) OldDefaultValidityDays(ctx context.Context) (v int, err error) {
  21400. if !m.op.Is(OpUpdateOne) {
  21401. return v, errors.New("OldDefaultValidityDays is only allowed on UpdateOne operations")
  21402. }
  21403. if m.id == nil || m.oldValue == nil {
  21404. return v, errors.New("OldDefaultValidityDays requires an ID field in the mutation")
  21405. }
  21406. oldValue, err := m.oldValue(ctx)
  21407. if err != nil {
  21408. return v, fmt.Errorf("querying old value for OldDefaultValidityDays: %w", err)
  21409. }
  21410. return oldValue.DefaultValidityDays, nil
  21411. }
  21412. // AddDefaultValidityDays adds i to the "default_validity_days" field.
  21413. func (m *GroupMutation) AddDefaultValidityDays(i int) {
  21414. if m.adddefault_validity_days != nil {
  21415. *m.adddefault_validity_days += i
  21416. } else {
  21417. m.adddefault_validity_days = &i
  21418. }
  21419. }
  21420. // AddedDefaultValidityDays returns the value that was added to the "default_validity_days" field in this mutation.
  21421. func (m *GroupMutation) AddedDefaultValidityDays() (r int, exists bool) {
  21422. v := m.adddefault_validity_days
  21423. if v == nil {
  21424. return
  21425. }
  21426. return *v, true
  21427. }
  21428. // ResetDefaultValidityDays resets all changes to the "default_validity_days" field.
  21429. func (m *GroupMutation) ResetDefaultValidityDays() {
  21430. m.default_validity_days = nil
  21431. m.adddefault_validity_days = nil
  21432. }
  21433. // SetAllowImageGeneration sets the "allow_image_generation" field.
  21434. func (m *GroupMutation) SetAllowImageGeneration(b bool) {
  21435. m.allow_image_generation = &b
  21436. }
  21437. // AllowImageGeneration returns the value of the "allow_image_generation" field in the mutation.
  21438. func (m *GroupMutation) AllowImageGeneration() (r bool, exists bool) {
  21439. v := m.allow_image_generation
  21440. if v == nil {
  21441. return
  21442. }
  21443. return *v, true
  21444. }
  21445. // OldAllowImageGeneration returns the old "allow_image_generation" field's value of the Group entity.
  21446. // If the Group object wasn't provided to the builder, the object is fetched from the database.
  21447. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21448. func (m *GroupMutation) OldAllowImageGeneration(ctx context.Context) (v bool, err error) {
  21449. if !m.op.Is(OpUpdateOne) {
  21450. return v, errors.New("OldAllowImageGeneration is only allowed on UpdateOne operations")
  21451. }
  21452. if m.id == nil || m.oldValue == nil {
  21453. return v, errors.New("OldAllowImageGeneration requires an ID field in the mutation")
  21454. }
  21455. oldValue, err := m.oldValue(ctx)
  21456. if err != nil {
  21457. return v, fmt.Errorf("querying old value for OldAllowImageGeneration: %w", err)
  21458. }
  21459. return oldValue.AllowImageGeneration, nil
  21460. }
  21461. // ResetAllowImageGeneration resets all changes to the "allow_image_generation" field.
  21462. func (m *GroupMutation) ResetAllowImageGeneration() {
  21463. m.allow_image_generation = nil
  21464. }
  21465. // SetAllowBatchImageGeneration sets the "allow_batch_image_generation" field.
  21466. func (m *GroupMutation) SetAllowBatchImageGeneration(b bool) {
  21467. m.allow_batch_image_generation = &b
  21468. }
  21469. // AllowBatchImageGeneration returns the value of the "allow_batch_image_generation" field in the mutation.
  21470. func (m *GroupMutation) AllowBatchImageGeneration() (r bool, exists bool) {
  21471. v := m.allow_batch_image_generation
  21472. if v == nil {
  21473. return
  21474. }
  21475. return *v, true
  21476. }
  21477. // OldAllowBatchImageGeneration returns the old "allow_batch_image_generation" field's value of the Group entity.
  21478. // If the Group object wasn't provided to the builder, the object is fetched from the database.
  21479. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21480. func (m *GroupMutation) OldAllowBatchImageGeneration(ctx context.Context) (v bool, err error) {
  21481. if !m.op.Is(OpUpdateOne) {
  21482. return v, errors.New("OldAllowBatchImageGeneration is only allowed on UpdateOne operations")
  21483. }
  21484. if m.id == nil || m.oldValue == nil {
  21485. return v, errors.New("OldAllowBatchImageGeneration requires an ID field in the mutation")
  21486. }
  21487. oldValue, err := m.oldValue(ctx)
  21488. if err != nil {
  21489. return v, fmt.Errorf("querying old value for OldAllowBatchImageGeneration: %w", err)
  21490. }
  21491. return oldValue.AllowBatchImageGeneration, nil
  21492. }
  21493. // ResetAllowBatchImageGeneration resets all changes to the "allow_batch_image_generation" field.
  21494. func (m *GroupMutation) ResetAllowBatchImageGeneration() {
  21495. m.allow_batch_image_generation = nil
  21496. }
  21497. // SetImageRateIndependent sets the "image_rate_independent" field.
  21498. func (m *GroupMutation) SetImageRateIndependent(b bool) {
  21499. m.image_rate_independent = &b
  21500. }
  21501. // ImageRateIndependent returns the value of the "image_rate_independent" field in the mutation.
  21502. func (m *GroupMutation) ImageRateIndependent() (r bool, exists bool) {
  21503. v := m.image_rate_independent
  21504. if v == nil {
  21505. return
  21506. }
  21507. return *v, true
  21508. }
  21509. // OldImageRateIndependent returns the old "image_rate_independent" field's value of the Group entity.
  21510. // If the Group object wasn't provided to the builder, the object is fetched from the database.
  21511. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21512. func (m *GroupMutation) OldImageRateIndependent(ctx context.Context) (v bool, err error) {
  21513. if !m.op.Is(OpUpdateOne) {
  21514. return v, errors.New("OldImageRateIndependent is only allowed on UpdateOne operations")
  21515. }
  21516. if m.id == nil || m.oldValue == nil {
  21517. return v, errors.New("OldImageRateIndependent requires an ID field in the mutation")
  21518. }
  21519. oldValue, err := m.oldValue(ctx)
  21520. if err != nil {
  21521. return v, fmt.Errorf("querying old value for OldImageRateIndependent: %w", err)
  21522. }
  21523. return oldValue.ImageRateIndependent, nil
  21524. }
  21525. // ResetImageRateIndependent resets all changes to the "image_rate_independent" field.
  21526. func (m *GroupMutation) ResetImageRateIndependent() {
  21527. m.image_rate_independent = nil
  21528. }
  21529. // SetImageRateMultiplier sets the "image_rate_multiplier" field.
  21530. func (m *GroupMutation) SetImageRateMultiplier(f float64) {
  21531. m.image_rate_multiplier = &f
  21532. m.addimage_rate_multiplier = nil
  21533. }
  21534. // ImageRateMultiplier returns the value of the "image_rate_multiplier" field in the mutation.
  21535. func (m *GroupMutation) ImageRateMultiplier() (r float64, exists bool) {
  21536. v := m.image_rate_multiplier
  21537. if v == nil {
  21538. return
  21539. }
  21540. return *v, true
  21541. }
  21542. // OldImageRateMultiplier returns the old "image_rate_multiplier" field's value of the Group entity.
  21543. // If the Group object wasn't provided to the builder, the object is fetched from the database.
  21544. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21545. func (m *GroupMutation) OldImageRateMultiplier(ctx context.Context) (v float64, err error) {
  21546. if !m.op.Is(OpUpdateOne) {
  21547. return v, errors.New("OldImageRateMultiplier is only allowed on UpdateOne operations")
  21548. }
  21549. if m.id == nil || m.oldValue == nil {
  21550. return v, errors.New("OldImageRateMultiplier requires an ID field in the mutation")
  21551. }
  21552. oldValue, err := m.oldValue(ctx)
  21553. if err != nil {
  21554. return v, fmt.Errorf("querying old value for OldImageRateMultiplier: %w", err)
  21555. }
  21556. return oldValue.ImageRateMultiplier, nil
  21557. }
  21558. // AddImageRateMultiplier adds f to the "image_rate_multiplier" field.
  21559. func (m *GroupMutation) AddImageRateMultiplier(f float64) {
  21560. if m.addimage_rate_multiplier != nil {
  21561. *m.addimage_rate_multiplier += f
  21562. } else {
  21563. m.addimage_rate_multiplier = &f
  21564. }
  21565. }
  21566. // AddedImageRateMultiplier returns the value that was added to the "image_rate_multiplier" field in this mutation.
  21567. func (m *GroupMutation) AddedImageRateMultiplier() (r float64, exists bool) {
  21568. v := m.addimage_rate_multiplier
  21569. if v == nil {
  21570. return
  21571. }
  21572. return *v, true
  21573. }
  21574. // ResetImageRateMultiplier resets all changes to the "image_rate_multiplier" field.
  21575. func (m *GroupMutation) ResetImageRateMultiplier() {
  21576. m.image_rate_multiplier = nil
  21577. m.addimage_rate_multiplier = nil
  21578. }
  21579. // SetImagePrice1k sets the "image_price_1k" field.
  21580. func (m *GroupMutation) SetImagePrice1k(f float64) {
  21581. m.image_price_1k = &f
  21582. m.addimage_price_1k = nil
  21583. }
  21584. // ImagePrice1k returns the value of the "image_price_1k" field in the mutation.
  21585. func (m *GroupMutation) ImagePrice1k() (r float64, exists bool) {
  21586. v := m.image_price_1k
  21587. if v == nil {
  21588. return
  21589. }
  21590. return *v, true
  21591. }
  21592. // OldImagePrice1k returns the old "image_price_1k" field's value of the Group entity.
  21593. // If the Group object wasn't provided to the builder, the object is fetched from the database.
  21594. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21595. func (m *GroupMutation) OldImagePrice1k(ctx context.Context) (v *float64, err error) {
  21596. if !m.op.Is(OpUpdateOne) {
  21597. return v, errors.New("OldImagePrice1k is only allowed on UpdateOne operations")
  21598. }
  21599. if m.id == nil || m.oldValue == nil {
  21600. return v, errors.New("OldImagePrice1k requires an ID field in the mutation")
  21601. }
  21602. oldValue, err := m.oldValue(ctx)
  21603. if err != nil {
  21604. return v, fmt.Errorf("querying old value for OldImagePrice1k: %w", err)
  21605. }
  21606. return oldValue.ImagePrice1k, nil
  21607. }
  21608. // AddImagePrice1k adds f to the "image_price_1k" field.
  21609. func (m *GroupMutation) AddImagePrice1k(f float64) {
  21610. if m.addimage_price_1k != nil {
  21611. *m.addimage_price_1k += f
  21612. } else {
  21613. m.addimage_price_1k = &f
  21614. }
  21615. }
  21616. // AddedImagePrice1k returns the value that was added to the "image_price_1k" field in this mutation.
  21617. func (m *GroupMutation) AddedImagePrice1k() (r float64, exists bool) {
  21618. v := m.addimage_price_1k
  21619. if v == nil {
  21620. return
  21621. }
  21622. return *v, true
  21623. }
  21624. // ClearImagePrice1k clears the value of the "image_price_1k" field.
  21625. func (m *GroupMutation) ClearImagePrice1k() {
  21626. m.image_price_1k = nil
  21627. m.addimage_price_1k = nil
  21628. m.clearedFields[group.FieldImagePrice1k] = struct{}{}
  21629. }
  21630. // ImagePrice1kCleared returns if the "image_price_1k" field was cleared in this mutation.
  21631. func (m *GroupMutation) ImagePrice1kCleared() bool {
  21632. _, ok := m.clearedFields[group.FieldImagePrice1k]
  21633. return ok
  21634. }
  21635. // ResetImagePrice1k resets all changes to the "image_price_1k" field.
  21636. func (m *GroupMutation) ResetImagePrice1k() {
  21637. m.image_price_1k = nil
  21638. m.addimage_price_1k = nil
  21639. delete(m.clearedFields, group.FieldImagePrice1k)
  21640. }
  21641. // SetImagePrice2k sets the "image_price_2k" field.
  21642. func (m *GroupMutation) SetImagePrice2k(f float64) {
  21643. m.image_price_2k = &f
  21644. m.addimage_price_2k = nil
  21645. }
  21646. // ImagePrice2k returns the value of the "image_price_2k" field in the mutation.
  21647. func (m *GroupMutation) ImagePrice2k() (r float64, exists bool) {
  21648. v := m.image_price_2k
  21649. if v == nil {
  21650. return
  21651. }
  21652. return *v, true
  21653. }
  21654. // OldImagePrice2k returns the old "image_price_2k" field's value of the Group entity.
  21655. // If the Group object wasn't provided to the builder, the object is fetched from the database.
  21656. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21657. func (m *GroupMutation) OldImagePrice2k(ctx context.Context) (v *float64, err error) {
  21658. if !m.op.Is(OpUpdateOne) {
  21659. return v, errors.New("OldImagePrice2k is only allowed on UpdateOne operations")
  21660. }
  21661. if m.id == nil || m.oldValue == nil {
  21662. return v, errors.New("OldImagePrice2k requires an ID field in the mutation")
  21663. }
  21664. oldValue, err := m.oldValue(ctx)
  21665. if err != nil {
  21666. return v, fmt.Errorf("querying old value for OldImagePrice2k: %w", err)
  21667. }
  21668. return oldValue.ImagePrice2k, nil
  21669. }
  21670. // AddImagePrice2k adds f to the "image_price_2k" field.
  21671. func (m *GroupMutation) AddImagePrice2k(f float64) {
  21672. if m.addimage_price_2k != nil {
  21673. *m.addimage_price_2k += f
  21674. } else {
  21675. m.addimage_price_2k = &f
  21676. }
  21677. }
  21678. // AddedImagePrice2k returns the value that was added to the "image_price_2k" field in this mutation.
  21679. func (m *GroupMutation) AddedImagePrice2k() (r float64, exists bool) {
  21680. v := m.addimage_price_2k
  21681. if v == nil {
  21682. return
  21683. }
  21684. return *v, true
  21685. }
  21686. // ClearImagePrice2k clears the value of the "image_price_2k" field.
  21687. func (m *GroupMutation) ClearImagePrice2k() {
  21688. m.image_price_2k = nil
  21689. m.addimage_price_2k = nil
  21690. m.clearedFields[group.FieldImagePrice2k] = struct{}{}
  21691. }
  21692. // ImagePrice2kCleared returns if the "image_price_2k" field was cleared in this mutation.
  21693. func (m *GroupMutation) ImagePrice2kCleared() bool {
  21694. _, ok := m.clearedFields[group.FieldImagePrice2k]
  21695. return ok
  21696. }
  21697. // ResetImagePrice2k resets all changes to the "image_price_2k" field.
  21698. func (m *GroupMutation) ResetImagePrice2k() {
  21699. m.image_price_2k = nil
  21700. m.addimage_price_2k = nil
  21701. delete(m.clearedFields, group.FieldImagePrice2k)
  21702. }
  21703. // SetImagePrice4k sets the "image_price_4k" field.
  21704. func (m *GroupMutation) SetImagePrice4k(f float64) {
  21705. m.image_price_4k = &f
  21706. m.addimage_price_4k = nil
  21707. }
  21708. // ImagePrice4k returns the value of the "image_price_4k" field in the mutation.
  21709. func (m *GroupMutation) ImagePrice4k() (r float64, exists bool) {
  21710. v := m.image_price_4k
  21711. if v == nil {
  21712. return
  21713. }
  21714. return *v, true
  21715. }
  21716. // OldImagePrice4k returns the old "image_price_4k" field's value of the Group entity.
  21717. // If the Group object wasn't provided to the builder, the object is fetched from the database.
  21718. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21719. func (m *GroupMutation) OldImagePrice4k(ctx context.Context) (v *float64, err error) {
  21720. if !m.op.Is(OpUpdateOne) {
  21721. return v, errors.New("OldImagePrice4k is only allowed on UpdateOne operations")
  21722. }
  21723. if m.id == nil || m.oldValue == nil {
  21724. return v, errors.New("OldImagePrice4k requires an ID field in the mutation")
  21725. }
  21726. oldValue, err := m.oldValue(ctx)
  21727. if err != nil {
  21728. return v, fmt.Errorf("querying old value for OldImagePrice4k: %w", err)
  21729. }
  21730. return oldValue.ImagePrice4k, nil
  21731. }
  21732. // AddImagePrice4k adds f to the "image_price_4k" field.
  21733. func (m *GroupMutation) AddImagePrice4k(f float64) {
  21734. if m.addimage_price_4k != nil {
  21735. *m.addimage_price_4k += f
  21736. } else {
  21737. m.addimage_price_4k = &f
  21738. }
  21739. }
  21740. // AddedImagePrice4k returns the value that was added to the "image_price_4k" field in this mutation.
  21741. func (m *GroupMutation) AddedImagePrice4k() (r float64, exists bool) {
  21742. v := m.addimage_price_4k
  21743. if v == nil {
  21744. return
  21745. }
  21746. return *v, true
  21747. }
  21748. // ClearImagePrice4k clears the value of the "image_price_4k" field.
  21749. func (m *GroupMutation) ClearImagePrice4k() {
  21750. m.image_price_4k = nil
  21751. m.addimage_price_4k = nil
  21752. m.clearedFields[group.FieldImagePrice4k] = struct{}{}
  21753. }
  21754. // ImagePrice4kCleared returns if the "image_price_4k" field was cleared in this mutation.
  21755. func (m *GroupMutation) ImagePrice4kCleared() bool {
  21756. _, ok := m.clearedFields[group.FieldImagePrice4k]
  21757. return ok
  21758. }
  21759. // ResetImagePrice4k resets all changes to the "image_price_4k" field.
  21760. func (m *GroupMutation) ResetImagePrice4k() {
  21761. m.image_price_4k = nil
  21762. m.addimage_price_4k = nil
  21763. delete(m.clearedFields, group.FieldImagePrice4k)
  21764. }
  21765. // SetBatchImageDiscountMultiplier sets the "batch_image_discount_multiplier" field.
  21766. func (m *GroupMutation) SetBatchImageDiscountMultiplier(f float64) {
  21767. m.batch_image_discount_multiplier = &f
  21768. m.addbatch_image_discount_multiplier = nil
  21769. }
  21770. // BatchImageDiscountMultiplier returns the value of the "batch_image_discount_multiplier" field in the mutation.
  21771. func (m *GroupMutation) BatchImageDiscountMultiplier() (r float64, exists bool) {
  21772. v := m.batch_image_discount_multiplier
  21773. if v == nil {
  21774. return
  21775. }
  21776. return *v, true
  21777. }
  21778. // OldBatchImageDiscountMultiplier returns the old "batch_image_discount_multiplier" field's value of the Group entity.
  21779. // If the Group object wasn't provided to the builder, the object is fetched from the database.
  21780. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21781. func (m *GroupMutation) OldBatchImageDiscountMultiplier(ctx context.Context) (v float64, err error) {
  21782. if !m.op.Is(OpUpdateOne) {
  21783. return v, errors.New("OldBatchImageDiscountMultiplier is only allowed on UpdateOne operations")
  21784. }
  21785. if m.id == nil || m.oldValue == nil {
  21786. return v, errors.New("OldBatchImageDiscountMultiplier requires an ID field in the mutation")
  21787. }
  21788. oldValue, err := m.oldValue(ctx)
  21789. if err != nil {
  21790. return v, fmt.Errorf("querying old value for OldBatchImageDiscountMultiplier: %w", err)
  21791. }
  21792. return oldValue.BatchImageDiscountMultiplier, nil
  21793. }
  21794. // AddBatchImageDiscountMultiplier adds f to the "batch_image_discount_multiplier" field.
  21795. func (m *GroupMutation) AddBatchImageDiscountMultiplier(f float64) {
  21796. if m.addbatch_image_discount_multiplier != nil {
  21797. *m.addbatch_image_discount_multiplier += f
  21798. } else {
  21799. m.addbatch_image_discount_multiplier = &f
  21800. }
  21801. }
  21802. // AddedBatchImageDiscountMultiplier returns the value that was added to the "batch_image_discount_multiplier" field in this mutation.
  21803. func (m *GroupMutation) AddedBatchImageDiscountMultiplier() (r float64, exists bool) {
  21804. v := m.addbatch_image_discount_multiplier
  21805. if v == nil {
  21806. return
  21807. }
  21808. return *v, true
  21809. }
  21810. // ResetBatchImageDiscountMultiplier resets all changes to the "batch_image_discount_multiplier" field.
  21811. func (m *GroupMutation) ResetBatchImageDiscountMultiplier() {
  21812. m.batch_image_discount_multiplier = nil
  21813. m.addbatch_image_discount_multiplier = nil
  21814. }
  21815. // SetBatchImageHoldMultiplier sets the "batch_image_hold_multiplier" field.
  21816. func (m *GroupMutation) SetBatchImageHoldMultiplier(f float64) {
  21817. m.batch_image_hold_multiplier = &f
  21818. m.addbatch_image_hold_multiplier = nil
  21819. }
  21820. // BatchImageHoldMultiplier returns the value of the "batch_image_hold_multiplier" field in the mutation.
  21821. func (m *GroupMutation) BatchImageHoldMultiplier() (r float64, exists bool) {
  21822. v := m.batch_image_hold_multiplier
  21823. if v == nil {
  21824. return
  21825. }
  21826. return *v, true
  21827. }
  21828. // OldBatchImageHoldMultiplier returns the old "batch_image_hold_multiplier" field's value of the Group entity.
  21829. // If the Group object wasn't provided to the builder, the object is fetched from the database.
  21830. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21831. func (m *GroupMutation) OldBatchImageHoldMultiplier(ctx context.Context) (v float64, err error) {
  21832. if !m.op.Is(OpUpdateOne) {
  21833. return v, errors.New("OldBatchImageHoldMultiplier is only allowed on UpdateOne operations")
  21834. }
  21835. if m.id == nil || m.oldValue == nil {
  21836. return v, errors.New("OldBatchImageHoldMultiplier requires an ID field in the mutation")
  21837. }
  21838. oldValue, err := m.oldValue(ctx)
  21839. if err != nil {
  21840. return v, fmt.Errorf("querying old value for OldBatchImageHoldMultiplier: %w", err)
  21841. }
  21842. return oldValue.BatchImageHoldMultiplier, nil
  21843. }
  21844. // AddBatchImageHoldMultiplier adds f to the "batch_image_hold_multiplier" field.
  21845. func (m *GroupMutation) AddBatchImageHoldMultiplier(f float64) {
  21846. if m.addbatch_image_hold_multiplier != nil {
  21847. *m.addbatch_image_hold_multiplier += f
  21848. } else {
  21849. m.addbatch_image_hold_multiplier = &f
  21850. }
  21851. }
  21852. // AddedBatchImageHoldMultiplier returns the value that was added to the "batch_image_hold_multiplier" field in this mutation.
  21853. func (m *GroupMutation) AddedBatchImageHoldMultiplier() (r float64, exists bool) {
  21854. v := m.addbatch_image_hold_multiplier
  21855. if v == nil {
  21856. return
  21857. }
  21858. return *v, true
  21859. }
  21860. // ResetBatchImageHoldMultiplier resets all changes to the "batch_image_hold_multiplier" field.
  21861. func (m *GroupMutation) ResetBatchImageHoldMultiplier() {
  21862. m.batch_image_hold_multiplier = nil
  21863. m.addbatch_image_hold_multiplier = nil
  21864. }
  21865. // SetVideoRateIndependent sets the "video_rate_independent" field.
  21866. func (m *GroupMutation) SetVideoRateIndependent(b bool) {
  21867. m.video_rate_independent = &b
  21868. }
  21869. // VideoRateIndependent returns the value of the "video_rate_independent" field in the mutation.
  21870. func (m *GroupMutation) VideoRateIndependent() (r bool, exists bool) {
  21871. v := m.video_rate_independent
  21872. if v == nil {
  21873. return
  21874. }
  21875. return *v, true
  21876. }
  21877. // OldVideoRateIndependent returns the old "video_rate_independent" field's value of the Group entity.
  21878. // If the Group object wasn't provided to the builder, the object is fetched from the database.
  21879. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21880. func (m *GroupMutation) OldVideoRateIndependent(ctx context.Context) (v bool, err error) {
  21881. if !m.op.Is(OpUpdateOne) {
  21882. return v, errors.New("OldVideoRateIndependent is only allowed on UpdateOne operations")
  21883. }
  21884. if m.id == nil || m.oldValue == nil {
  21885. return v, errors.New("OldVideoRateIndependent requires an ID field in the mutation")
  21886. }
  21887. oldValue, err := m.oldValue(ctx)
  21888. if err != nil {
  21889. return v, fmt.Errorf("querying old value for OldVideoRateIndependent: %w", err)
  21890. }
  21891. return oldValue.VideoRateIndependent, nil
  21892. }
  21893. // ResetVideoRateIndependent resets all changes to the "video_rate_independent" field.
  21894. func (m *GroupMutation) ResetVideoRateIndependent() {
  21895. m.video_rate_independent = nil
  21896. }
  21897. // SetVideoRateMultiplier sets the "video_rate_multiplier" field.
  21898. func (m *GroupMutation) SetVideoRateMultiplier(f float64) {
  21899. m.video_rate_multiplier = &f
  21900. m.addvideo_rate_multiplier = nil
  21901. }
  21902. // VideoRateMultiplier returns the value of the "video_rate_multiplier" field in the mutation.
  21903. func (m *GroupMutation) VideoRateMultiplier() (r float64, exists bool) {
  21904. v := m.video_rate_multiplier
  21905. if v == nil {
  21906. return
  21907. }
  21908. return *v, true
  21909. }
  21910. // OldVideoRateMultiplier returns the old "video_rate_multiplier" field's value of the Group entity.
  21911. // If the Group object wasn't provided to the builder, the object is fetched from the database.
  21912. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21913. func (m *GroupMutation) OldVideoRateMultiplier(ctx context.Context) (v float64, err error) {
  21914. if !m.op.Is(OpUpdateOne) {
  21915. return v, errors.New("OldVideoRateMultiplier is only allowed on UpdateOne operations")
  21916. }
  21917. if m.id == nil || m.oldValue == nil {
  21918. return v, errors.New("OldVideoRateMultiplier requires an ID field in the mutation")
  21919. }
  21920. oldValue, err := m.oldValue(ctx)
  21921. if err != nil {
  21922. return v, fmt.Errorf("querying old value for OldVideoRateMultiplier: %w", err)
  21923. }
  21924. return oldValue.VideoRateMultiplier, nil
  21925. }
  21926. // AddVideoRateMultiplier adds f to the "video_rate_multiplier" field.
  21927. func (m *GroupMutation) AddVideoRateMultiplier(f float64) {
  21928. if m.addvideo_rate_multiplier != nil {
  21929. *m.addvideo_rate_multiplier += f
  21930. } else {
  21931. m.addvideo_rate_multiplier = &f
  21932. }
  21933. }
  21934. // AddedVideoRateMultiplier returns the value that was added to the "video_rate_multiplier" field in this mutation.
  21935. func (m *GroupMutation) AddedVideoRateMultiplier() (r float64, exists bool) {
  21936. v := m.addvideo_rate_multiplier
  21937. if v == nil {
  21938. return
  21939. }
  21940. return *v, true
  21941. }
  21942. // ResetVideoRateMultiplier resets all changes to the "video_rate_multiplier" field.
  21943. func (m *GroupMutation) ResetVideoRateMultiplier() {
  21944. m.video_rate_multiplier = nil
  21945. m.addvideo_rate_multiplier = nil
  21946. }
  21947. // SetVideoPrice480p sets the "video_price_480p" field.
  21948. func (m *GroupMutation) SetVideoPrice480p(f float64) {
  21949. m.video_price_480p = &f
  21950. m.addvideo_price_480p = nil
  21951. }
  21952. // VideoPrice480p returns the value of the "video_price_480p" field in the mutation.
  21953. func (m *GroupMutation) VideoPrice480p() (r float64, exists bool) {
  21954. v := m.video_price_480p
  21955. if v == nil {
  21956. return
  21957. }
  21958. return *v, true
  21959. }
  21960. // OldVideoPrice480p returns the old "video_price_480p" field's value of the Group entity.
  21961. // If the Group object wasn't provided to the builder, the object is fetched from the database.
  21962. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21963. func (m *GroupMutation) OldVideoPrice480p(ctx context.Context) (v *float64, err error) {
  21964. if !m.op.Is(OpUpdateOne) {
  21965. return v, errors.New("OldVideoPrice480p is only allowed on UpdateOne operations")
  21966. }
  21967. if m.id == nil || m.oldValue == nil {
  21968. return v, errors.New("OldVideoPrice480p requires an ID field in the mutation")
  21969. }
  21970. oldValue, err := m.oldValue(ctx)
  21971. if err != nil {
  21972. return v, fmt.Errorf("querying old value for OldVideoPrice480p: %w", err)
  21973. }
  21974. return oldValue.VideoPrice480p, nil
  21975. }
  21976. // AddVideoPrice480p adds f to the "video_price_480p" field.
  21977. func (m *GroupMutation) AddVideoPrice480p(f float64) {
  21978. if m.addvideo_price_480p != nil {
  21979. *m.addvideo_price_480p += f
  21980. } else {
  21981. m.addvideo_price_480p = &f
  21982. }
  21983. }
  21984. // AddedVideoPrice480p returns the value that was added to the "video_price_480p" field in this mutation.
  21985. func (m *GroupMutation) AddedVideoPrice480p() (r float64, exists bool) {
  21986. v := m.addvideo_price_480p
  21987. if v == nil {
  21988. return
  21989. }
  21990. return *v, true
  21991. }
  21992. // ClearVideoPrice480p clears the value of the "video_price_480p" field.
  21993. func (m *GroupMutation) ClearVideoPrice480p() {
  21994. m.video_price_480p = nil
  21995. m.addvideo_price_480p = nil
  21996. m.clearedFields[group.FieldVideoPrice480p] = struct{}{}
  21997. }
  21998. // VideoPrice480pCleared returns if the "video_price_480p" field was cleared in this mutation.
  21999. func (m *GroupMutation) VideoPrice480pCleared() bool {
  22000. _, ok := m.clearedFields[group.FieldVideoPrice480p]
  22001. return ok
  22002. }
  22003. // ResetVideoPrice480p resets all changes to the "video_price_480p" field.
  22004. func (m *GroupMutation) ResetVideoPrice480p() {
  22005. m.video_price_480p = nil
  22006. m.addvideo_price_480p = nil
  22007. delete(m.clearedFields, group.FieldVideoPrice480p)
  22008. }
  22009. // SetVideoPrice720p sets the "video_price_720p" field.
  22010. func (m *GroupMutation) SetVideoPrice720p(f float64) {
  22011. m.video_price_720p = &f
  22012. m.addvideo_price_720p = nil
  22013. }
  22014. // VideoPrice720p returns the value of the "video_price_720p" field in the mutation.
  22015. func (m *GroupMutation) VideoPrice720p() (r float64, exists bool) {
  22016. v := m.video_price_720p
  22017. if v == nil {
  22018. return
  22019. }
  22020. return *v, true
  22021. }
  22022. // OldVideoPrice720p returns the old "video_price_720p" field's value of the Group entity.
  22023. // If the Group object wasn't provided to the builder, the object is fetched from the database.
  22024. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22025. func (m *GroupMutation) OldVideoPrice720p(ctx context.Context) (v *float64, err error) {
  22026. if !m.op.Is(OpUpdateOne) {
  22027. return v, errors.New("OldVideoPrice720p is only allowed on UpdateOne operations")
  22028. }
  22029. if m.id == nil || m.oldValue == nil {
  22030. return v, errors.New("OldVideoPrice720p requires an ID field in the mutation")
  22031. }
  22032. oldValue, err := m.oldValue(ctx)
  22033. if err != nil {
  22034. return v, fmt.Errorf("querying old value for OldVideoPrice720p: %w", err)
  22035. }
  22036. return oldValue.VideoPrice720p, nil
  22037. }
  22038. // AddVideoPrice720p adds f to the "video_price_720p" field.
  22039. func (m *GroupMutation) AddVideoPrice720p(f float64) {
  22040. if m.addvideo_price_720p != nil {
  22041. *m.addvideo_price_720p += f
  22042. } else {
  22043. m.addvideo_price_720p = &f
  22044. }
  22045. }
  22046. // AddedVideoPrice720p returns the value that was added to the "video_price_720p" field in this mutation.
  22047. func (m *GroupMutation) AddedVideoPrice720p() (r float64, exists bool) {
  22048. v := m.addvideo_price_720p
  22049. if v == nil {
  22050. return
  22051. }
  22052. return *v, true
  22053. }
  22054. // ClearVideoPrice720p clears the value of the "video_price_720p" field.
  22055. func (m *GroupMutation) ClearVideoPrice720p() {
  22056. m.video_price_720p = nil
  22057. m.addvideo_price_720p = nil
  22058. m.clearedFields[group.FieldVideoPrice720p] = struct{}{}
  22059. }
  22060. // VideoPrice720pCleared returns if the "video_price_720p" field was cleared in this mutation.
  22061. func (m *GroupMutation) VideoPrice720pCleared() bool {
  22062. _, ok := m.clearedFields[group.FieldVideoPrice720p]
  22063. return ok
  22064. }
  22065. // ResetVideoPrice720p resets all changes to the "video_price_720p" field.
  22066. func (m *GroupMutation) ResetVideoPrice720p() {
  22067. m.video_price_720p = nil
  22068. m.addvideo_price_720p = nil
  22069. delete(m.clearedFields, group.FieldVideoPrice720p)
  22070. }
  22071. // SetVideoPrice1080p sets the "video_price_1080p" field.
  22072. func (m *GroupMutation) SetVideoPrice1080p(f float64) {
  22073. m.video_price_1080p = &f
  22074. m.addvideo_price_1080p = nil
  22075. }
  22076. // VideoPrice1080p returns the value of the "video_price_1080p" field in the mutation.
  22077. func (m *GroupMutation) VideoPrice1080p() (r float64, exists bool) {
  22078. v := m.video_price_1080p
  22079. if v == nil {
  22080. return
  22081. }
  22082. return *v, true
  22083. }
  22084. // OldVideoPrice1080p returns the old "video_price_1080p" field's value of the Group entity.
  22085. // If the Group object wasn't provided to the builder, the object is fetched from the database.
  22086. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22087. func (m *GroupMutation) OldVideoPrice1080p(ctx context.Context) (v *float64, err error) {
  22088. if !m.op.Is(OpUpdateOne) {
  22089. return v, errors.New("OldVideoPrice1080p is only allowed on UpdateOne operations")
  22090. }
  22091. if m.id == nil || m.oldValue == nil {
  22092. return v, errors.New("OldVideoPrice1080p requires an ID field in the mutation")
  22093. }
  22094. oldValue, err := m.oldValue(ctx)
  22095. if err != nil {
  22096. return v, fmt.Errorf("querying old value for OldVideoPrice1080p: %w", err)
  22097. }
  22098. return oldValue.VideoPrice1080p, nil
  22099. }
  22100. // AddVideoPrice1080p adds f to the "video_price_1080p" field.
  22101. func (m *GroupMutation) AddVideoPrice1080p(f float64) {
  22102. if m.addvideo_price_1080p != nil {
  22103. *m.addvideo_price_1080p += f
  22104. } else {
  22105. m.addvideo_price_1080p = &f
  22106. }
  22107. }
  22108. // AddedVideoPrice1080p returns the value that was added to the "video_price_1080p" field in this mutation.
  22109. func (m *GroupMutation) AddedVideoPrice1080p() (r float64, exists bool) {
  22110. v := m.addvideo_price_1080p
  22111. if v == nil {
  22112. return
  22113. }
  22114. return *v, true
  22115. }
  22116. // ClearVideoPrice1080p clears the value of the "video_price_1080p" field.
  22117. func (m *GroupMutation) ClearVideoPrice1080p() {
  22118. m.video_price_1080p = nil
  22119. m.addvideo_price_1080p = nil
  22120. m.clearedFields[group.FieldVideoPrice1080p] = struct{}{}
  22121. }
  22122. // VideoPrice1080pCleared returns if the "video_price_1080p" field was cleared in this mutation.
  22123. func (m *GroupMutation) VideoPrice1080pCleared() bool {
  22124. _, ok := m.clearedFields[group.FieldVideoPrice1080p]
  22125. return ok
  22126. }
  22127. // ResetVideoPrice1080p resets all changes to the "video_price_1080p" field.
  22128. func (m *GroupMutation) ResetVideoPrice1080p() {
  22129. m.video_price_1080p = nil
  22130. m.addvideo_price_1080p = nil
  22131. delete(m.clearedFields, group.FieldVideoPrice1080p)
  22132. }
  22133. // SetVideoModelPrices sets the "video_model_prices" field.
  22134. func (m *GroupMutation) SetVideoModelPrices(value map[string]map[string]float64) {
  22135. m.video_model_prices = &value
  22136. }
  22137. // VideoModelPrices returns the value of the "video_model_prices" field in the mutation.
  22138. func (m *GroupMutation) VideoModelPrices() (r map[string]map[string]float64, exists bool) {
  22139. v := m.video_model_prices
  22140. if v == nil {
  22141. return
  22142. }
  22143. return *v, true
  22144. }
  22145. // OldVideoModelPrices returns the old "video_model_prices" field's value of the Group entity.
  22146. // If the Group object wasn't provided to the builder, the object is fetched from the database.
  22147. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22148. func (m *GroupMutation) OldVideoModelPrices(ctx context.Context) (v map[string]map[string]float64, err error) {
  22149. if !m.op.Is(OpUpdateOne) {
  22150. return v, errors.New("OldVideoModelPrices is only allowed on UpdateOne operations")
  22151. }
  22152. if m.id == nil || m.oldValue == nil {
  22153. return v, errors.New("OldVideoModelPrices requires an ID field in the mutation")
  22154. }
  22155. oldValue, err := m.oldValue(ctx)
  22156. if err != nil {
  22157. return v, fmt.Errorf("querying old value for OldVideoModelPrices: %w", err)
  22158. }
  22159. return oldValue.VideoModelPrices, nil
  22160. }
  22161. // ClearVideoModelPrices clears the value of the "video_model_prices" field.
  22162. func (m *GroupMutation) ClearVideoModelPrices() {
  22163. m.video_model_prices = nil
  22164. m.clearedFields[group.FieldVideoModelPrices] = struct{}{}
  22165. }
  22166. // VideoModelPricesCleared returns if the "video_model_prices" field was cleared in this mutation.
  22167. func (m *GroupMutation) VideoModelPricesCleared() bool {
  22168. _, ok := m.clearedFields[group.FieldVideoModelPrices]
  22169. return ok
  22170. }
  22171. // ResetVideoModelPrices resets all changes to the "video_model_prices" field.
  22172. func (m *GroupMutation) ResetVideoModelPrices() {
  22173. m.video_model_prices = nil
  22174. delete(m.clearedFields, group.FieldVideoModelPrices)
  22175. }
  22176. // SetWebSearchPricePerCall sets the "web_search_price_per_call" field.
  22177. func (m *GroupMutation) SetWebSearchPricePerCall(f float64) {
  22178. m.web_search_price_per_call = &f
  22179. m.addweb_search_price_per_call = nil
  22180. }
  22181. // WebSearchPricePerCall returns the value of the "web_search_price_per_call" field in the mutation.
  22182. func (m *GroupMutation) WebSearchPricePerCall() (r float64, exists bool) {
  22183. v := m.web_search_price_per_call
  22184. if v == nil {
  22185. return
  22186. }
  22187. return *v, true
  22188. }
  22189. // OldWebSearchPricePerCall returns the old "web_search_price_per_call" field's value of the Group entity.
  22190. // If the Group object wasn't provided to the builder, the object is fetched from the database.
  22191. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22192. func (m *GroupMutation) OldWebSearchPricePerCall(ctx context.Context) (v *float64, err error) {
  22193. if !m.op.Is(OpUpdateOne) {
  22194. return v, errors.New("OldWebSearchPricePerCall is only allowed on UpdateOne operations")
  22195. }
  22196. if m.id == nil || m.oldValue == nil {
  22197. return v, errors.New("OldWebSearchPricePerCall requires an ID field in the mutation")
  22198. }
  22199. oldValue, err := m.oldValue(ctx)
  22200. if err != nil {
  22201. return v, fmt.Errorf("querying old value for OldWebSearchPricePerCall: %w", err)
  22202. }
  22203. return oldValue.WebSearchPricePerCall, nil
  22204. }
  22205. // AddWebSearchPricePerCall adds f to the "web_search_price_per_call" field.
  22206. func (m *GroupMutation) AddWebSearchPricePerCall(f float64) {
  22207. if m.addweb_search_price_per_call != nil {
  22208. *m.addweb_search_price_per_call += f
  22209. } else {
  22210. m.addweb_search_price_per_call = &f
  22211. }
  22212. }
  22213. // AddedWebSearchPricePerCall returns the value that was added to the "web_search_price_per_call" field in this mutation.
  22214. func (m *GroupMutation) AddedWebSearchPricePerCall() (r float64, exists bool) {
  22215. v := m.addweb_search_price_per_call
  22216. if v == nil {
  22217. return
  22218. }
  22219. return *v, true
  22220. }
  22221. // ClearWebSearchPricePerCall clears the value of the "web_search_price_per_call" field.
  22222. func (m *GroupMutation) ClearWebSearchPricePerCall() {
  22223. m.web_search_price_per_call = nil
  22224. m.addweb_search_price_per_call = nil
  22225. m.clearedFields[group.FieldWebSearchPricePerCall] = struct{}{}
  22226. }
  22227. // WebSearchPricePerCallCleared returns if the "web_search_price_per_call" field was cleared in this mutation.
  22228. func (m *GroupMutation) WebSearchPricePerCallCleared() bool {
  22229. _, ok := m.clearedFields[group.FieldWebSearchPricePerCall]
  22230. return ok
  22231. }
  22232. // ResetWebSearchPricePerCall resets all changes to the "web_search_price_per_call" field.
  22233. func (m *GroupMutation) ResetWebSearchPricePerCall() {
  22234. m.web_search_price_per_call = nil
  22235. m.addweb_search_price_per_call = nil
  22236. delete(m.clearedFields, group.FieldWebSearchPricePerCall)
  22237. }
  22238. // SetSearchPricePer1k sets the "search_price_per_1k" field.
  22239. func (m *GroupMutation) SetSearchPricePer1k(f float64) {
  22240. m.search_price_per_1k = &f
  22241. m.addsearch_price_per_1k = nil
  22242. }
  22243. // SearchPricePer1k returns the value of the "search_price_per_1k" field in the mutation.
  22244. func (m *GroupMutation) SearchPricePer1k() (r float64, exists bool) {
  22245. v := m.search_price_per_1k
  22246. if v == nil {
  22247. return
  22248. }
  22249. return *v, true
  22250. }
  22251. // OldSearchPricePer1k returns the old "search_price_per_1k" field's value of the Group entity.
  22252. // If the Group object wasn't provided to the builder, the object is fetched from the database.
  22253. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22254. func (m *GroupMutation) OldSearchPricePer1k(ctx context.Context) (v *float64, err error) {
  22255. if !m.op.Is(OpUpdateOne) {
  22256. return v, errors.New("OldSearchPricePer1k is only allowed on UpdateOne operations")
  22257. }
  22258. if m.id == nil || m.oldValue == nil {
  22259. return v, errors.New("OldSearchPricePer1k requires an ID field in the mutation")
  22260. }
  22261. oldValue, err := m.oldValue(ctx)
  22262. if err != nil {
  22263. return v, fmt.Errorf("querying old value for OldSearchPricePer1k: %w", err)
  22264. }
  22265. return oldValue.SearchPricePer1k, nil
  22266. }
  22267. // AddSearchPricePer1k adds f to the "search_price_per_1k" field.
  22268. func (m *GroupMutation) AddSearchPricePer1k(f float64) {
  22269. if m.addsearch_price_per_1k != nil {
  22270. *m.addsearch_price_per_1k += f
  22271. } else {
  22272. m.addsearch_price_per_1k = &f
  22273. }
  22274. }
  22275. // AddedSearchPricePer1k returns the value that was added to the "search_price_per_1k" field in this mutation.
  22276. func (m *GroupMutation) AddedSearchPricePer1k() (r float64, exists bool) {
  22277. v := m.addsearch_price_per_1k
  22278. if v == nil {
  22279. return
  22280. }
  22281. return *v, true
  22282. }
  22283. // ClearSearchPricePer1k clears the value of the "search_price_per_1k" field.
  22284. func (m *GroupMutation) ClearSearchPricePer1k() {
  22285. m.search_price_per_1k = nil
  22286. m.addsearch_price_per_1k = nil
  22287. m.clearedFields[group.FieldSearchPricePer1k] = struct{}{}
  22288. }
  22289. // SearchPricePer1kCleared returns if the "search_price_per_1k" field was cleared in this mutation.
  22290. func (m *GroupMutation) SearchPricePer1kCleared() bool {
  22291. _, ok := m.clearedFields[group.FieldSearchPricePer1k]
  22292. return ok
  22293. }
  22294. // ResetSearchPricePer1k resets all changes to the "search_price_per_1k" field.
  22295. func (m *GroupMutation) ResetSearchPricePer1k() {
  22296. m.search_price_per_1k = nil
  22297. m.addsearch_price_per_1k = nil
  22298. delete(m.clearedFields, group.FieldSearchPricePer1k)
  22299. }
  22300. // SetAudioRealtimePricePerMin sets the "audio_realtime_price_per_min" field.
  22301. func (m *GroupMutation) SetAudioRealtimePricePerMin(f float64) {
  22302. m.audio_realtime_price_per_min = &f
  22303. m.addaudio_realtime_price_per_min = nil
  22304. }
  22305. // AudioRealtimePricePerMin returns the value of the "audio_realtime_price_per_min" field in the mutation.
  22306. func (m *GroupMutation) AudioRealtimePricePerMin() (r float64, exists bool) {
  22307. v := m.audio_realtime_price_per_min
  22308. if v == nil {
  22309. return
  22310. }
  22311. return *v, true
  22312. }
  22313. // OldAudioRealtimePricePerMin returns the old "audio_realtime_price_per_min" field's value of the Group entity.
  22314. // If the Group object wasn't provided to the builder, the object is fetched from the database.
  22315. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22316. func (m *GroupMutation) OldAudioRealtimePricePerMin(ctx context.Context) (v *float64, err error) {
  22317. if !m.op.Is(OpUpdateOne) {
  22318. return v, errors.New("OldAudioRealtimePricePerMin is only allowed on UpdateOne operations")
  22319. }
  22320. if m.id == nil || m.oldValue == nil {
  22321. return v, errors.New("OldAudioRealtimePricePerMin requires an ID field in the mutation")
  22322. }
  22323. oldValue, err := m.oldValue(ctx)
  22324. if err != nil {
  22325. return v, fmt.Errorf("querying old value for OldAudioRealtimePricePerMin: %w", err)
  22326. }
  22327. return oldValue.AudioRealtimePricePerMin, nil
  22328. }
  22329. // AddAudioRealtimePricePerMin adds f to the "audio_realtime_price_per_min" field.
  22330. func (m *GroupMutation) AddAudioRealtimePricePerMin(f float64) {
  22331. if m.addaudio_realtime_price_per_min != nil {
  22332. *m.addaudio_realtime_price_per_min += f
  22333. } else {
  22334. m.addaudio_realtime_price_per_min = &f
  22335. }
  22336. }
  22337. // AddedAudioRealtimePricePerMin returns the value that was added to the "audio_realtime_price_per_min" field in this mutation.
  22338. func (m *GroupMutation) AddedAudioRealtimePricePerMin() (r float64, exists bool) {
  22339. v := m.addaudio_realtime_price_per_min
  22340. if v == nil {
  22341. return
  22342. }
  22343. return *v, true
  22344. }
  22345. // ClearAudioRealtimePricePerMin clears the value of the "audio_realtime_price_per_min" field.
  22346. func (m *GroupMutation) ClearAudioRealtimePricePerMin() {
  22347. m.audio_realtime_price_per_min = nil
  22348. m.addaudio_realtime_price_per_min = nil
  22349. m.clearedFields[group.FieldAudioRealtimePricePerMin] = struct{}{}
  22350. }
  22351. // AudioRealtimePricePerMinCleared returns if the "audio_realtime_price_per_min" field was cleared in this mutation.
  22352. func (m *GroupMutation) AudioRealtimePricePerMinCleared() bool {
  22353. _, ok := m.clearedFields[group.FieldAudioRealtimePricePerMin]
  22354. return ok
  22355. }
  22356. // ResetAudioRealtimePricePerMin resets all changes to the "audio_realtime_price_per_min" field.
  22357. func (m *GroupMutation) ResetAudioRealtimePricePerMin() {
  22358. m.audio_realtime_price_per_min = nil
  22359. m.addaudio_realtime_price_per_min = nil
  22360. delete(m.clearedFields, group.FieldAudioRealtimePricePerMin)
  22361. }
  22362. // SetAudioTtsPricePerMillionChars sets the "audio_tts_price_per_million_chars" field.
  22363. func (m *GroupMutation) SetAudioTtsPricePerMillionChars(f float64) {
  22364. m.audio_tts_price_per_million_chars = &f
  22365. m.addaudio_tts_price_per_million_chars = nil
  22366. }
  22367. // AudioTtsPricePerMillionChars returns the value of the "audio_tts_price_per_million_chars" field in the mutation.
  22368. func (m *GroupMutation) AudioTtsPricePerMillionChars() (r float64, exists bool) {
  22369. v := m.audio_tts_price_per_million_chars
  22370. if v == nil {
  22371. return
  22372. }
  22373. return *v, true
  22374. }
  22375. // OldAudioTtsPricePerMillionChars returns the old "audio_tts_price_per_million_chars" field's value of the Group entity.
  22376. // If the Group object wasn't provided to the builder, the object is fetched from the database.
  22377. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22378. func (m *GroupMutation) OldAudioTtsPricePerMillionChars(ctx context.Context) (v *float64, err error) {
  22379. if !m.op.Is(OpUpdateOne) {
  22380. return v, errors.New("OldAudioTtsPricePerMillionChars is only allowed on UpdateOne operations")
  22381. }
  22382. if m.id == nil || m.oldValue == nil {
  22383. return v, errors.New("OldAudioTtsPricePerMillionChars requires an ID field in the mutation")
  22384. }
  22385. oldValue, err := m.oldValue(ctx)
  22386. if err != nil {
  22387. return v, fmt.Errorf("querying old value for OldAudioTtsPricePerMillionChars: %w", err)
  22388. }
  22389. return oldValue.AudioTtsPricePerMillionChars, nil
  22390. }
  22391. // AddAudioTtsPricePerMillionChars adds f to the "audio_tts_price_per_million_chars" field.
  22392. func (m *GroupMutation) AddAudioTtsPricePerMillionChars(f float64) {
  22393. if m.addaudio_tts_price_per_million_chars != nil {
  22394. *m.addaudio_tts_price_per_million_chars += f
  22395. } else {
  22396. m.addaudio_tts_price_per_million_chars = &f
  22397. }
  22398. }
  22399. // AddedAudioTtsPricePerMillionChars returns the value that was added to the "audio_tts_price_per_million_chars" field in this mutation.
  22400. func (m *GroupMutation) AddedAudioTtsPricePerMillionChars() (r float64, exists bool) {
  22401. v := m.addaudio_tts_price_per_million_chars
  22402. if v == nil {
  22403. return
  22404. }
  22405. return *v, true
  22406. }
  22407. // ClearAudioTtsPricePerMillionChars clears the value of the "audio_tts_price_per_million_chars" field.
  22408. func (m *GroupMutation) ClearAudioTtsPricePerMillionChars() {
  22409. m.audio_tts_price_per_million_chars = nil
  22410. m.addaudio_tts_price_per_million_chars = nil
  22411. m.clearedFields[group.FieldAudioTtsPricePerMillionChars] = struct{}{}
  22412. }
  22413. // AudioTtsPricePerMillionCharsCleared returns if the "audio_tts_price_per_million_chars" field was cleared in this mutation.
  22414. func (m *GroupMutation) AudioTtsPricePerMillionCharsCleared() bool {
  22415. _, ok := m.clearedFields[group.FieldAudioTtsPricePerMillionChars]
  22416. return ok
  22417. }
  22418. // ResetAudioTtsPricePerMillionChars resets all changes to the "audio_tts_price_per_million_chars" field.
  22419. func (m *GroupMutation) ResetAudioTtsPricePerMillionChars() {
  22420. m.audio_tts_price_per_million_chars = nil
  22421. m.addaudio_tts_price_per_million_chars = nil
  22422. delete(m.clearedFields, group.FieldAudioTtsPricePerMillionChars)
  22423. }
  22424. // SetAudioSttPricePerHour sets the "audio_stt_price_per_hour" field.
  22425. func (m *GroupMutation) SetAudioSttPricePerHour(f float64) {
  22426. m.audio_stt_price_per_hour = &f
  22427. m.addaudio_stt_price_per_hour = nil
  22428. }
  22429. // AudioSttPricePerHour returns the value of the "audio_stt_price_per_hour" field in the mutation.
  22430. func (m *GroupMutation) AudioSttPricePerHour() (r float64, exists bool) {
  22431. v := m.audio_stt_price_per_hour
  22432. if v == nil {
  22433. return
  22434. }
  22435. return *v, true
  22436. }
  22437. // OldAudioSttPricePerHour returns the old "audio_stt_price_per_hour" field's value of the Group entity.
  22438. // If the Group object wasn't provided to the builder, the object is fetched from the database.
  22439. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22440. func (m *GroupMutation) OldAudioSttPricePerHour(ctx context.Context) (v *float64, err error) {
  22441. if !m.op.Is(OpUpdateOne) {
  22442. return v, errors.New("OldAudioSttPricePerHour is only allowed on UpdateOne operations")
  22443. }
  22444. if m.id == nil || m.oldValue == nil {
  22445. return v, errors.New("OldAudioSttPricePerHour requires an ID field in the mutation")
  22446. }
  22447. oldValue, err := m.oldValue(ctx)
  22448. if err != nil {
  22449. return v, fmt.Errorf("querying old value for OldAudioSttPricePerHour: %w", err)
  22450. }
  22451. return oldValue.AudioSttPricePerHour, nil
  22452. }
  22453. // AddAudioSttPricePerHour adds f to the "audio_stt_price_per_hour" field.
  22454. func (m *GroupMutation) AddAudioSttPricePerHour(f float64) {
  22455. if m.addaudio_stt_price_per_hour != nil {
  22456. *m.addaudio_stt_price_per_hour += f
  22457. } else {
  22458. m.addaudio_stt_price_per_hour = &f
  22459. }
  22460. }
  22461. // AddedAudioSttPricePerHour returns the value that was added to the "audio_stt_price_per_hour" field in this mutation.
  22462. func (m *GroupMutation) AddedAudioSttPricePerHour() (r float64, exists bool) {
  22463. v := m.addaudio_stt_price_per_hour
  22464. if v == nil {
  22465. return
  22466. }
  22467. return *v, true
  22468. }
  22469. // ClearAudioSttPricePerHour clears the value of the "audio_stt_price_per_hour" field.
  22470. func (m *GroupMutation) ClearAudioSttPricePerHour() {
  22471. m.audio_stt_price_per_hour = nil
  22472. m.addaudio_stt_price_per_hour = nil
  22473. m.clearedFields[group.FieldAudioSttPricePerHour] = struct{}{}
  22474. }
  22475. // AudioSttPricePerHourCleared returns if the "audio_stt_price_per_hour" field was cleared in this mutation.
  22476. func (m *GroupMutation) AudioSttPricePerHourCleared() bool {
  22477. _, ok := m.clearedFields[group.FieldAudioSttPricePerHour]
  22478. return ok
  22479. }
  22480. // ResetAudioSttPricePerHour resets all changes to the "audio_stt_price_per_hour" field.
  22481. func (m *GroupMutation) ResetAudioSttPricePerHour() {
  22482. m.audio_stt_price_per_hour = nil
  22483. m.addaudio_stt_price_per_hour = nil
  22484. delete(m.clearedFields, group.FieldAudioSttPricePerHour)
  22485. }
  22486. // SetLongContextPricingEnabled sets the "long_context_pricing_enabled" field.
  22487. func (m *GroupMutation) SetLongContextPricingEnabled(b bool) {
  22488. m.long_context_pricing_enabled = &b
  22489. }
  22490. // LongContextPricingEnabled returns the value of the "long_context_pricing_enabled" field in the mutation.
  22491. func (m *GroupMutation) LongContextPricingEnabled() (r bool, exists bool) {
  22492. v := m.long_context_pricing_enabled
  22493. if v == nil {
  22494. return
  22495. }
  22496. return *v, true
  22497. }
  22498. // OldLongContextPricingEnabled returns the old "long_context_pricing_enabled" field's value of the Group entity.
  22499. // If the Group object wasn't provided to the builder, the object is fetched from the database.
  22500. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22501. func (m *GroupMutation) OldLongContextPricingEnabled(ctx context.Context) (v bool, err error) {
  22502. if !m.op.Is(OpUpdateOne) {
  22503. return v, errors.New("OldLongContextPricingEnabled is only allowed on UpdateOne operations")
  22504. }
  22505. if m.id == nil || m.oldValue == nil {
  22506. return v, errors.New("OldLongContextPricingEnabled requires an ID field in the mutation")
  22507. }
  22508. oldValue, err := m.oldValue(ctx)
  22509. if err != nil {
  22510. return v, fmt.Errorf("querying old value for OldLongContextPricingEnabled: %w", err)
  22511. }
  22512. return oldValue.LongContextPricingEnabled, nil
  22513. }
  22514. // ResetLongContextPricingEnabled resets all changes to the "long_context_pricing_enabled" field.
  22515. func (m *GroupMutation) ResetLongContextPricingEnabled() {
  22516. m.long_context_pricing_enabled = nil
  22517. }
  22518. // SetModelPricing sets the "model_pricing" field.
  22519. func (m *GroupMutation) SetModelPricing(j jsontext.Value) {
  22520. m.model_pricing = &j
  22521. m.appendmodel_pricing = nil
  22522. }
  22523. // ModelPricing returns the value of the "model_pricing" field in the mutation.
  22524. func (m *GroupMutation) ModelPricing() (r jsontext.Value, exists bool) {
  22525. v := m.model_pricing
  22526. if v == nil {
  22527. return
  22528. }
  22529. return *v, true
  22530. }
  22531. // OldModelPricing returns the old "model_pricing" field's value of the Group entity.
  22532. // If the Group object wasn't provided to the builder, the object is fetched from the database.
  22533. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22534. func (m *GroupMutation) OldModelPricing(ctx context.Context) (v jsontext.Value, err error) {
  22535. if !m.op.Is(OpUpdateOne) {
  22536. return v, errors.New("OldModelPricing is only allowed on UpdateOne operations")
  22537. }
  22538. if m.id == nil || m.oldValue == nil {
  22539. return v, errors.New("OldModelPricing requires an ID field in the mutation")
  22540. }
  22541. oldValue, err := m.oldValue(ctx)
  22542. if err != nil {
  22543. return v, fmt.Errorf("querying old value for OldModelPricing: %w", err)
  22544. }
  22545. return oldValue.ModelPricing, nil
  22546. }
  22547. // AppendModelPricing adds j to the "model_pricing" field.
  22548. func (m *GroupMutation) AppendModelPricing(j jsontext.Value) {
  22549. m.appendmodel_pricing = append(m.appendmodel_pricing, j...)
  22550. }
  22551. // AppendedModelPricing returns the list of values that were appended to the "model_pricing" field in this mutation.
  22552. func (m *GroupMutation) AppendedModelPricing() (jsontext.Value, bool) {
  22553. if len(m.appendmodel_pricing) == 0 {
  22554. return nil, false
  22555. }
  22556. return m.appendmodel_pricing, true
  22557. }
  22558. // ClearModelPricing clears the value of the "model_pricing" field.
  22559. func (m *GroupMutation) ClearModelPricing() {
  22560. m.model_pricing = nil
  22561. m.appendmodel_pricing = nil
  22562. m.clearedFields[group.FieldModelPricing] = struct{}{}
  22563. }
  22564. // ModelPricingCleared returns if the "model_pricing" field was cleared in this mutation.
  22565. func (m *GroupMutation) ModelPricingCleared() bool {
  22566. _, ok := m.clearedFields[group.FieldModelPricing]
  22567. return ok
  22568. }
  22569. // ResetModelPricing resets all changes to the "model_pricing" field.
  22570. func (m *GroupMutation) ResetModelPricing() {
  22571. m.model_pricing = nil
  22572. m.appendmodel_pricing = nil
  22573. delete(m.clearedFields, group.FieldModelPricing)
  22574. }
  22575. // SetClaudeCodeOnly sets the "claude_code_only" field.
  22576. func (m *GroupMutation) SetClaudeCodeOnly(b bool) {
  22577. m.claude_code_only = &b
  22578. }
  22579. // ClaudeCodeOnly returns the value of the "claude_code_only" field in the mutation.
  22580. func (m *GroupMutation) ClaudeCodeOnly() (r bool, exists bool) {
  22581. v := m.claude_code_only
  22582. if v == nil {
  22583. return
  22584. }
  22585. return *v, true
  22586. }
  22587. // OldClaudeCodeOnly returns the old "claude_code_only" field's value of the Group entity.
  22588. // If the Group object wasn't provided to the builder, the object is fetched from the database.
  22589. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22590. func (m *GroupMutation) OldClaudeCodeOnly(ctx context.Context) (v bool, err error) {
  22591. if !m.op.Is(OpUpdateOne) {
  22592. return v, errors.New("OldClaudeCodeOnly is only allowed on UpdateOne operations")
  22593. }
  22594. if m.id == nil || m.oldValue == nil {
  22595. return v, errors.New("OldClaudeCodeOnly requires an ID field in the mutation")
  22596. }
  22597. oldValue, err := m.oldValue(ctx)
  22598. if err != nil {
  22599. return v, fmt.Errorf("querying old value for OldClaudeCodeOnly: %w", err)
  22600. }
  22601. return oldValue.ClaudeCodeOnly, nil
  22602. }
  22603. // ResetClaudeCodeOnly resets all changes to the "claude_code_only" field.
  22604. func (m *GroupMutation) ResetClaudeCodeOnly() {
  22605. m.claude_code_only = nil
  22606. }
  22607. // SetFallbackGroupID sets the "fallback_group_id" field.
  22608. func (m *GroupMutation) SetFallbackGroupID(i int64) {
  22609. m.fallback_group_id = &i
  22610. m.addfallback_group_id = nil
  22611. }
  22612. // FallbackGroupID returns the value of the "fallback_group_id" field in the mutation.
  22613. func (m *GroupMutation) FallbackGroupID() (r int64, exists bool) {
  22614. v := m.fallback_group_id
  22615. if v == nil {
  22616. return
  22617. }
  22618. return *v, true
  22619. }
  22620. // OldFallbackGroupID returns the old "fallback_group_id" field's value of the Group entity.
  22621. // If the Group object wasn't provided to the builder, the object is fetched from the database.
  22622. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22623. func (m *GroupMutation) OldFallbackGroupID(ctx context.Context) (v *int64, err error) {
  22624. if !m.op.Is(OpUpdateOne) {
  22625. return v, errors.New("OldFallbackGroupID is only allowed on UpdateOne operations")
  22626. }
  22627. if m.id == nil || m.oldValue == nil {
  22628. return v, errors.New("OldFallbackGroupID requires an ID field in the mutation")
  22629. }
  22630. oldValue, err := m.oldValue(ctx)
  22631. if err != nil {
  22632. return v, fmt.Errorf("querying old value for OldFallbackGroupID: %w", err)
  22633. }
  22634. return oldValue.FallbackGroupID, nil
  22635. }
  22636. // AddFallbackGroupID adds i to the "fallback_group_id" field.
  22637. func (m *GroupMutation) AddFallbackGroupID(i int64) {
  22638. if m.addfallback_group_id != nil {
  22639. *m.addfallback_group_id += i
  22640. } else {
  22641. m.addfallback_group_id = &i
  22642. }
  22643. }
  22644. // AddedFallbackGroupID returns the value that was added to the "fallback_group_id" field in this mutation.
  22645. func (m *GroupMutation) AddedFallbackGroupID() (r int64, exists bool) {
  22646. v := m.addfallback_group_id
  22647. if v == nil {
  22648. return
  22649. }
  22650. return *v, true
  22651. }
  22652. // ClearFallbackGroupID clears the value of the "fallback_group_id" field.
  22653. func (m *GroupMutation) ClearFallbackGroupID() {
  22654. m.fallback_group_id = nil
  22655. m.addfallback_group_id = nil
  22656. m.clearedFields[group.FieldFallbackGroupID] = struct{}{}
  22657. }
  22658. // FallbackGroupIDCleared returns if the "fallback_group_id" field was cleared in this mutation.
  22659. func (m *GroupMutation) FallbackGroupIDCleared() bool {
  22660. _, ok := m.clearedFields[group.FieldFallbackGroupID]
  22661. return ok
  22662. }
  22663. // ResetFallbackGroupID resets all changes to the "fallback_group_id" field.
  22664. func (m *GroupMutation) ResetFallbackGroupID() {
  22665. m.fallback_group_id = nil
  22666. m.addfallback_group_id = nil
  22667. delete(m.clearedFields, group.FieldFallbackGroupID)
  22668. }
  22669. // SetFallbackGroupIDOnInvalidRequest sets the "fallback_group_id_on_invalid_request" field.
  22670. func (m *GroupMutation) SetFallbackGroupIDOnInvalidRequest(i int64) {
  22671. m.fallback_group_id_on_invalid_request = &i
  22672. m.addfallback_group_id_on_invalid_request = nil
  22673. }
  22674. // FallbackGroupIDOnInvalidRequest returns the value of the "fallback_group_id_on_invalid_request" field in the mutation.
  22675. func (m *GroupMutation) FallbackGroupIDOnInvalidRequest() (r int64, exists bool) {
  22676. v := m.fallback_group_id_on_invalid_request
  22677. if v == nil {
  22678. return
  22679. }
  22680. return *v, true
  22681. }
  22682. // OldFallbackGroupIDOnInvalidRequest returns the old "fallback_group_id_on_invalid_request" field's value of the Group entity.
  22683. // If the Group object wasn't provided to the builder, the object is fetched from the database.
  22684. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22685. func (m *GroupMutation) OldFallbackGroupIDOnInvalidRequest(ctx context.Context) (v *int64, err error) {
  22686. if !m.op.Is(OpUpdateOne) {
  22687. return v, errors.New("OldFallbackGroupIDOnInvalidRequest is only allowed on UpdateOne operations")
  22688. }
  22689. if m.id == nil || m.oldValue == nil {
  22690. return v, errors.New("OldFallbackGroupIDOnInvalidRequest requires an ID field in the mutation")
  22691. }
  22692. oldValue, err := m.oldValue(ctx)
  22693. if err != nil {
  22694. return v, fmt.Errorf("querying old value for OldFallbackGroupIDOnInvalidRequest: %w", err)
  22695. }
  22696. return oldValue.FallbackGroupIDOnInvalidRequest, nil
  22697. }
  22698. // AddFallbackGroupIDOnInvalidRequest adds i to the "fallback_group_id_on_invalid_request" field.
  22699. func (m *GroupMutation) AddFallbackGroupIDOnInvalidRequest(i int64) {
  22700. if m.addfallback_group_id_on_invalid_request != nil {
  22701. *m.addfallback_group_id_on_invalid_request += i
  22702. } else {
  22703. m.addfallback_group_id_on_invalid_request = &i
  22704. }
  22705. }
  22706. // AddedFallbackGroupIDOnInvalidRequest returns the value that was added to the "fallback_group_id_on_invalid_request" field in this mutation.
  22707. func (m *GroupMutation) AddedFallbackGroupIDOnInvalidRequest() (r int64, exists bool) {
  22708. v := m.addfallback_group_id_on_invalid_request
  22709. if v == nil {
  22710. return
  22711. }
  22712. return *v, true
  22713. }
  22714. // ClearFallbackGroupIDOnInvalidRequest clears the value of the "fallback_group_id_on_invalid_request" field.
  22715. func (m *GroupMutation) ClearFallbackGroupIDOnInvalidRequest() {
  22716. m.fallback_group_id_on_invalid_request = nil
  22717. m.addfallback_group_id_on_invalid_request = nil
  22718. m.clearedFields[group.FieldFallbackGroupIDOnInvalidRequest] = struct{}{}
  22719. }
  22720. // FallbackGroupIDOnInvalidRequestCleared returns if the "fallback_group_id_on_invalid_request" field was cleared in this mutation.
  22721. func (m *GroupMutation) FallbackGroupIDOnInvalidRequestCleared() bool {
  22722. _, ok := m.clearedFields[group.FieldFallbackGroupIDOnInvalidRequest]
  22723. return ok
  22724. }
  22725. // ResetFallbackGroupIDOnInvalidRequest resets all changes to the "fallback_group_id_on_invalid_request" field.
  22726. func (m *GroupMutation) ResetFallbackGroupIDOnInvalidRequest() {
  22727. m.fallback_group_id_on_invalid_request = nil
  22728. m.addfallback_group_id_on_invalid_request = nil
  22729. delete(m.clearedFields, group.FieldFallbackGroupIDOnInvalidRequest)
  22730. }
  22731. // SetModelRouting sets the "model_routing" field.
  22732. func (m *GroupMutation) SetModelRouting(value map[string][]int64) {
  22733. m.model_routing = &value
  22734. }
  22735. // ModelRouting returns the value of the "model_routing" field in the mutation.
  22736. func (m *GroupMutation) ModelRouting() (r map[string][]int64, exists bool) {
  22737. v := m.model_routing
  22738. if v == nil {
  22739. return
  22740. }
  22741. return *v, true
  22742. }
  22743. // OldModelRouting returns the old "model_routing" field's value of the Group entity.
  22744. // If the Group object wasn't provided to the builder, the object is fetched from the database.
  22745. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22746. func (m *GroupMutation) OldModelRouting(ctx context.Context) (v map[string][]int64, err error) {
  22747. if !m.op.Is(OpUpdateOne) {
  22748. return v, errors.New("OldModelRouting is only allowed on UpdateOne operations")
  22749. }
  22750. if m.id == nil || m.oldValue == nil {
  22751. return v, errors.New("OldModelRouting requires an ID field in the mutation")
  22752. }
  22753. oldValue, err := m.oldValue(ctx)
  22754. if err != nil {
  22755. return v, fmt.Errorf("querying old value for OldModelRouting: %w", err)
  22756. }
  22757. return oldValue.ModelRouting, nil
  22758. }
  22759. // ClearModelRouting clears the value of the "model_routing" field.
  22760. func (m *GroupMutation) ClearModelRouting() {
  22761. m.model_routing = nil
  22762. m.clearedFields[group.FieldModelRouting] = struct{}{}
  22763. }
  22764. // ModelRoutingCleared returns if the "model_routing" field was cleared in this mutation.
  22765. func (m *GroupMutation) ModelRoutingCleared() bool {
  22766. _, ok := m.clearedFields[group.FieldModelRouting]
  22767. return ok
  22768. }
  22769. // ResetModelRouting resets all changes to the "model_routing" field.
  22770. func (m *GroupMutation) ResetModelRouting() {
  22771. m.model_routing = nil
  22772. delete(m.clearedFields, group.FieldModelRouting)
  22773. }
  22774. // SetModelRoutingEnabled sets the "model_routing_enabled" field.
  22775. func (m *GroupMutation) SetModelRoutingEnabled(b bool) {
  22776. m.model_routing_enabled = &b
  22777. }
  22778. // ModelRoutingEnabled returns the value of the "model_routing_enabled" field in the mutation.
  22779. func (m *GroupMutation) ModelRoutingEnabled() (r bool, exists bool) {
  22780. v := m.model_routing_enabled
  22781. if v == nil {
  22782. return
  22783. }
  22784. return *v, true
  22785. }
  22786. // OldModelRoutingEnabled returns the old "model_routing_enabled" field's value of the Group entity.
  22787. // If the Group object wasn't provided to the builder, the object is fetched from the database.
  22788. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22789. func (m *GroupMutation) OldModelRoutingEnabled(ctx context.Context) (v bool, err error) {
  22790. if !m.op.Is(OpUpdateOne) {
  22791. return v, errors.New("OldModelRoutingEnabled is only allowed on UpdateOne operations")
  22792. }
  22793. if m.id == nil || m.oldValue == nil {
  22794. return v, errors.New("OldModelRoutingEnabled requires an ID field in the mutation")
  22795. }
  22796. oldValue, err := m.oldValue(ctx)
  22797. if err != nil {
  22798. return v, fmt.Errorf("querying old value for OldModelRoutingEnabled: %w", err)
  22799. }
  22800. return oldValue.ModelRoutingEnabled, nil
  22801. }
  22802. // ResetModelRoutingEnabled resets all changes to the "model_routing_enabled" field.
  22803. func (m *GroupMutation) ResetModelRoutingEnabled() {
  22804. m.model_routing_enabled = nil
  22805. }
  22806. // SetMcpXMLInject sets the "mcp_xml_inject" field.
  22807. func (m *GroupMutation) SetMcpXMLInject(b bool) {
  22808. m.mcp_xml_inject = &b
  22809. }
  22810. // McpXMLInject returns the value of the "mcp_xml_inject" field in the mutation.
  22811. func (m *GroupMutation) McpXMLInject() (r bool, exists bool) {
  22812. v := m.mcp_xml_inject
  22813. if v == nil {
  22814. return
  22815. }
  22816. return *v, true
  22817. }
  22818. // OldMcpXMLInject returns the old "mcp_xml_inject" field's value of the Group entity.
  22819. // If the Group object wasn't provided to the builder, the object is fetched from the database.
  22820. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22821. func (m *GroupMutation) OldMcpXMLInject(ctx context.Context) (v bool, err error) {
  22822. if !m.op.Is(OpUpdateOne) {
  22823. return v, errors.New("OldMcpXMLInject is only allowed on UpdateOne operations")
  22824. }
  22825. if m.id == nil || m.oldValue == nil {
  22826. return v, errors.New("OldMcpXMLInject requires an ID field in the mutation")
  22827. }
  22828. oldValue, err := m.oldValue(ctx)
  22829. if err != nil {
  22830. return v, fmt.Errorf("querying old value for OldMcpXMLInject: %w", err)
  22831. }
  22832. return oldValue.McpXMLInject, nil
  22833. }
  22834. // ResetMcpXMLInject resets all changes to the "mcp_xml_inject" field.
  22835. func (m *GroupMutation) ResetMcpXMLInject() {
  22836. m.mcp_xml_inject = nil
  22837. }
  22838. // SetSupportedModelScopes sets the "supported_model_scopes" field.
  22839. func (m *GroupMutation) SetSupportedModelScopes(s []string) {
  22840. m.supported_model_scopes = &s
  22841. m.appendsupported_model_scopes = nil
  22842. }
  22843. // SupportedModelScopes returns the value of the "supported_model_scopes" field in the mutation.
  22844. func (m *GroupMutation) SupportedModelScopes() (r []string, exists bool) {
  22845. v := m.supported_model_scopes
  22846. if v == nil {
  22847. return
  22848. }
  22849. return *v, true
  22850. }
  22851. // OldSupportedModelScopes returns the old "supported_model_scopes" field's value of the Group entity.
  22852. // If the Group object wasn't provided to the builder, the object is fetched from the database.
  22853. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22854. func (m *GroupMutation) OldSupportedModelScopes(ctx context.Context) (v []string, err error) {
  22855. if !m.op.Is(OpUpdateOne) {
  22856. return v, errors.New("OldSupportedModelScopes is only allowed on UpdateOne operations")
  22857. }
  22858. if m.id == nil || m.oldValue == nil {
  22859. return v, errors.New("OldSupportedModelScopes requires an ID field in the mutation")
  22860. }
  22861. oldValue, err := m.oldValue(ctx)
  22862. if err != nil {
  22863. return v, fmt.Errorf("querying old value for OldSupportedModelScopes: %w", err)
  22864. }
  22865. return oldValue.SupportedModelScopes, nil
  22866. }
  22867. // AppendSupportedModelScopes adds s to the "supported_model_scopes" field.
  22868. func (m *GroupMutation) AppendSupportedModelScopes(s []string) {
  22869. m.appendsupported_model_scopes = append(m.appendsupported_model_scopes, s...)
  22870. }
  22871. // AppendedSupportedModelScopes returns the list of values that were appended to the "supported_model_scopes" field in this mutation.
  22872. func (m *GroupMutation) AppendedSupportedModelScopes() ([]string, bool) {
  22873. if len(m.appendsupported_model_scopes) == 0 {
  22874. return nil, false
  22875. }
  22876. return m.appendsupported_model_scopes, true
  22877. }
  22878. // ResetSupportedModelScopes resets all changes to the "supported_model_scopes" field.
  22879. func (m *GroupMutation) ResetSupportedModelScopes() {
  22880. m.supported_model_scopes = nil
  22881. m.appendsupported_model_scopes = nil
  22882. }
  22883. // SetSortOrder sets the "sort_order" field.
  22884. func (m *GroupMutation) SetSortOrder(i int) {
  22885. m.sort_order = &i
  22886. m.addsort_order = nil
  22887. }
  22888. // SortOrder returns the value of the "sort_order" field in the mutation.
  22889. func (m *GroupMutation) SortOrder() (r int, exists bool) {
  22890. v := m.sort_order
  22891. if v == nil {
  22892. return
  22893. }
  22894. return *v, true
  22895. }
  22896. // OldSortOrder returns the old "sort_order" field's value of the Group entity.
  22897. // If the Group object wasn't provided to the builder, the object is fetched from the database.
  22898. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22899. func (m *GroupMutation) OldSortOrder(ctx context.Context) (v int, err error) {
  22900. if !m.op.Is(OpUpdateOne) {
  22901. return v, errors.New("OldSortOrder is only allowed on UpdateOne operations")
  22902. }
  22903. if m.id == nil || m.oldValue == nil {
  22904. return v, errors.New("OldSortOrder requires an ID field in the mutation")
  22905. }
  22906. oldValue, err := m.oldValue(ctx)
  22907. if err != nil {
  22908. return v, fmt.Errorf("querying old value for OldSortOrder: %w", err)
  22909. }
  22910. return oldValue.SortOrder, nil
  22911. }
  22912. // AddSortOrder adds i to the "sort_order" field.
  22913. func (m *GroupMutation) AddSortOrder(i int) {
  22914. if m.addsort_order != nil {
  22915. *m.addsort_order += i
  22916. } else {
  22917. m.addsort_order = &i
  22918. }
  22919. }
  22920. // AddedSortOrder returns the value that was added to the "sort_order" field in this mutation.
  22921. func (m *GroupMutation) AddedSortOrder() (r int, exists bool) {
  22922. v := m.addsort_order
  22923. if v == nil {
  22924. return
  22925. }
  22926. return *v, true
  22927. }
  22928. // ResetSortOrder resets all changes to the "sort_order" field.
  22929. func (m *GroupMutation) ResetSortOrder() {
  22930. m.sort_order = nil
  22931. m.addsort_order = nil
  22932. }
  22933. // SetAllowMessagesDispatch sets the "allow_messages_dispatch" field.
  22934. func (m *GroupMutation) SetAllowMessagesDispatch(b bool) {
  22935. m.allow_messages_dispatch = &b
  22936. }
  22937. // AllowMessagesDispatch returns the value of the "allow_messages_dispatch" field in the mutation.
  22938. func (m *GroupMutation) AllowMessagesDispatch() (r bool, exists bool) {
  22939. v := m.allow_messages_dispatch
  22940. if v == nil {
  22941. return
  22942. }
  22943. return *v, true
  22944. }
  22945. // OldAllowMessagesDispatch returns the old "allow_messages_dispatch" field's value of the Group entity.
  22946. // If the Group object wasn't provided to the builder, the object is fetched from the database.
  22947. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22948. func (m *GroupMutation) OldAllowMessagesDispatch(ctx context.Context) (v bool, err error) {
  22949. if !m.op.Is(OpUpdateOne) {
  22950. return v, errors.New("OldAllowMessagesDispatch is only allowed on UpdateOne operations")
  22951. }
  22952. if m.id == nil || m.oldValue == nil {
  22953. return v, errors.New("OldAllowMessagesDispatch requires an ID field in the mutation")
  22954. }
  22955. oldValue, err := m.oldValue(ctx)
  22956. if err != nil {
  22957. return v, fmt.Errorf("querying old value for OldAllowMessagesDispatch: %w", err)
  22958. }
  22959. return oldValue.AllowMessagesDispatch, nil
  22960. }
  22961. // ResetAllowMessagesDispatch resets all changes to the "allow_messages_dispatch" field.
  22962. func (m *GroupMutation) ResetAllowMessagesDispatch() {
  22963. m.allow_messages_dispatch = nil
  22964. }
  22965. // SetAllowLive sets the "allow_live" field.
  22966. func (m *GroupMutation) SetAllowLive(b bool) {
  22967. m.allow_live = &b
  22968. }
  22969. // AllowLive returns the value of the "allow_live" field in the mutation.
  22970. func (m *GroupMutation) AllowLive() (r bool, exists bool) {
  22971. v := m.allow_live
  22972. if v == nil {
  22973. return
  22974. }
  22975. return *v, true
  22976. }
  22977. // OldAllowLive returns the old "allow_live" field's value of the Group entity.
  22978. // If the Group object wasn't provided to the builder, the object is fetched from the database.
  22979. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22980. func (m *GroupMutation) OldAllowLive(ctx context.Context) (v bool, err error) {
  22981. if !m.op.Is(OpUpdateOne) {
  22982. return v, errors.New("OldAllowLive is only allowed on UpdateOne operations")
  22983. }
  22984. if m.id == nil || m.oldValue == nil {
  22985. return v, errors.New("OldAllowLive requires an ID field in the mutation")
  22986. }
  22987. oldValue, err := m.oldValue(ctx)
  22988. if err != nil {
  22989. return v, fmt.Errorf("querying old value for OldAllowLive: %w", err)
  22990. }
  22991. return oldValue.AllowLive, nil
  22992. }
  22993. // ResetAllowLive resets all changes to the "allow_live" field.
  22994. func (m *GroupMutation) ResetAllowLive() {
  22995. m.allow_live = nil
  22996. }
  22997. // SetForceOpenaiFast sets the "force_openai_fast" field.
  22998. func (m *GroupMutation) SetForceOpenaiFast(b bool) {
  22999. m.force_openai_fast = &b
  23000. }
  23001. // ForceOpenaiFast returns the value of the "force_openai_fast" field in the mutation.
  23002. func (m *GroupMutation) ForceOpenaiFast() (r bool, exists bool) {
  23003. v := m.force_openai_fast
  23004. if v == nil {
  23005. return
  23006. }
  23007. return *v, true
  23008. }
  23009. // OldForceOpenaiFast returns the old "force_openai_fast" field's value of the Group entity.
  23010. // If the Group object wasn't provided to the builder, the object is fetched from the database.
  23011. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23012. func (m *GroupMutation) OldForceOpenaiFast(ctx context.Context) (v bool, err error) {
  23013. if !m.op.Is(OpUpdateOne) {
  23014. return v, errors.New("OldForceOpenaiFast is only allowed on UpdateOne operations")
  23015. }
  23016. if m.id == nil || m.oldValue == nil {
  23017. return v, errors.New("OldForceOpenaiFast requires an ID field in the mutation")
  23018. }
  23019. oldValue, err := m.oldValue(ctx)
  23020. if err != nil {
  23021. return v, fmt.Errorf("querying old value for OldForceOpenaiFast: %w", err)
  23022. }
  23023. return oldValue.ForceOpenaiFast, nil
  23024. }
  23025. // ResetForceOpenaiFast resets all changes to the "force_openai_fast" field.
  23026. func (m *GroupMutation) ResetForceOpenaiFast() {
  23027. m.force_openai_fast = nil
  23028. }
  23029. // SetFreeOpenaiFast sets the "free_openai_fast" field.
  23030. func (m *GroupMutation) SetFreeOpenaiFast(b bool) {
  23031. m.free_openai_fast = &b
  23032. }
  23033. // FreeOpenaiFast returns the value of the "free_openai_fast" field in the mutation.
  23034. func (m *GroupMutation) FreeOpenaiFast() (r bool, exists bool) {
  23035. v := m.free_openai_fast
  23036. if v == nil {
  23037. return
  23038. }
  23039. return *v, true
  23040. }
  23041. // OldFreeOpenaiFast returns the old "free_openai_fast" field's value of the Group entity.
  23042. // If the Group object wasn't provided to the builder, the object is fetched from the database.
  23043. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23044. func (m *GroupMutation) OldFreeOpenaiFast(ctx context.Context) (v bool, err error) {
  23045. if !m.op.Is(OpUpdateOne) {
  23046. return v, errors.New("OldFreeOpenaiFast is only allowed on UpdateOne operations")
  23047. }
  23048. if m.id == nil || m.oldValue == nil {
  23049. return v, errors.New("OldFreeOpenaiFast requires an ID field in the mutation")
  23050. }
  23051. oldValue, err := m.oldValue(ctx)
  23052. if err != nil {
  23053. return v, fmt.Errorf("querying old value for OldFreeOpenaiFast: %w", err)
  23054. }
  23055. return oldValue.FreeOpenaiFast, nil
  23056. }
  23057. // ResetFreeOpenaiFast resets all changes to the "free_openai_fast" field.
  23058. func (m *GroupMutation) ResetFreeOpenaiFast() {
  23059. m.free_openai_fast = nil
  23060. }
  23061. // SetRequireOauthOnly sets the "require_oauth_only" field.
  23062. func (m *GroupMutation) SetRequireOauthOnly(b bool) {
  23063. m.require_oauth_only = &b
  23064. }
  23065. // RequireOauthOnly returns the value of the "require_oauth_only" field in the mutation.
  23066. func (m *GroupMutation) RequireOauthOnly() (r bool, exists bool) {
  23067. v := m.require_oauth_only
  23068. if v == nil {
  23069. return
  23070. }
  23071. return *v, true
  23072. }
  23073. // OldRequireOauthOnly returns the old "require_oauth_only" field's value of the Group entity.
  23074. // If the Group object wasn't provided to the builder, the object is fetched from the database.
  23075. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23076. func (m *GroupMutation) OldRequireOauthOnly(ctx context.Context) (v bool, err error) {
  23077. if !m.op.Is(OpUpdateOne) {
  23078. return v, errors.New("OldRequireOauthOnly is only allowed on UpdateOne operations")
  23079. }
  23080. if m.id == nil || m.oldValue == nil {
  23081. return v, errors.New("OldRequireOauthOnly requires an ID field in the mutation")
  23082. }
  23083. oldValue, err := m.oldValue(ctx)
  23084. if err != nil {
  23085. return v, fmt.Errorf("querying old value for OldRequireOauthOnly: %w", err)
  23086. }
  23087. return oldValue.RequireOauthOnly, nil
  23088. }
  23089. // ResetRequireOauthOnly resets all changes to the "require_oauth_only" field.
  23090. func (m *GroupMutation) ResetRequireOauthOnly() {
  23091. m.require_oauth_only = nil
  23092. }
  23093. // SetRequirePrivacySet sets the "require_privacy_set" field.
  23094. func (m *GroupMutation) SetRequirePrivacySet(b bool) {
  23095. m.require_privacy_set = &b
  23096. }
  23097. // RequirePrivacySet returns the value of the "require_privacy_set" field in the mutation.
  23098. func (m *GroupMutation) RequirePrivacySet() (r bool, exists bool) {
  23099. v := m.require_privacy_set
  23100. if v == nil {
  23101. return
  23102. }
  23103. return *v, true
  23104. }
  23105. // OldRequirePrivacySet returns the old "require_privacy_set" field's value of the Group entity.
  23106. // If the Group object wasn't provided to the builder, the object is fetched from the database.
  23107. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23108. func (m *GroupMutation) OldRequirePrivacySet(ctx context.Context) (v bool, err error) {
  23109. if !m.op.Is(OpUpdateOne) {
  23110. return v, errors.New("OldRequirePrivacySet is only allowed on UpdateOne operations")
  23111. }
  23112. if m.id == nil || m.oldValue == nil {
  23113. return v, errors.New("OldRequirePrivacySet requires an ID field in the mutation")
  23114. }
  23115. oldValue, err := m.oldValue(ctx)
  23116. if err != nil {
  23117. return v, fmt.Errorf("querying old value for OldRequirePrivacySet: %w", err)
  23118. }
  23119. return oldValue.RequirePrivacySet, nil
  23120. }
  23121. // ResetRequirePrivacySet resets all changes to the "require_privacy_set" field.
  23122. func (m *GroupMutation) ResetRequirePrivacySet() {
  23123. m.require_privacy_set = nil
  23124. }
  23125. // SetDefaultMappedModel sets the "default_mapped_model" field.
  23126. func (m *GroupMutation) SetDefaultMappedModel(s string) {
  23127. m.default_mapped_model = &s
  23128. }
  23129. // DefaultMappedModel returns the value of the "default_mapped_model" field in the mutation.
  23130. func (m *GroupMutation) DefaultMappedModel() (r string, exists bool) {
  23131. v := m.default_mapped_model
  23132. if v == nil {
  23133. return
  23134. }
  23135. return *v, true
  23136. }
  23137. // OldDefaultMappedModel returns the old "default_mapped_model" field's value of the Group entity.
  23138. // If the Group object wasn't provided to the builder, the object is fetched from the database.
  23139. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23140. func (m *GroupMutation) OldDefaultMappedModel(ctx context.Context) (v string, err error) {
  23141. if !m.op.Is(OpUpdateOne) {
  23142. return v, errors.New("OldDefaultMappedModel is only allowed on UpdateOne operations")
  23143. }
  23144. if m.id == nil || m.oldValue == nil {
  23145. return v, errors.New("OldDefaultMappedModel requires an ID field in the mutation")
  23146. }
  23147. oldValue, err := m.oldValue(ctx)
  23148. if err != nil {
  23149. return v, fmt.Errorf("querying old value for OldDefaultMappedModel: %w", err)
  23150. }
  23151. return oldValue.DefaultMappedModel, nil
  23152. }
  23153. // ResetDefaultMappedModel resets all changes to the "default_mapped_model" field.
  23154. func (m *GroupMutation) ResetDefaultMappedModel() {
  23155. m.default_mapped_model = nil
  23156. }
  23157. // SetMessagesDispatchModelConfig sets the "messages_dispatch_model_config" field.
  23158. func (m *GroupMutation) SetMessagesDispatchModelConfig(damdmc domain.OpenAIMessagesDispatchModelConfig) {
  23159. m.messages_dispatch_model_config = &damdmc
  23160. }
  23161. // MessagesDispatchModelConfig returns the value of the "messages_dispatch_model_config" field in the mutation.
  23162. func (m *GroupMutation) MessagesDispatchModelConfig() (r domain.OpenAIMessagesDispatchModelConfig, exists bool) {
  23163. v := m.messages_dispatch_model_config
  23164. if v == nil {
  23165. return
  23166. }
  23167. return *v, true
  23168. }
  23169. // OldMessagesDispatchModelConfig returns the old "messages_dispatch_model_config" field's value of the Group entity.
  23170. // If the Group object wasn't provided to the builder, the object is fetched from the database.
  23171. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23172. func (m *GroupMutation) OldMessagesDispatchModelConfig(ctx context.Context) (v domain.OpenAIMessagesDispatchModelConfig, err error) {
  23173. if !m.op.Is(OpUpdateOne) {
  23174. return v, errors.New("OldMessagesDispatchModelConfig is only allowed on UpdateOne operations")
  23175. }
  23176. if m.id == nil || m.oldValue == nil {
  23177. return v, errors.New("OldMessagesDispatchModelConfig requires an ID field in the mutation")
  23178. }
  23179. oldValue, err := m.oldValue(ctx)
  23180. if err != nil {
  23181. return v, fmt.Errorf("querying old value for OldMessagesDispatchModelConfig: %w", err)
  23182. }
  23183. return oldValue.MessagesDispatchModelConfig, nil
  23184. }
  23185. // ResetMessagesDispatchModelConfig resets all changes to the "messages_dispatch_model_config" field.
  23186. func (m *GroupMutation) ResetMessagesDispatchModelConfig() {
  23187. m.messages_dispatch_model_config = nil
  23188. }
  23189. // SetModelAllowlist sets the "model_allowlist" field.
  23190. func (m *GroupMutation) SetModelAllowlist(dma domain.GroupModelAllowlist) {
  23191. m.model_allowlist = &dma
  23192. }
  23193. // ModelAllowlist returns the value of the "model_allowlist" field in the mutation.
  23194. func (m *GroupMutation) ModelAllowlist() (r domain.GroupModelAllowlist, exists bool) {
  23195. v := m.model_allowlist
  23196. if v == nil {
  23197. return
  23198. }
  23199. return *v, true
  23200. }
  23201. // OldModelAllowlist returns the old "model_allowlist" field's value of the Group entity.
  23202. // If the Group object wasn't provided to the builder, the object is fetched from the database.
  23203. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23204. func (m *GroupMutation) OldModelAllowlist(ctx context.Context) (v domain.GroupModelAllowlist, err error) {
  23205. if !m.op.Is(OpUpdateOne) {
  23206. return v, errors.New("OldModelAllowlist is only allowed on UpdateOne operations")
  23207. }
  23208. if m.id == nil || m.oldValue == nil {
  23209. return v, errors.New("OldModelAllowlist requires an ID field in the mutation")
  23210. }
  23211. oldValue, err := m.oldValue(ctx)
  23212. if err != nil {
  23213. return v, fmt.Errorf("querying old value for OldModelAllowlist: %w", err)
  23214. }
  23215. return oldValue.ModelAllowlist, nil
  23216. }
  23217. // ResetModelAllowlist resets all changes to the "model_allowlist" field.
  23218. func (m *GroupMutation) ResetModelAllowlist() {
  23219. m.model_allowlist = nil
  23220. }
  23221. // SetCodexModelsManifestConfig sets the "codex_models_manifest_config" field.
  23222. func (m *GroupMutation) SetCodexModelsManifestConfig(dcmmc domain.GroupCodexModelsManifestConfig) {
  23223. m.codex_models_manifest_config = &dcmmc
  23224. }
  23225. // CodexModelsManifestConfig returns the value of the "codex_models_manifest_config" field in the mutation.
  23226. func (m *GroupMutation) CodexModelsManifestConfig() (r domain.GroupCodexModelsManifestConfig, exists bool) {
  23227. v := m.codex_models_manifest_config
  23228. if v == nil {
  23229. return
  23230. }
  23231. return *v, true
  23232. }
  23233. // OldCodexModelsManifestConfig returns the old "codex_models_manifest_config" field's value of the Group entity.
  23234. // If the Group object wasn't provided to the builder, the object is fetched from the database.
  23235. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23236. func (m *GroupMutation) OldCodexModelsManifestConfig(ctx context.Context) (v domain.GroupCodexModelsManifestConfig, err error) {
  23237. if !m.op.Is(OpUpdateOne) {
  23238. return v, errors.New("OldCodexModelsManifestConfig is only allowed on UpdateOne operations")
  23239. }
  23240. if m.id == nil || m.oldValue == nil {
  23241. return v, errors.New("OldCodexModelsManifestConfig requires an ID field in the mutation")
  23242. }
  23243. oldValue, err := m.oldValue(ctx)
  23244. if err != nil {
  23245. return v, fmt.Errorf("querying old value for OldCodexModelsManifestConfig: %w", err)
  23246. }
  23247. return oldValue.CodexModelsManifestConfig, nil
  23248. }
  23249. // ResetCodexModelsManifestConfig resets all changes to the "codex_models_manifest_config" field.
  23250. func (m *GroupMutation) ResetCodexModelsManifestConfig() {
  23251. m.codex_models_manifest_config = nil
  23252. }
  23253. // SetRpmLimit sets the "rpm_limit" field.
  23254. func (m *GroupMutation) SetRpmLimit(i int) {
  23255. m.rpm_limit = &i
  23256. m.addrpm_limit = nil
  23257. }
  23258. // RpmLimit returns the value of the "rpm_limit" field in the mutation.
  23259. func (m *GroupMutation) RpmLimit() (r int, exists bool) {
  23260. v := m.rpm_limit
  23261. if v == nil {
  23262. return
  23263. }
  23264. return *v, true
  23265. }
  23266. // OldRpmLimit returns the old "rpm_limit" field's value of the Group entity.
  23267. // If the Group object wasn't provided to the builder, the object is fetched from the database.
  23268. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23269. func (m *GroupMutation) OldRpmLimit(ctx context.Context) (v int, err error) {
  23270. if !m.op.Is(OpUpdateOne) {
  23271. return v, errors.New("OldRpmLimit is only allowed on UpdateOne operations")
  23272. }
  23273. if m.id == nil || m.oldValue == nil {
  23274. return v, errors.New("OldRpmLimit requires an ID field in the mutation")
  23275. }
  23276. oldValue, err := m.oldValue(ctx)
  23277. if err != nil {
  23278. return v, fmt.Errorf("querying old value for OldRpmLimit: %w", err)
  23279. }
  23280. return oldValue.RpmLimit, nil
  23281. }
  23282. // AddRpmLimit adds i to the "rpm_limit" field.
  23283. func (m *GroupMutation) AddRpmLimit(i int) {
  23284. if m.addrpm_limit != nil {
  23285. *m.addrpm_limit += i
  23286. } else {
  23287. m.addrpm_limit = &i
  23288. }
  23289. }
  23290. // AddedRpmLimit returns the value that was added to the "rpm_limit" field in this mutation.
  23291. func (m *GroupMutation) AddedRpmLimit() (r int, exists bool) {
  23292. v := m.addrpm_limit
  23293. if v == nil {
  23294. return
  23295. }
  23296. return *v, true
  23297. }
  23298. // ResetRpmLimit resets all changes to the "rpm_limit" field.
  23299. func (m *GroupMutation) ResetRpmLimit() {
  23300. m.rpm_limit = nil
  23301. m.addrpm_limit = nil
  23302. }
  23303. // SetMaxReasoningEffort sets the "max_reasoning_effort" field.
  23304. func (m *GroupMutation) SetMaxReasoningEffort(s string) {
  23305. m.max_reasoning_effort = &s
  23306. }
  23307. // MaxReasoningEffort returns the value of the "max_reasoning_effort" field in the mutation.
  23308. func (m *GroupMutation) MaxReasoningEffort() (r string, exists bool) {
  23309. v := m.max_reasoning_effort
  23310. if v == nil {
  23311. return
  23312. }
  23313. return *v, true
  23314. }
  23315. // OldMaxReasoningEffort returns the old "max_reasoning_effort" field's value of the Group entity.
  23316. // If the Group object wasn't provided to the builder, the object is fetched from the database.
  23317. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23318. func (m *GroupMutation) OldMaxReasoningEffort(ctx context.Context) (v string, err error) {
  23319. if !m.op.Is(OpUpdateOne) {
  23320. return v, errors.New("OldMaxReasoningEffort is only allowed on UpdateOne operations")
  23321. }
  23322. if m.id == nil || m.oldValue == nil {
  23323. return v, errors.New("OldMaxReasoningEffort requires an ID field in the mutation")
  23324. }
  23325. oldValue, err := m.oldValue(ctx)
  23326. if err != nil {
  23327. return v, fmt.Errorf("querying old value for OldMaxReasoningEffort: %w", err)
  23328. }
  23329. return oldValue.MaxReasoningEffort, nil
  23330. }
  23331. // ResetMaxReasoningEffort resets all changes to the "max_reasoning_effort" field.
  23332. func (m *GroupMutation) ResetMaxReasoningEffort() {
  23333. m.max_reasoning_effort = nil
  23334. }
  23335. // SetMaxReasoningEffortOverLimit sets the "max_reasoning_effort_over_limit" field.
  23336. func (m *GroupMutation) SetMaxReasoningEffortOverLimit(s string) {
  23337. m.max_reasoning_effort_over_limit = &s
  23338. }
  23339. // MaxReasoningEffortOverLimit returns the value of the "max_reasoning_effort_over_limit" field in the mutation.
  23340. func (m *GroupMutation) MaxReasoningEffortOverLimit() (r string, exists bool) {
  23341. v := m.max_reasoning_effort_over_limit
  23342. if v == nil {
  23343. return
  23344. }
  23345. return *v, true
  23346. }
  23347. // OldMaxReasoningEffortOverLimit returns the old "max_reasoning_effort_over_limit" field's value of the Group entity.
  23348. // If the Group object wasn't provided to the builder, the object is fetched from the database.
  23349. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23350. func (m *GroupMutation) OldMaxReasoningEffortOverLimit(ctx context.Context) (v string, err error) {
  23351. if !m.op.Is(OpUpdateOne) {
  23352. return v, errors.New("OldMaxReasoningEffortOverLimit is only allowed on UpdateOne operations")
  23353. }
  23354. if m.id == nil || m.oldValue == nil {
  23355. return v, errors.New("OldMaxReasoningEffortOverLimit requires an ID field in the mutation")
  23356. }
  23357. oldValue, err := m.oldValue(ctx)
  23358. if err != nil {
  23359. return v, fmt.Errorf("querying old value for OldMaxReasoningEffortOverLimit: %w", err)
  23360. }
  23361. return oldValue.MaxReasoningEffortOverLimit, nil
  23362. }
  23363. // ResetMaxReasoningEffortOverLimit resets all changes to the "max_reasoning_effort_over_limit" field.
  23364. func (m *GroupMutation) ResetMaxReasoningEffortOverLimit() {
  23365. m.max_reasoning_effort_over_limit = nil
  23366. }
  23367. // SetReasoningEffortMappings sets the "reasoning_effort_mappings" field.
  23368. func (m *GroupMutation) SetReasoningEffortMappings(dem []domain.ReasoningEffortMapping) {
  23369. m.reasoning_effort_mappings = &dem
  23370. m.appendreasoning_effort_mappings = nil
  23371. }
  23372. // ReasoningEffortMappings returns the value of the "reasoning_effort_mappings" field in the mutation.
  23373. func (m *GroupMutation) ReasoningEffortMappings() (r []domain.ReasoningEffortMapping, exists bool) {
  23374. v := m.reasoning_effort_mappings
  23375. if v == nil {
  23376. return
  23377. }
  23378. return *v, true
  23379. }
  23380. // OldReasoningEffortMappings returns the old "reasoning_effort_mappings" field's value of the Group entity.
  23381. // If the Group object wasn't provided to the builder, the object is fetched from the database.
  23382. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23383. func (m *GroupMutation) OldReasoningEffortMappings(ctx context.Context) (v []domain.ReasoningEffortMapping, err error) {
  23384. if !m.op.Is(OpUpdateOne) {
  23385. return v, errors.New("OldReasoningEffortMappings is only allowed on UpdateOne operations")
  23386. }
  23387. if m.id == nil || m.oldValue == nil {
  23388. return v, errors.New("OldReasoningEffortMappings requires an ID field in the mutation")
  23389. }
  23390. oldValue, err := m.oldValue(ctx)
  23391. if err != nil {
  23392. return v, fmt.Errorf("querying old value for OldReasoningEffortMappings: %w", err)
  23393. }
  23394. return oldValue.ReasoningEffortMappings, nil
  23395. }
  23396. // AppendReasoningEffortMappings adds dem to the "reasoning_effort_mappings" field.
  23397. func (m *GroupMutation) AppendReasoningEffortMappings(dem []domain.ReasoningEffortMapping) {
  23398. m.appendreasoning_effort_mappings = append(m.appendreasoning_effort_mappings, dem...)
  23399. }
  23400. // AppendedReasoningEffortMappings returns the list of values that were appended to the "reasoning_effort_mappings" field in this mutation.
  23401. func (m *GroupMutation) AppendedReasoningEffortMappings() ([]domain.ReasoningEffortMapping, bool) {
  23402. if len(m.appendreasoning_effort_mappings) == 0 {
  23403. return nil, false
  23404. }
  23405. return m.appendreasoning_effort_mappings, true
  23406. }
  23407. // ResetReasoningEffortMappings resets all changes to the "reasoning_effort_mappings" field.
  23408. func (m *GroupMutation) ResetReasoningEffortMappings() {
  23409. m.reasoning_effort_mappings = nil
  23410. m.appendreasoning_effort_mappings = nil
  23411. }
  23412. // SetProfitControlEnabled sets the "profit_control_enabled" field.
  23413. func (m *GroupMutation) SetProfitControlEnabled(b bool) {
  23414. m.profit_control_enabled = &b
  23415. }
  23416. // ProfitControlEnabled returns the value of the "profit_control_enabled" field in the mutation.
  23417. func (m *GroupMutation) ProfitControlEnabled() (r bool, exists bool) {
  23418. v := m.profit_control_enabled
  23419. if v == nil {
  23420. return
  23421. }
  23422. return *v, true
  23423. }
  23424. // OldProfitControlEnabled returns the old "profit_control_enabled" field's value of the Group entity.
  23425. // If the Group object wasn't provided to the builder, the object is fetched from the database.
  23426. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23427. func (m *GroupMutation) OldProfitControlEnabled(ctx context.Context) (v bool, err error) {
  23428. if !m.op.Is(OpUpdateOne) {
  23429. return v, errors.New("OldProfitControlEnabled is only allowed on UpdateOne operations")
  23430. }
  23431. if m.id == nil || m.oldValue == nil {
  23432. return v, errors.New("OldProfitControlEnabled requires an ID field in the mutation")
  23433. }
  23434. oldValue, err := m.oldValue(ctx)
  23435. if err != nil {
  23436. return v, fmt.Errorf("querying old value for OldProfitControlEnabled: %w", err)
  23437. }
  23438. return oldValue.ProfitControlEnabled, nil
  23439. }
  23440. // ResetProfitControlEnabled resets all changes to the "profit_control_enabled" field.
  23441. func (m *GroupMutation) ResetProfitControlEnabled() {
  23442. m.profit_control_enabled = nil
  23443. }
  23444. // SetProfitMinMargin sets the "profit_min_margin" field.
  23445. func (m *GroupMutation) SetProfitMinMargin(f float64) {
  23446. m.profit_min_margin = &f
  23447. m.addprofit_min_margin = nil
  23448. }
  23449. // ProfitMinMargin returns the value of the "profit_min_margin" field in the mutation.
  23450. func (m *GroupMutation) ProfitMinMargin() (r float64, exists bool) {
  23451. v := m.profit_min_margin
  23452. if v == nil {
  23453. return
  23454. }
  23455. return *v, true
  23456. }
  23457. // OldProfitMinMargin returns the old "profit_min_margin" field's value of the Group entity.
  23458. // If the Group object wasn't provided to the builder, the object is fetched from the database.
  23459. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23460. func (m *GroupMutation) OldProfitMinMargin(ctx context.Context) (v float64, err error) {
  23461. if !m.op.Is(OpUpdateOne) {
  23462. return v, errors.New("OldProfitMinMargin is only allowed on UpdateOne operations")
  23463. }
  23464. if m.id == nil || m.oldValue == nil {
  23465. return v, errors.New("OldProfitMinMargin requires an ID field in the mutation")
  23466. }
  23467. oldValue, err := m.oldValue(ctx)
  23468. if err != nil {
  23469. return v, fmt.Errorf("querying old value for OldProfitMinMargin: %w", err)
  23470. }
  23471. return oldValue.ProfitMinMargin, nil
  23472. }
  23473. // AddProfitMinMargin adds f to the "profit_min_margin" field.
  23474. func (m *GroupMutation) AddProfitMinMargin(f float64) {
  23475. if m.addprofit_min_margin != nil {
  23476. *m.addprofit_min_margin += f
  23477. } else {
  23478. m.addprofit_min_margin = &f
  23479. }
  23480. }
  23481. // AddedProfitMinMargin returns the value that was added to the "profit_min_margin" field in this mutation.
  23482. func (m *GroupMutation) AddedProfitMinMargin() (r float64, exists bool) {
  23483. v := m.addprofit_min_margin
  23484. if v == nil {
  23485. return
  23486. }
  23487. return *v, true
  23488. }
  23489. // ResetProfitMinMargin resets all changes to the "profit_min_margin" field.
  23490. func (m *GroupMutation) ResetProfitMinMargin() {
  23491. m.profit_min_margin = nil
  23492. m.addprofit_min_margin = nil
  23493. }
  23494. // SetProfitSafetyBuffer sets the "profit_safety_buffer" field.
  23495. func (m *GroupMutation) SetProfitSafetyBuffer(f float64) {
  23496. m.profit_safety_buffer = &f
  23497. m.addprofit_safety_buffer = nil
  23498. }
  23499. // ProfitSafetyBuffer returns the value of the "profit_safety_buffer" field in the mutation.
  23500. func (m *GroupMutation) ProfitSafetyBuffer() (r float64, exists bool) {
  23501. v := m.profit_safety_buffer
  23502. if v == nil {
  23503. return
  23504. }
  23505. return *v, true
  23506. }
  23507. // OldProfitSafetyBuffer returns the old "profit_safety_buffer" field's value of the Group entity.
  23508. // If the Group object wasn't provided to the builder, the object is fetched from the database.
  23509. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23510. func (m *GroupMutation) OldProfitSafetyBuffer(ctx context.Context) (v float64, err error) {
  23511. if !m.op.Is(OpUpdateOne) {
  23512. return v, errors.New("OldProfitSafetyBuffer is only allowed on UpdateOne operations")
  23513. }
  23514. if m.id == nil || m.oldValue == nil {
  23515. return v, errors.New("OldProfitSafetyBuffer requires an ID field in the mutation")
  23516. }
  23517. oldValue, err := m.oldValue(ctx)
  23518. if err != nil {
  23519. return v, fmt.Errorf("querying old value for OldProfitSafetyBuffer: %w", err)
  23520. }
  23521. return oldValue.ProfitSafetyBuffer, nil
  23522. }
  23523. // AddProfitSafetyBuffer adds f to the "profit_safety_buffer" field.
  23524. func (m *GroupMutation) AddProfitSafetyBuffer(f float64) {
  23525. if m.addprofit_safety_buffer != nil {
  23526. *m.addprofit_safety_buffer += f
  23527. } else {
  23528. m.addprofit_safety_buffer = &f
  23529. }
  23530. }
  23531. // AddedProfitSafetyBuffer returns the value that was added to the "profit_safety_buffer" field in this mutation.
  23532. func (m *GroupMutation) AddedProfitSafetyBuffer() (r float64, exists bool) {
  23533. v := m.addprofit_safety_buffer
  23534. if v == nil {
  23535. return
  23536. }
  23537. return *v, true
  23538. }
  23539. // ResetProfitSafetyBuffer resets all changes to the "profit_safety_buffer" field.
  23540. func (m *GroupMutation) ResetProfitSafetyBuffer() {
  23541. m.profit_safety_buffer = nil
  23542. m.addprofit_safety_buffer = nil
  23543. }
  23544. // AddAPIKeyIDs adds the "api_keys" edge to the APIKey entity by ids.
  23545. func (m *GroupMutation) AddAPIKeyIDs(ids ...int64) {
  23546. if m.api_keys == nil {
  23547. m.api_keys = make(map[int64]struct{})
  23548. }
  23549. for i := range ids {
  23550. m.api_keys[ids[i]] = struct{}{}
  23551. }
  23552. }
  23553. // ClearAPIKeys clears the "api_keys" edge to the APIKey entity.
  23554. func (m *GroupMutation) ClearAPIKeys() {
  23555. m.clearedapi_keys = true
  23556. }
  23557. // APIKeysCleared reports if the "api_keys" edge to the APIKey entity was cleared.
  23558. func (m *GroupMutation) APIKeysCleared() bool {
  23559. return m.clearedapi_keys
  23560. }
  23561. // RemoveAPIKeyIDs removes the "api_keys" edge to the APIKey entity by IDs.
  23562. func (m *GroupMutation) RemoveAPIKeyIDs(ids ...int64) {
  23563. if m.removedapi_keys == nil {
  23564. m.removedapi_keys = make(map[int64]struct{})
  23565. }
  23566. for i := range ids {
  23567. delete(m.api_keys, ids[i])
  23568. m.removedapi_keys[ids[i]] = struct{}{}
  23569. }
  23570. }
  23571. // RemovedAPIKeys returns the removed IDs of the "api_keys" edge to the APIKey entity.
  23572. func (m *GroupMutation) RemovedAPIKeysIDs() (ids []int64) {
  23573. for id := range m.removedapi_keys {
  23574. ids = append(ids, id)
  23575. }
  23576. return
  23577. }
  23578. // APIKeysIDs returns the "api_keys" edge IDs in the mutation.
  23579. func (m *GroupMutation) APIKeysIDs() (ids []int64) {
  23580. for id := range m.api_keys {
  23581. ids = append(ids, id)
  23582. }
  23583. return
  23584. }
  23585. // ResetAPIKeys resets all changes to the "api_keys" edge.
  23586. func (m *GroupMutation) ResetAPIKeys() {
  23587. m.api_keys = nil
  23588. m.clearedapi_keys = false
  23589. m.removedapi_keys = nil
  23590. }
  23591. // AddRedeemCodeIDs adds the "redeem_codes" edge to the RedeemCode entity by ids.
  23592. func (m *GroupMutation) AddRedeemCodeIDs(ids ...int64) {
  23593. if m.redeem_codes == nil {
  23594. m.redeem_codes = make(map[int64]struct{})
  23595. }
  23596. for i := range ids {
  23597. m.redeem_codes[ids[i]] = struct{}{}
  23598. }
  23599. }
  23600. // ClearRedeemCodes clears the "redeem_codes" edge to the RedeemCode entity.
  23601. func (m *GroupMutation) ClearRedeemCodes() {
  23602. m.clearedredeem_codes = true
  23603. }
  23604. // RedeemCodesCleared reports if the "redeem_codes" edge to the RedeemCode entity was cleared.
  23605. func (m *GroupMutation) RedeemCodesCleared() bool {
  23606. return m.clearedredeem_codes
  23607. }
  23608. // RemoveRedeemCodeIDs removes the "redeem_codes" edge to the RedeemCode entity by IDs.
  23609. func (m *GroupMutation) RemoveRedeemCodeIDs(ids ...int64) {
  23610. if m.removedredeem_codes == nil {
  23611. m.removedredeem_codes = make(map[int64]struct{})
  23612. }
  23613. for i := range ids {
  23614. delete(m.redeem_codes, ids[i])
  23615. m.removedredeem_codes[ids[i]] = struct{}{}
  23616. }
  23617. }
  23618. // RemovedRedeemCodes returns the removed IDs of the "redeem_codes" edge to the RedeemCode entity.
  23619. func (m *GroupMutation) RemovedRedeemCodesIDs() (ids []int64) {
  23620. for id := range m.removedredeem_codes {
  23621. ids = append(ids, id)
  23622. }
  23623. return
  23624. }
  23625. // RedeemCodesIDs returns the "redeem_codes" edge IDs in the mutation.
  23626. func (m *GroupMutation) RedeemCodesIDs() (ids []int64) {
  23627. for id := range m.redeem_codes {
  23628. ids = append(ids, id)
  23629. }
  23630. return
  23631. }
  23632. // ResetRedeemCodes resets all changes to the "redeem_codes" edge.
  23633. func (m *GroupMutation) ResetRedeemCodes() {
  23634. m.redeem_codes = nil
  23635. m.clearedredeem_codes = false
  23636. m.removedredeem_codes = nil
  23637. }
  23638. // AddSubscriptionIDs adds the "subscriptions" edge to the UserSubscription entity by ids.
  23639. func (m *GroupMutation) AddSubscriptionIDs(ids ...int64) {
  23640. if m.subscriptions == nil {
  23641. m.subscriptions = make(map[int64]struct{})
  23642. }
  23643. for i := range ids {
  23644. m.subscriptions[ids[i]] = struct{}{}
  23645. }
  23646. }
  23647. // ClearSubscriptions clears the "subscriptions" edge to the UserSubscription entity.
  23648. func (m *GroupMutation) ClearSubscriptions() {
  23649. m.clearedsubscriptions = true
  23650. }
  23651. // SubscriptionsCleared reports if the "subscriptions" edge to the UserSubscription entity was cleared.
  23652. func (m *GroupMutation) SubscriptionsCleared() bool {
  23653. return m.clearedsubscriptions
  23654. }
  23655. // RemoveSubscriptionIDs removes the "subscriptions" edge to the UserSubscription entity by IDs.
  23656. func (m *GroupMutation) RemoveSubscriptionIDs(ids ...int64) {
  23657. if m.removedsubscriptions == nil {
  23658. m.removedsubscriptions = make(map[int64]struct{})
  23659. }
  23660. for i := range ids {
  23661. delete(m.subscriptions, ids[i])
  23662. m.removedsubscriptions[ids[i]] = struct{}{}
  23663. }
  23664. }
  23665. // RemovedSubscriptions returns the removed IDs of the "subscriptions" edge to the UserSubscription entity.
  23666. func (m *GroupMutation) RemovedSubscriptionsIDs() (ids []int64) {
  23667. for id := range m.removedsubscriptions {
  23668. ids = append(ids, id)
  23669. }
  23670. return
  23671. }
  23672. // SubscriptionsIDs returns the "subscriptions" edge IDs in the mutation.
  23673. func (m *GroupMutation) SubscriptionsIDs() (ids []int64) {
  23674. for id := range m.subscriptions {
  23675. ids = append(ids, id)
  23676. }
  23677. return
  23678. }
  23679. // ResetSubscriptions resets all changes to the "subscriptions" edge.
  23680. func (m *GroupMutation) ResetSubscriptions() {
  23681. m.subscriptions = nil
  23682. m.clearedsubscriptions = false
  23683. m.removedsubscriptions = nil
  23684. }
  23685. // AddUsageLogIDs adds the "usage_logs" edge to the UsageLog entity by ids.
  23686. func (m *GroupMutation) AddUsageLogIDs(ids ...int64) {
  23687. if m.usage_logs == nil {
  23688. m.usage_logs = make(map[int64]struct{})
  23689. }
  23690. for i := range ids {
  23691. m.usage_logs[ids[i]] = struct{}{}
  23692. }
  23693. }
  23694. // ClearUsageLogs clears the "usage_logs" edge to the UsageLog entity.
  23695. func (m *GroupMutation) ClearUsageLogs() {
  23696. m.clearedusage_logs = true
  23697. }
  23698. // UsageLogsCleared reports if the "usage_logs" edge to the UsageLog entity was cleared.
  23699. func (m *GroupMutation) UsageLogsCleared() bool {
  23700. return m.clearedusage_logs
  23701. }
  23702. // RemoveUsageLogIDs removes the "usage_logs" edge to the UsageLog entity by IDs.
  23703. func (m *GroupMutation) RemoveUsageLogIDs(ids ...int64) {
  23704. if m.removedusage_logs == nil {
  23705. m.removedusage_logs = make(map[int64]struct{})
  23706. }
  23707. for i := range ids {
  23708. delete(m.usage_logs, ids[i])
  23709. m.removedusage_logs[ids[i]] = struct{}{}
  23710. }
  23711. }
  23712. // RemovedUsageLogs returns the removed IDs of the "usage_logs" edge to the UsageLog entity.
  23713. func (m *GroupMutation) RemovedUsageLogsIDs() (ids []int64) {
  23714. for id := range m.removedusage_logs {
  23715. ids = append(ids, id)
  23716. }
  23717. return
  23718. }
  23719. // UsageLogsIDs returns the "usage_logs" edge IDs in the mutation.
  23720. func (m *GroupMutation) UsageLogsIDs() (ids []int64) {
  23721. for id := range m.usage_logs {
  23722. ids = append(ids, id)
  23723. }
  23724. return
  23725. }
  23726. // ResetUsageLogs resets all changes to the "usage_logs" edge.
  23727. func (m *GroupMutation) ResetUsageLogs() {
  23728. m.usage_logs = nil
  23729. m.clearedusage_logs = false
  23730. m.removedusage_logs = nil
  23731. }
  23732. // AddAccountIDs adds the "accounts" edge to the Account entity by ids.
  23733. func (m *GroupMutation) AddAccountIDs(ids ...int64) {
  23734. if m.accounts == nil {
  23735. m.accounts = make(map[int64]struct{})
  23736. }
  23737. for i := range ids {
  23738. m.accounts[ids[i]] = struct{}{}
  23739. }
  23740. }
  23741. // ClearAccounts clears the "accounts" edge to the Account entity.
  23742. func (m *GroupMutation) ClearAccounts() {
  23743. m.clearedaccounts = true
  23744. }
  23745. // AccountsCleared reports if the "accounts" edge to the Account entity was cleared.
  23746. func (m *GroupMutation) AccountsCleared() bool {
  23747. return m.clearedaccounts
  23748. }
  23749. // RemoveAccountIDs removes the "accounts" edge to the Account entity by IDs.
  23750. func (m *GroupMutation) RemoveAccountIDs(ids ...int64) {
  23751. if m.removedaccounts == nil {
  23752. m.removedaccounts = make(map[int64]struct{})
  23753. }
  23754. for i := range ids {
  23755. delete(m.accounts, ids[i])
  23756. m.removedaccounts[ids[i]] = struct{}{}
  23757. }
  23758. }
  23759. // RemovedAccounts returns the removed IDs of the "accounts" edge to the Account entity.
  23760. func (m *GroupMutation) RemovedAccountsIDs() (ids []int64) {
  23761. for id := range m.removedaccounts {
  23762. ids = append(ids, id)
  23763. }
  23764. return
  23765. }
  23766. // AccountsIDs returns the "accounts" edge IDs in the mutation.
  23767. func (m *GroupMutation) AccountsIDs() (ids []int64) {
  23768. for id := range m.accounts {
  23769. ids = append(ids, id)
  23770. }
  23771. return
  23772. }
  23773. // ResetAccounts resets all changes to the "accounts" edge.
  23774. func (m *GroupMutation) ResetAccounts() {
  23775. m.accounts = nil
  23776. m.clearedaccounts = false
  23777. m.removedaccounts = nil
  23778. }
  23779. // AddAllowedUserIDs adds the "allowed_users" edge to the User entity by ids.
  23780. func (m *GroupMutation) AddAllowedUserIDs(ids ...int64) {
  23781. if m.allowed_users == nil {
  23782. m.allowed_users = make(map[int64]struct{})
  23783. }
  23784. for i := range ids {
  23785. m.allowed_users[ids[i]] = struct{}{}
  23786. }
  23787. }
  23788. // ClearAllowedUsers clears the "allowed_users" edge to the User entity.
  23789. func (m *GroupMutation) ClearAllowedUsers() {
  23790. m.clearedallowed_users = true
  23791. }
  23792. // AllowedUsersCleared reports if the "allowed_users" edge to the User entity was cleared.
  23793. func (m *GroupMutation) AllowedUsersCleared() bool {
  23794. return m.clearedallowed_users
  23795. }
  23796. // RemoveAllowedUserIDs removes the "allowed_users" edge to the User entity by IDs.
  23797. func (m *GroupMutation) RemoveAllowedUserIDs(ids ...int64) {
  23798. if m.removedallowed_users == nil {
  23799. m.removedallowed_users = make(map[int64]struct{})
  23800. }
  23801. for i := range ids {
  23802. delete(m.allowed_users, ids[i])
  23803. m.removedallowed_users[ids[i]] = struct{}{}
  23804. }
  23805. }
  23806. // RemovedAllowedUsers returns the removed IDs of the "allowed_users" edge to the User entity.
  23807. func (m *GroupMutation) RemovedAllowedUsersIDs() (ids []int64) {
  23808. for id := range m.removedallowed_users {
  23809. ids = append(ids, id)
  23810. }
  23811. return
  23812. }
  23813. // AllowedUsersIDs returns the "allowed_users" edge IDs in the mutation.
  23814. func (m *GroupMutation) AllowedUsersIDs() (ids []int64) {
  23815. for id := range m.allowed_users {
  23816. ids = append(ids, id)
  23817. }
  23818. return
  23819. }
  23820. // ResetAllowedUsers resets all changes to the "allowed_users" edge.
  23821. func (m *GroupMutation) ResetAllowedUsers() {
  23822. m.allowed_users = nil
  23823. m.clearedallowed_users = false
  23824. m.removedallowed_users = nil
  23825. }
  23826. // Where appends a list predicates to the GroupMutation builder.
  23827. func (m *GroupMutation) Where(ps ...predicate.Group) {
  23828. m.predicates = append(m.predicates, ps...)
  23829. }
  23830. // WhereP appends storage-level predicates to the GroupMutation builder. Using this method,
  23831. // users can use type-assertion to append predicates that do not depend on any generated package.
  23832. func (m *GroupMutation) WhereP(ps ...func(*sql.Selector)) {
  23833. p := make([]predicate.Group, len(ps))
  23834. for i := range ps {
  23835. p[i] = ps[i]
  23836. }
  23837. m.Where(p...)
  23838. }
  23839. // Op returns the operation name.
  23840. func (m *GroupMutation) Op() Op {
  23841. return m.op
  23842. }
  23843. // SetOp allows setting the mutation operation.
  23844. func (m *GroupMutation) SetOp(op Op) {
  23845. m.op = op
  23846. }
  23847. // Type returns the node type of this mutation (Group).
  23848. func (m *GroupMutation) Type() string {
  23849. return m.typ
  23850. }
  23851. // Fields returns all fields that were changed during this mutation. Note that in
  23852. // order to get all numeric fields that were incremented/decremented, call
  23853. // AddedFields().
  23854. func (m *GroupMutation) Fields() []string {
  23855. fields := make([]string, 0, 69)
  23856. if m.created_at != nil {
  23857. fields = append(fields, group.FieldCreatedAt)
  23858. }
  23859. if m.updated_at != nil {
  23860. fields = append(fields, group.FieldUpdatedAt)
  23861. }
  23862. if m.deleted_at != nil {
  23863. fields = append(fields, group.FieldDeletedAt)
  23864. }
  23865. if m.name != nil {
  23866. fields = append(fields, group.FieldName)
  23867. }
  23868. if m.description != nil {
  23869. fields = append(fields, group.FieldDescription)
  23870. }
  23871. if m.rate_multiplier != nil {
  23872. fields = append(fields, group.FieldRateMultiplier)
  23873. }
  23874. if m.peak_rate_enabled != nil {
  23875. fields = append(fields, group.FieldPeakRateEnabled)
  23876. }
  23877. if m.peak_start != nil {
  23878. fields = append(fields, group.FieldPeakStart)
  23879. }
  23880. if m.peak_end != nil {
  23881. fields = append(fields, group.FieldPeakEnd)
  23882. }
  23883. if m.peak_rate_multiplier != nil {
  23884. fields = append(fields, group.FieldPeakRateMultiplier)
  23885. }
  23886. if m.is_exclusive != nil {
  23887. fields = append(fields, group.FieldIsExclusive)
  23888. }
  23889. if m.security_policy_enabled != nil {
  23890. fields = append(fields, group.FieldSecurityPolicyEnabled)
  23891. }
  23892. if m.security_policy_mode != nil {
  23893. fields = append(fields, group.FieldSecurityPolicyMode)
  23894. }
  23895. if m.security_policy_email_enabled != nil {
  23896. fields = append(fields, group.FieldSecurityPolicyEmailEnabled)
  23897. }
  23898. if m.status != nil {
  23899. fields = append(fields, group.FieldStatus)
  23900. }
  23901. if m.duplicate_operation_id != nil {
  23902. fields = append(fields, group.FieldDuplicateOperationID)
  23903. }
  23904. if m.platform != nil {
  23905. fields = append(fields, group.FieldPlatform)
  23906. }
  23907. if m.subscription_type != nil {
  23908. fields = append(fields, group.FieldSubscriptionType)
  23909. }
  23910. if m.daily_limit_usd != nil {
  23911. fields = append(fields, group.FieldDailyLimitUsd)
  23912. }
  23913. if m.weekly_limit_usd != nil {
  23914. fields = append(fields, group.FieldWeeklyLimitUsd)
  23915. }
  23916. if m.monthly_limit_usd != nil {
  23917. fields = append(fields, group.FieldMonthlyLimitUsd)
  23918. }
  23919. if m.default_validity_days != nil {
  23920. fields = append(fields, group.FieldDefaultValidityDays)
  23921. }
  23922. if m.allow_image_generation != nil {
  23923. fields = append(fields, group.FieldAllowImageGeneration)
  23924. }
  23925. if m.allow_batch_image_generation != nil {
  23926. fields = append(fields, group.FieldAllowBatchImageGeneration)
  23927. }
  23928. if m.image_rate_independent != nil {
  23929. fields = append(fields, group.FieldImageRateIndependent)
  23930. }
  23931. if m.image_rate_multiplier != nil {
  23932. fields = append(fields, group.FieldImageRateMultiplier)
  23933. }
  23934. if m.image_price_1k != nil {
  23935. fields = append(fields, group.FieldImagePrice1k)
  23936. }
  23937. if m.image_price_2k != nil {
  23938. fields = append(fields, group.FieldImagePrice2k)
  23939. }
  23940. if m.image_price_4k != nil {
  23941. fields = append(fields, group.FieldImagePrice4k)
  23942. }
  23943. if m.batch_image_discount_multiplier != nil {
  23944. fields = append(fields, group.FieldBatchImageDiscountMultiplier)
  23945. }
  23946. if m.batch_image_hold_multiplier != nil {
  23947. fields = append(fields, group.FieldBatchImageHoldMultiplier)
  23948. }
  23949. if m.video_rate_independent != nil {
  23950. fields = append(fields, group.FieldVideoRateIndependent)
  23951. }
  23952. if m.video_rate_multiplier != nil {
  23953. fields = append(fields, group.FieldVideoRateMultiplier)
  23954. }
  23955. if m.video_price_480p != nil {
  23956. fields = append(fields, group.FieldVideoPrice480p)
  23957. }
  23958. if m.video_price_720p != nil {
  23959. fields = append(fields, group.FieldVideoPrice720p)
  23960. }
  23961. if m.video_price_1080p != nil {
  23962. fields = append(fields, group.FieldVideoPrice1080p)
  23963. }
  23964. if m.video_model_prices != nil {
  23965. fields = append(fields, group.FieldVideoModelPrices)
  23966. }
  23967. if m.web_search_price_per_call != nil {
  23968. fields = append(fields, group.FieldWebSearchPricePerCall)
  23969. }
  23970. if m.search_price_per_1k != nil {
  23971. fields = append(fields, group.FieldSearchPricePer1k)
  23972. }
  23973. if m.audio_realtime_price_per_min != nil {
  23974. fields = append(fields, group.FieldAudioRealtimePricePerMin)
  23975. }
  23976. if m.audio_tts_price_per_million_chars != nil {
  23977. fields = append(fields, group.FieldAudioTtsPricePerMillionChars)
  23978. }
  23979. if m.audio_stt_price_per_hour != nil {
  23980. fields = append(fields, group.FieldAudioSttPricePerHour)
  23981. }
  23982. if m.long_context_pricing_enabled != nil {
  23983. fields = append(fields, group.FieldLongContextPricingEnabled)
  23984. }
  23985. if m.model_pricing != nil {
  23986. fields = append(fields, group.FieldModelPricing)
  23987. }
  23988. if m.claude_code_only != nil {
  23989. fields = append(fields, group.FieldClaudeCodeOnly)
  23990. }
  23991. if m.fallback_group_id != nil {
  23992. fields = append(fields, group.FieldFallbackGroupID)
  23993. }
  23994. if m.fallback_group_id_on_invalid_request != nil {
  23995. fields = append(fields, group.FieldFallbackGroupIDOnInvalidRequest)
  23996. }
  23997. if m.model_routing != nil {
  23998. fields = append(fields, group.FieldModelRouting)
  23999. }
  24000. if m.model_routing_enabled != nil {
  24001. fields = append(fields, group.FieldModelRoutingEnabled)
  24002. }
  24003. if m.mcp_xml_inject != nil {
  24004. fields = append(fields, group.FieldMcpXMLInject)
  24005. }
  24006. if m.supported_model_scopes != nil {
  24007. fields = append(fields, group.FieldSupportedModelScopes)
  24008. }
  24009. if m.sort_order != nil {
  24010. fields = append(fields, group.FieldSortOrder)
  24011. }
  24012. if m.allow_messages_dispatch != nil {
  24013. fields = append(fields, group.FieldAllowMessagesDispatch)
  24014. }
  24015. if m.allow_live != nil {
  24016. fields = append(fields, group.FieldAllowLive)
  24017. }
  24018. if m.force_openai_fast != nil {
  24019. fields = append(fields, group.FieldForceOpenaiFast)
  24020. }
  24021. if m.free_openai_fast != nil {
  24022. fields = append(fields, group.FieldFreeOpenaiFast)
  24023. }
  24024. if m.require_oauth_only != nil {
  24025. fields = append(fields, group.FieldRequireOauthOnly)
  24026. }
  24027. if m.require_privacy_set != nil {
  24028. fields = append(fields, group.FieldRequirePrivacySet)
  24029. }
  24030. if m.default_mapped_model != nil {
  24031. fields = append(fields, group.FieldDefaultMappedModel)
  24032. }
  24033. if m.messages_dispatch_model_config != nil {
  24034. fields = append(fields, group.FieldMessagesDispatchModelConfig)
  24035. }
  24036. if m.model_allowlist != nil {
  24037. fields = append(fields, group.FieldModelAllowlist)
  24038. }
  24039. if m.codex_models_manifest_config != nil {
  24040. fields = append(fields, group.FieldCodexModelsManifestConfig)
  24041. }
  24042. if m.rpm_limit != nil {
  24043. fields = append(fields, group.FieldRpmLimit)
  24044. }
  24045. if m.max_reasoning_effort != nil {
  24046. fields = append(fields, group.FieldMaxReasoningEffort)
  24047. }
  24048. if m.max_reasoning_effort_over_limit != nil {
  24049. fields = append(fields, group.FieldMaxReasoningEffortOverLimit)
  24050. }
  24051. if m.reasoning_effort_mappings != nil {
  24052. fields = append(fields, group.FieldReasoningEffortMappings)
  24053. }
  24054. if m.profit_control_enabled != nil {
  24055. fields = append(fields, group.FieldProfitControlEnabled)
  24056. }
  24057. if m.profit_min_margin != nil {
  24058. fields = append(fields, group.FieldProfitMinMargin)
  24059. }
  24060. if m.profit_safety_buffer != nil {
  24061. fields = append(fields, group.FieldProfitSafetyBuffer)
  24062. }
  24063. return fields
  24064. }
  24065. // Field returns the value of a field with the given name. The second boolean
  24066. // return value indicates that this field was not set, or was not defined in the
  24067. // schema.
  24068. func (m *GroupMutation) Field(name string) (ent.Value, bool) {
  24069. switch name {
  24070. case group.FieldCreatedAt:
  24071. return m.CreatedAt()
  24072. case group.FieldUpdatedAt:
  24073. return m.UpdatedAt()
  24074. case group.FieldDeletedAt:
  24075. return m.DeletedAt()
  24076. case group.FieldName:
  24077. return m.Name()
  24078. case group.FieldDescription:
  24079. return m.Description()
  24080. case group.FieldRateMultiplier:
  24081. return m.RateMultiplier()
  24082. case group.FieldPeakRateEnabled:
  24083. return m.PeakRateEnabled()
  24084. case group.FieldPeakStart:
  24085. return m.PeakStart()
  24086. case group.FieldPeakEnd:
  24087. return m.PeakEnd()
  24088. case group.FieldPeakRateMultiplier:
  24089. return m.PeakRateMultiplier()
  24090. case group.FieldIsExclusive:
  24091. return m.IsExclusive()
  24092. case group.FieldSecurityPolicyEnabled:
  24093. return m.SecurityPolicyEnabled()
  24094. case group.FieldSecurityPolicyMode:
  24095. return m.SecurityPolicyMode()
  24096. case group.FieldSecurityPolicyEmailEnabled:
  24097. return m.SecurityPolicyEmailEnabled()
  24098. case group.FieldStatus:
  24099. return m.Status()
  24100. case group.FieldDuplicateOperationID:
  24101. return m.DuplicateOperationID()
  24102. case group.FieldPlatform:
  24103. return m.Platform()
  24104. case group.FieldSubscriptionType:
  24105. return m.SubscriptionType()
  24106. case group.FieldDailyLimitUsd:
  24107. return m.DailyLimitUsd()
  24108. case group.FieldWeeklyLimitUsd:
  24109. return m.WeeklyLimitUsd()
  24110. case group.FieldMonthlyLimitUsd:
  24111. return m.MonthlyLimitUsd()
  24112. case group.FieldDefaultValidityDays:
  24113. return m.DefaultValidityDays()
  24114. case group.FieldAllowImageGeneration:
  24115. return m.AllowImageGeneration()
  24116. case group.FieldAllowBatchImageGeneration:
  24117. return m.AllowBatchImageGeneration()
  24118. case group.FieldImageRateIndependent:
  24119. return m.ImageRateIndependent()
  24120. case group.FieldImageRateMultiplier:
  24121. return m.ImageRateMultiplier()
  24122. case group.FieldImagePrice1k:
  24123. return m.ImagePrice1k()
  24124. case group.FieldImagePrice2k:
  24125. return m.ImagePrice2k()
  24126. case group.FieldImagePrice4k:
  24127. return m.ImagePrice4k()
  24128. case group.FieldBatchImageDiscountMultiplier:
  24129. return m.BatchImageDiscountMultiplier()
  24130. case group.FieldBatchImageHoldMultiplier:
  24131. return m.BatchImageHoldMultiplier()
  24132. case group.FieldVideoRateIndependent:
  24133. return m.VideoRateIndependent()
  24134. case group.FieldVideoRateMultiplier:
  24135. return m.VideoRateMultiplier()
  24136. case group.FieldVideoPrice480p:
  24137. return m.VideoPrice480p()
  24138. case group.FieldVideoPrice720p:
  24139. return m.VideoPrice720p()
  24140. case group.FieldVideoPrice1080p:
  24141. return m.VideoPrice1080p()
  24142. case group.FieldVideoModelPrices:
  24143. return m.VideoModelPrices()
  24144. case group.FieldWebSearchPricePerCall:
  24145. return m.WebSearchPricePerCall()
  24146. case group.FieldSearchPricePer1k:
  24147. return m.SearchPricePer1k()
  24148. case group.FieldAudioRealtimePricePerMin:
  24149. return m.AudioRealtimePricePerMin()
  24150. case group.FieldAudioTtsPricePerMillionChars:
  24151. return m.AudioTtsPricePerMillionChars()
  24152. case group.FieldAudioSttPricePerHour:
  24153. return m.AudioSttPricePerHour()
  24154. case group.FieldLongContextPricingEnabled:
  24155. return m.LongContextPricingEnabled()
  24156. case group.FieldModelPricing:
  24157. return m.ModelPricing()
  24158. case group.FieldClaudeCodeOnly:
  24159. return m.ClaudeCodeOnly()
  24160. case group.FieldFallbackGroupID:
  24161. return m.FallbackGroupID()
  24162. case group.FieldFallbackGroupIDOnInvalidRequest:
  24163. return m.FallbackGroupIDOnInvalidRequest()
  24164. case group.FieldModelRouting:
  24165. return m.ModelRouting()
  24166. case group.FieldModelRoutingEnabled:
  24167. return m.ModelRoutingEnabled()
  24168. case group.FieldMcpXMLInject:
  24169. return m.McpXMLInject()
  24170. case group.FieldSupportedModelScopes:
  24171. return m.SupportedModelScopes()
  24172. case group.FieldSortOrder:
  24173. return m.SortOrder()
  24174. case group.FieldAllowMessagesDispatch:
  24175. return m.AllowMessagesDispatch()
  24176. case group.FieldAllowLive:
  24177. return m.AllowLive()
  24178. case group.FieldForceOpenaiFast:
  24179. return m.ForceOpenaiFast()
  24180. case group.FieldFreeOpenaiFast:
  24181. return m.FreeOpenaiFast()
  24182. case group.FieldRequireOauthOnly:
  24183. return m.RequireOauthOnly()
  24184. case group.FieldRequirePrivacySet:
  24185. return m.RequirePrivacySet()
  24186. case group.FieldDefaultMappedModel:
  24187. return m.DefaultMappedModel()
  24188. case group.FieldMessagesDispatchModelConfig:
  24189. return m.MessagesDispatchModelConfig()
  24190. case group.FieldModelAllowlist:
  24191. return m.ModelAllowlist()
  24192. case group.FieldCodexModelsManifestConfig:
  24193. return m.CodexModelsManifestConfig()
  24194. case group.FieldRpmLimit:
  24195. return m.RpmLimit()
  24196. case group.FieldMaxReasoningEffort:
  24197. return m.MaxReasoningEffort()
  24198. case group.FieldMaxReasoningEffortOverLimit:
  24199. return m.MaxReasoningEffortOverLimit()
  24200. case group.FieldReasoningEffortMappings:
  24201. return m.ReasoningEffortMappings()
  24202. case group.FieldProfitControlEnabled:
  24203. return m.ProfitControlEnabled()
  24204. case group.FieldProfitMinMargin:
  24205. return m.ProfitMinMargin()
  24206. case group.FieldProfitSafetyBuffer:
  24207. return m.ProfitSafetyBuffer()
  24208. }
  24209. return nil, false
  24210. }
  24211. // OldField returns the old value of the field from the database. An error is
  24212. // returned if the mutation operation is not UpdateOne, or the query to the
  24213. // database failed.
  24214. func (m *GroupMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  24215. switch name {
  24216. case group.FieldCreatedAt:
  24217. return m.OldCreatedAt(ctx)
  24218. case group.FieldUpdatedAt:
  24219. return m.OldUpdatedAt(ctx)
  24220. case group.FieldDeletedAt:
  24221. return m.OldDeletedAt(ctx)
  24222. case group.FieldName:
  24223. return m.OldName(ctx)
  24224. case group.FieldDescription:
  24225. return m.OldDescription(ctx)
  24226. case group.FieldRateMultiplier:
  24227. return m.OldRateMultiplier(ctx)
  24228. case group.FieldPeakRateEnabled:
  24229. return m.OldPeakRateEnabled(ctx)
  24230. case group.FieldPeakStart:
  24231. return m.OldPeakStart(ctx)
  24232. case group.FieldPeakEnd:
  24233. return m.OldPeakEnd(ctx)
  24234. case group.FieldPeakRateMultiplier:
  24235. return m.OldPeakRateMultiplier(ctx)
  24236. case group.FieldIsExclusive:
  24237. return m.OldIsExclusive(ctx)
  24238. case group.FieldSecurityPolicyEnabled:
  24239. return m.OldSecurityPolicyEnabled(ctx)
  24240. case group.FieldSecurityPolicyMode:
  24241. return m.OldSecurityPolicyMode(ctx)
  24242. case group.FieldSecurityPolicyEmailEnabled:
  24243. return m.OldSecurityPolicyEmailEnabled(ctx)
  24244. case group.FieldStatus:
  24245. return m.OldStatus(ctx)
  24246. case group.FieldDuplicateOperationID:
  24247. return m.OldDuplicateOperationID(ctx)
  24248. case group.FieldPlatform:
  24249. return m.OldPlatform(ctx)
  24250. case group.FieldSubscriptionType:
  24251. return m.OldSubscriptionType(ctx)
  24252. case group.FieldDailyLimitUsd:
  24253. return m.OldDailyLimitUsd(ctx)
  24254. case group.FieldWeeklyLimitUsd:
  24255. return m.OldWeeklyLimitUsd(ctx)
  24256. case group.FieldMonthlyLimitUsd:
  24257. return m.OldMonthlyLimitUsd(ctx)
  24258. case group.FieldDefaultValidityDays:
  24259. return m.OldDefaultValidityDays(ctx)
  24260. case group.FieldAllowImageGeneration:
  24261. return m.OldAllowImageGeneration(ctx)
  24262. case group.FieldAllowBatchImageGeneration:
  24263. return m.OldAllowBatchImageGeneration(ctx)
  24264. case group.FieldImageRateIndependent:
  24265. return m.OldImageRateIndependent(ctx)
  24266. case group.FieldImageRateMultiplier:
  24267. return m.OldImageRateMultiplier(ctx)
  24268. case group.FieldImagePrice1k:
  24269. return m.OldImagePrice1k(ctx)
  24270. case group.FieldImagePrice2k:
  24271. return m.OldImagePrice2k(ctx)
  24272. case group.FieldImagePrice4k:
  24273. return m.OldImagePrice4k(ctx)
  24274. case group.FieldBatchImageDiscountMultiplier:
  24275. return m.OldBatchImageDiscountMultiplier(ctx)
  24276. case group.FieldBatchImageHoldMultiplier:
  24277. return m.OldBatchImageHoldMultiplier(ctx)
  24278. case group.FieldVideoRateIndependent:
  24279. return m.OldVideoRateIndependent(ctx)
  24280. case group.FieldVideoRateMultiplier:
  24281. return m.OldVideoRateMultiplier(ctx)
  24282. case group.FieldVideoPrice480p:
  24283. return m.OldVideoPrice480p(ctx)
  24284. case group.FieldVideoPrice720p:
  24285. return m.OldVideoPrice720p(ctx)
  24286. case group.FieldVideoPrice1080p:
  24287. return m.OldVideoPrice1080p(ctx)
  24288. case group.FieldVideoModelPrices:
  24289. return m.OldVideoModelPrices(ctx)
  24290. case group.FieldWebSearchPricePerCall:
  24291. return m.OldWebSearchPricePerCall(ctx)
  24292. case group.FieldSearchPricePer1k:
  24293. return m.OldSearchPricePer1k(ctx)
  24294. case group.FieldAudioRealtimePricePerMin:
  24295. return m.OldAudioRealtimePricePerMin(ctx)
  24296. case group.FieldAudioTtsPricePerMillionChars:
  24297. return m.OldAudioTtsPricePerMillionChars(ctx)
  24298. case group.FieldAudioSttPricePerHour:
  24299. return m.OldAudioSttPricePerHour(ctx)
  24300. case group.FieldLongContextPricingEnabled:
  24301. return m.OldLongContextPricingEnabled(ctx)
  24302. case group.FieldModelPricing:
  24303. return m.OldModelPricing(ctx)
  24304. case group.FieldClaudeCodeOnly:
  24305. return m.OldClaudeCodeOnly(ctx)
  24306. case group.FieldFallbackGroupID:
  24307. return m.OldFallbackGroupID(ctx)
  24308. case group.FieldFallbackGroupIDOnInvalidRequest:
  24309. return m.OldFallbackGroupIDOnInvalidRequest(ctx)
  24310. case group.FieldModelRouting:
  24311. return m.OldModelRouting(ctx)
  24312. case group.FieldModelRoutingEnabled:
  24313. return m.OldModelRoutingEnabled(ctx)
  24314. case group.FieldMcpXMLInject:
  24315. return m.OldMcpXMLInject(ctx)
  24316. case group.FieldSupportedModelScopes:
  24317. return m.OldSupportedModelScopes(ctx)
  24318. case group.FieldSortOrder:
  24319. return m.OldSortOrder(ctx)
  24320. case group.FieldAllowMessagesDispatch:
  24321. return m.OldAllowMessagesDispatch(ctx)
  24322. case group.FieldAllowLive:
  24323. return m.OldAllowLive(ctx)
  24324. case group.FieldForceOpenaiFast:
  24325. return m.OldForceOpenaiFast(ctx)
  24326. case group.FieldFreeOpenaiFast:
  24327. return m.OldFreeOpenaiFast(ctx)
  24328. case group.FieldRequireOauthOnly:
  24329. return m.OldRequireOauthOnly(ctx)
  24330. case group.FieldRequirePrivacySet:
  24331. return m.OldRequirePrivacySet(ctx)
  24332. case group.FieldDefaultMappedModel:
  24333. return m.OldDefaultMappedModel(ctx)
  24334. case group.FieldMessagesDispatchModelConfig:
  24335. return m.OldMessagesDispatchModelConfig(ctx)
  24336. case group.FieldModelAllowlist:
  24337. return m.OldModelAllowlist(ctx)
  24338. case group.FieldCodexModelsManifestConfig:
  24339. return m.OldCodexModelsManifestConfig(ctx)
  24340. case group.FieldRpmLimit:
  24341. return m.OldRpmLimit(ctx)
  24342. case group.FieldMaxReasoningEffort:
  24343. return m.OldMaxReasoningEffort(ctx)
  24344. case group.FieldMaxReasoningEffortOverLimit:
  24345. return m.OldMaxReasoningEffortOverLimit(ctx)
  24346. case group.FieldReasoningEffortMappings:
  24347. return m.OldReasoningEffortMappings(ctx)
  24348. case group.FieldProfitControlEnabled:
  24349. return m.OldProfitControlEnabled(ctx)
  24350. case group.FieldProfitMinMargin:
  24351. return m.OldProfitMinMargin(ctx)
  24352. case group.FieldProfitSafetyBuffer:
  24353. return m.OldProfitSafetyBuffer(ctx)
  24354. }
  24355. return nil, fmt.Errorf("unknown Group field %s", name)
  24356. }
  24357. // SetField sets the value of a field with the given name. It returns an error if
  24358. // the field is not defined in the schema, or if the type mismatched the field
  24359. // type.
  24360. func (m *GroupMutation) SetField(name string, value ent.Value) error {
  24361. switch name {
  24362. case group.FieldCreatedAt:
  24363. v, ok := value.(time.Time)
  24364. if !ok {
  24365. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24366. }
  24367. m.SetCreatedAt(v)
  24368. return nil
  24369. case group.FieldUpdatedAt:
  24370. v, ok := value.(time.Time)
  24371. if !ok {
  24372. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24373. }
  24374. m.SetUpdatedAt(v)
  24375. return nil
  24376. case group.FieldDeletedAt:
  24377. v, ok := value.(time.Time)
  24378. if !ok {
  24379. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24380. }
  24381. m.SetDeletedAt(v)
  24382. return nil
  24383. case group.FieldName:
  24384. v, ok := value.(string)
  24385. if !ok {
  24386. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24387. }
  24388. m.SetName(v)
  24389. return nil
  24390. case group.FieldDescription:
  24391. v, ok := value.(string)
  24392. if !ok {
  24393. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24394. }
  24395. m.SetDescription(v)
  24396. return nil
  24397. case group.FieldRateMultiplier:
  24398. v, ok := value.(float64)
  24399. if !ok {
  24400. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24401. }
  24402. m.SetRateMultiplier(v)
  24403. return nil
  24404. case group.FieldPeakRateEnabled:
  24405. v, ok := value.(bool)
  24406. if !ok {
  24407. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24408. }
  24409. m.SetPeakRateEnabled(v)
  24410. return nil
  24411. case group.FieldPeakStart:
  24412. v, ok := value.(string)
  24413. if !ok {
  24414. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24415. }
  24416. m.SetPeakStart(v)
  24417. return nil
  24418. case group.FieldPeakEnd:
  24419. v, ok := value.(string)
  24420. if !ok {
  24421. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24422. }
  24423. m.SetPeakEnd(v)
  24424. return nil
  24425. case group.FieldPeakRateMultiplier:
  24426. v, ok := value.(float64)
  24427. if !ok {
  24428. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24429. }
  24430. m.SetPeakRateMultiplier(v)
  24431. return nil
  24432. case group.FieldIsExclusive:
  24433. v, ok := value.(bool)
  24434. if !ok {
  24435. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24436. }
  24437. m.SetIsExclusive(v)
  24438. return nil
  24439. case group.FieldSecurityPolicyEnabled:
  24440. v, ok := value.(bool)
  24441. if !ok {
  24442. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24443. }
  24444. m.SetSecurityPolicyEnabled(v)
  24445. return nil
  24446. case group.FieldSecurityPolicyMode:
  24447. v, ok := value.(string)
  24448. if !ok {
  24449. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24450. }
  24451. m.SetSecurityPolicyMode(v)
  24452. return nil
  24453. case group.FieldSecurityPolicyEmailEnabled:
  24454. v, ok := value.(bool)
  24455. if !ok {
  24456. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24457. }
  24458. m.SetSecurityPolicyEmailEnabled(v)
  24459. return nil
  24460. case group.FieldStatus:
  24461. v, ok := value.(string)
  24462. if !ok {
  24463. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24464. }
  24465. m.SetStatus(v)
  24466. return nil
  24467. case group.FieldDuplicateOperationID:
  24468. v, ok := value.(string)
  24469. if !ok {
  24470. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24471. }
  24472. m.SetDuplicateOperationID(v)
  24473. return nil
  24474. case group.FieldPlatform:
  24475. v, ok := value.(string)
  24476. if !ok {
  24477. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24478. }
  24479. m.SetPlatform(v)
  24480. return nil
  24481. case group.FieldSubscriptionType:
  24482. v, ok := value.(string)
  24483. if !ok {
  24484. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24485. }
  24486. m.SetSubscriptionType(v)
  24487. return nil
  24488. case group.FieldDailyLimitUsd:
  24489. v, ok := value.(float64)
  24490. if !ok {
  24491. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24492. }
  24493. m.SetDailyLimitUsd(v)
  24494. return nil
  24495. case group.FieldWeeklyLimitUsd:
  24496. v, ok := value.(float64)
  24497. if !ok {
  24498. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24499. }
  24500. m.SetWeeklyLimitUsd(v)
  24501. return nil
  24502. case group.FieldMonthlyLimitUsd:
  24503. v, ok := value.(float64)
  24504. if !ok {
  24505. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24506. }
  24507. m.SetMonthlyLimitUsd(v)
  24508. return nil
  24509. case group.FieldDefaultValidityDays:
  24510. v, ok := value.(int)
  24511. if !ok {
  24512. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24513. }
  24514. m.SetDefaultValidityDays(v)
  24515. return nil
  24516. case group.FieldAllowImageGeneration:
  24517. v, ok := value.(bool)
  24518. if !ok {
  24519. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24520. }
  24521. m.SetAllowImageGeneration(v)
  24522. return nil
  24523. case group.FieldAllowBatchImageGeneration:
  24524. v, ok := value.(bool)
  24525. if !ok {
  24526. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24527. }
  24528. m.SetAllowBatchImageGeneration(v)
  24529. return nil
  24530. case group.FieldImageRateIndependent:
  24531. v, ok := value.(bool)
  24532. if !ok {
  24533. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24534. }
  24535. m.SetImageRateIndependent(v)
  24536. return nil
  24537. case group.FieldImageRateMultiplier:
  24538. v, ok := value.(float64)
  24539. if !ok {
  24540. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24541. }
  24542. m.SetImageRateMultiplier(v)
  24543. return nil
  24544. case group.FieldImagePrice1k:
  24545. v, ok := value.(float64)
  24546. if !ok {
  24547. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24548. }
  24549. m.SetImagePrice1k(v)
  24550. return nil
  24551. case group.FieldImagePrice2k:
  24552. v, ok := value.(float64)
  24553. if !ok {
  24554. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24555. }
  24556. m.SetImagePrice2k(v)
  24557. return nil
  24558. case group.FieldImagePrice4k:
  24559. v, ok := value.(float64)
  24560. if !ok {
  24561. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24562. }
  24563. m.SetImagePrice4k(v)
  24564. return nil
  24565. case group.FieldBatchImageDiscountMultiplier:
  24566. v, ok := value.(float64)
  24567. if !ok {
  24568. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24569. }
  24570. m.SetBatchImageDiscountMultiplier(v)
  24571. return nil
  24572. case group.FieldBatchImageHoldMultiplier:
  24573. v, ok := value.(float64)
  24574. if !ok {
  24575. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24576. }
  24577. m.SetBatchImageHoldMultiplier(v)
  24578. return nil
  24579. case group.FieldVideoRateIndependent:
  24580. v, ok := value.(bool)
  24581. if !ok {
  24582. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24583. }
  24584. m.SetVideoRateIndependent(v)
  24585. return nil
  24586. case group.FieldVideoRateMultiplier:
  24587. v, ok := value.(float64)
  24588. if !ok {
  24589. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24590. }
  24591. m.SetVideoRateMultiplier(v)
  24592. return nil
  24593. case group.FieldVideoPrice480p:
  24594. v, ok := value.(float64)
  24595. if !ok {
  24596. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24597. }
  24598. m.SetVideoPrice480p(v)
  24599. return nil
  24600. case group.FieldVideoPrice720p:
  24601. v, ok := value.(float64)
  24602. if !ok {
  24603. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24604. }
  24605. m.SetVideoPrice720p(v)
  24606. return nil
  24607. case group.FieldVideoPrice1080p:
  24608. v, ok := value.(float64)
  24609. if !ok {
  24610. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24611. }
  24612. m.SetVideoPrice1080p(v)
  24613. return nil
  24614. case group.FieldVideoModelPrices:
  24615. v, ok := value.(map[string]map[string]float64)
  24616. if !ok {
  24617. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24618. }
  24619. m.SetVideoModelPrices(v)
  24620. return nil
  24621. case group.FieldWebSearchPricePerCall:
  24622. v, ok := value.(float64)
  24623. if !ok {
  24624. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24625. }
  24626. m.SetWebSearchPricePerCall(v)
  24627. return nil
  24628. case group.FieldSearchPricePer1k:
  24629. v, ok := value.(float64)
  24630. if !ok {
  24631. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24632. }
  24633. m.SetSearchPricePer1k(v)
  24634. return nil
  24635. case group.FieldAudioRealtimePricePerMin:
  24636. v, ok := value.(float64)
  24637. if !ok {
  24638. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24639. }
  24640. m.SetAudioRealtimePricePerMin(v)
  24641. return nil
  24642. case group.FieldAudioTtsPricePerMillionChars:
  24643. v, ok := value.(float64)
  24644. if !ok {
  24645. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24646. }
  24647. m.SetAudioTtsPricePerMillionChars(v)
  24648. return nil
  24649. case group.FieldAudioSttPricePerHour:
  24650. v, ok := value.(float64)
  24651. if !ok {
  24652. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24653. }
  24654. m.SetAudioSttPricePerHour(v)
  24655. return nil
  24656. case group.FieldLongContextPricingEnabled:
  24657. v, ok := value.(bool)
  24658. if !ok {
  24659. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24660. }
  24661. m.SetLongContextPricingEnabled(v)
  24662. return nil
  24663. case group.FieldModelPricing:
  24664. v, ok := value.(jsontext.Value)
  24665. if !ok {
  24666. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24667. }
  24668. m.SetModelPricing(v)
  24669. return nil
  24670. case group.FieldClaudeCodeOnly:
  24671. v, ok := value.(bool)
  24672. if !ok {
  24673. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24674. }
  24675. m.SetClaudeCodeOnly(v)
  24676. return nil
  24677. case group.FieldFallbackGroupID:
  24678. v, ok := value.(int64)
  24679. if !ok {
  24680. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24681. }
  24682. m.SetFallbackGroupID(v)
  24683. return nil
  24684. case group.FieldFallbackGroupIDOnInvalidRequest:
  24685. v, ok := value.(int64)
  24686. if !ok {
  24687. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24688. }
  24689. m.SetFallbackGroupIDOnInvalidRequest(v)
  24690. return nil
  24691. case group.FieldModelRouting:
  24692. v, ok := value.(map[string][]int64)
  24693. if !ok {
  24694. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24695. }
  24696. m.SetModelRouting(v)
  24697. return nil
  24698. case group.FieldModelRoutingEnabled:
  24699. v, ok := value.(bool)
  24700. if !ok {
  24701. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24702. }
  24703. m.SetModelRoutingEnabled(v)
  24704. return nil
  24705. case group.FieldMcpXMLInject:
  24706. v, ok := value.(bool)
  24707. if !ok {
  24708. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24709. }
  24710. m.SetMcpXMLInject(v)
  24711. return nil
  24712. case group.FieldSupportedModelScopes:
  24713. v, ok := value.([]string)
  24714. if !ok {
  24715. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24716. }
  24717. m.SetSupportedModelScopes(v)
  24718. return nil
  24719. case group.FieldSortOrder:
  24720. v, ok := value.(int)
  24721. if !ok {
  24722. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24723. }
  24724. m.SetSortOrder(v)
  24725. return nil
  24726. case group.FieldAllowMessagesDispatch:
  24727. v, ok := value.(bool)
  24728. if !ok {
  24729. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24730. }
  24731. m.SetAllowMessagesDispatch(v)
  24732. return nil
  24733. case group.FieldAllowLive:
  24734. v, ok := value.(bool)
  24735. if !ok {
  24736. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24737. }
  24738. m.SetAllowLive(v)
  24739. return nil
  24740. case group.FieldForceOpenaiFast:
  24741. v, ok := value.(bool)
  24742. if !ok {
  24743. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24744. }
  24745. m.SetForceOpenaiFast(v)
  24746. return nil
  24747. case group.FieldFreeOpenaiFast:
  24748. v, ok := value.(bool)
  24749. if !ok {
  24750. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24751. }
  24752. m.SetFreeOpenaiFast(v)
  24753. return nil
  24754. case group.FieldRequireOauthOnly:
  24755. v, ok := value.(bool)
  24756. if !ok {
  24757. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24758. }
  24759. m.SetRequireOauthOnly(v)
  24760. return nil
  24761. case group.FieldRequirePrivacySet:
  24762. v, ok := value.(bool)
  24763. if !ok {
  24764. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24765. }
  24766. m.SetRequirePrivacySet(v)
  24767. return nil
  24768. case group.FieldDefaultMappedModel:
  24769. v, ok := value.(string)
  24770. if !ok {
  24771. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24772. }
  24773. m.SetDefaultMappedModel(v)
  24774. return nil
  24775. case group.FieldMessagesDispatchModelConfig:
  24776. v, ok := value.(domain.OpenAIMessagesDispatchModelConfig)
  24777. if !ok {
  24778. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24779. }
  24780. m.SetMessagesDispatchModelConfig(v)
  24781. return nil
  24782. case group.FieldModelAllowlist:
  24783. v, ok := value.(domain.GroupModelAllowlist)
  24784. if !ok {
  24785. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24786. }
  24787. m.SetModelAllowlist(v)
  24788. return nil
  24789. case group.FieldCodexModelsManifestConfig:
  24790. v, ok := value.(domain.GroupCodexModelsManifestConfig)
  24791. if !ok {
  24792. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24793. }
  24794. m.SetCodexModelsManifestConfig(v)
  24795. return nil
  24796. case group.FieldRpmLimit:
  24797. v, ok := value.(int)
  24798. if !ok {
  24799. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24800. }
  24801. m.SetRpmLimit(v)
  24802. return nil
  24803. case group.FieldMaxReasoningEffort:
  24804. v, ok := value.(string)
  24805. if !ok {
  24806. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24807. }
  24808. m.SetMaxReasoningEffort(v)
  24809. return nil
  24810. case group.FieldMaxReasoningEffortOverLimit:
  24811. v, ok := value.(string)
  24812. if !ok {
  24813. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24814. }
  24815. m.SetMaxReasoningEffortOverLimit(v)
  24816. return nil
  24817. case group.FieldReasoningEffortMappings:
  24818. v, ok := value.([]domain.ReasoningEffortMapping)
  24819. if !ok {
  24820. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24821. }
  24822. m.SetReasoningEffortMappings(v)
  24823. return nil
  24824. case group.FieldProfitControlEnabled:
  24825. v, ok := value.(bool)
  24826. if !ok {
  24827. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24828. }
  24829. m.SetProfitControlEnabled(v)
  24830. return nil
  24831. case group.FieldProfitMinMargin:
  24832. v, ok := value.(float64)
  24833. if !ok {
  24834. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24835. }
  24836. m.SetProfitMinMargin(v)
  24837. return nil
  24838. case group.FieldProfitSafetyBuffer:
  24839. v, ok := value.(float64)
  24840. if !ok {
  24841. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24842. }
  24843. m.SetProfitSafetyBuffer(v)
  24844. return nil
  24845. }
  24846. return fmt.Errorf("unknown Group field %s", name)
  24847. }
  24848. // AddedFields returns all numeric fields that were incremented/decremented during
  24849. // this mutation.
  24850. func (m *GroupMutation) AddedFields() []string {
  24851. var fields []string
  24852. if m.addrate_multiplier != nil {
  24853. fields = append(fields, group.FieldRateMultiplier)
  24854. }
  24855. if m.addpeak_rate_multiplier != nil {
  24856. fields = append(fields, group.FieldPeakRateMultiplier)
  24857. }
  24858. if m.adddaily_limit_usd != nil {
  24859. fields = append(fields, group.FieldDailyLimitUsd)
  24860. }
  24861. if m.addweekly_limit_usd != nil {
  24862. fields = append(fields, group.FieldWeeklyLimitUsd)
  24863. }
  24864. if m.addmonthly_limit_usd != nil {
  24865. fields = append(fields, group.FieldMonthlyLimitUsd)
  24866. }
  24867. if m.adddefault_validity_days != nil {
  24868. fields = append(fields, group.FieldDefaultValidityDays)
  24869. }
  24870. if m.addimage_rate_multiplier != nil {
  24871. fields = append(fields, group.FieldImageRateMultiplier)
  24872. }
  24873. if m.addimage_price_1k != nil {
  24874. fields = append(fields, group.FieldImagePrice1k)
  24875. }
  24876. if m.addimage_price_2k != nil {
  24877. fields = append(fields, group.FieldImagePrice2k)
  24878. }
  24879. if m.addimage_price_4k != nil {
  24880. fields = append(fields, group.FieldImagePrice4k)
  24881. }
  24882. if m.addbatch_image_discount_multiplier != nil {
  24883. fields = append(fields, group.FieldBatchImageDiscountMultiplier)
  24884. }
  24885. if m.addbatch_image_hold_multiplier != nil {
  24886. fields = append(fields, group.FieldBatchImageHoldMultiplier)
  24887. }
  24888. if m.addvideo_rate_multiplier != nil {
  24889. fields = append(fields, group.FieldVideoRateMultiplier)
  24890. }
  24891. if m.addvideo_price_480p != nil {
  24892. fields = append(fields, group.FieldVideoPrice480p)
  24893. }
  24894. if m.addvideo_price_720p != nil {
  24895. fields = append(fields, group.FieldVideoPrice720p)
  24896. }
  24897. if m.addvideo_price_1080p != nil {
  24898. fields = append(fields, group.FieldVideoPrice1080p)
  24899. }
  24900. if m.addweb_search_price_per_call != nil {
  24901. fields = append(fields, group.FieldWebSearchPricePerCall)
  24902. }
  24903. if m.addsearch_price_per_1k != nil {
  24904. fields = append(fields, group.FieldSearchPricePer1k)
  24905. }
  24906. if m.addaudio_realtime_price_per_min != nil {
  24907. fields = append(fields, group.FieldAudioRealtimePricePerMin)
  24908. }
  24909. if m.addaudio_tts_price_per_million_chars != nil {
  24910. fields = append(fields, group.FieldAudioTtsPricePerMillionChars)
  24911. }
  24912. if m.addaudio_stt_price_per_hour != nil {
  24913. fields = append(fields, group.FieldAudioSttPricePerHour)
  24914. }
  24915. if m.addfallback_group_id != nil {
  24916. fields = append(fields, group.FieldFallbackGroupID)
  24917. }
  24918. if m.addfallback_group_id_on_invalid_request != nil {
  24919. fields = append(fields, group.FieldFallbackGroupIDOnInvalidRequest)
  24920. }
  24921. if m.addsort_order != nil {
  24922. fields = append(fields, group.FieldSortOrder)
  24923. }
  24924. if m.addrpm_limit != nil {
  24925. fields = append(fields, group.FieldRpmLimit)
  24926. }
  24927. if m.addprofit_min_margin != nil {
  24928. fields = append(fields, group.FieldProfitMinMargin)
  24929. }
  24930. if m.addprofit_safety_buffer != nil {
  24931. fields = append(fields, group.FieldProfitSafetyBuffer)
  24932. }
  24933. return fields
  24934. }
  24935. // AddedField returns the numeric value that was incremented/decremented on a field
  24936. // with the given name. The second boolean return value indicates that this field
  24937. // was not set, or was not defined in the schema.
  24938. func (m *GroupMutation) AddedField(name string) (ent.Value, bool) {
  24939. switch name {
  24940. case group.FieldRateMultiplier:
  24941. return m.AddedRateMultiplier()
  24942. case group.FieldPeakRateMultiplier:
  24943. return m.AddedPeakRateMultiplier()
  24944. case group.FieldDailyLimitUsd:
  24945. return m.AddedDailyLimitUsd()
  24946. case group.FieldWeeklyLimitUsd:
  24947. return m.AddedWeeklyLimitUsd()
  24948. case group.FieldMonthlyLimitUsd:
  24949. return m.AddedMonthlyLimitUsd()
  24950. case group.FieldDefaultValidityDays:
  24951. return m.AddedDefaultValidityDays()
  24952. case group.FieldImageRateMultiplier:
  24953. return m.AddedImageRateMultiplier()
  24954. case group.FieldImagePrice1k:
  24955. return m.AddedImagePrice1k()
  24956. case group.FieldImagePrice2k:
  24957. return m.AddedImagePrice2k()
  24958. case group.FieldImagePrice4k:
  24959. return m.AddedImagePrice4k()
  24960. case group.FieldBatchImageDiscountMultiplier:
  24961. return m.AddedBatchImageDiscountMultiplier()
  24962. case group.FieldBatchImageHoldMultiplier:
  24963. return m.AddedBatchImageHoldMultiplier()
  24964. case group.FieldVideoRateMultiplier:
  24965. return m.AddedVideoRateMultiplier()
  24966. case group.FieldVideoPrice480p:
  24967. return m.AddedVideoPrice480p()
  24968. case group.FieldVideoPrice720p:
  24969. return m.AddedVideoPrice720p()
  24970. case group.FieldVideoPrice1080p:
  24971. return m.AddedVideoPrice1080p()
  24972. case group.FieldWebSearchPricePerCall:
  24973. return m.AddedWebSearchPricePerCall()
  24974. case group.FieldSearchPricePer1k:
  24975. return m.AddedSearchPricePer1k()
  24976. case group.FieldAudioRealtimePricePerMin:
  24977. return m.AddedAudioRealtimePricePerMin()
  24978. case group.FieldAudioTtsPricePerMillionChars:
  24979. return m.AddedAudioTtsPricePerMillionChars()
  24980. case group.FieldAudioSttPricePerHour:
  24981. return m.AddedAudioSttPricePerHour()
  24982. case group.FieldFallbackGroupID:
  24983. return m.AddedFallbackGroupID()
  24984. case group.FieldFallbackGroupIDOnInvalidRequest:
  24985. return m.AddedFallbackGroupIDOnInvalidRequest()
  24986. case group.FieldSortOrder:
  24987. return m.AddedSortOrder()
  24988. case group.FieldRpmLimit:
  24989. return m.AddedRpmLimit()
  24990. case group.FieldProfitMinMargin:
  24991. return m.AddedProfitMinMargin()
  24992. case group.FieldProfitSafetyBuffer:
  24993. return m.AddedProfitSafetyBuffer()
  24994. }
  24995. return nil, false
  24996. }
  24997. // AddField adds the value to the field with the given name. It returns an error if
  24998. // the field is not defined in the schema, or if the type mismatched the field
  24999. // type.
  25000. func (m *GroupMutation) AddField(name string, value ent.Value) error {
  25001. switch name {
  25002. case group.FieldRateMultiplier:
  25003. v, ok := value.(float64)
  25004. if !ok {
  25005. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25006. }
  25007. m.AddRateMultiplier(v)
  25008. return nil
  25009. case group.FieldPeakRateMultiplier:
  25010. v, ok := value.(float64)
  25011. if !ok {
  25012. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25013. }
  25014. m.AddPeakRateMultiplier(v)
  25015. return nil
  25016. case group.FieldDailyLimitUsd:
  25017. v, ok := value.(float64)
  25018. if !ok {
  25019. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25020. }
  25021. m.AddDailyLimitUsd(v)
  25022. return nil
  25023. case group.FieldWeeklyLimitUsd:
  25024. v, ok := value.(float64)
  25025. if !ok {
  25026. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25027. }
  25028. m.AddWeeklyLimitUsd(v)
  25029. return nil
  25030. case group.FieldMonthlyLimitUsd:
  25031. v, ok := value.(float64)
  25032. if !ok {
  25033. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25034. }
  25035. m.AddMonthlyLimitUsd(v)
  25036. return nil
  25037. case group.FieldDefaultValidityDays:
  25038. v, ok := value.(int)
  25039. if !ok {
  25040. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25041. }
  25042. m.AddDefaultValidityDays(v)
  25043. return nil
  25044. case group.FieldImageRateMultiplier:
  25045. v, ok := value.(float64)
  25046. if !ok {
  25047. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25048. }
  25049. m.AddImageRateMultiplier(v)
  25050. return nil
  25051. case group.FieldImagePrice1k:
  25052. v, ok := value.(float64)
  25053. if !ok {
  25054. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25055. }
  25056. m.AddImagePrice1k(v)
  25057. return nil
  25058. case group.FieldImagePrice2k:
  25059. v, ok := value.(float64)
  25060. if !ok {
  25061. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25062. }
  25063. m.AddImagePrice2k(v)
  25064. return nil
  25065. case group.FieldImagePrice4k:
  25066. v, ok := value.(float64)
  25067. if !ok {
  25068. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25069. }
  25070. m.AddImagePrice4k(v)
  25071. return nil
  25072. case group.FieldBatchImageDiscountMultiplier:
  25073. v, ok := value.(float64)
  25074. if !ok {
  25075. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25076. }
  25077. m.AddBatchImageDiscountMultiplier(v)
  25078. return nil
  25079. case group.FieldBatchImageHoldMultiplier:
  25080. v, ok := value.(float64)
  25081. if !ok {
  25082. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25083. }
  25084. m.AddBatchImageHoldMultiplier(v)
  25085. return nil
  25086. case group.FieldVideoRateMultiplier:
  25087. v, ok := value.(float64)
  25088. if !ok {
  25089. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25090. }
  25091. m.AddVideoRateMultiplier(v)
  25092. return nil
  25093. case group.FieldVideoPrice480p:
  25094. v, ok := value.(float64)
  25095. if !ok {
  25096. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25097. }
  25098. m.AddVideoPrice480p(v)
  25099. return nil
  25100. case group.FieldVideoPrice720p:
  25101. v, ok := value.(float64)
  25102. if !ok {
  25103. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25104. }
  25105. m.AddVideoPrice720p(v)
  25106. return nil
  25107. case group.FieldVideoPrice1080p:
  25108. v, ok := value.(float64)
  25109. if !ok {
  25110. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25111. }
  25112. m.AddVideoPrice1080p(v)
  25113. return nil
  25114. case group.FieldWebSearchPricePerCall:
  25115. v, ok := value.(float64)
  25116. if !ok {
  25117. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25118. }
  25119. m.AddWebSearchPricePerCall(v)
  25120. return nil
  25121. case group.FieldSearchPricePer1k:
  25122. v, ok := value.(float64)
  25123. if !ok {
  25124. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25125. }
  25126. m.AddSearchPricePer1k(v)
  25127. return nil
  25128. case group.FieldAudioRealtimePricePerMin:
  25129. v, ok := value.(float64)
  25130. if !ok {
  25131. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25132. }
  25133. m.AddAudioRealtimePricePerMin(v)
  25134. return nil
  25135. case group.FieldAudioTtsPricePerMillionChars:
  25136. v, ok := value.(float64)
  25137. if !ok {
  25138. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25139. }
  25140. m.AddAudioTtsPricePerMillionChars(v)
  25141. return nil
  25142. case group.FieldAudioSttPricePerHour:
  25143. v, ok := value.(float64)
  25144. if !ok {
  25145. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25146. }
  25147. m.AddAudioSttPricePerHour(v)
  25148. return nil
  25149. case group.FieldFallbackGroupID:
  25150. v, ok := value.(int64)
  25151. if !ok {
  25152. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25153. }
  25154. m.AddFallbackGroupID(v)
  25155. return nil
  25156. case group.FieldFallbackGroupIDOnInvalidRequest:
  25157. v, ok := value.(int64)
  25158. if !ok {
  25159. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25160. }
  25161. m.AddFallbackGroupIDOnInvalidRequest(v)
  25162. return nil
  25163. case group.FieldSortOrder:
  25164. v, ok := value.(int)
  25165. if !ok {
  25166. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25167. }
  25168. m.AddSortOrder(v)
  25169. return nil
  25170. case group.FieldRpmLimit:
  25171. v, ok := value.(int)
  25172. if !ok {
  25173. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25174. }
  25175. m.AddRpmLimit(v)
  25176. return nil
  25177. case group.FieldProfitMinMargin:
  25178. v, ok := value.(float64)
  25179. if !ok {
  25180. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25181. }
  25182. m.AddProfitMinMargin(v)
  25183. return nil
  25184. case group.FieldProfitSafetyBuffer:
  25185. v, ok := value.(float64)
  25186. if !ok {
  25187. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25188. }
  25189. m.AddProfitSafetyBuffer(v)
  25190. return nil
  25191. }
  25192. return fmt.Errorf("unknown Group numeric field %s", name)
  25193. }
  25194. // ClearedFields returns all nullable fields that were cleared during this
  25195. // mutation.
  25196. func (m *GroupMutation) ClearedFields() []string {
  25197. var fields []string
  25198. if m.FieldCleared(group.FieldDeletedAt) {
  25199. fields = append(fields, group.FieldDeletedAt)
  25200. }
  25201. if m.FieldCleared(group.FieldDescription) {
  25202. fields = append(fields, group.FieldDescription)
  25203. }
  25204. if m.FieldCleared(group.FieldDuplicateOperationID) {
  25205. fields = append(fields, group.FieldDuplicateOperationID)
  25206. }
  25207. if m.FieldCleared(group.FieldDailyLimitUsd) {
  25208. fields = append(fields, group.FieldDailyLimitUsd)
  25209. }
  25210. if m.FieldCleared(group.FieldWeeklyLimitUsd) {
  25211. fields = append(fields, group.FieldWeeklyLimitUsd)
  25212. }
  25213. if m.FieldCleared(group.FieldMonthlyLimitUsd) {
  25214. fields = append(fields, group.FieldMonthlyLimitUsd)
  25215. }
  25216. if m.FieldCleared(group.FieldImagePrice1k) {
  25217. fields = append(fields, group.FieldImagePrice1k)
  25218. }
  25219. if m.FieldCleared(group.FieldImagePrice2k) {
  25220. fields = append(fields, group.FieldImagePrice2k)
  25221. }
  25222. if m.FieldCleared(group.FieldImagePrice4k) {
  25223. fields = append(fields, group.FieldImagePrice4k)
  25224. }
  25225. if m.FieldCleared(group.FieldVideoPrice480p) {
  25226. fields = append(fields, group.FieldVideoPrice480p)
  25227. }
  25228. if m.FieldCleared(group.FieldVideoPrice720p) {
  25229. fields = append(fields, group.FieldVideoPrice720p)
  25230. }
  25231. if m.FieldCleared(group.FieldVideoPrice1080p) {
  25232. fields = append(fields, group.FieldVideoPrice1080p)
  25233. }
  25234. if m.FieldCleared(group.FieldVideoModelPrices) {
  25235. fields = append(fields, group.FieldVideoModelPrices)
  25236. }
  25237. if m.FieldCleared(group.FieldWebSearchPricePerCall) {
  25238. fields = append(fields, group.FieldWebSearchPricePerCall)
  25239. }
  25240. if m.FieldCleared(group.FieldSearchPricePer1k) {
  25241. fields = append(fields, group.FieldSearchPricePer1k)
  25242. }
  25243. if m.FieldCleared(group.FieldAudioRealtimePricePerMin) {
  25244. fields = append(fields, group.FieldAudioRealtimePricePerMin)
  25245. }
  25246. if m.FieldCleared(group.FieldAudioTtsPricePerMillionChars) {
  25247. fields = append(fields, group.FieldAudioTtsPricePerMillionChars)
  25248. }
  25249. if m.FieldCleared(group.FieldAudioSttPricePerHour) {
  25250. fields = append(fields, group.FieldAudioSttPricePerHour)
  25251. }
  25252. if m.FieldCleared(group.FieldModelPricing) {
  25253. fields = append(fields, group.FieldModelPricing)
  25254. }
  25255. if m.FieldCleared(group.FieldFallbackGroupID) {
  25256. fields = append(fields, group.FieldFallbackGroupID)
  25257. }
  25258. if m.FieldCleared(group.FieldFallbackGroupIDOnInvalidRequest) {
  25259. fields = append(fields, group.FieldFallbackGroupIDOnInvalidRequest)
  25260. }
  25261. if m.FieldCleared(group.FieldModelRouting) {
  25262. fields = append(fields, group.FieldModelRouting)
  25263. }
  25264. return fields
  25265. }
  25266. // FieldCleared returns a boolean indicating if a field with the given name was
  25267. // cleared in this mutation.
  25268. func (m *GroupMutation) FieldCleared(name string) bool {
  25269. _, ok := m.clearedFields[name]
  25270. return ok
  25271. }
  25272. // ClearField clears the value of the field with the given name. It returns an
  25273. // error if the field is not defined in the schema.
  25274. func (m *GroupMutation) ClearField(name string) error {
  25275. switch name {
  25276. case group.FieldDeletedAt:
  25277. m.ClearDeletedAt()
  25278. return nil
  25279. case group.FieldDescription:
  25280. m.ClearDescription()
  25281. return nil
  25282. case group.FieldDuplicateOperationID:
  25283. m.ClearDuplicateOperationID()
  25284. return nil
  25285. case group.FieldDailyLimitUsd:
  25286. m.ClearDailyLimitUsd()
  25287. return nil
  25288. case group.FieldWeeklyLimitUsd:
  25289. m.ClearWeeklyLimitUsd()
  25290. return nil
  25291. case group.FieldMonthlyLimitUsd:
  25292. m.ClearMonthlyLimitUsd()
  25293. return nil
  25294. case group.FieldImagePrice1k:
  25295. m.ClearImagePrice1k()
  25296. return nil
  25297. case group.FieldImagePrice2k:
  25298. m.ClearImagePrice2k()
  25299. return nil
  25300. case group.FieldImagePrice4k:
  25301. m.ClearImagePrice4k()
  25302. return nil
  25303. case group.FieldVideoPrice480p:
  25304. m.ClearVideoPrice480p()
  25305. return nil
  25306. case group.FieldVideoPrice720p:
  25307. m.ClearVideoPrice720p()
  25308. return nil
  25309. case group.FieldVideoPrice1080p:
  25310. m.ClearVideoPrice1080p()
  25311. return nil
  25312. case group.FieldVideoModelPrices:
  25313. m.ClearVideoModelPrices()
  25314. return nil
  25315. case group.FieldWebSearchPricePerCall:
  25316. m.ClearWebSearchPricePerCall()
  25317. return nil
  25318. case group.FieldSearchPricePer1k:
  25319. m.ClearSearchPricePer1k()
  25320. return nil
  25321. case group.FieldAudioRealtimePricePerMin:
  25322. m.ClearAudioRealtimePricePerMin()
  25323. return nil
  25324. case group.FieldAudioTtsPricePerMillionChars:
  25325. m.ClearAudioTtsPricePerMillionChars()
  25326. return nil
  25327. case group.FieldAudioSttPricePerHour:
  25328. m.ClearAudioSttPricePerHour()
  25329. return nil
  25330. case group.FieldModelPricing:
  25331. m.ClearModelPricing()
  25332. return nil
  25333. case group.FieldFallbackGroupID:
  25334. m.ClearFallbackGroupID()
  25335. return nil
  25336. case group.FieldFallbackGroupIDOnInvalidRequest:
  25337. m.ClearFallbackGroupIDOnInvalidRequest()
  25338. return nil
  25339. case group.FieldModelRouting:
  25340. m.ClearModelRouting()
  25341. return nil
  25342. }
  25343. return fmt.Errorf("unknown Group nullable field %s", name)
  25344. }
  25345. // ResetField resets all changes in the mutation for the field with the given name.
  25346. // It returns an error if the field is not defined in the schema.
  25347. func (m *GroupMutation) ResetField(name string) error {
  25348. switch name {
  25349. case group.FieldCreatedAt:
  25350. m.ResetCreatedAt()
  25351. return nil
  25352. case group.FieldUpdatedAt:
  25353. m.ResetUpdatedAt()
  25354. return nil
  25355. case group.FieldDeletedAt:
  25356. m.ResetDeletedAt()
  25357. return nil
  25358. case group.FieldName:
  25359. m.ResetName()
  25360. return nil
  25361. case group.FieldDescription:
  25362. m.ResetDescription()
  25363. return nil
  25364. case group.FieldRateMultiplier:
  25365. m.ResetRateMultiplier()
  25366. return nil
  25367. case group.FieldPeakRateEnabled:
  25368. m.ResetPeakRateEnabled()
  25369. return nil
  25370. case group.FieldPeakStart:
  25371. m.ResetPeakStart()
  25372. return nil
  25373. case group.FieldPeakEnd:
  25374. m.ResetPeakEnd()
  25375. return nil
  25376. case group.FieldPeakRateMultiplier:
  25377. m.ResetPeakRateMultiplier()
  25378. return nil
  25379. case group.FieldIsExclusive:
  25380. m.ResetIsExclusive()
  25381. return nil
  25382. case group.FieldSecurityPolicyEnabled:
  25383. m.ResetSecurityPolicyEnabled()
  25384. return nil
  25385. case group.FieldSecurityPolicyMode:
  25386. m.ResetSecurityPolicyMode()
  25387. return nil
  25388. case group.FieldSecurityPolicyEmailEnabled:
  25389. m.ResetSecurityPolicyEmailEnabled()
  25390. return nil
  25391. case group.FieldStatus:
  25392. m.ResetStatus()
  25393. return nil
  25394. case group.FieldDuplicateOperationID:
  25395. m.ResetDuplicateOperationID()
  25396. return nil
  25397. case group.FieldPlatform:
  25398. m.ResetPlatform()
  25399. return nil
  25400. case group.FieldSubscriptionType:
  25401. m.ResetSubscriptionType()
  25402. return nil
  25403. case group.FieldDailyLimitUsd:
  25404. m.ResetDailyLimitUsd()
  25405. return nil
  25406. case group.FieldWeeklyLimitUsd:
  25407. m.ResetWeeklyLimitUsd()
  25408. return nil
  25409. case group.FieldMonthlyLimitUsd:
  25410. m.ResetMonthlyLimitUsd()
  25411. return nil
  25412. case group.FieldDefaultValidityDays:
  25413. m.ResetDefaultValidityDays()
  25414. return nil
  25415. case group.FieldAllowImageGeneration:
  25416. m.ResetAllowImageGeneration()
  25417. return nil
  25418. case group.FieldAllowBatchImageGeneration:
  25419. m.ResetAllowBatchImageGeneration()
  25420. return nil
  25421. case group.FieldImageRateIndependent:
  25422. m.ResetImageRateIndependent()
  25423. return nil
  25424. case group.FieldImageRateMultiplier:
  25425. m.ResetImageRateMultiplier()
  25426. return nil
  25427. case group.FieldImagePrice1k:
  25428. m.ResetImagePrice1k()
  25429. return nil
  25430. case group.FieldImagePrice2k:
  25431. m.ResetImagePrice2k()
  25432. return nil
  25433. case group.FieldImagePrice4k:
  25434. m.ResetImagePrice4k()
  25435. return nil
  25436. case group.FieldBatchImageDiscountMultiplier:
  25437. m.ResetBatchImageDiscountMultiplier()
  25438. return nil
  25439. case group.FieldBatchImageHoldMultiplier:
  25440. m.ResetBatchImageHoldMultiplier()
  25441. return nil
  25442. case group.FieldVideoRateIndependent:
  25443. m.ResetVideoRateIndependent()
  25444. return nil
  25445. case group.FieldVideoRateMultiplier:
  25446. m.ResetVideoRateMultiplier()
  25447. return nil
  25448. case group.FieldVideoPrice480p:
  25449. m.ResetVideoPrice480p()
  25450. return nil
  25451. case group.FieldVideoPrice720p:
  25452. m.ResetVideoPrice720p()
  25453. return nil
  25454. case group.FieldVideoPrice1080p:
  25455. m.ResetVideoPrice1080p()
  25456. return nil
  25457. case group.FieldVideoModelPrices:
  25458. m.ResetVideoModelPrices()
  25459. return nil
  25460. case group.FieldWebSearchPricePerCall:
  25461. m.ResetWebSearchPricePerCall()
  25462. return nil
  25463. case group.FieldSearchPricePer1k:
  25464. m.ResetSearchPricePer1k()
  25465. return nil
  25466. case group.FieldAudioRealtimePricePerMin:
  25467. m.ResetAudioRealtimePricePerMin()
  25468. return nil
  25469. case group.FieldAudioTtsPricePerMillionChars:
  25470. m.ResetAudioTtsPricePerMillionChars()
  25471. return nil
  25472. case group.FieldAudioSttPricePerHour:
  25473. m.ResetAudioSttPricePerHour()
  25474. return nil
  25475. case group.FieldLongContextPricingEnabled:
  25476. m.ResetLongContextPricingEnabled()
  25477. return nil
  25478. case group.FieldModelPricing:
  25479. m.ResetModelPricing()
  25480. return nil
  25481. case group.FieldClaudeCodeOnly:
  25482. m.ResetClaudeCodeOnly()
  25483. return nil
  25484. case group.FieldFallbackGroupID:
  25485. m.ResetFallbackGroupID()
  25486. return nil
  25487. case group.FieldFallbackGroupIDOnInvalidRequest:
  25488. m.ResetFallbackGroupIDOnInvalidRequest()
  25489. return nil
  25490. case group.FieldModelRouting:
  25491. m.ResetModelRouting()
  25492. return nil
  25493. case group.FieldModelRoutingEnabled:
  25494. m.ResetModelRoutingEnabled()
  25495. return nil
  25496. case group.FieldMcpXMLInject:
  25497. m.ResetMcpXMLInject()
  25498. return nil
  25499. case group.FieldSupportedModelScopes:
  25500. m.ResetSupportedModelScopes()
  25501. return nil
  25502. case group.FieldSortOrder:
  25503. m.ResetSortOrder()
  25504. return nil
  25505. case group.FieldAllowMessagesDispatch:
  25506. m.ResetAllowMessagesDispatch()
  25507. return nil
  25508. case group.FieldAllowLive:
  25509. m.ResetAllowLive()
  25510. return nil
  25511. case group.FieldForceOpenaiFast:
  25512. m.ResetForceOpenaiFast()
  25513. return nil
  25514. case group.FieldFreeOpenaiFast:
  25515. m.ResetFreeOpenaiFast()
  25516. return nil
  25517. case group.FieldRequireOauthOnly:
  25518. m.ResetRequireOauthOnly()
  25519. return nil
  25520. case group.FieldRequirePrivacySet:
  25521. m.ResetRequirePrivacySet()
  25522. return nil
  25523. case group.FieldDefaultMappedModel:
  25524. m.ResetDefaultMappedModel()
  25525. return nil
  25526. case group.FieldMessagesDispatchModelConfig:
  25527. m.ResetMessagesDispatchModelConfig()
  25528. return nil
  25529. case group.FieldModelAllowlist:
  25530. m.ResetModelAllowlist()
  25531. return nil
  25532. case group.FieldCodexModelsManifestConfig:
  25533. m.ResetCodexModelsManifestConfig()
  25534. return nil
  25535. case group.FieldRpmLimit:
  25536. m.ResetRpmLimit()
  25537. return nil
  25538. case group.FieldMaxReasoningEffort:
  25539. m.ResetMaxReasoningEffort()
  25540. return nil
  25541. case group.FieldMaxReasoningEffortOverLimit:
  25542. m.ResetMaxReasoningEffortOverLimit()
  25543. return nil
  25544. case group.FieldReasoningEffortMappings:
  25545. m.ResetReasoningEffortMappings()
  25546. return nil
  25547. case group.FieldProfitControlEnabled:
  25548. m.ResetProfitControlEnabled()
  25549. return nil
  25550. case group.FieldProfitMinMargin:
  25551. m.ResetProfitMinMargin()
  25552. return nil
  25553. case group.FieldProfitSafetyBuffer:
  25554. m.ResetProfitSafetyBuffer()
  25555. return nil
  25556. }
  25557. return fmt.Errorf("unknown Group field %s", name)
  25558. }
  25559. // AddedEdges returns all edge names that were set/added in this mutation.
  25560. func (m *GroupMutation) AddedEdges() []string {
  25561. edges := make([]string, 0, 6)
  25562. if m.api_keys != nil {
  25563. edges = append(edges, group.EdgeAPIKeys)
  25564. }
  25565. if m.redeem_codes != nil {
  25566. edges = append(edges, group.EdgeRedeemCodes)
  25567. }
  25568. if m.subscriptions != nil {
  25569. edges = append(edges, group.EdgeSubscriptions)
  25570. }
  25571. if m.usage_logs != nil {
  25572. edges = append(edges, group.EdgeUsageLogs)
  25573. }
  25574. if m.accounts != nil {
  25575. edges = append(edges, group.EdgeAccounts)
  25576. }
  25577. if m.allowed_users != nil {
  25578. edges = append(edges, group.EdgeAllowedUsers)
  25579. }
  25580. return edges
  25581. }
  25582. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  25583. // name in this mutation.
  25584. func (m *GroupMutation) AddedIDs(name string) []ent.Value {
  25585. switch name {
  25586. case group.EdgeAPIKeys:
  25587. ids := make([]ent.Value, 0, len(m.api_keys))
  25588. for id := range m.api_keys {
  25589. ids = append(ids, id)
  25590. }
  25591. return ids
  25592. case group.EdgeRedeemCodes:
  25593. ids := make([]ent.Value, 0, len(m.redeem_codes))
  25594. for id := range m.redeem_codes {
  25595. ids = append(ids, id)
  25596. }
  25597. return ids
  25598. case group.EdgeSubscriptions:
  25599. ids := make([]ent.Value, 0, len(m.subscriptions))
  25600. for id := range m.subscriptions {
  25601. ids = append(ids, id)
  25602. }
  25603. return ids
  25604. case group.EdgeUsageLogs:
  25605. ids := make([]ent.Value, 0, len(m.usage_logs))
  25606. for id := range m.usage_logs {
  25607. ids = append(ids, id)
  25608. }
  25609. return ids
  25610. case group.EdgeAccounts:
  25611. ids := make([]ent.Value, 0, len(m.accounts))
  25612. for id := range m.accounts {
  25613. ids = append(ids, id)
  25614. }
  25615. return ids
  25616. case group.EdgeAllowedUsers:
  25617. ids := make([]ent.Value, 0, len(m.allowed_users))
  25618. for id := range m.allowed_users {
  25619. ids = append(ids, id)
  25620. }
  25621. return ids
  25622. }
  25623. return nil
  25624. }
  25625. // RemovedEdges returns all edge names that were removed in this mutation.
  25626. func (m *GroupMutation) RemovedEdges() []string {
  25627. edges := make([]string, 0, 6)
  25628. if m.removedapi_keys != nil {
  25629. edges = append(edges, group.EdgeAPIKeys)
  25630. }
  25631. if m.removedredeem_codes != nil {
  25632. edges = append(edges, group.EdgeRedeemCodes)
  25633. }
  25634. if m.removedsubscriptions != nil {
  25635. edges = append(edges, group.EdgeSubscriptions)
  25636. }
  25637. if m.removedusage_logs != nil {
  25638. edges = append(edges, group.EdgeUsageLogs)
  25639. }
  25640. if m.removedaccounts != nil {
  25641. edges = append(edges, group.EdgeAccounts)
  25642. }
  25643. if m.removedallowed_users != nil {
  25644. edges = append(edges, group.EdgeAllowedUsers)
  25645. }
  25646. return edges
  25647. }
  25648. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  25649. // the given name in this mutation.
  25650. func (m *GroupMutation) RemovedIDs(name string) []ent.Value {
  25651. switch name {
  25652. case group.EdgeAPIKeys:
  25653. ids := make([]ent.Value, 0, len(m.removedapi_keys))
  25654. for id := range m.removedapi_keys {
  25655. ids = append(ids, id)
  25656. }
  25657. return ids
  25658. case group.EdgeRedeemCodes:
  25659. ids := make([]ent.Value, 0, len(m.removedredeem_codes))
  25660. for id := range m.removedredeem_codes {
  25661. ids = append(ids, id)
  25662. }
  25663. return ids
  25664. case group.EdgeSubscriptions:
  25665. ids := make([]ent.Value, 0, len(m.removedsubscriptions))
  25666. for id := range m.removedsubscriptions {
  25667. ids = append(ids, id)
  25668. }
  25669. return ids
  25670. case group.EdgeUsageLogs:
  25671. ids := make([]ent.Value, 0, len(m.removedusage_logs))
  25672. for id := range m.removedusage_logs {
  25673. ids = append(ids, id)
  25674. }
  25675. return ids
  25676. case group.EdgeAccounts:
  25677. ids := make([]ent.Value, 0, len(m.removedaccounts))
  25678. for id := range m.removedaccounts {
  25679. ids = append(ids, id)
  25680. }
  25681. return ids
  25682. case group.EdgeAllowedUsers:
  25683. ids := make([]ent.Value, 0, len(m.removedallowed_users))
  25684. for id := range m.removedallowed_users {
  25685. ids = append(ids, id)
  25686. }
  25687. return ids
  25688. }
  25689. return nil
  25690. }
  25691. // ClearedEdges returns all edge names that were cleared in this mutation.
  25692. func (m *GroupMutation) ClearedEdges() []string {
  25693. edges := make([]string, 0, 6)
  25694. if m.clearedapi_keys {
  25695. edges = append(edges, group.EdgeAPIKeys)
  25696. }
  25697. if m.clearedredeem_codes {
  25698. edges = append(edges, group.EdgeRedeemCodes)
  25699. }
  25700. if m.clearedsubscriptions {
  25701. edges = append(edges, group.EdgeSubscriptions)
  25702. }
  25703. if m.clearedusage_logs {
  25704. edges = append(edges, group.EdgeUsageLogs)
  25705. }
  25706. if m.clearedaccounts {
  25707. edges = append(edges, group.EdgeAccounts)
  25708. }
  25709. if m.clearedallowed_users {
  25710. edges = append(edges, group.EdgeAllowedUsers)
  25711. }
  25712. return edges
  25713. }
  25714. // EdgeCleared returns a boolean which indicates if the edge with the given name
  25715. // was cleared in this mutation.
  25716. func (m *GroupMutation) EdgeCleared(name string) bool {
  25717. switch name {
  25718. case group.EdgeAPIKeys:
  25719. return m.clearedapi_keys
  25720. case group.EdgeRedeemCodes:
  25721. return m.clearedredeem_codes
  25722. case group.EdgeSubscriptions:
  25723. return m.clearedsubscriptions
  25724. case group.EdgeUsageLogs:
  25725. return m.clearedusage_logs
  25726. case group.EdgeAccounts:
  25727. return m.clearedaccounts
  25728. case group.EdgeAllowedUsers:
  25729. return m.clearedallowed_users
  25730. }
  25731. return false
  25732. }
  25733. // ClearEdge clears the value of the edge with the given name. It returns an error
  25734. // if that edge is not defined in the schema.
  25735. func (m *GroupMutation) ClearEdge(name string) error {
  25736. switch name {
  25737. }
  25738. return fmt.Errorf("unknown Group unique edge %s", name)
  25739. }
  25740. // ResetEdge resets all changes to the edge with the given name in this mutation.
  25741. // It returns an error if the edge is not defined in the schema.
  25742. func (m *GroupMutation) ResetEdge(name string) error {
  25743. switch name {
  25744. case group.EdgeAPIKeys:
  25745. m.ResetAPIKeys()
  25746. return nil
  25747. case group.EdgeRedeemCodes:
  25748. m.ResetRedeemCodes()
  25749. return nil
  25750. case group.EdgeSubscriptions:
  25751. m.ResetSubscriptions()
  25752. return nil
  25753. case group.EdgeUsageLogs:
  25754. m.ResetUsageLogs()
  25755. return nil
  25756. case group.EdgeAccounts:
  25757. m.ResetAccounts()
  25758. return nil
  25759. case group.EdgeAllowedUsers:
  25760. m.ResetAllowedUsers()
  25761. return nil
  25762. }
  25763. return fmt.Errorf("unknown Group edge %s", name)
  25764. }
  25765. // IdempotencyRecordMutation represents an operation that mutates the IdempotencyRecord nodes in the graph.
  25766. type IdempotencyRecordMutation struct {
  25767. config
  25768. op Op
  25769. typ string
  25770. id *int64
  25771. created_at *time.Time
  25772. updated_at *time.Time
  25773. scope *string
  25774. idempotency_key_hash *string
  25775. request_fingerprint *string
  25776. status *string
  25777. response_status *int
  25778. addresponse_status *int
  25779. response_body *string
  25780. error_reason *string
  25781. locked_until *time.Time
  25782. expires_at *time.Time
  25783. clearedFields map[string]struct{}
  25784. done bool
  25785. oldValue func(context.Context) (*IdempotencyRecord, error)
  25786. predicates []predicate.IdempotencyRecord
  25787. }
  25788. var _ ent.Mutation = (*IdempotencyRecordMutation)(nil)
  25789. // idempotencyrecordOption allows management of the mutation configuration using functional options.
  25790. type idempotencyrecordOption func(*IdempotencyRecordMutation)
  25791. // newIdempotencyRecordMutation creates new mutation for the IdempotencyRecord entity.
  25792. func newIdempotencyRecordMutation(c config, op Op, opts ...idempotencyrecordOption) *IdempotencyRecordMutation {
  25793. m := &IdempotencyRecordMutation{
  25794. config: c,
  25795. op: op,
  25796. typ: TypeIdempotencyRecord,
  25797. clearedFields: make(map[string]struct{}),
  25798. }
  25799. for _, opt := range opts {
  25800. opt(m)
  25801. }
  25802. return m
  25803. }
  25804. // withIdempotencyRecordID sets the ID field of the mutation.
  25805. func withIdempotencyRecordID(id int64) idempotencyrecordOption {
  25806. return func(m *IdempotencyRecordMutation) {
  25807. var (
  25808. err error
  25809. once sync.Once
  25810. value *IdempotencyRecord
  25811. )
  25812. m.oldValue = func(ctx context.Context) (*IdempotencyRecord, error) {
  25813. once.Do(func() {
  25814. if m.done {
  25815. err = errors.New("querying old values post mutation is not allowed")
  25816. } else {
  25817. value, err = m.Client().IdempotencyRecord.Get(ctx, id)
  25818. }
  25819. })
  25820. return value, err
  25821. }
  25822. m.id = &id
  25823. }
  25824. }
  25825. // withIdempotencyRecord sets the old IdempotencyRecord of the mutation.
  25826. func withIdempotencyRecord(node *IdempotencyRecord) idempotencyrecordOption {
  25827. return func(m *IdempotencyRecordMutation) {
  25828. m.oldValue = func(context.Context) (*IdempotencyRecord, error) {
  25829. return node, nil
  25830. }
  25831. m.id = &node.ID
  25832. }
  25833. }
  25834. // Client returns a new `ent.Client` from the mutation. If the mutation was
  25835. // executed in a transaction (ent.Tx), a transactional client is returned.
  25836. func (m IdempotencyRecordMutation) Client() *Client {
  25837. client := &Client{config: m.config}
  25838. client.init()
  25839. return client
  25840. }
  25841. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  25842. // it returns an error otherwise.
  25843. func (m IdempotencyRecordMutation) Tx() (*Tx, error) {
  25844. if _, ok := m.driver.(*txDriver); !ok {
  25845. return nil, errors.New("ent: mutation is not running in a transaction")
  25846. }
  25847. tx := &Tx{config: m.config}
  25848. tx.init()
  25849. return tx, nil
  25850. }
  25851. // ID returns the ID value in the mutation. Note that the ID is only available
  25852. // if it was provided to the builder or after it was returned from the database.
  25853. func (m *IdempotencyRecordMutation) ID() (id int64, exists bool) {
  25854. if m.id == nil {
  25855. return
  25856. }
  25857. return *m.id, true
  25858. }
  25859. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  25860. // That means, if the mutation is applied within a transaction with an isolation level such
  25861. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  25862. // or updated by the mutation.
  25863. func (m *IdempotencyRecordMutation) IDs(ctx context.Context) ([]int64, error) {
  25864. switch {
  25865. case m.op.Is(OpUpdateOne | OpDeleteOne):
  25866. id, exists := m.ID()
  25867. if exists {
  25868. return []int64{id}, nil
  25869. }
  25870. fallthrough
  25871. case m.op.Is(OpUpdate | OpDelete):
  25872. return m.Client().IdempotencyRecord.Query().Where(m.predicates...).IDs(ctx)
  25873. default:
  25874. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  25875. }
  25876. }
  25877. // SetCreatedAt sets the "created_at" field.
  25878. func (m *IdempotencyRecordMutation) SetCreatedAt(t time.Time) {
  25879. m.created_at = &t
  25880. }
  25881. // CreatedAt returns the value of the "created_at" field in the mutation.
  25882. func (m *IdempotencyRecordMutation) CreatedAt() (r time.Time, exists bool) {
  25883. v := m.created_at
  25884. if v == nil {
  25885. return
  25886. }
  25887. return *v, true
  25888. }
  25889. // OldCreatedAt returns the old "created_at" field's value of the IdempotencyRecord entity.
  25890. // If the IdempotencyRecord object wasn't provided to the builder, the object is fetched from the database.
  25891. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25892. func (m *IdempotencyRecordMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  25893. if !m.op.Is(OpUpdateOne) {
  25894. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  25895. }
  25896. if m.id == nil || m.oldValue == nil {
  25897. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  25898. }
  25899. oldValue, err := m.oldValue(ctx)
  25900. if err != nil {
  25901. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  25902. }
  25903. return oldValue.CreatedAt, nil
  25904. }
  25905. // ResetCreatedAt resets all changes to the "created_at" field.
  25906. func (m *IdempotencyRecordMutation) ResetCreatedAt() {
  25907. m.created_at = nil
  25908. }
  25909. // SetUpdatedAt sets the "updated_at" field.
  25910. func (m *IdempotencyRecordMutation) SetUpdatedAt(t time.Time) {
  25911. m.updated_at = &t
  25912. }
  25913. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  25914. func (m *IdempotencyRecordMutation) UpdatedAt() (r time.Time, exists bool) {
  25915. v := m.updated_at
  25916. if v == nil {
  25917. return
  25918. }
  25919. return *v, true
  25920. }
  25921. // OldUpdatedAt returns the old "updated_at" field's value of the IdempotencyRecord entity.
  25922. // If the IdempotencyRecord object wasn't provided to the builder, the object is fetched from the database.
  25923. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25924. func (m *IdempotencyRecordMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  25925. if !m.op.Is(OpUpdateOne) {
  25926. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  25927. }
  25928. if m.id == nil || m.oldValue == nil {
  25929. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  25930. }
  25931. oldValue, err := m.oldValue(ctx)
  25932. if err != nil {
  25933. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  25934. }
  25935. return oldValue.UpdatedAt, nil
  25936. }
  25937. // ResetUpdatedAt resets all changes to the "updated_at" field.
  25938. func (m *IdempotencyRecordMutation) ResetUpdatedAt() {
  25939. m.updated_at = nil
  25940. }
  25941. // SetScope sets the "scope" field.
  25942. func (m *IdempotencyRecordMutation) SetScope(s string) {
  25943. m.scope = &s
  25944. }
  25945. // Scope returns the value of the "scope" field in the mutation.
  25946. func (m *IdempotencyRecordMutation) Scope() (r string, exists bool) {
  25947. v := m.scope
  25948. if v == nil {
  25949. return
  25950. }
  25951. return *v, true
  25952. }
  25953. // OldScope returns the old "scope" field's value of the IdempotencyRecord entity.
  25954. // If the IdempotencyRecord object wasn't provided to the builder, the object is fetched from the database.
  25955. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25956. func (m *IdempotencyRecordMutation) OldScope(ctx context.Context) (v string, err error) {
  25957. if !m.op.Is(OpUpdateOne) {
  25958. return v, errors.New("OldScope is only allowed on UpdateOne operations")
  25959. }
  25960. if m.id == nil || m.oldValue == nil {
  25961. return v, errors.New("OldScope requires an ID field in the mutation")
  25962. }
  25963. oldValue, err := m.oldValue(ctx)
  25964. if err != nil {
  25965. return v, fmt.Errorf("querying old value for OldScope: %w", err)
  25966. }
  25967. return oldValue.Scope, nil
  25968. }
  25969. // ResetScope resets all changes to the "scope" field.
  25970. func (m *IdempotencyRecordMutation) ResetScope() {
  25971. m.scope = nil
  25972. }
  25973. // SetIdempotencyKeyHash sets the "idempotency_key_hash" field.
  25974. func (m *IdempotencyRecordMutation) SetIdempotencyKeyHash(s string) {
  25975. m.idempotency_key_hash = &s
  25976. }
  25977. // IdempotencyKeyHash returns the value of the "idempotency_key_hash" field in the mutation.
  25978. func (m *IdempotencyRecordMutation) IdempotencyKeyHash() (r string, exists bool) {
  25979. v := m.idempotency_key_hash
  25980. if v == nil {
  25981. return
  25982. }
  25983. return *v, true
  25984. }
  25985. // OldIdempotencyKeyHash returns the old "idempotency_key_hash" field's value of the IdempotencyRecord entity.
  25986. // If the IdempotencyRecord object wasn't provided to the builder, the object is fetched from the database.
  25987. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25988. func (m *IdempotencyRecordMutation) OldIdempotencyKeyHash(ctx context.Context) (v string, err error) {
  25989. if !m.op.Is(OpUpdateOne) {
  25990. return v, errors.New("OldIdempotencyKeyHash is only allowed on UpdateOne operations")
  25991. }
  25992. if m.id == nil || m.oldValue == nil {
  25993. return v, errors.New("OldIdempotencyKeyHash requires an ID field in the mutation")
  25994. }
  25995. oldValue, err := m.oldValue(ctx)
  25996. if err != nil {
  25997. return v, fmt.Errorf("querying old value for OldIdempotencyKeyHash: %w", err)
  25998. }
  25999. return oldValue.IdempotencyKeyHash, nil
  26000. }
  26001. // ResetIdempotencyKeyHash resets all changes to the "idempotency_key_hash" field.
  26002. func (m *IdempotencyRecordMutation) ResetIdempotencyKeyHash() {
  26003. m.idempotency_key_hash = nil
  26004. }
  26005. // SetRequestFingerprint sets the "request_fingerprint" field.
  26006. func (m *IdempotencyRecordMutation) SetRequestFingerprint(s string) {
  26007. m.request_fingerprint = &s
  26008. }
  26009. // RequestFingerprint returns the value of the "request_fingerprint" field in the mutation.
  26010. func (m *IdempotencyRecordMutation) RequestFingerprint() (r string, exists bool) {
  26011. v := m.request_fingerprint
  26012. if v == nil {
  26013. return
  26014. }
  26015. return *v, true
  26016. }
  26017. // OldRequestFingerprint returns the old "request_fingerprint" field's value of the IdempotencyRecord entity.
  26018. // If the IdempotencyRecord object wasn't provided to the builder, the object is fetched from the database.
  26019. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26020. func (m *IdempotencyRecordMutation) OldRequestFingerprint(ctx context.Context) (v string, err error) {
  26021. if !m.op.Is(OpUpdateOne) {
  26022. return v, errors.New("OldRequestFingerprint is only allowed on UpdateOne operations")
  26023. }
  26024. if m.id == nil || m.oldValue == nil {
  26025. return v, errors.New("OldRequestFingerprint requires an ID field in the mutation")
  26026. }
  26027. oldValue, err := m.oldValue(ctx)
  26028. if err != nil {
  26029. return v, fmt.Errorf("querying old value for OldRequestFingerprint: %w", err)
  26030. }
  26031. return oldValue.RequestFingerprint, nil
  26032. }
  26033. // ResetRequestFingerprint resets all changes to the "request_fingerprint" field.
  26034. func (m *IdempotencyRecordMutation) ResetRequestFingerprint() {
  26035. m.request_fingerprint = nil
  26036. }
  26037. // SetStatus sets the "status" field.
  26038. func (m *IdempotencyRecordMutation) SetStatus(s string) {
  26039. m.status = &s
  26040. }
  26041. // Status returns the value of the "status" field in the mutation.
  26042. func (m *IdempotencyRecordMutation) Status() (r string, exists bool) {
  26043. v := m.status
  26044. if v == nil {
  26045. return
  26046. }
  26047. return *v, true
  26048. }
  26049. // OldStatus returns the old "status" field's value of the IdempotencyRecord entity.
  26050. // If the IdempotencyRecord object wasn't provided to the builder, the object is fetched from the database.
  26051. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26052. func (m *IdempotencyRecordMutation) OldStatus(ctx context.Context) (v string, err error) {
  26053. if !m.op.Is(OpUpdateOne) {
  26054. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  26055. }
  26056. if m.id == nil || m.oldValue == nil {
  26057. return v, errors.New("OldStatus requires an ID field in the mutation")
  26058. }
  26059. oldValue, err := m.oldValue(ctx)
  26060. if err != nil {
  26061. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  26062. }
  26063. return oldValue.Status, nil
  26064. }
  26065. // ResetStatus resets all changes to the "status" field.
  26066. func (m *IdempotencyRecordMutation) ResetStatus() {
  26067. m.status = nil
  26068. }
  26069. // SetResponseStatus sets the "response_status" field.
  26070. func (m *IdempotencyRecordMutation) SetResponseStatus(i int) {
  26071. m.response_status = &i
  26072. m.addresponse_status = nil
  26073. }
  26074. // ResponseStatus returns the value of the "response_status" field in the mutation.
  26075. func (m *IdempotencyRecordMutation) ResponseStatus() (r int, exists bool) {
  26076. v := m.response_status
  26077. if v == nil {
  26078. return
  26079. }
  26080. return *v, true
  26081. }
  26082. // OldResponseStatus returns the old "response_status" field's value of the IdempotencyRecord entity.
  26083. // If the IdempotencyRecord object wasn't provided to the builder, the object is fetched from the database.
  26084. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26085. func (m *IdempotencyRecordMutation) OldResponseStatus(ctx context.Context) (v *int, err error) {
  26086. if !m.op.Is(OpUpdateOne) {
  26087. return v, errors.New("OldResponseStatus is only allowed on UpdateOne operations")
  26088. }
  26089. if m.id == nil || m.oldValue == nil {
  26090. return v, errors.New("OldResponseStatus requires an ID field in the mutation")
  26091. }
  26092. oldValue, err := m.oldValue(ctx)
  26093. if err != nil {
  26094. return v, fmt.Errorf("querying old value for OldResponseStatus: %w", err)
  26095. }
  26096. return oldValue.ResponseStatus, nil
  26097. }
  26098. // AddResponseStatus adds i to the "response_status" field.
  26099. func (m *IdempotencyRecordMutation) AddResponseStatus(i int) {
  26100. if m.addresponse_status != nil {
  26101. *m.addresponse_status += i
  26102. } else {
  26103. m.addresponse_status = &i
  26104. }
  26105. }
  26106. // AddedResponseStatus returns the value that was added to the "response_status" field in this mutation.
  26107. func (m *IdempotencyRecordMutation) AddedResponseStatus() (r int, exists bool) {
  26108. v := m.addresponse_status
  26109. if v == nil {
  26110. return
  26111. }
  26112. return *v, true
  26113. }
  26114. // ClearResponseStatus clears the value of the "response_status" field.
  26115. func (m *IdempotencyRecordMutation) ClearResponseStatus() {
  26116. m.response_status = nil
  26117. m.addresponse_status = nil
  26118. m.clearedFields[idempotencyrecord.FieldResponseStatus] = struct{}{}
  26119. }
  26120. // ResponseStatusCleared returns if the "response_status" field was cleared in this mutation.
  26121. func (m *IdempotencyRecordMutation) ResponseStatusCleared() bool {
  26122. _, ok := m.clearedFields[idempotencyrecord.FieldResponseStatus]
  26123. return ok
  26124. }
  26125. // ResetResponseStatus resets all changes to the "response_status" field.
  26126. func (m *IdempotencyRecordMutation) ResetResponseStatus() {
  26127. m.response_status = nil
  26128. m.addresponse_status = nil
  26129. delete(m.clearedFields, idempotencyrecord.FieldResponseStatus)
  26130. }
  26131. // SetResponseBody sets the "response_body" field.
  26132. func (m *IdempotencyRecordMutation) SetResponseBody(s string) {
  26133. m.response_body = &s
  26134. }
  26135. // ResponseBody returns the value of the "response_body" field in the mutation.
  26136. func (m *IdempotencyRecordMutation) ResponseBody() (r string, exists bool) {
  26137. v := m.response_body
  26138. if v == nil {
  26139. return
  26140. }
  26141. return *v, true
  26142. }
  26143. // OldResponseBody returns the old "response_body" field's value of the IdempotencyRecord entity.
  26144. // If the IdempotencyRecord object wasn't provided to the builder, the object is fetched from the database.
  26145. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26146. func (m *IdempotencyRecordMutation) OldResponseBody(ctx context.Context) (v *string, err error) {
  26147. if !m.op.Is(OpUpdateOne) {
  26148. return v, errors.New("OldResponseBody is only allowed on UpdateOne operations")
  26149. }
  26150. if m.id == nil || m.oldValue == nil {
  26151. return v, errors.New("OldResponseBody requires an ID field in the mutation")
  26152. }
  26153. oldValue, err := m.oldValue(ctx)
  26154. if err != nil {
  26155. return v, fmt.Errorf("querying old value for OldResponseBody: %w", err)
  26156. }
  26157. return oldValue.ResponseBody, nil
  26158. }
  26159. // ClearResponseBody clears the value of the "response_body" field.
  26160. func (m *IdempotencyRecordMutation) ClearResponseBody() {
  26161. m.response_body = nil
  26162. m.clearedFields[idempotencyrecord.FieldResponseBody] = struct{}{}
  26163. }
  26164. // ResponseBodyCleared returns if the "response_body" field was cleared in this mutation.
  26165. func (m *IdempotencyRecordMutation) ResponseBodyCleared() bool {
  26166. _, ok := m.clearedFields[idempotencyrecord.FieldResponseBody]
  26167. return ok
  26168. }
  26169. // ResetResponseBody resets all changes to the "response_body" field.
  26170. func (m *IdempotencyRecordMutation) ResetResponseBody() {
  26171. m.response_body = nil
  26172. delete(m.clearedFields, idempotencyrecord.FieldResponseBody)
  26173. }
  26174. // SetErrorReason sets the "error_reason" field.
  26175. func (m *IdempotencyRecordMutation) SetErrorReason(s string) {
  26176. m.error_reason = &s
  26177. }
  26178. // ErrorReason returns the value of the "error_reason" field in the mutation.
  26179. func (m *IdempotencyRecordMutation) ErrorReason() (r string, exists bool) {
  26180. v := m.error_reason
  26181. if v == nil {
  26182. return
  26183. }
  26184. return *v, true
  26185. }
  26186. // OldErrorReason returns the old "error_reason" field's value of the IdempotencyRecord entity.
  26187. // If the IdempotencyRecord object wasn't provided to the builder, the object is fetched from the database.
  26188. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26189. func (m *IdempotencyRecordMutation) OldErrorReason(ctx context.Context) (v *string, err error) {
  26190. if !m.op.Is(OpUpdateOne) {
  26191. return v, errors.New("OldErrorReason is only allowed on UpdateOne operations")
  26192. }
  26193. if m.id == nil || m.oldValue == nil {
  26194. return v, errors.New("OldErrorReason requires an ID field in the mutation")
  26195. }
  26196. oldValue, err := m.oldValue(ctx)
  26197. if err != nil {
  26198. return v, fmt.Errorf("querying old value for OldErrorReason: %w", err)
  26199. }
  26200. return oldValue.ErrorReason, nil
  26201. }
  26202. // ClearErrorReason clears the value of the "error_reason" field.
  26203. func (m *IdempotencyRecordMutation) ClearErrorReason() {
  26204. m.error_reason = nil
  26205. m.clearedFields[idempotencyrecord.FieldErrorReason] = struct{}{}
  26206. }
  26207. // ErrorReasonCleared returns if the "error_reason" field was cleared in this mutation.
  26208. func (m *IdempotencyRecordMutation) ErrorReasonCleared() bool {
  26209. _, ok := m.clearedFields[idempotencyrecord.FieldErrorReason]
  26210. return ok
  26211. }
  26212. // ResetErrorReason resets all changes to the "error_reason" field.
  26213. func (m *IdempotencyRecordMutation) ResetErrorReason() {
  26214. m.error_reason = nil
  26215. delete(m.clearedFields, idempotencyrecord.FieldErrorReason)
  26216. }
  26217. // SetLockedUntil sets the "locked_until" field.
  26218. func (m *IdempotencyRecordMutation) SetLockedUntil(t time.Time) {
  26219. m.locked_until = &t
  26220. }
  26221. // LockedUntil returns the value of the "locked_until" field in the mutation.
  26222. func (m *IdempotencyRecordMutation) LockedUntil() (r time.Time, exists bool) {
  26223. v := m.locked_until
  26224. if v == nil {
  26225. return
  26226. }
  26227. return *v, true
  26228. }
  26229. // OldLockedUntil returns the old "locked_until" field's value of the IdempotencyRecord entity.
  26230. // If the IdempotencyRecord object wasn't provided to the builder, the object is fetched from the database.
  26231. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26232. func (m *IdempotencyRecordMutation) OldLockedUntil(ctx context.Context) (v *time.Time, err error) {
  26233. if !m.op.Is(OpUpdateOne) {
  26234. return v, errors.New("OldLockedUntil is only allowed on UpdateOne operations")
  26235. }
  26236. if m.id == nil || m.oldValue == nil {
  26237. return v, errors.New("OldLockedUntil requires an ID field in the mutation")
  26238. }
  26239. oldValue, err := m.oldValue(ctx)
  26240. if err != nil {
  26241. return v, fmt.Errorf("querying old value for OldLockedUntil: %w", err)
  26242. }
  26243. return oldValue.LockedUntil, nil
  26244. }
  26245. // ClearLockedUntil clears the value of the "locked_until" field.
  26246. func (m *IdempotencyRecordMutation) ClearLockedUntil() {
  26247. m.locked_until = nil
  26248. m.clearedFields[idempotencyrecord.FieldLockedUntil] = struct{}{}
  26249. }
  26250. // LockedUntilCleared returns if the "locked_until" field was cleared in this mutation.
  26251. func (m *IdempotencyRecordMutation) LockedUntilCleared() bool {
  26252. _, ok := m.clearedFields[idempotencyrecord.FieldLockedUntil]
  26253. return ok
  26254. }
  26255. // ResetLockedUntil resets all changes to the "locked_until" field.
  26256. func (m *IdempotencyRecordMutation) ResetLockedUntil() {
  26257. m.locked_until = nil
  26258. delete(m.clearedFields, idempotencyrecord.FieldLockedUntil)
  26259. }
  26260. // SetExpiresAt sets the "expires_at" field.
  26261. func (m *IdempotencyRecordMutation) SetExpiresAt(t time.Time) {
  26262. m.expires_at = &t
  26263. }
  26264. // ExpiresAt returns the value of the "expires_at" field in the mutation.
  26265. func (m *IdempotencyRecordMutation) ExpiresAt() (r time.Time, exists bool) {
  26266. v := m.expires_at
  26267. if v == nil {
  26268. return
  26269. }
  26270. return *v, true
  26271. }
  26272. // OldExpiresAt returns the old "expires_at" field's value of the IdempotencyRecord entity.
  26273. // If the IdempotencyRecord object wasn't provided to the builder, the object is fetched from the database.
  26274. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26275. func (m *IdempotencyRecordMutation) OldExpiresAt(ctx context.Context) (v time.Time, err error) {
  26276. if !m.op.Is(OpUpdateOne) {
  26277. return v, errors.New("OldExpiresAt is only allowed on UpdateOne operations")
  26278. }
  26279. if m.id == nil || m.oldValue == nil {
  26280. return v, errors.New("OldExpiresAt requires an ID field in the mutation")
  26281. }
  26282. oldValue, err := m.oldValue(ctx)
  26283. if err != nil {
  26284. return v, fmt.Errorf("querying old value for OldExpiresAt: %w", err)
  26285. }
  26286. return oldValue.ExpiresAt, nil
  26287. }
  26288. // ResetExpiresAt resets all changes to the "expires_at" field.
  26289. func (m *IdempotencyRecordMutation) ResetExpiresAt() {
  26290. m.expires_at = nil
  26291. }
  26292. // Where appends a list predicates to the IdempotencyRecordMutation builder.
  26293. func (m *IdempotencyRecordMutation) Where(ps ...predicate.IdempotencyRecord) {
  26294. m.predicates = append(m.predicates, ps...)
  26295. }
  26296. // WhereP appends storage-level predicates to the IdempotencyRecordMutation builder. Using this method,
  26297. // users can use type-assertion to append predicates that do not depend on any generated package.
  26298. func (m *IdempotencyRecordMutation) WhereP(ps ...func(*sql.Selector)) {
  26299. p := make([]predicate.IdempotencyRecord, len(ps))
  26300. for i := range ps {
  26301. p[i] = ps[i]
  26302. }
  26303. m.Where(p...)
  26304. }
  26305. // Op returns the operation name.
  26306. func (m *IdempotencyRecordMutation) Op() Op {
  26307. return m.op
  26308. }
  26309. // SetOp allows setting the mutation operation.
  26310. func (m *IdempotencyRecordMutation) SetOp(op Op) {
  26311. m.op = op
  26312. }
  26313. // Type returns the node type of this mutation (IdempotencyRecord).
  26314. func (m *IdempotencyRecordMutation) Type() string {
  26315. return m.typ
  26316. }
  26317. // Fields returns all fields that were changed during this mutation. Note that in
  26318. // order to get all numeric fields that were incremented/decremented, call
  26319. // AddedFields().
  26320. func (m *IdempotencyRecordMutation) Fields() []string {
  26321. fields := make([]string, 0, 11)
  26322. if m.created_at != nil {
  26323. fields = append(fields, idempotencyrecord.FieldCreatedAt)
  26324. }
  26325. if m.updated_at != nil {
  26326. fields = append(fields, idempotencyrecord.FieldUpdatedAt)
  26327. }
  26328. if m.scope != nil {
  26329. fields = append(fields, idempotencyrecord.FieldScope)
  26330. }
  26331. if m.idempotency_key_hash != nil {
  26332. fields = append(fields, idempotencyrecord.FieldIdempotencyKeyHash)
  26333. }
  26334. if m.request_fingerprint != nil {
  26335. fields = append(fields, idempotencyrecord.FieldRequestFingerprint)
  26336. }
  26337. if m.status != nil {
  26338. fields = append(fields, idempotencyrecord.FieldStatus)
  26339. }
  26340. if m.response_status != nil {
  26341. fields = append(fields, idempotencyrecord.FieldResponseStatus)
  26342. }
  26343. if m.response_body != nil {
  26344. fields = append(fields, idempotencyrecord.FieldResponseBody)
  26345. }
  26346. if m.error_reason != nil {
  26347. fields = append(fields, idempotencyrecord.FieldErrorReason)
  26348. }
  26349. if m.locked_until != nil {
  26350. fields = append(fields, idempotencyrecord.FieldLockedUntil)
  26351. }
  26352. if m.expires_at != nil {
  26353. fields = append(fields, idempotencyrecord.FieldExpiresAt)
  26354. }
  26355. return fields
  26356. }
  26357. // Field returns the value of a field with the given name. The second boolean
  26358. // return value indicates that this field was not set, or was not defined in the
  26359. // schema.
  26360. func (m *IdempotencyRecordMutation) Field(name string) (ent.Value, bool) {
  26361. switch name {
  26362. case idempotencyrecord.FieldCreatedAt:
  26363. return m.CreatedAt()
  26364. case idempotencyrecord.FieldUpdatedAt:
  26365. return m.UpdatedAt()
  26366. case idempotencyrecord.FieldScope:
  26367. return m.Scope()
  26368. case idempotencyrecord.FieldIdempotencyKeyHash:
  26369. return m.IdempotencyKeyHash()
  26370. case idempotencyrecord.FieldRequestFingerprint:
  26371. return m.RequestFingerprint()
  26372. case idempotencyrecord.FieldStatus:
  26373. return m.Status()
  26374. case idempotencyrecord.FieldResponseStatus:
  26375. return m.ResponseStatus()
  26376. case idempotencyrecord.FieldResponseBody:
  26377. return m.ResponseBody()
  26378. case idempotencyrecord.FieldErrorReason:
  26379. return m.ErrorReason()
  26380. case idempotencyrecord.FieldLockedUntil:
  26381. return m.LockedUntil()
  26382. case idempotencyrecord.FieldExpiresAt:
  26383. return m.ExpiresAt()
  26384. }
  26385. return nil, false
  26386. }
  26387. // OldField returns the old value of the field from the database. An error is
  26388. // returned if the mutation operation is not UpdateOne, or the query to the
  26389. // database failed.
  26390. func (m *IdempotencyRecordMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  26391. switch name {
  26392. case idempotencyrecord.FieldCreatedAt:
  26393. return m.OldCreatedAt(ctx)
  26394. case idempotencyrecord.FieldUpdatedAt:
  26395. return m.OldUpdatedAt(ctx)
  26396. case idempotencyrecord.FieldScope:
  26397. return m.OldScope(ctx)
  26398. case idempotencyrecord.FieldIdempotencyKeyHash:
  26399. return m.OldIdempotencyKeyHash(ctx)
  26400. case idempotencyrecord.FieldRequestFingerprint:
  26401. return m.OldRequestFingerprint(ctx)
  26402. case idempotencyrecord.FieldStatus:
  26403. return m.OldStatus(ctx)
  26404. case idempotencyrecord.FieldResponseStatus:
  26405. return m.OldResponseStatus(ctx)
  26406. case idempotencyrecord.FieldResponseBody:
  26407. return m.OldResponseBody(ctx)
  26408. case idempotencyrecord.FieldErrorReason:
  26409. return m.OldErrorReason(ctx)
  26410. case idempotencyrecord.FieldLockedUntil:
  26411. return m.OldLockedUntil(ctx)
  26412. case idempotencyrecord.FieldExpiresAt:
  26413. return m.OldExpiresAt(ctx)
  26414. }
  26415. return nil, fmt.Errorf("unknown IdempotencyRecord field %s", name)
  26416. }
  26417. // SetField sets the value of a field with the given name. It returns an error if
  26418. // the field is not defined in the schema, or if the type mismatched the field
  26419. // type.
  26420. func (m *IdempotencyRecordMutation) SetField(name string, value ent.Value) error {
  26421. switch name {
  26422. case idempotencyrecord.FieldCreatedAt:
  26423. v, ok := value.(time.Time)
  26424. if !ok {
  26425. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26426. }
  26427. m.SetCreatedAt(v)
  26428. return nil
  26429. case idempotencyrecord.FieldUpdatedAt:
  26430. v, ok := value.(time.Time)
  26431. if !ok {
  26432. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26433. }
  26434. m.SetUpdatedAt(v)
  26435. return nil
  26436. case idempotencyrecord.FieldScope:
  26437. v, ok := value.(string)
  26438. if !ok {
  26439. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26440. }
  26441. m.SetScope(v)
  26442. return nil
  26443. case idempotencyrecord.FieldIdempotencyKeyHash:
  26444. v, ok := value.(string)
  26445. if !ok {
  26446. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26447. }
  26448. m.SetIdempotencyKeyHash(v)
  26449. return nil
  26450. case idempotencyrecord.FieldRequestFingerprint:
  26451. v, ok := value.(string)
  26452. if !ok {
  26453. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26454. }
  26455. m.SetRequestFingerprint(v)
  26456. return nil
  26457. case idempotencyrecord.FieldStatus:
  26458. v, ok := value.(string)
  26459. if !ok {
  26460. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26461. }
  26462. m.SetStatus(v)
  26463. return nil
  26464. case idempotencyrecord.FieldResponseStatus:
  26465. v, ok := value.(int)
  26466. if !ok {
  26467. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26468. }
  26469. m.SetResponseStatus(v)
  26470. return nil
  26471. case idempotencyrecord.FieldResponseBody:
  26472. v, ok := value.(string)
  26473. if !ok {
  26474. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26475. }
  26476. m.SetResponseBody(v)
  26477. return nil
  26478. case idempotencyrecord.FieldErrorReason:
  26479. v, ok := value.(string)
  26480. if !ok {
  26481. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26482. }
  26483. m.SetErrorReason(v)
  26484. return nil
  26485. case idempotencyrecord.FieldLockedUntil:
  26486. v, ok := value.(time.Time)
  26487. if !ok {
  26488. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26489. }
  26490. m.SetLockedUntil(v)
  26491. return nil
  26492. case idempotencyrecord.FieldExpiresAt:
  26493. v, ok := value.(time.Time)
  26494. if !ok {
  26495. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26496. }
  26497. m.SetExpiresAt(v)
  26498. return nil
  26499. }
  26500. return fmt.Errorf("unknown IdempotencyRecord field %s", name)
  26501. }
  26502. // AddedFields returns all numeric fields that were incremented/decremented during
  26503. // this mutation.
  26504. func (m *IdempotencyRecordMutation) AddedFields() []string {
  26505. var fields []string
  26506. if m.addresponse_status != nil {
  26507. fields = append(fields, idempotencyrecord.FieldResponseStatus)
  26508. }
  26509. return fields
  26510. }
  26511. // AddedField returns the numeric value that was incremented/decremented on a field
  26512. // with the given name. The second boolean return value indicates that this field
  26513. // was not set, or was not defined in the schema.
  26514. func (m *IdempotencyRecordMutation) AddedField(name string) (ent.Value, bool) {
  26515. switch name {
  26516. case idempotencyrecord.FieldResponseStatus:
  26517. return m.AddedResponseStatus()
  26518. }
  26519. return nil, false
  26520. }
  26521. // AddField adds the value to the field with the given name. It returns an error if
  26522. // the field is not defined in the schema, or if the type mismatched the field
  26523. // type.
  26524. func (m *IdempotencyRecordMutation) AddField(name string, value ent.Value) error {
  26525. switch name {
  26526. case idempotencyrecord.FieldResponseStatus:
  26527. v, ok := value.(int)
  26528. if !ok {
  26529. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26530. }
  26531. m.AddResponseStatus(v)
  26532. return nil
  26533. }
  26534. return fmt.Errorf("unknown IdempotencyRecord numeric field %s", name)
  26535. }
  26536. // ClearedFields returns all nullable fields that were cleared during this
  26537. // mutation.
  26538. func (m *IdempotencyRecordMutation) ClearedFields() []string {
  26539. var fields []string
  26540. if m.FieldCleared(idempotencyrecord.FieldResponseStatus) {
  26541. fields = append(fields, idempotencyrecord.FieldResponseStatus)
  26542. }
  26543. if m.FieldCleared(idempotencyrecord.FieldResponseBody) {
  26544. fields = append(fields, idempotencyrecord.FieldResponseBody)
  26545. }
  26546. if m.FieldCleared(idempotencyrecord.FieldErrorReason) {
  26547. fields = append(fields, idempotencyrecord.FieldErrorReason)
  26548. }
  26549. if m.FieldCleared(idempotencyrecord.FieldLockedUntil) {
  26550. fields = append(fields, idempotencyrecord.FieldLockedUntil)
  26551. }
  26552. return fields
  26553. }
  26554. // FieldCleared returns a boolean indicating if a field with the given name was
  26555. // cleared in this mutation.
  26556. func (m *IdempotencyRecordMutation) FieldCleared(name string) bool {
  26557. _, ok := m.clearedFields[name]
  26558. return ok
  26559. }
  26560. // ClearField clears the value of the field with the given name. It returns an
  26561. // error if the field is not defined in the schema.
  26562. func (m *IdempotencyRecordMutation) ClearField(name string) error {
  26563. switch name {
  26564. case idempotencyrecord.FieldResponseStatus:
  26565. m.ClearResponseStatus()
  26566. return nil
  26567. case idempotencyrecord.FieldResponseBody:
  26568. m.ClearResponseBody()
  26569. return nil
  26570. case idempotencyrecord.FieldErrorReason:
  26571. m.ClearErrorReason()
  26572. return nil
  26573. case idempotencyrecord.FieldLockedUntil:
  26574. m.ClearLockedUntil()
  26575. return nil
  26576. }
  26577. return fmt.Errorf("unknown IdempotencyRecord nullable field %s", name)
  26578. }
  26579. // ResetField resets all changes in the mutation for the field with the given name.
  26580. // It returns an error if the field is not defined in the schema.
  26581. func (m *IdempotencyRecordMutation) ResetField(name string) error {
  26582. switch name {
  26583. case idempotencyrecord.FieldCreatedAt:
  26584. m.ResetCreatedAt()
  26585. return nil
  26586. case idempotencyrecord.FieldUpdatedAt:
  26587. m.ResetUpdatedAt()
  26588. return nil
  26589. case idempotencyrecord.FieldScope:
  26590. m.ResetScope()
  26591. return nil
  26592. case idempotencyrecord.FieldIdempotencyKeyHash:
  26593. m.ResetIdempotencyKeyHash()
  26594. return nil
  26595. case idempotencyrecord.FieldRequestFingerprint:
  26596. m.ResetRequestFingerprint()
  26597. return nil
  26598. case idempotencyrecord.FieldStatus:
  26599. m.ResetStatus()
  26600. return nil
  26601. case idempotencyrecord.FieldResponseStatus:
  26602. m.ResetResponseStatus()
  26603. return nil
  26604. case idempotencyrecord.FieldResponseBody:
  26605. m.ResetResponseBody()
  26606. return nil
  26607. case idempotencyrecord.FieldErrorReason:
  26608. m.ResetErrorReason()
  26609. return nil
  26610. case idempotencyrecord.FieldLockedUntil:
  26611. m.ResetLockedUntil()
  26612. return nil
  26613. case idempotencyrecord.FieldExpiresAt:
  26614. m.ResetExpiresAt()
  26615. return nil
  26616. }
  26617. return fmt.Errorf("unknown IdempotencyRecord field %s", name)
  26618. }
  26619. // AddedEdges returns all edge names that were set/added in this mutation.
  26620. func (m *IdempotencyRecordMutation) AddedEdges() []string {
  26621. edges := make([]string, 0, 0)
  26622. return edges
  26623. }
  26624. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  26625. // name in this mutation.
  26626. func (m *IdempotencyRecordMutation) AddedIDs(name string) []ent.Value {
  26627. return nil
  26628. }
  26629. // RemovedEdges returns all edge names that were removed in this mutation.
  26630. func (m *IdempotencyRecordMutation) RemovedEdges() []string {
  26631. edges := make([]string, 0, 0)
  26632. return edges
  26633. }
  26634. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  26635. // the given name in this mutation.
  26636. func (m *IdempotencyRecordMutation) RemovedIDs(name string) []ent.Value {
  26637. return nil
  26638. }
  26639. // ClearedEdges returns all edge names that were cleared in this mutation.
  26640. func (m *IdempotencyRecordMutation) ClearedEdges() []string {
  26641. edges := make([]string, 0, 0)
  26642. return edges
  26643. }
  26644. // EdgeCleared returns a boolean which indicates if the edge with the given name
  26645. // was cleared in this mutation.
  26646. func (m *IdempotencyRecordMutation) EdgeCleared(name string) bool {
  26647. return false
  26648. }
  26649. // ClearEdge clears the value of the edge with the given name. It returns an error
  26650. // if that edge is not defined in the schema.
  26651. func (m *IdempotencyRecordMutation) ClearEdge(name string) error {
  26652. return fmt.Errorf("unknown IdempotencyRecord unique edge %s", name)
  26653. }
  26654. // ResetEdge resets all changes to the edge with the given name in this mutation.
  26655. // It returns an error if the edge is not defined in the schema.
  26656. func (m *IdempotencyRecordMutation) ResetEdge(name string) error {
  26657. return fmt.Errorf("unknown IdempotencyRecord edge %s", name)
  26658. }
  26659. // IdentityAdoptionDecisionMutation represents an operation that mutates the IdentityAdoptionDecision nodes in the graph.
  26660. type IdentityAdoptionDecisionMutation struct {
  26661. config
  26662. op Op
  26663. typ string
  26664. id *int64
  26665. created_at *time.Time
  26666. updated_at *time.Time
  26667. adopt_display_name *bool
  26668. adopt_avatar *bool
  26669. decided_at *time.Time
  26670. clearedFields map[string]struct{}
  26671. pending_auth_session *int64
  26672. clearedpending_auth_session bool
  26673. identity *int64
  26674. clearedidentity bool
  26675. done bool
  26676. oldValue func(context.Context) (*IdentityAdoptionDecision, error)
  26677. predicates []predicate.IdentityAdoptionDecision
  26678. }
  26679. var _ ent.Mutation = (*IdentityAdoptionDecisionMutation)(nil)
  26680. // identityadoptiondecisionOption allows management of the mutation configuration using functional options.
  26681. type identityadoptiondecisionOption func(*IdentityAdoptionDecisionMutation)
  26682. // newIdentityAdoptionDecisionMutation creates new mutation for the IdentityAdoptionDecision entity.
  26683. func newIdentityAdoptionDecisionMutation(c config, op Op, opts ...identityadoptiondecisionOption) *IdentityAdoptionDecisionMutation {
  26684. m := &IdentityAdoptionDecisionMutation{
  26685. config: c,
  26686. op: op,
  26687. typ: TypeIdentityAdoptionDecision,
  26688. clearedFields: make(map[string]struct{}),
  26689. }
  26690. for _, opt := range opts {
  26691. opt(m)
  26692. }
  26693. return m
  26694. }
  26695. // withIdentityAdoptionDecisionID sets the ID field of the mutation.
  26696. func withIdentityAdoptionDecisionID(id int64) identityadoptiondecisionOption {
  26697. return func(m *IdentityAdoptionDecisionMutation) {
  26698. var (
  26699. err error
  26700. once sync.Once
  26701. value *IdentityAdoptionDecision
  26702. )
  26703. m.oldValue = func(ctx context.Context) (*IdentityAdoptionDecision, error) {
  26704. once.Do(func() {
  26705. if m.done {
  26706. err = errors.New("querying old values post mutation is not allowed")
  26707. } else {
  26708. value, err = m.Client().IdentityAdoptionDecision.Get(ctx, id)
  26709. }
  26710. })
  26711. return value, err
  26712. }
  26713. m.id = &id
  26714. }
  26715. }
  26716. // withIdentityAdoptionDecision sets the old IdentityAdoptionDecision of the mutation.
  26717. func withIdentityAdoptionDecision(node *IdentityAdoptionDecision) identityadoptiondecisionOption {
  26718. return func(m *IdentityAdoptionDecisionMutation) {
  26719. m.oldValue = func(context.Context) (*IdentityAdoptionDecision, error) {
  26720. return node, nil
  26721. }
  26722. m.id = &node.ID
  26723. }
  26724. }
  26725. // Client returns a new `ent.Client` from the mutation. If the mutation was
  26726. // executed in a transaction (ent.Tx), a transactional client is returned.
  26727. func (m IdentityAdoptionDecisionMutation) Client() *Client {
  26728. client := &Client{config: m.config}
  26729. client.init()
  26730. return client
  26731. }
  26732. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  26733. // it returns an error otherwise.
  26734. func (m IdentityAdoptionDecisionMutation) Tx() (*Tx, error) {
  26735. if _, ok := m.driver.(*txDriver); !ok {
  26736. return nil, errors.New("ent: mutation is not running in a transaction")
  26737. }
  26738. tx := &Tx{config: m.config}
  26739. tx.init()
  26740. return tx, nil
  26741. }
  26742. // ID returns the ID value in the mutation. Note that the ID is only available
  26743. // if it was provided to the builder or after it was returned from the database.
  26744. func (m *IdentityAdoptionDecisionMutation) ID() (id int64, exists bool) {
  26745. if m.id == nil {
  26746. return
  26747. }
  26748. return *m.id, true
  26749. }
  26750. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  26751. // That means, if the mutation is applied within a transaction with an isolation level such
  26752. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  26753. // or updated by the mutation.
  26754. func (m *IdentityAdoptionDecisionMutation) IDs(ctx context.Context) ([]int64, error) {
  26755. switch {
  26756. case m.op.Is(OpUpdateOne | OpDeleteOne):
  26757. id, exists := m.ID()
  26758. if exists {
  26759. return []int64{id}, nil
  26760. }
  26761. fallthrough
  26762. case m.op.Is(OpUpdate | OpDelete):
  26763. return m.Client().IdentityAdoptionDecision.Query().Where(m.predicates...).IDs(ctx)
  26764. default:
  26765. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  26766. }
  26767. }
  26768. // SetCreatedAt sets the "created_at" field.
  26769. func (m *IdentityAdoptionDecisionMutation) SetCreatedAt(t time.Time) {
  26770. m.created_at = &t
  26771. }
  26772. // CreatedAt returns the value of the "created_at" field in the mutation.
  26773. func (m *IdentityAdoptionDecisionMutation) CreatedAt() (r time.Time, exists bool) {
  26774. v := m.created_at
  26775. if v == nil {
  26776. return
  26777. }
  26778. return *v, true
  26779. }
  26780. // OldCreatedAt returns the old "created_at" field's value of the IdentityAdoptionDecision entity.
  26781. // If the IdentityAdoptionDecision object wasn't provided to the builder, the object is fetched from the database.
  26782. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26783. func (m *IdentityAdoptionDecisionMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  26784. if !m.op.Is(OpUpdateOne) {
  26785. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  26786. }
  26787. if m.id == nil || m.oldValue == nil {
  26788. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  26789. }
  26790. oldValue, err := m.oldValue(ctx)
  26791. if err != nil {
  26792. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  26793. }
  26794. return oldValue.CreatedAt, nil
  26795. }
  26796. // ResetCreatedAt resets all changes to the "created_at" field.
  26797. func (m *IdentityAdoptionDecisionMutation) ResetCreatedAt() {
  26798. m.created_at = nil
  26799. }
  26800. // SetUpdatedAt sets the "updated_at" field.
  26801. func (m *IdentityAdoptionDecisionMutation) SetUpdatedAt(t time.Time) {
  26802. m.updated_at = &t
  26803. }
  26804. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  26805. func (m *IdentityAdoptionDecisionMutation) UpdatedAt() (r time.Time, exists bool) {
  26806. v := m.updated_at
  26807. if v == nil {
  26808. return
  26809. }
  26810. return *v, true
  26811. }
  26812. // OldUpdatedAt returns the old "updated_at" field's value of the IdentityAdoptionDecision entity.
  26813. // If the IdentityAdoptionDecision object wasn't provided to the builder, the object is fetched from the database.
  26814. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26815. func (m *IdentityAdoptionDecisionMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  26816. if !m.op.Is(OpUpdateOne) {
  26817. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  26818. }
  26819. if m.id == nil || m.oldValue == nil {
  26820. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  26821. }
  26822. oldValue, err := m.oldValue(ctx)
  26823. if err != nil {
  26824. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  26825. }
  26826. return oldValue.UpdatedAt, nil
  26827. }
  26828. // ResetUpdatedAt resets all changes to the "updated_at" field.
  26829. func (m *IdentityAdoptionDecisionMutation) ResetUpdatedAt() {
  26830. m.updated_at = nil
  26831. }
  26832. // SetPendingAuthSessionID sets the "pending_auth_session_id" field.
  26833. func (m *IdentityAdoptionDecisionMutation) SetPendingAuthSessionID(i int64) {
  26834. m.pending_auth_session = &i
  26835. }
  26836. // PendingAuthSessionID returns the value of the "pending_auth_session_id" field in the mutation.
  26837. func (m *IdentityAdoptionDecisionMutation) PendingAuthSessionID() (r int64, exists bool) {
  26838. v := m.pending_auth_session
  26839. if v == nil {
  26840. return
  26841. }
  26842. return *v, true
  26843. }
  26844. // OldPendingAuthSessionID returns the old "pending_auth_session_id" field's value of the IdentityAdoptionDecision entity.
  26845. // If the IdentityAdoptionDecision object wasn't provided to the builder, the object is fetched from the database.
  26846. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26847. func (m *IdentityAdoptionDecisionMutation) OldPendingAuthSessionID(ctx context.Context) (v int64, err error) {
  26848. if !m.op.Is(OpUpdateOne) {
  26849. return v, errors.New("OldPendingAuthSessionID is only allowed on UpdateOne operations")
  26850. }
  26851. if m.id == nil || m.oldValue == nil {
  26852. return v, errors.New("OldPendingAuthSessionID requires an ID field in the mutation")
  26853. }
  26854. oldValue, err := m.oldValue(ctx)
  26855. if err != nil {
  26856. return v, fmt.Errorf("querying old value for OldPendingAuthSessionID: %w", err)
  26857. }
  26858. return oldValue.PendingAuthSessionID, nil
  26859. }
  26860. // ResetPendingAuthSessionID resets all changes to the "pending_auth_session_id" field.
  26861. func (m *IdentityAdoptionDecisionMutation) ResetPendingAuthSessionID() {
  26862. m.pending_auth_session = nil
  26863. }
  26864. // SetIdentityID sets the "identity_id" field.
  26865. func (m *IdentityAdoptionDecisionMutation) SetIdentityID(i int64) {
  26866. m.identity = &i
  26867. }
  26868. // IdentityID returns the value of the "identity_id" field in the mutation.
  26869. func (m *IdentityAdoptionDecisionMutation) IdentityID() (r int64, exists bool) {
  26870. v := m.identity
  26871. if v == nil {
  26872. return
  26873. }
  26874. return *v, true
  26875. }
  26876. // OldIdentityID returns the old "identity_id" field's value of the IdentityAdoptionDecision entity.
  26877. // If the IdentityAdoptionDecision object wasn't provided to the builder, the object is fetched from the database.
  26878. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26879. func (m *IdentityAdoptionDecisionMutation) OldIdentityID(ctx context.Context) (v *int64, err error) {
  26880. if !m.op.Is(OpUpdateOne) {
  26881. return v, errors.New("OldIdentityID is only allowed on UpdateOne operations")
  26882. }
  26883. if m.id == nil || m.oldValue == nil {
  26884. return v, errors.New("OldIdentityID requires an ID field in the mutation")
  26885. }
  26886. oldValue, err := m.oldValue(ctx)
  26887. if err != nil {
  26888. return v, fmt.Errorf("querying old value for OldIdentityID: %w", err)
  26889. }
  26890. return oldValue.IdentityID, nil
  26891. }
  26892. // ClearIdentityID clears the value of the "identity_id" field.
  26893. func (m *IdentityAdoptionDecisionMutation) ClearIdentityID() {
  26894. m.identity = nil
  26895. m.clearedFields[identityadoptiondecision.FieldIdentityID] = struct{}{}
  26896. }
  26897. // IdentityIDCleared returns if the "identity_id" field was cleared in this mutation.
  26898. func (m *IdentityAdoptionDecisionMutation) IdentityIDCleared() bool {
  26899. _, ok := m.clearedFields[identityadoptiondecision.FieldIdentityID]
  26900. return ok
  26901. }
  26902. // ResetIdentityID resets all changes to the "identity_id" field.
  26903. func (m *IdentityAdoptionDecisionMutation) ResetIdentityID() {
  26904. m.identity = nil
  26905. delete(m.clearedFields, identityadoptiondecision.FieldIdentityID)
  26906. }
  26907. // SetAdoptDisplayName sets the "adopt_display_name" field.
  26908. func (m *IdentityAdoptionDecisionMutation) SetAdoptDisplayName(b bool) {
  26909. m.adopt_display_name = &b
  26910. }
  26911. // AdoptDisplayName returns the value of the "adopt_display_name" field in the mutation.
  26912. func (m *IdentityAdoptionDecisionMutation) AdoptDisplayName() (r bool, exists bool) {
  26913. v := m.adopt_display_name
  26914. if v == nil {
  26915. return
  26916. }
  26917. return *v, true
  26918. }
  26919. // OldAdoptDisplayName returns the old "adopt_display_name" field's value of the IdentityAdoptionDecision entity.
  26920. // If the IdentityAdoptionDecision object wasn't provided to the builder, the object is fetched from the database.
  26921. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26922. func (m *IdentityAdoptionDecisionMutation) OldAdoptDisplayName(ctx context.Context) (v bool, err error) {
  26923. if !m.op.Is(OpUpdateOne) {
  26924. return v, errors.New("OldAdoptDisplayName is only allowed on UpdateOne operations")
  26925. }
  26926. if m.id == nil || m.oldValue == nil {
  26927. return v, errors.New("OldAdoptDisplayName requires an ID field in the mutation")
  26928. }
  26929. oldValue, err := m.oldValue(ctx)
  26930. if err != nil {
  26931. return v, fmt.Errorf("querying old value for OldAdoptDisplayName: %w", err)
  26932. }
  26933. return oldValue.AdoptDisplayName, nil
  26934. }
  26935. // ResetAdoptDisplayName resets all changes to the "adopt_display_name" field.
  26936. func (m *IdentityAdoptionDecisionMutation) ResetAdoptDisplayName() {
  26937. m.adopt_display_name = nil
  26938. }
  26939. // SetAdoptAvatar sets the "adopt_avatar" field.
  26940. func (m *IdentityAdoptionDecisionMutation) SetAdoptAvatar(b bool) {
  26941. m.adopt_avatar = &b
  26942. }
  26943. // AdoptAvatar returns the value of the "adopt_avatar" field in the mutation.
  26944. func (m *IdentityAdoptionDecisionMutation) AdoptAvatar() (r bool, exists bool) {
  26945. v := m.adopt_avatar
  26946. if v == nil {
  26947. return
  26948. }
  26949. return *v, true
  26950. }
  26951. // OldAdoptAvatar returns the old "adopt_avatar" field's value of the IdentityAdoptionDecision entity.
  26952. // If the IdentityAdoptionDecision object wasn't provided to the builder, the object is fetched from the database.
  26953. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26954. func (m *IdentityAdoptionDecisionMutation) OldAdoptAvatar(ctx context.Context) (v bool, err error) {
  26955. if !m.op.Is(OpUpdateOne) {
  26956. return v, errors.New("OldAdoptAvatar is only allowed on UpdateOne operations")
  26957. }
  26958. if m.id == nil || m.oldValue == nil {
  26959. return v, errors.New("OldAdoptAvatar requires an ID field in the mutation")
  26960. }
  26961. oldValue, err := m.oldValue(ctx)
  26962. if err != nil {
  26963. return v, fmt.Errorf("querying old value for OldAdoptAvatar: %w", err)
  26964. }
  26965. return oldValue.AdoptAvatar, nil
  26966. }
  26967. // ResetAdoptAvatar resets all changes to the "adopt_avatar" field.
  26968. func (m *IdentityAdoptionDecisionMutation) ResetAdoptAvatar() {
  26969. m.adopt_avatar = nil
  26970. }
  26971. // SetDecidedAt sets the "decided_at" field.
  26972. func (m *IdentityAdoptionDecisionMutation) SetDecidedAt(t time.Time) {
  26973. m.decided_at = &t
  26974. }
  26975. // DecidedAt returns the value of the "decided_at" field in the mutation.
  26976. func (m *IdentityAdoptionDecisionMutation) DecidedAt() (r time.Time, exists bool) {
  26977. v := m.decided_at
  26978. if v == nil {
  26979. return
  26980. }
  26981. return *v, true
  26982. }
  26983. // OldDecidedAt returns the old "decided_at" field's value of the IdentityAdoptionDecision entity.
  26984. // If the IdentityAdoptionDecision object wasn't provided to the builder, the object is fetched from the database.
  26985. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26986. func (m *IdentityAdoptionDecisionMutation) OldDecidedAt(ctx context.Context) (v time.Time, err error) {
  26987. if !m.op.Is(OpUpdateOne) {
  26988. return v, errors.New("OldDecidedAt is only allowed on UpdateOne operations")
  26989. }
  26990. if m.id == nil || m.oldValue == nil {
  26991. return v, errors.New("OldDecidedAt requires an ID field in the mutation")
  26992. }
  26993. oldValue, err := m.oldValue(ctx)
  26994. if err != nil {
  26995. return v, fmt.Errorf("querying old value for OldDecidedAt: %w", err)
  26996. }
  26997. return oldValue.DecidedAt, nil
  26998. }
  26999. // ResetDecidedAt resets all changes to the "decided_at" field.
  27000. func (m *IdentityAdoptionDecisionMutation) ResetDecidedAt() {
  27001. m.decided_at = nil
  27002. }
  27003. // ClearPendingAuthSession clears the "pending_auth_session" edge to the PendingAuthSession entity.
  27004. func (m *IdentityAdoptionDecisionMutation) ClearPendingAuthSession() {
  27005. m.clearedpending_auth_session = true
  27006. m.clearedFields[identityadoptiondecision.FieldPendingAuthSessionID] = struct{}{}
  27007. }
  27008. // PendingAuthSessionCleared reports if the "pending_auth_session" edge to the PendingAuthSession entity was cleared.
  27009. func (m *IdentityAdoptionDecisionMutation) PendingAuthSessionCleared() bool {
  27010. return m.clearedpending_auth_session
  27011. }
  27012. // PendingAuthSessionIDs returns the "pending_auth_session" edge IDs in the mutation.
  27013. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  27014. // PendingAuthSessionID instead. It exists only for internal usage by the builders.
  27015. func (m *IdentityAdoptionDecisionMutation) PendingAuthSessionIDs() (ids []int64) {
  27016. if id := m.pending_auth_session; id != nil {
  27017. ids = append(ids, *id)
  27018. }
  27019. return
  27020. }
  27021. // ResetPendingAuthSession resets all changes to the "pending_auth_session" edge.
  27022. func (m *IdentityAdoptionDecisionMutation) ResetPendingAuthSession() {
  27023. m.pending_auth_session = nil
  27024. m.clearedpending_auth_session = false
  27025. }
  27026. // ClearIdentity clears the "identity" edge to the AuthIdentity entity.
  27027. func (m *IdentityAdoptionDecisionMutation) ClearIdentity() {
  27028. m.clearedidentity = true
  27029. m.clearedFields[identityadoptiondecision.FieldIdentityID] = struct{}{}
  27030. }
  27031. // IdentityCleared reports if the "identity" edge to the AuthIdentity entity was cleared.
  27032. func (m *IdentityAdoptionDecisionMutation) IdentityCleared() bool {
  27033. return m.IdentityIDCleared() || m.clearedidentity
  27034. }
  27035. // IdentityIDs returns the "identity" edge IDs in the mutation.
  27036. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  27037. // IdentityID instead. It exists only for internal usage by the builders.
  27038. func (m *IdentityAdoptionDecisionMutation) IdentityIDs() (ids []int64) {
  27039. if id := m.identity; id != nil {
  27040. ids = append(ids, *id)
  27041. }
  27042. return
  27043. }
  27044. // ResetIdentity resets all changes to the "identity" edge.
  27045. func (m *IdentityAdoptionDecisionMutation) ResetIdentity() {
  27046. m.identity = nil
  27047. m.clearedidentity = false
  27048. }
  27049. // Where appends a list predicates to the IdentityAdoptionDecisionMutation builder.
  27050. func (m *IdentityAdoptionDecisionMutation) Where(ps ...predicate.IdentityAdoptionDecision) {
  27051. m.predicates = append(m.predicates, ps...)
  27052. }
  27053. // WhereP appends storage-level predicates to the IdentityAdoptionDecisionMutation builder. Using this method,
  27054. // users can use type-assertion to append predicates that do not depend on any generated package.
  27055. func (m *IdentityAdoptionDecisionMutation) WhereP(ps ...func(*sql.Selector)) {
  27056. p := make([]predicate.IdentityAdoptionDecision, len(ps))
  27057. for i := range ps {
  27058. p[i] = ps[i]
  27059. }
  27060. m.Where(p...)
  27061. }
  27062. // Op returns the operation name.
  27063. func (m *IdentityAdoptionDecisionMutation) Op() Op {
  27064. return m.op
  27065. }
  27066. // SetOp allows setting the mutation operation.
  27067. func (m *IdentityAdoptionDecisionMutation) SetOp(op Op) {
  27068. m.op = op
  27069. }
  27070. // Type returns the node type of this mutation (IdentityAdoptionDecision).
  27071. func (m *IdentityAdoptionDecisionMutation) Type() string {
  27072. return m.typ
  27073. }
  27074. // Fields returns all fields that were changed during this mutation. Note that in
  27075. // order to get all numeric fields that were incremented/decremented, call
  27076. // AddedFields().
  27077. func (m *IdentityAdoptionDecisionMutation) Fields() []string {
  27078. fields := make([]string, 0, 7)
  27079. if m.created_at != nil {
  27080. fields = append(fields, identityadoptiondecision.FieldCreatedAt)
  27081. }
  27082. if m.updated_at != nil {
  27083. fields = append(fields, identityadoptiondecision.FieldUpdatedAt)
  27084. }
  27085. if m.pending_auth_session != nil {
  27086. fields = append(fields, identityadoptiondecision.FieldPendingAuthSessionID)
  27087. }
  27088. if m.identity != nil {
  27089. fields = append(fields, identityadoptiondecision.FieldIdentityID)
  27090. }
  27091. if m.adopt_display_name != nil {
  27092. fields = append(fields, identityadoptiondecision.FieldAdoptDisplayName)
  27093. }
  27094. if m.adopt_avatar != nil {
  27095. fields = append(fields, identityadoptiondecision.FieldAdoptAvatar)
  27096. }
  27097. if m.decided_at != nil {
  27098. fields = append(fields, identityadoptiondecision.FieldDecidedAt)
  27099. }
  27100. return fields
  27101. }
  27102. // Field returns the value of a field with the given name. The second boolean
  27103. // return value indicates that this field was not set, or was not defined in the
  27104. // schema.
  27105. func (m *IdentityAdoptionDecisionMutation) Field(name string) (ent.Value, bool) {
  27106. switch name {
  27107. case identityadoptiondecision.FieldCreatedAt:
  27108. return m.CreatedAt()
  27109. case identityadoptiondecision.FieldUpdatedAt:
  27110. return m.UpdatedAt()
  27111. case identityadoptiondecision.FieldPendingAuthSessionID:
  27112. return m.PendingAuthSessionID()
  27113. case identityadoptiondecision.FieldIdentityID:
  27114. return m.IdentityID()
  27115. case identityadoptiondecision.FieldAdoptDisplayName:
  27116. return m.AdoptDisplayName()
  27117. case identityadoptiondecision.FieldAdoptAvatar:
  27118. return m.AdoptAvatar()
  27119. case identityadoptiondecision.FieldDecidedAt:
  27120. return m.DecidedAt()
  27121. }
  27122. return nil, false
  27123. }
  27124. // OldField returns the old value of the field from the database. An error is
  27125. // returned if the mutation operation is not UpdateOne, or the query to the
  27126. // database failed.
  27127. func (m *IdentityAdoptionDecisionMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  27128. switch name {
  27129. case identityadoptiondecision.FieldCreatedAt:
  27130. return m.OldCreatedAt(ctx)
  27131. case identityadoptiondecision.FieldUpdatedAt:
  27132. return m.OldUpdatedAt(ctx)
  27133. case identityadoptiondecision.FieldPendingAuthSessionID:
  27134. return m.OldPendingAuthSessionID(ctx)
  27135. case identityadoptiondecision.FieldIdentityID:
  27136. return m.OldIdentityID(ctx)
  27137. case identityadoptiondecision.FieldAdoptDisplayName:
  27138. return m.OldAdoptDisplayName(ctx)
  27139. case identityadoptiondecision.FieldAdoptAvatar:
  27140. return m.OldAdoptAvatar(ctx)
  27141. case identityadoptiondecision.FieldDecidedAt:
  27142. return m.OldDecidedAt(ctx)
  27143. }
  27144. return nil, fmt.Errorf("unknown IdentityAdoptionDecision field %s", name)
  27145. }
  27146. // SetField sets the value of a field with the given name. It returns an error if
  27147. // the field is not defined in the schema, or if the type mismatched the field
  27148. // type.
  27149. func (m *IdentityAdoptionDecisionMutation) SetField(name string, value ent.Value) error {
  27150. switch name {
  27151. case identityadoptiondecision.FieldCreatedAt:
  27152. v, ok := value.(time.Time)
  27153. if !ok {
  27154. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27155. }
  27156. m.SetCreatedAt(v)
  27157. return nil
  27158. case identityadoptiondecision.FieldUpdatedAt:
  27159. v, ok := value.(time.Time)
  27160. if !ok {
  27161. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27162. }
  27163. m.SetUpdatedAt(v)
  27164. return nil
  27165. case identityadoptiondecision.FieldPendingAuthSessionID:
  27166. v, ok := value.(int64)
  27167. if !ok {
  27168. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27169. }
  27170. m.SetPendingAuthSessionID(v)
  27171. return nil
  27172. case identityadoptiondecision.FieldIdentityID:
  27173. v, ok := value.(int64)
  27174. if !ok {
  27175. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27176. }
  27177. m.SetIdentityID(v)
  27178. return nil
  27179. case identityadoptiondecision.FieldAdoptDisplayName:
  27180. v, ok := value.(bool)
  27181. if !ok {
  27182. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27183. }
  27184. m.SetAdoptDisplayName(v)
  27185. return nil
  27186. case identityadoptiondecision.FieldAdoptAvatar:
  27187. v, ok := value.(bool)
  27188. if !ok {
  27189. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27190. }
  27191. m.SetAdoptAvatar(v)
  27192. return nil
  27193. case identityadoptiondecision.FieldDecidedAt:
  27194. v, ok := value.(time.Time)
  27195. if !ok {
  27196. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27197. }
  27198. m.SetDecidedAt(v)
  27199. return nil
  27200. }
  27201. return fmt.Errorf("unknown IdentityAdoptionDecision field %s", name)
  27202. }
  27203. // AddedFields returns all numeric fields that were incremented/decremented during
  27204. // this mutation.
  27205. func (m *IdentityAdoptionDecisionMutation) AddedFields() []string {
  27206. var fields []string
  27207. return fields
  27208. }
  27209. // AddedField returns the numeric value that was incremented/decremented on a field
  27210. // with the given name. The second boolean return value indicates that this field
  27211. // was not set, or was not defined in the schema.
  27212. func (m *IdentityAdoptionDecisionMutation) AddedField(name string) (ent.Value, bool) {
  27213. switch name {
  27214. }
  27215. return nil, false
  27216. }
  27217. // AddField adds the value to the field with the given name. It returns an error if
  27218. // the field is not defined in the schema, or if the type mismatched the field
  27219. // type.
  27220. func (m *IdentityAdoptionDecisionMutation) AddField(name string, value ent.Value) error {
  27221. switch name {
  27222. }
  27223. return fmt.Errorf("unknown IdentityAdoptionDecision numeric field %s", name)
  27224. }
  27225. // ClearedFields returns all nullable fields that were cleared during this
  27226. // mutation.
  27227. func (m *IdentityAdoptionDecisionMutation) ClearedFields() []string {
  27228. var fields []string
  27229. if m.FieldCleared(identityadoptiondecision.FieldIdentityID) {
  27230. fields = append(fields, identityadoptiondecision.FieldIdentityID)
  27231. }
  27232. return fields
  27233. }
  27234. // FieldCleared returns a boolean indicating if a field with the given name was
  27235. // cleared in this mutation.
  27236. func (m *IdentityAdoptionDecisionMutation) FieldCleared(name string) bool {
  27237. _, ok := m.clearedFields[name]
  27238. return ok
  27239. }
  27240. // ClearField clears the value of the field with the given name. It returns an
  27241. // error if the field is not defined in the schema.
  27242. func (m *IdentityAdoptionDecisionMutation) ClearField(name string) error {
  27243. switch name {
  27244. case identityadoptiondecision.FieldIdentityID:
  27245. m.ClearIdentityID()
  27246. return nil
  27247. }
  27248. return fmt.Errorf("unknown IdentityAdoptionDecision nullable field %s", name)
  27249. }
  27250. // ResetField resets all changes in the mutation for the field with the given name.
  27251. // It returns an error if the field is not defined in the schema.
  27252. func (m *IdentityAdoptionDecisionMutation) ResetField(name string) error {
  27253. switch name {
  27254. case identityadoptiondecision.FieldCreatedAt:
  27255. m.ResetCreatedAt()
  27256. return nil
  27257. case identityadoptiondecision.FieldUpdatedAt:
  27258. m.ResetUpdatedAt()
  27259. return nil
  27260. case identityadoptiondecision.FieldPendingAuthSessionID:
  27261. m.ResetPendingAuthSessionID()
  27262. return nil
  27263. case identityadoptiondecision.FieldIdentityID:
  27264. m.ResetIdentityID()
  27265. return nil
  27266. case identityadoptiondecision.FieldAdoptDisplayName:
  27267. m.ResetAdoptDisplayName()
  27268. return nil
  27269. case identityadoptiondecision.FieldAdoptAvatar:
  27270. m.ResetAdoptAvatar()
  27271. return nil
  27272. case identityadoptiondecision.FieldDecidedAt:
  27273. m.ResetDecidedAt()
  27274. return nil
  27275. }
  27276. return fmt.Errorf("unknown IdentityAdoptionDecision field %s", name)
  27277. }
  27278. // AddedEdges returns all edge names that were set/added in this mutation.
  27279. func (m *IdentityAdoptionDecisionMutation) AddedEdges() []string {
  27280. edges := make([]string, 0, 2)
  27281. if m.pending_auth_session != nil {
  27282. edges = append(edges, identityadoptiondecision.EdgePendingAuthSession)
  27283. }
  27284. if m.identity != nil {
  27285. edges = append(edges, identityadoptiondecision.EdgeIdentity)
  27286. }
  27287. return edges
  27288. }
  27289. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  27290. // name in this mutation.
  27291. func (m *IdentityAdoptionDecisionMutation) AddedIDs(name string) []ent.Value {
  27292. switch name {
  27293. case identityadoptiondecision.EdgePendingAuthSession:
  27294. if id := m.pending_auth_session; id != nil {
  27295. return []ent.Value{*id}
  27296. }
  27297. case identityadoptiondecision.EdgeIdentity:
  27298. if id := m.identity; id != nil {
  27299. return []ent.Value{*id}
  27300. }
  27301. }
  27302. return nil
  27303. }
  27304. // RemovedEdges returns all edge names that were removed in this mutation.
  27305. func (m *IdentityAdoptionDecisionMutation) RemovedEdges() []string {
  27306. edges := make([]string, 0, 2)
  27307. return edges
  27308. }
  27309. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  27310. // the given name in this mutation.
  27311. func (m *IdentityAdoptionDecisionMutation) RemovedIDs(name string) []ent.Value {
  27312. return nil
  27313. }
  27314. // ClearedEdges returns all edge names that were cleared in this mutation.
  27315. func (m *IdentityAdoptionDecisionMutation) ClearedEdges() []string {
  27316. edges := make([]string, 0, 2)
  27317. if m.clearedpending_auth_session {
  27318. edges = append(edges, identityadoptiondecision.EdgePendingAuthSession)
  27319. }
  27320. if m.clearedidentity {
  27321. edges = append(edges, identityadoptiondecision.EdgeIdentity)
  27322. }
  27323. return edges
  27324. }
  27325. // EdgeCleared returns a boolean which indicates if the edge with the given name
  27326. // was cleared in this mutation.
  27327. func (m *IdentityAdoptionDecisionMutation) EdgeCleared(name string) bool {
  27328. switch name {
  27329. case identityadoptiondecision.EdgePendingAuthSession:
  27330. return m.clearedpending_auth_session
  27331. case identityadoptiondecision.EdgeIdentity:
  27332. return m.clearedidentity
  27333. }
  27334. return false
  27335. }
  27336. // ClearEdge clears the value of the edge with the given name. It returns an error
  27337. // if that edge is not defined in the schema.
  27338. func (m *IdentityAdoptionDecisionMutation) ClearEdge(name string) error {
  27339. switch name {
  27340. case identityadoptiondecision.EdgePendingAuthSession:
  27341. m.ClearPendingAuthSession()
  27342. return nil
  27343. case identityadoptiondecision.EdgeIdentity:
  27344. m.ClearIdentity()
  27345. return nil
  27346. }
  27347. return fmt.Errorf("unknown IdentityAdoptionDecision unique edge %s", name)
  27348. }
  27349. // ResetEdge resets all changes to the edge with the given name in this mutation.
  27350. // It returns an error if the edge is not defined in the schema.
  27351. func (m *IdentityAdoptionDecisionMutation) ResetEdge(name string) error {
  27352. switch name {
  27353. case identityadoptiondecision.EdgePendingAuthSession:
  27354. m.ResetPendingAuthSession()
  27355. return nil
  27356. case identityadoptiondecision.EdgeIdentity:
  27357. m.ResetIdentity()
  27358. return nil
  27359. }
  27360. return fmt.Errorf("unknown IdentityAdoptionDecision edge %s", name)
  27361. }
  27362. // PaymentAuditLogMutation represents an operation that mutates the PaymentAuditLog nodes in the graph.
  27363. type PaymentAuditLogMutation struct {
  27364. config
  27365. op Op
  27366. typ string
  27367. id *int64
  27368. order_id *string
  27369. action *string
  27370. detail *string
  27371. operator *string
  27372. created_at *time.Time
  27373. clearedFields map[string]struct{}
  27374. done bool
  27375. oldValue func(context.Context) (*PaymentAuditLog, error)
  27376. predicates []predicate.PaymentAuditLog
  27377. }
  27378. var _ ent.Mutation = (*PaymentAuditLogMutation)(nil)
  27379. // paymentauditlogOption allows management of the mutation configuration using functional options.
  27380. type paymentauditlogOption func(*PaymentAuditLogMutation)
  27381. // newPaymentAuditLogMutation creates new mutation for the PaymentAuditLog entity.
  27382. func newPaymentAuditLogMutation(c config, op Op, opts ...paymentauditlogOption) *PaymentAuditLogMutation {
  27383. m := &PaymentAuditLogMutation{
  27384. config: c,
  27385. op: op,
  27386. typ: TypePaymentAuditLog,
  27387. clearedFields: make(map[string]struct{}),
  27388. }
  27389. for _, opt := range opts {
  27390. opt(m)
  27391. }
  27392. return m
  27393. }
  27394. // withPaymentAuditLogID sets the ID field of the mutation.
  27395. func withPaymentAuditLogID(id int64) paymentauditlogOption {
  27396. return func(m *PaymentAuditLogMutation) {
  27397. var (
  27398. err error
  27399. once sync.Once
  27400. value *PaymentAuditLog
  27401. )
  27402. m.oldValue = func(ctx context.Context) (*PaymentAuditLog, error) {
  27403. once.Do(func() {
  27404. if m.done {
  27405. err = errors.New("querying old values post mutation is not allowed")
  27406. } else {
  27407. value, err = m.Client().PaymentAuditLog.Get(ctx, id)
  27408. }
  27409. })
  27410. return value, err
  27411. }
  27412. m.id = &id
  27413. }
  27414. }
  27415. // withPaymentAuditLog sets the old PaymentAuditLog of the mutation.
  27416. func withPaymentAuditLog(node *PaymentAuditLog) paymentauditlogOption {
  27417. return func(m *PaymentAuditLogMutation) {
  27418. m.oldValue = func(context.Context) (*PaymentAuditLog, error) {
  27419. return node, nil
  27420. }
  27421. m.id = &node.ID
  27422. }
  27423. }
  27424. // Client returns a new `ent.Client` from the mutation. If the mutation was
  27425. // executed in a transaction (ent.Tx), a transactional client is returned.
  27426. func (m PaymentAuditLogMutation) Client() *Client {
  27427. client := &Client{config: m.config}
  27428. client.init()
  27429. return client
  27430. }
  27431. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  27432. // it returns an error otherwise.
  27433. func (m PaymentAuditLogMutation) Tx() (*Tx, error) {
  27434. if _, ok := m.driver.(*txDriver); !ok {
  27435. return nil, errors.New("ent: mutation is not running in a transaction")
  27436. }
  27437. tx := &Tx{config: m.config}
  27438. tx.init()
  27439. return tx, nil
  27440. }
  27441. // ID returns the ID value in the mutation. Note that the ID is only available
  27442. // if it was provided to the builder or after it was returned from the database.
  27443. func (m *PaymentAuditLogMutation) ID() (id int64, exists bool) {
  27444. if m.id == nil {
  27445. return
  27446. }
  27447. return *m.id, true
  27448. }
  27449. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  27450. // That means, if the mutation is applied within a transaction with an isolation level such
  27451. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  27452. // or updated by the mutation.
  27453. func (m *PaymentAuditLogMutation) IDs(ctx context.Context) ([]int64, error) {
  27454. switch {
  27455. case m.op.Is(OpUpdateOne | OpDeleteOne):
  27456. id, exists := m.ID()
  27457. if exists {
  27458. return []int64{id}, nil
  27459. }
  27460. fallthrough
  27461. case m.op.Is(OpUpdate | OpDelete):
  27462. return m.Client().PaymentAuditLog.Query().Where(m.predicates...).IDs(ctx)
  27463. default:
  27464. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  27465. }
  27466. }
  27467. // SetOrderID sets the "order_id" field.
  27468. func (m *PaymentAuditLogMutation) SetOrderID(s string) {
  27469. m.order_id = &s
  27470. }
  27471. // OrderID returns the value of the "order_id" field in the mutation.
  27472. func (m *PaymentAuditLogMutation) OrderID() (r string, exists bool) {
  27473. v := m.order_id
  27474. if v == nil {
  27475. return
  27476. }
  27477. return *v, true
  27478. }
  27479. // OldOrderID returns the old "order_id" field's value of the PaymentAuditLog entity.
  27480. // If the PaymentAuditLog object wasn't provided to the builder, the object is fetched from the database.
  27481. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27482. func (m *PaymentAuditLogMutation) OldOrderID(ctx context.Context) (v string, err error) {
  27483. if !m.op.Is(OpUpdateOne) {
  27484. return v, errors.New("OldOrderID is only allowed on UpdateOne operations")
  27485. }
  27486. if m.id == nil || m.oldValue == nil {
  27487. return v, errors.New("OldOrderID requires an ID field in the mutation")
  27488. }
  27489. oldValue, err := m.oldValue(ctx)
  27490. if err != nil {
  27491. return v, fmt.Errorf("querying old value for OldOrderID: %w", err)
  27492. }
  27493. return oldValue.OrderID, nil
  27494. }
  27495. // ResetOrderID resets all changes to the "order_id" field.
  27496. func (m *PaymentAuditLogMutation) ResetOrderID() {
  27497. m.order_id = nil
  27498. }
  27499. // SetAction sets the "action" field.
  27500. func (m *PaymentAuditLogMutation) SetAction(s string) {
  27501. m.action = &s
  27502. }
  27503. // Action returns the value of the "action" field in the mutation.
  27504. func (m *PaymentAuditLogMutation) Action() (r string, exists bool) {
  27505. v := m.action
  27506. if v == nil {
  27507. return
  27508. }
  27509. return *v, true
  27510. }
  27511. // OldAction returns the old "action" field's value of the PaymentAuditLog entity.
  27512. // If the PaymentAuditLog object wasn't provided to the builder, the object is fetched from the database.
  27513. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27514. func (m *PaymentAuditLogMutation) OldAction(ctx context.Context) (v string, err error) {
  27515. if !m.op.Is(OpUpdateOne) {
  27516. return v, errors.New("OldAction is only allowed on UpdateOne operations")
  27517. }
  27518. if m.id == nil || m.oldValue == nil {
  27519. return v, errors.New("OldAction requires an ID field in the mutation")
  27520. }
  27521. oldValue, err := m.oldValue(ctx)
  27522. if err != nil {
  27523. return v, fmt.Errorf("querying old value for OldAction: %w", err)
  27524. }
  27525. return oldValue.Action, nil
  27526. }
  27527. // ResetAction resets all changes to the "action" field.
  27528. func (m *PaymentAuditLogMutation) ResetAction() {
  27529. m.action = nil
  27530. }
  27531. // SetDetail sets the "detail" field.
  27532. func (m *PaymentAuditLogMutation) SetDetail(s string) {
  27533. m.detail = &s
  27534. }
  27535. // Detail returns the value of the "detail" field in the mutation.
  27536. func (m *PaymentAuditLogMutation) Detail() (r string, exists bool) {
  27537. v := m.detail
  27538. if v == nil {
  27539. return
  27540. }
  27541. return *v, true
  27542. }
  27543. // OldDetail returns the old "detail" field's value of the PaymentAuditLog entity.
  27544. // If the PaymentAuditLog object wasn't provided to the builder, the object is fetched from the database.
  27545. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27546. func (m *PaymentAuditLogMutation) OldDetail(ctx context.Context) (v string, err error) {
  27547. if !m.op.Is(OpUpdateOne) {
  27548. return v, errors.New("OldDetail is only allowed on UpdateOne operations")
  27549. }
  27550. if m.id == nil || m.oldValue == nil {
  27551. return v, errors.New("OldDetail requires an ID field in the mutation")
  27552. }
  27553. oldValue, err := m.oldValue(ctx)
  27554. if err != nil {
  27555. return v, fmt.Errorf("querying old value for OldDetail: %w", err)
  27556. }
  27557. return oldValue.Detail, nil
  27558. }
  27559. // ResetDetail resets all changes to the "detail" field.
  27560. func (m *PaymentAuditLogMutation) ResetDetail() {
  27561. m.detail = nil
  27562. }
  27563. // SetOperator sets the "operator" field.
  27564. func (m *PaymentAuditLogMutation) SetOperator(s string) {
  27565. m.operator = &s
  27566. }
  27567. // Operator returns the value of the "operator" field in the mutation.
  27568. func (m *PaymentAuditLogMutation) Operator() (r string, exists bool) {
  27569. v := m.operator
  27570. if v == nil {
  27571. return
  27572. }
  27573. return *v, true
  27574. }
  27575. // OldOperator returns the old "operator" field's value of the PaymentAuditLog entity.
  27576. // If the PaymentAuditLog object wasn't provided to the builder, the object is fetched from the database.
  27577. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27578. func (m *PaymentAuditLogMutation) OldOperator(ctx context.Context) (v string, err error) {
  27579. if !m.op.Is(OpUpdateOne) {
  27580. return v, errors.New("OldOperator is only allowed on UpdateOne operations")
  27581. }
  27582. if m.id == nil || m.oldValue == nil {
  27583. return v, errors.New("OldOperator requires an ID field in the mutation")
  27584. }
  27585. oldValue, err := m.oldValue(ctx)
  27586. if err != nil {
  27587. return v, fmt.Errorf("querying old value for OldOperator: %w", err)
  27588. }
  27589. return oldValue.Operator, nil
  27590. }
  27591. // ResetOperator resets all changes to the "operator" field.
  27592. func (m *PaymentAuditLogMutation) ResetOperator() {
  27593. m.operator = nil
  27594. }
  27595. // SetCreatedAt sets the "created_at" field.
  27596. func (m *PaymentAuditLogMutation) SetCreatedAt(t time.Time) {
  27597. m.created_at = &t
  27598. }
  27599. // CreatedAt returns the value of the "created_at" field in the mutation.
  27600. func (m *PaymentAuditLogMutation) CreatedAt() (r time.Time, exists bool) {
  27601. v := m.created_at
  27602. if v == nil {
  27603. return
  27604. }
  27605. return *v, true
  27606. }
  27607. // OldCreatedAt returns the old "created_at" field's value of the PaymentAuditLog entity.
  27608. // If the PaymentAuditLog object wasn't provided to the builder, the object is fetched from the database.
  27609. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27610. func (m *PaymentAuditLogMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  27611. if !m.op.Is(OpUpdateOne) {
  27612. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  27613. }
  27614. if m.id == nil || m.oldValue == nil {
  27615. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  27616. }
  27617. oldValue, err := m.oldValue(ctx)
  27618. if err != nil {
  27619. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  27620. }
  27621. return oldValue.CreatedAt, nil
  27622. }
  27623. // ResetCreatedAt resets all changes to the "created_at" field.
  27624. func (m *PaymentAuditLogMutation) ResetCreatedAt() {
  27625. m.created_at = nil
  27626. }
  27627. // Where appends a list predicates to the PaymentAuditLogMutation builder.
  27628. func (m *PaymentAuditLogMutation) Where(ps ...predicate.PaymentAuditLog) {
  27629. m.predicates = append(m.predicates, ps...)
  27630. }
  27631. // WhereP appends storage-level predicates to the PaymentAuditLogMutation builder. Using this method,
  27632. // users can use type-assertion to append predicates that do not depend on any generated package.
  27633. func (m *PaymentAuditLogMutation) WhereP(ps ...func(*sql.Selector)) {
  27634. p := make([]predicate.PaymentAuditLog, len(ps))
  27635. for i := range ps {
  27636. p[i] = ps[i]
  27637. }
  27638. m.Where(p...)
  27639. }
  27640. // Op returns the operation name.
  27641. func (m *PaymentAuditLogMutation) Op() Op {
  27642. return m.op
  27643. }
  27644. // SetOp allows setting the mutation operation.
  27645. func (m *PaymentAuditLogMutation) SetOp(op Op) {
  27646. m.op = op
  27647. }
  27648. // Type returns the node type of this mutation (PaymentAuditLog).
  27649. func (m *PaymentAuditLogMutation) Type() string {
  27650. return m.typ
  27651. }
  27652. // Fields returns all fields that were changed during this mutation. Note that in
  27653. // order to get all numeric fields that were incremented/decremented, call
  27654. // AddedFields().
  27655. func (m *PaymentAuditLogMutation) Fields() []string {
  27656. fields := make([]string, 0, 5)
  27657. if m.order_id != nil {
  27658. fields = append(fields, paymentauditlog.FieldOrderID)
  27659. }
  27660. if m.action != nil {
  27661. fields = append(fields, paymentauditlog.FieldAction)
  27662. }
  27663. if m.detail != nil {
  27664. fields = append(fields, paymentauditlog.FieldDetail)
  27665. }
  27666. if m.operator != nil {
  27667. fields = append(fields, paymentauditlog.FieldOperator)
  27668. }
  27669. if m.created_at != nil {
  27670. fields = append(fields, paymentauditlog.FieldCreatedAt)
  27671. }
  27672. return fields
  27673. }
  27674. // Field returns the value of a field with the given name. The second boolean
  27675. // return value indicates that this field was not set, or was not defined in the
  27676. // schema.
  27677. func (m *PaymentAuditLogMutation) Field(name string) (ent.Value, bool) {
  27678. switch name {
  27679. case paymentauditlog.FieldOrderID:
  27680. return m.OrderID()
  27681. case paymentauditlog.FieldAction:
  27682. return m.Action()
  27683. case paymentauditlog.FieldDetail:
  27684. return m.Detail()
  27685. case paymentauditlog.FieldOperator:
  27686. return m.Operator()
  27687. case paymentauditlog.FieldCreatedAt:
  27688. return m.CreatedAt()
  27689. }
  27690. return nil, false
  27691. }
  27692. // OldField returns the old value of the field from the database. An error is
  27693. // returned if the mutation operation is not UpdateOne, or the query to the
  27694. // database failed.
  27695. func (m *PaymentAuditLogMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  27696. switch name {
  27697. case paymentauditlog.FieldOrderID:
  27698. return m.OldOrderID(ctx)
  27699. case paymentauditlog.FieldAction:
  27700. return m.OldAction(ctx)
  27701. case paymentauditlog.FieldDetail:
  27702. return m.OldDetail(ctx)
  27703. case paymentauditlog.FieldOperator:
  27704. return m.OldOperator(ctx)
  27705. case paymentauditlog.FieldCreatedAt:
  27706. return m.OldCreatedAt(ctx)
  27707. }
  27708. return nil, fmt.Errorf("unknown PaymentAuditLog field %s", name)
  27709. }
  27710. // SetField sets the value of a field with the given name. It returns an error if
  27711. // the field is not defined in the schema, or if the type mismatched the field
  27712. // type.
  27713. func (m *PaymentAuditLogMutation) SetField(name string, value ent.Value) error {
  27714. switch name {
  27715. case paymentauditlog.FieldOrderID:
  27716. v, ok := value.(string)
  27717. if !ok {
  27718. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27719. }
  27720. m.SetOrderID(v)
  27721. return nil
  27722. case paymentauditlog.FieldAction:
  27723. v, ok := value.(string)
  27724. if !ok {
  27725. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27726. }
  27727. m.SetAction(v)
  27728. return nil
  27729. case paymentauditlog.FieldDetail:
  27730. v, ok := value.(string)
  27731. if !ok {
  27732. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27733. }
  27734. m.SetDetail(v)
  27735. return nil
  27736. case paymentauditlog.FieldOperator:
  27737. v, ok := value.(string)
  27738. if !ok {
  27739. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27740. }
  27741. m.SetOperator(v)
  27742. return nil
  27743. case paymentauditlog.FieldCreatedAt:
  27744. v, ok := value.(time.Time)
  27745. if !ok {
  27746. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27747. }
  27748. m.SetCreatedAt(v)
  27749. return nil
  27750. }
  27751. return fmt.Errorf("unknown PaymentAuditLog field %s", name)
  27752. }
  27753. // AddedFields returns all numeric fields that were incremented/decremented during
  27754. // this mutation.
  27755. func (m *PaymentAuditLogMutation) AddedFields() []string {
  27756. return nil
  27757. }
  27758. // AddedField returns the numeric value that was incremented/decremented on a field
  27759. // with the given name. The second boolean return value indicates that this field
  27760. // was not set, or was not defined in the schema.
  27761. func (m *PaymentAuditLogMutation) AddedField(name string) (ent.Value, bool) {
  27762. return nil, false
  27763. }
  27764. // AddField adds the value to the field with the given name. It returns an error if
  27765. // the field is not defined in the schema, or if the type mismatched the field
  27766. // type.
  27767. func (m *PaymentAuditLogMutation) AddField(name string, value ent.Value) error {
  27768. switch name {
  27769. }
  27770. return fmt.Errorf("unknown PaymentAuditLog numeric field %s", name)
  27771. }
  27772. // ClearedFields returns all nullable fields that were cleared during this
  27773. // mutation.
  27774. func (m *PaymentAuditLogMutation) ClearedFields() []string {
  27775. return nil
  27776. }
  27777. // FieldCleared returns a boolean indicating if a field with the given name was
  27778. // cleared in this mutation.
  27779. func (m *PaymentAuditLogMutation) FieldCleared(name string) bool {
  27780. _, ok := m.clearedFields[name]
  27781. return ok
  27782. }
  27783. // ClearField clears the value of the field with the given name. It returns an
  27784. // error if the field is not defined in the schema.
  27785. func (m *PaymentAuditLogMutation) ClearField(name string) error {
  27786. return fmt.Errorf("unknown PaymentAuditLog nullable field %s", name)
  27787. }
  27788. // ResetField resets all changes in the mutation for the field with the given name.
  27789. // It returns an error if the field is not defined in the schema.
  27790. func (m *PaymentAuditLogMutation) ResetField(name string) error {
  27791. switch name {
  27792. case paymentauditlog.FieldOrderID:
  27793. m.ResetOrderID()
  27794. return nil
  27795. case paymentauditlog.FieldAction:
  27796. m.ResetAction()
  27797. return nil
  27798. case paymentauditlog.FieldDetail:
  27799. m.ResetDetail()
  27800. return nil
  27801. case paymentauditlog.FieldOperator:
  27802. m.ResetOperator()
  27803. return nil
  27804. case paymentauditlog.FieldCreatedAt:
  27805. m.ResetCreatedAt()
  27806. return nil
  27807. }
  27808. return fmt.Errorf("unknown PaymentAuditLog field %s", name)
  27809. }
  27810. // AddedEdges returns all edge names that were set/added in this mutation.
  27811. func (m *PaymentAuditLogMutation) AddedEdges() []string {
  27812. edges := make([]string, 0, 0)
  27813. return edges
  27814. }
  27815. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  27816. // name in this mutation.
  27817. func (m *PaymentAuditLogMutation) AddedIDs(name string) []ent.Value {
  27818. return nil
  27819. }
  27820. // RemovedEdges returns all edge names that were removed in this mutation.
  27821. func (m *PaymentAuditLogMutation) RemovedEdges() []string {
  27822. edges := make([]string, 0, 0)
  27823. return edges
  27824. }
  27825. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  27826. // the given name in this mutation.
  27827. func (m *PaymentAuditLogMutation) RemovedIDs(name string) []ent.Value {
  27828. return nil
  27829. }
  27830. // ClearedEdges returns all edge names that were cleared in this mutation.
  27831. func (m *PaymentAuditLogMutation) ClearedEdges() []string {
  27832. edges := make([]string, 0, 0)
  27833. return edges
  27834. }
  27835. // EdgeCleared returns a boolean which indicates if the edge with the given name
  27836. // was cleared in this mutation.
  27837. func (m *PaymentAuditLogMutation) EdgeCleared(name string) bool {
  27838. return false
  27839. }
  27840. // ClearEdge clears the value of the edge with the given name. It returns an error
  27841. // if that edge is not defined in the schema.
  27842. func (m *PaymentAuditLogMutation) ClearEdge(name string) error {
  27843. return fmt.Errorf("unknown PaymentAuditLog unique edge %s", name)
  27844. }
  27845. // ResetEdge resets all changes to the edge with the given name in this mutation.
  27846. // It returns an error if the edge is not defined in the schema.
  27847. func (m *PaymentAuditLogMutation) ResetEdge(name string) error {
  27848. return fmt.Errorf("unknown PaymentAuditLog edge %s", name)
  27849. }
  27850. // PaymentOrderMutation represents an operation that mutates the PaymentOrder nodes in the graph.
  27851. type PaymentOrderMutation struct {
  27852. config
  27853. op Op
  27854. typ string
  27855. id *int64
  27856. user_email *string
  27857. user_name *string
  27858. user_notes *string
  27859. amount *float64
  27860. addamount *float64
  27861. pay_amount *float64
  27862. addpay_amount *float64
  27863. fee_rate *float64
  27864. addfee_rate *float64
  27865. recharge_code *string
  27866. out_trade_no *string
  27867. payment_type *string
  27868. payment_trade_no *string
  27869. pay_url *string
  27870. qr_code *string
  27871. qr_code_img *string
  27872. order_type *string
  27873. plan_id *int64
  27874. addplan_id *int64
  27875. subscription_group_id *int64
  27876. addsubscription_group_id *int64
  27877. subscription_days *int
  27878. addsubscription_days *int
  27879. provider_instance_id *string
  27880. provider_key *string
  27881. provider_snapshot *map[string]interface{}
  27882. status *string
  27883. refund_amount *float64
  27884. addrefund_amount *float64
  27885. refund_reason *string
  27886. refund_at *time.Time
  27887. force_refund *bool
  27888. refund_requested_at *time.Time
  27889. refund_request_reason *string
  27890. refund_requested_by *string
  27891. expires_at *time.Time
  27892. paid_at *time.Time
  27893. completed_at *time.Time
  27894. failed_at *time.Time
  27895. failed_reason *string
  27896. client_ip *string
  27897. src_host *string
  27898. src_url *string
  27899. created_at *time.Time
  27900. updated_at *time.Time
  27901. clearedFields map[string]struct{}
  27902. user *int64
  27903. cleareduser bool
  27904. done bool
  27905. oldValue func(context.Context) (*PaymentOrder, error)
  27906. predicates []predicate.PaymentOrder
  27907. }
  27908. var _ ent.Mutation = (*PaymentOrderMutation)(nil)
  27909. // paymentorderOption allows management of the mutation configuration using functional options.
  27910. type paymentorderOption func(*PaymentOrderMutation)
  27911. // newPaymentOrderMutation creates new mutation for the PaymentOrder entity.
  27912. func newPaymentOrderMutation(c config, op Op, opts ...paymentorderOption) *PaymentOrderMutation {
  27913. m := &PaymentOrderMutation{
  27914. config: c,
  27915. op: op,
  27916. typ: TypePaymentOrder,
  27917. clearedFields: make(map[string]struct{}),
  27918. }
  27919. for _, opt := range opts {
  27920. opt(m)
  27921. }
  27922. return m
  27923. }
  27924. // withPaymentOrderID sets the ID field of the mutation.
  27925. func withPaymentOrderID(id int64) paymentorderOption {
  27926. return func(m *PaymentOrderMutation) {
  27927. var (
  27928. err error
  27929. once sync.Once
  27930. value *PaymentOrder
  27931. )
  27932. m.oldValue = func(ctx context.Context) (*PaymentOrder, error) {
  27933. once.Do(func() {
  27934. if m.done {
  27935. err = errors.New("querying old values post mutation is not allowed")
  27936. } else {
  27937. value, err = m.Client().PaymentOrder.Get(ctx, id)
  27938. }
  27939. })
  27940. return value, err
  27941. }
  27942. m.id = &id
  27943. }
  27944. }
  27945. // withPaymentOrder sets the old PaymentOrder of the mutation.
  27946. func withPaymentOrder(node *PaymentOrder) paymentorderOption {
  27947. return func(m *PaymentOrderMutation) {
  27948. m.oldValue = func(context.Context) (*PaymentOrder, error) {
  27949. return node, nil
  27950. }
  27951. m.id = &node.ID
  27952. }
  27953. }
  27954. // Client returns a new `ent.Client` from the mutation. If the mutation was
  27955. // executed in a transaction (ent.Tx), a transactional client is returned.
  27956. func (m PaymentOrderMutation) Client() *Client {
  27957. client := &Client{config: m.config}
  27958. client.init()
  27959. return client
  27960. }
  27961. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  27962. // it returns an error otherwise.
  27963. func (m PaymentOrderMutation) Tx() (*Tx, error) {
  27964. if _, ok := m.driver.(*txDriver); !ok {
  27965. return nil, errors.New("ent: mutation is not running in a transaction")
  27966. }
  27967. tx := &Tx{config: m.config}
  27968. tx.init()
  27969. return tx, nil
  27970. }
  27971. // ID returns the ID value in the mutation. Note that the ID is only available
  27972. // if it was provided to the builder or after it was returned from the database.
  27973. func (m *PaymentOrderMutation) ID() (id int64, exists bool) {
  27974. if m.id == nil {
  27975. return
  27976. }
  27977. return *m.id, true
  27978. }
  27979. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  27980. // That means, if the mutation is applied within a transaction with an isolation level such
  27981. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  27982. // or updated by the mutation.
  27983. func (m *PaymentOrderMutation) IDs(ctx context.Context) ([]int64, error) {
  27984. switch {
  27985. case m.op.Is(OpUpdateOne | OpDeleteOne):
  27986. id, exists := m.ID()
  27987. if exists {
  27988. return []int64{id}, nil
  27989. }
  27990. fallthrough
  27991. case m.op.Is(OpUpdate | OpDelete):
  27992. return m.Client().PaymentOrder.Query().Where(m.predicates...).IDs(ctx)
  27993. default:
  27994. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  27995. }
  27996. }
  27997. // SetUserID sets the "user_id" field.
  27998. func (m *PaymentOrderMutation) SetUserID(i int64) {
  27999. m.user = &i
  28000. }
  28001. // UserID returns the value of the "user_id" field in the mutation.
  28002. func (m *PaymentOrderMutation) UserID() (r int64, exists bool) {
  28003. v := m.user
  28004. if v == nil {
  28005. return
  28006. }
  28007. return *v, true
  28008. }
  28009. // OldUserID returns the old "user_id" field's value of the PaymentOrder entity.
  28010. // If the PaymentOrder object wasn't provided to the builder, the object is fetched from the database.
  28011. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28012. func (m *PaymentOrderMutation) OldUserID(ctx context.Context) (v int64, err error) {
  28013. if !m.op.Is(OpUpdateOne) {
  28014. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  28015. }
  28016. if m.id == nil || m.oldValue == nil {
  28017. return v, errors.New("OldUserID requires an ID field in the mutation")
  28018. }
  28019. oldValue, err := m.oldValue(ctx)
  28020. if err != nil {
  28021. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  28022. }
  28023. return oldValue.UserID, nil
  28024. }
  28025. // ResetUserID resets all changes to the "user_id" field.
  28026. func (m *PaymentOrderMutation) ResetUserID() {
  28027. m.user = nil
  28028. }
  28029. // SetUserEmail sets the "user_email" field.
  28030. func (m *PaymentOrderMutation) SetUserEmail(s string) {
  28031. m.user_email = &s
  28032. }
  28033. // UserEmail returns the value of the "user_email" field in the mutation.
  28034. func (m *PaymentOrderMutation) UserEmail() (r string, exists bool) {
  28035. v := m.user_email
  28036. if v == nil {
  28037. return
  28038. }
  28039. return *v, true
  28040. }
  28041. // OldUserEmail returns the old "user_email" field's value of the PaymentOrder entity.
  28042. // If the PaymentOrder object wasn't provided to the builder, the object is fetched from the database.
  28043. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28044. func (m *PaymentOrderMutation) OldUserEmail(ctx context.Context) (v string, err error) {
  28045. if !m.op.Is(OpUpdateOne) {
  28046. return v, errors.New("OldUserEmail is only allowed on UpdateOne operations")
  28047. }
  28048. if m.id == nil || m.oldValue == nil {
  28049. return v, errors.New("OldUserEmail requires an ID field in the mutation")
  28050. }
  28051. oldValue, err := m.oldValue(ctx)
  28052. if err != nil {
  28053. return v, fmt.Errorf("querying old value for OldUserEmail: %w", err)
  28054. }
  28055. return oldValue.UserEmail, nil
  28056. }
  28057. // ResetUserEmail resets all changes to the "user_email" field.
  28058. func (m *PaymentOrderMutation) ResetUserEmail() {
  28059. m.user_email = nil
  28060. }
  28061. // SetUserName sets the "user_name" field.
  28062. func (m *PaymentOrderMutation) SetUserName(s string) {
  28063. m.user_name = &s
  28064. }
  28065. // UserName returns the value of the "user_name" field in the mutation.
  28066. func (m *PaymentOrderMutation) UserName() (r string, exists bool) {
  28067. v := m.user_name
  28068. if v == nil {
  28069. return
  28070. }
  28071. return *v, true
  28072. }
  28073. // OldUserName returns the old "user_name" field's value of the PaymentOrder entity.
  28074. // If the PaymentOrder object wasn't provided to the builder, the object is fetched from the database.
  28075. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28076. func (m *PaymentOrderMutation) OldUserName(ctx context.Context) (v string, err error) {
  28077. if !m.op.Is(OpUpdateOne) {
  28078. return v, errors.New("OldUserName is only allowed on UpdateOne operations")
  28079. }
  28080. if m.id == nil || m.oldValue == nil {
  28081. return v, errors.New("OldUserName requires an ID field in the mutation")
  28082. }
  28083. oldValue, err := m.oldValue(ctx)
  28084. if err != nil {
  28085. return v, fmt.Errorf("querying old value for OldUserName: %w", err)
  28086. }
  28087. return oldValue.UserName, nil
  28088. }
  28089. // ResetUserName resets all changes to the "user_name" field.
  28090. func (m *PaymentOrderMutation) ResetUserName() {
  28091. m.user_name = nil
  28092. }
  28093. // SetUserNotes sets the "user_notes" field.
  28094. func (m *PaymentOrderMutation) SetUserNotes(s string) {
  28095. m.user_notes = &s
  28096. }
  28097. // UserNotes returns the value of the "user_notes" field in the mutation.
  28098. func (m *PaymentOrderMutation) UserNotes() (r string, exists bool) {
  28099. v := m.user_notes
  28100. if v == nil {
  28101. return
  28102. }
  28103. return *v, true
  28104. }
  28105. // OldUserNotes returns the old "user_notes" field's value of the PaymentOrder entity.
  28106. // If the PaymentOrder object wasn't provided to the builder, the object is fetched from the database.
  28107. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28108. func (m *PaymentOrderMutation) OldUserNotes(ctx context.Context) (v *string, err error) {
  28109. if !m.op.Is(OpUpdateOne) {
  28110. return v, errors.New("OldUserNotes is only allowed on UpdateOne operations")
  28111. }
  28112. if m.id == nil || m.oldValue == nil {
  28113. return v, errors.New("OldUserNotes requires an ID field in the mutation")
  28114. }
  28115. oldValue, err := m.oldValue(ctx)
  28116. if err != nil {
  28117. return v, fmt.Errorf("querying old value for OldUserNotes: %w", err)
  28118. }
  28119. return oldValue.UserNotes, nil
  28120. }
  28121. // ClearUserNotes clears the value of the "user_notes" field.
  28122. func (m *PaymentOrderMutation) ClearUserNotes() {
  28123. m.user_notes = nil
  28124. m.clearedFields[paymentorder.FieldUserNotes] = struct{}{}
  28125. }
  28126. // UserNotesCleared returns if the "user_notes" field was cleared in this mutation.
  28127. func (m *PaymentOrderMutation) UserNotesCleared() bool {
  28128. _, ok := m.clearedFields[paymentorder.FieldUserNotes]
  28129. return ok
  28130. }
  28131. // ResetUserNotes resets all changes to the "user_notes" field.
  28132. func (m *PaymentOrderMutation) ResetUserNotes() {
  28133. m.user_notes = nil
  28134. delete(m.clearedFields, paymentorder.FieldUserNotes)
  28135. }
  28136. // SetAmount sets the "amount" field.
  28137. func (m *PaymentOrderMutation) SetAmount(f float64) {
  28138. m.amount = &f
  28139. m.addamount = nil
  28140. }
  28141. // Amount returns the value of the "amount" field in the mutation.
  28142. func (m *PaymentOrderMutation) Amount() (r float64, exists bool) {
  28143. v := m.amount
  28144. if v == nil {
  28145. return
  28146. }
  28147. return *v, true
  28148. }
  28149. // OldAmount returns the old "amount" field's value of the PaymentOrder entity.
  28150. // If the PaymentOrder object wasn't provided to the builder, the object is fetched from the database.
  28151. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28152. func (m *PaymentOrderMutation) OldAmount(ctx context.Context) (v float64, err error) {
  28153. if !m.op.Is(OpUpdateOne) {
  28154. return v, errors.New("OldAmount is only allowed on UpdateOne operations")
  28155. }
  28156. if m.id == nil || m.oldValue == nil {
  28157. return v, errors.New("OldAmount requires an ID field in the mutation")
  28158. }
  28159. oldValue, err := m.oldValue(ctx)
  28160. if err != nil {
  28161. return v, fmt.Errorf("querying old value for OldAmount: %w", err)
  28162. }
  28163. return oldValue.Amount, nil
  28164. }
  28165. // AddAmount adds f to the "amount" field.
  28166. func (m *PaymentOrderMutation) AddAmount(f float64) {
  28167. if m.addamount != nil {
  28168. *m.addamount += f
  28169. } else {
  28170. m.addamount = &f
  28171. }
  28172. }
  28173. // AddedAmount returns the value that was added to the "amount" field in this mutation.
  28174. func (m *PaymentOrderMutation) AddedAmount() (r float64, exists bool) {
  28175. v := m.addamount
  28176. if v == nil {
  28177. return
  28178. }
  28179. return *v, true
  28180. }
  28181. // ResetAmount resets all changes to the "amount" field.
  28182. func (m *PaymentOrderMutation) ResetAmount() {
  28183. m.amount = nil
  28184. m.addamount = nil
  28185. }
  28186. // SetPayAmount sets the "pay_amount" field.
  28187. func (m *PaymentOrderMutation) SetPayAmount(f float64) {
  28188. m.pay_amount = &f
  28189. m.addpay_amount = nil
  28190. }
  28191. // PayAmount returns the value of the "pay_amount" field in the mutation.
  28192. func (m *PaymentOrderMutation) PayAmount() (r float64, exists bool) {
  28193. v := m.pay_amount
  28194. if v == nil {
  28195. return
  28196. }
  28197. return *v, true
  28198. }
  28199. // OldPayAmount returns the old "pay_amount" field's value of the PaymentOrder entity.
  28200. // If the PaymentOrder object wasn't provided to the builder, the object is fetched from the database.
  28201. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28202. func (m *PaymentOrderMutation) OldPayAmount(ctx context.Context) (v float64, err error) {
  28203. if !m.op.Is(OpUpdateOne) {
  28204. return v, errors.New("OldPayAmount is only allowed on UpdateOne operations")
  28205. }
  28206. if m.id == nil || m.oldValue == nil {
  28207. return v, errors.New("OldPayAmount requires an ID field in the mutation")
  28208. }
  28209. oldValue, err := m.oldValue(ctx)
  28210. if err != nil {
  28211. return v, fmt.Errorf("querying old value for OldPayAmount: %w", err)
  28212. }
  28213. return oldValue.PayAmount, nil
  28214. }
  28215. // AddPayAmount adds f to the "pay_amount" field.
  28216. func (m *PaymentOrderMutation) AddPayAmount(f float64) {
  28217. if m.addpay_amount != nil {
  28218. *m.addpay_amount += f
  28219. } else {
  28220. m.addpay_amount = &f
  28221. }
  28222. }
  28223. // AddedPayAmount returns the value that was added to the "pay_amount" field in this mutation.
  28224. func (m *PaymentOrderMutation) AddedPayAmount() (r float64, exists bool) {
  28225. v := m.addpay_amount
  28226. if v == nil {
  28227. return
  28228. }
  28229. return *v, true
  28230. }
  28231. // ResetPayAmount resets all changes to the "pay_amount" field.
  28232. func (m *PaymentOrderMutation) ResetPayAmount() {
  28233. m.pay_amount = nil
  28234. m.addpay_amount = nil
  28235. }
  28236. // SetFeeRate sets the "fee_rate" field.
  28237. func (m *PaymentOrderMutation) SetFeeRate(f float64) {
  28238. m.fee_rate = &f
  28239. m.addfee_rate = nil
  28240. }
  28241. // FeeRate returns the value of the "fee_rate" field in the mutation.
  28242. func (m *PaymentOrderMutation) FeeRate() (r float64, exists bool) {
  28243. v := m.fee_rate
  28244. if v == nil {
  28245. return
  28246. }
  28247. return *v, true
  28248. }
  28249. // OldFeeRate returns the old "fee_rate" field's value of the PaymentOrder entity.
  28250. // If the PaymentOrder object wasn't provided to the builder, the object is fetched from the database.
  28251. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28252. func (m *PaymentOrderMutation) OldFeeRate(ctx context.Context) (v float64, err error) {
  28253. if !m.op.Is(OpUpdateOne) {
  28254. return v, errors.New("OldFeeRate is only allowed on UpdateOne operations")
  28255. }
  28256. if m.id == nil || m.oldValue == nil {
  28257. return v, errors.New("OldFeeRate requires an ID field in the mutation")
  28258. }
  28259. oldValue, err := m.oldValue(ctx)
  28260. if err != nil {
  28261. return v, fmt.Errorf("querying old value for OldFeeRate: %w", err)
  28262. }
  28263. return oldValue.FeeRate, nil
  28264. }
  28265. // AddFeeRate adds f to the "fee_rate" field.
  28266. func (m *PaymentOrderMutation) AddFeeRate(f float64) {
  28267. if m.addfee_rate != nil {
  28268. *m.addfee_rate += f
  28269. } else {
  28270. m.addfee_rate = &f
  28271. }
  28272. }
  28273. // AddedFeeRate returns the value that was added to the "fee_rate" field in this mutation.
  28274. func (m *PaymentOrderMutation) AddedFeeRate() (r float64, exists bool) {
  28275. v := m.addfee_rate
  28276. if v == nil {
  28277. return
  28278. }
  28279. return *v, true
  28280. }
  28281. // ResetFeeRate resets all changes to the "fee_rate" field.
  28282. func (m *PaymentOrderMutation) ResetFeeRate() {
  28283. m.fee_rate = nil
  28284. m.addfee_rate = nil
  28285. }
  28286. // SetRechargeCode sets the "recharge_code" field.
  28287. func (m *PaymentOrderMutation) SetRechargeCode(s string) {
  28288. m.recharge_code = &s
  28289. }
  28290. // RechargeCode returns the value of the "recharge_code" field in the mutation.
  28291. func (m *PaymentOrderMutation) RechargeCode() (r string, exists bool) {
  28292. v := m.recharge_code
  28293. if v == nil {
  28294. return
  28295. }
  28296. return *v, true
  28297. }
  28298. // OldRechargeCode returns the old "recharge_code" field's value of the PaymentOrder entity.
  28299. // If the PaymentOrder object wasn't provided to the builder, the object is fetched from the database.
  28300. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28301. func (m *PaymentOrderMutation) OldRechargeCode(ctx context.Context) (v string, err error) {
  28302. if !m.op.Is(OpUpdateOne) {
  28303. return v, errors.New("OldRechargeCode is only allowed on UpdateOne operations")
  28304. }
  28305. if m.id == nil || m.oldValue == nil {
  28306. return v, errors.New("OldRechargeCode requires an ID field in the mutation")
  28307. }
  28308. oldValue, err := m.oldValue(ctx)
  28309. if err != nil {
  28310. return v, fmt.Errorf("querying old value for OldRechargeCode: %w", err)
  28311. }
  28312. return oldValue.RechargeCode, nil
  28313. }
  28314. // ResetRechargeCode resets all changes to the "recharge_code" field.
  28315. func (m *PaymentOrderMutation) ResetRechargeCode() {
  28316. m.recharge_code = nil
  28317. }
  28318. // SetOutTradeNo sets the "out_trade_no" field.
  28319. func (m *PaymentOrderMutation) SetOutTradeNo(s string) {
  28320. m.out_trade_no = &s
  28321. }
  28322. // OutTradeNo returns the value of the "out_trade_no" field in the mutation.
  28323. func (m *PaymentOrderMutation) OutTradeNo() (r string, exists bool) {
  28324. v := m.out_trade_no
  28325. if v == nil {
  28326. return
  28327. }
  28328. return *v, true
  28329. }
  28330. // OldOutTradeNo returns the old "out_trade_no" field's value of the PaymentOrder entity.
  28331. // If the PaymentOrder object wasn't provided to the builder, the object is fetched from the database.
  28332. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28333. func (m *PaymentOrderMutation) OldOutTradeNo(ctx context.Context) (v string, err error) {
  28334. if !m.op.Is(OpUpdateOne) {
  28335. return v, errors.New("OldOutTradeNo is only allowed on UpdateOne operations")
  28336. }
  28337. if m.id == nil || m.oldValue == nil {
  28338. return v, errors.New("OldOutTradeNo requires an ID field in the mutation")
  28339. }
  28340. oldValue, err := m.oldValue(ctx)
  28341. if err != nil {
  28342. return v, fmt.Errorf("querying old value for OldOutTradeNo: %w", err)
  28343. }
  28344. return oldValue.OutTradeNo, nil
  28345. }
  28346. // ResetOutTradeNo resets all changes to the "out_trade_no" field.
  28347. func (m *PaymentOrderMutation) ResetOutTradeNo() {
  28348. m.out_trade_no = nil
  28349. }
  28350. // SetPaymentType sets the "payment_type" field.
  28351. func (m *PaymentOrderMutation) SetPaymentType(s string) {
  28352. m.payment_type = &s
  28353. }
  28354. // PaymentType returns the value of the "payment_type" field in the mutation.
  28355. func (m *PaymentOrderMutation) PaymentType() (r string, exists bool) {
  28356. v := m.payment_type
  28357. if v == nil {
  28358. return
  28359. }
  28360. return *v, true
  28361. }
  28362. // OldPaymentType returns the old "payment_type" field's value of the PaymentOrder entity.
  28363. // If the PaymentOrder object wasn't provided to the builder, the object is fetched from the database.
  28364. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28365. func (m *PaymentOrderMutation) OldPaymentType(ctx context.Context) (v string, err error) {
  28366. if !m.op.Is(OpUpdateOne) {
  28367. return v, errors.New("OldPaymentType is only allowed on UpdateOne operations")
  28368. }
  28369. if m.id == nil || m.oldValue == nil {
  28370. return v, errors.New("OldPaymentType requires an ID field in the mutation")
  28371. }
  28372. oldValue, err := m.oldValue(ctx)
  28373. if err != nil {
  28374. return v, fmt.Errorf("querying old value for OldPaymentType: %w", err)
  28375. }
  28376. return oldValue.PaymentType, nil
  28377. }
  28378. // ResetPaymentType resets all changes to the "payment_type" field.
  28379. func (m *PaymentOrderMutation) ResetPaymentType() {
  28380. m.payment_type = nil
  28381. }
  28382. // SetPaymentTradeNo sets the "payment_trade_no" field.
  28383. func (m *PaymentOrderMutation) SetPaymentTradeNo(s string) {
  28384. m.payment_trade_no = &s
  28385. }
  28386. // PaymentTradeNo returns the value of the "payment_trade_no" field in the mutation.
  28387. func (m *PaymentOrderMutation) PaymentTradeNo() (r string, exists bool) {
  28388. v := m.payment_trade_no
  28389. if v == nil {
  28390. return
  28391. }
  28392. return *v, true
  28393. }
  28394. // OldPaymentTradeNo returns the old "payment_trade_no" field's value of the PaymentOrder entity.
  28395. // If the PaymentOrder object wasn't provided to the builder, the object is fetched from the database.
  28396. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28397. func (m *PaymentOrderMutation) OldPaymentTradeNo(ctx context.Context) (v string, err error) {
  28398. if !m.op.Is(OpUpdateOne) {
  28399. return v, errors.New("OldPaymentTradeNo is only allowed on UpdateOne operations")
  28400. }
  28401. if m.id == nil || m.oldValue == nil {
  28402. return v, errors.New("OldPaymentTradeNo requires an ID field in the mutation")
  28403. }
  28404. oldValue, err := m.oldValue(ctx)
  28405. if err != nil {
  28406. return v, fmt.Errorf("querying old value for OldPaymentTradeNo: %w", err)
  28407. }
  28408. return oldValue.PaymentTradeNo, nil
  28409. }
  28410. // ResetPaymentTradeNo resets all changes to the "payment_trade_no" field.
  28411. func (m *PaymentOrderMutation) ResetPaymentTradeNo() {
  28412. m.payment_trade_no = nil
  28413. }
  28414. // SetPayURL sets the "pay_url" field.
  28415. func (m *PaymentOrderMutation) SetPayURL(s string) {
  28416. m.pay_url = &s
  28417. }
  28418. // PayURL returns the value of the "pay_url" field in the mutation.
  28419. func (m *PaymentOrderMutation) PayURL() (r string, exists bool) {
  28420. v := m.pay_url
  28421. if v == nil {
  28422. return
  28423. }
  28424. return *v, true
  28425. }
  28426. // OldPayURL returns the old "pay_url" field's value of the PaymentOrder entity.
  28427. // If the PaymentOrder object wasn't provided to the builder, the object is fetched from the database.
  28428. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28429. func (m *PaymentOrderMutation) OldPayURL(ctx context.Context) (v *string, err error) {
  28430. if !m.op.Is(OpUpdateOne) {
  28431. return v, errors.New("OldPayURL is only allowed on UpdateOne operations")
  28432. }
  28433. if m.id == nil || m.oldValue == nil {
  28434. return v, errors.New("OldPayURL requires an ID field in the mutation")
  28435. }
  28436. oldValue, err := m.oldValue(ctx)
  28437. if err != nil {
  28438. return v, fmt.Errorf("querying old value for OldPayURL: %w", err)
  28439. }
  28440. return oldValue.PayURL, nil
  28441. }
  28442. // ClearPayURL clears the value of the "pay_url" field.
  28443. func (m *PaymentOrderMutation) ClearPayURL() {
  28444. m.pay_url = nil
  28445. m.clearedFields[paymentorder.FieldPayURL] = struct{}{}
  28446. }
  28447. // PayURLCleared returns if the "pay_url" field was cleared in this mutation.
  28448. func (m *PaymentOrderMutation) PayURLCleared() bool {
  28449. _, ok := m.clearedFields[paymentorder.FieldPayURL]
  28450. return ok
  28451. }
  28452. // ResetPayURL resets all changes to the "pay_url" field.
  28453. func (m *PaymentOrderMutation) ResetPayURL() {
  28454. m.pay_url = nil
  28455. delete(m.clearedFields, paymentorder.FieldPayURL)
  28456. }
  28457. // SetQrCode sets the "qr_code" field.
  28458. func (m *PaymentOrderMutation) SetQrCode(s string) {
  28459. m.qr_code = &s
  28460. }
  28461. // QrCode returns the value of the "qr_code" field in the mutation.
  28462. func (m *PaymentOrderMutation) QrCode() (r string, exists bool) {
  28463. v := m.qr_code
  28464. if v == nil {
  28465. return
  28466. }
  28467. return *v, true
  28468. }
  28469. // OldQrCode returns the old "qr_code" field's value of the PaymentOrder entity.
  28470. // If the PaymentOrder object wasn't provided to the builder, the object is fetched from the database.
  28471. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28472. func (m *PaymentOrderMutation) OldQrCode(ctx context.Context) (v *string, err error) {
  28473. if !m.op.Is(OpUpdateOne) {
  28474. return v, errors.New("OldQrCode is only allowed on UpdateOne operations")
  28475. }
  28476. if m.id == nil || m.oldValue == nil {
  28477. return v, errors.New("OldQrCode requires an ID field in the mutation")
  28478. }
  28479. oldValue, err := m.oldValue(ctx)
  28480. if err != nil {
  28481. return v, fmt.Errorf("querying old value for OldQrCode: %w", err)
  28482. }
  28483. return oldValue.QrCode, nil
  28484. }
  28485. // ClearQrCode clears the value of the "qr_code" field.
  28486. func (m *PaymentOrderMutation) ClearQrCode() {
  28487. m.qr_code = nil
  28488. m.clearedFields[paymentorder.FieldQrCode] = struct{}{}
  28489. }
  28490. // QrCodeCleared returns if the "qr_code" field was cleared in this mutation.
  28491. func (m *PaymentOrderMutation) QrCodeCleared() bool {
  28492. _, ok := m.clearedFields[paymentorder.FieldQrCode]
  28493. return ok
  28494. }
  28495. // ResetQrCode resets all changes to the "qr_code" field.
  28496. func (m *PaymentOrderMutation) ResetQrCode() {
  28497. m.qr_code = nil
  28498. delete(m.clearedFields, paymentorder.FieldQrCode)
  28499. }
  28500. // SetQrCodeImg sets the "qr_code_img" field.
  28501. func (m *PaymentOrderMutation) SetQrCodeImg(s string) {
  28502. m.qr_code_img = &s
  28503. }
  28504. // QrCodeImg returns the value of the "qr_code_img" field in the mutation.
  28505. func (m *PaymentOrderMutation) QrCodeImg() (r string, exists bool) {
  28506. v := m.qr_code_img
  28507. if v == nil {
  28508. return
  28509. }
  28510. return *v, true
  28511. }
  28512. // OldQrCodeImg returns the old "qr_code_img" field's value of the PaymentOrder entity.
  28513. // If the PaymentOrder object wasn't provided to the builder, the object is fetched from the database.
  28514. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28515. func (m *PaymentOrderMutation) OldQrCodeImg(ctx context.Context) (v *string, err error) {
  28516. if !m.op.Is(OpUpdateOne) {
  28517. return v, errors.New("OldQrCodeImg is only allowed on UpdateOne operations")
  28518. }
  28519. if m.id == nil || m.oldValue == nil {
  28520. return v, errors.New("OldQrCodeImg requires an ID field in the mutation")
  28521. }
  28522. oldValue, err := m.oldValue(ctx)
  28523. if err != nil {
  28524. return v, fmt.Errorf("querying old value for OldQrCodeImg: %w", err)
  28525. }
  28526. return oldValue.QrCodeImg, nil
  28527. }
  28528. // ClearQrCodeImg clears the value of the "qr_code_img" field.
  28529. func (m *PaymentOrderMutation) ClearQrCodeImg() {
  28530. m.qr_code_img = nil
  28531. m.clearedFields[paymentorder.FieldQrCodeImg] = struct{}{}
  28532. }
  28533. // QrCodeImgCleared returns if the "qr_code_img" field was cleared in this mutation.
  28534. func (m *PaymentOrderMutation) QrCodeImgCleared() bool {
  28535. _, ok := m.clearedFields[paymentorder.FieldQrCodeImg]
  28536. return ok
  28537. }
  28538. // ResetQrCodeImg resets all changes to the "qr_code_img" field.
  28539. func (m *PaymentOrderMutation) ResetQrCodeImg() {
  28540. m.qr_code_img = nil
  28541. delete(m.clearedFields, paymentorder.FieldQrCodeImg)
  28542. }
  28543. // SetOrderType sets the "order_type" field.
  28544. func (m *PaymentOrderMutation) SetOrderType(s string) {
  28545. m.order_type = &s
  28546. }
  28547. // OrderType returns the value of the "order_type" field in the mutation.
  28548. func (m *PaymentOrderMutation) OrderType() (r string, exists bool) {
  28549. v := m.order_type
  28550. if v == nil {
  28551. return
  28552. }
  28553. return *v, true
  28554. }
  28555. // OldOrderType returns the old "order_type" field's value of the PaymentOrder entity.
  28556. // If the PaymentOrder object wasn't provided to the builder, the object is fetched from the database.
  28557. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28558. func (m *PaymentOrderMutation) OldOrderType(ctx context.Context) (v string, err error) {
  28559. if !m.op.Is(OpUpdateOne) {
  28560. return v, errors.New("OldOrderType is only allowed on UpdateOne operations")
  28561. }
  28562. if m.id == nil || m.oldValue == nil {
  28563. return v, errors.New("OldOrderType requires an ID field in the mutation")
  28564. }
  28565. oldValue, err := m.oldValue(ctx)
  28566. if err != nil {
  28567. return v, fmt.Errorf("querying old value for OldOrderType: %w", err)
  28568. }
  28569. return oldValue.OrderType, nil
  28570. }
  28571. // ResetOrderType resets all changes to the "order_type" field.
  28572. func (m *PaymentOrderMutation) ResetOrderType() {
  28573. m.order_type = nil
  28574. }
  28575. // SetPlanID sets the "plan_id" field.
  28576. func (m *PaymentOrderMutation) SetPlanID(i int64) {
  28577. m.plan_id = &i
  28578. m.addplan_id = nil
  28579. }
  28580. // PlanID returns the value of the "plan_id" field in the mutation.
  28581. func (m *PaymentOrderMutation) PlanID() (r int64, exists bool) {
  28582. v := m.plan_id
  28583. if v == nil {
  28584. return
  28585. }
  28586. return *v, true
  28587. }
  28588. // OldPlanID returns the old "plan_id" field's value of the PaymentOrder entity.
  28589. // If the PaymentOrder object wasn't provided to the builder, the object is fetched from the database.
  28590. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28591. func (m *PaymentOrderMutation) OldPlanID(ctx context.Context) (v *int64, err error) {
  28592. if !m.op.Is(OpUpdateOne) {
  28593. return v, errors.New("OldPlanID is only allowed on UpdateOne operations")
  28594. }
  28595. if m.id == nil || m.oldValue == nil {
  28596. return v, errors.New("OldPlanID requires an ID field in the mutation")
  28597. }
  28598. oldValue, err := m.oldValue(ctx)
  28599. if err != nil {
  28600. return v, fmt.Errorf("querying old value for OldPlanID: %w", err)
  28601. }
  28602. return oldValue.PlanID, nil
  28603. }
  28604. // AddPlanID adds i to the "plan_id" field.
  28605. func (m *PaymentOrderMutation) AddPlanID(i int64) {
  28606. if m.addplan_id != nil {
  28607. *m.addplan_id += i
  28608. } else {
  28609. m.addplan_id = &i
  28610. }
  28611. }
  28612. // AddedPlanID returns the value that was added to the "plan_id" field in this mutation.
  28613. func (m *PaymentOrderMutation) AddedPlanID() (r int64, exists bool) {
  28614. v := m.addplan_id
  28615. if v == nil {
  28616. return
  28617. }
  28618. return *v, true
  28619. }
  28620. // ClearPlanID clears the value of the "plan_id" field.
  28621. func (m *PaymentOrderMutation) ClearPlanID() {
  28622. m.plan_id = nil
  28623. m.addplan_id = nil
  28624. m.clearedFields[paymentorder.FieldPlanID] = struct{}{}
  28625. }
  28626. // PlanIDCleared returns if the "plan_id" field was cleared in this mutation.
  28627. func (m *PaymentOrderMutation) PlanIDCleared() bool {
  28628. _, ok := m.clearedFields[paymentorder.FieldPlanID]
  28629. return ok
  28630. }
  28631. // ResetPlanID resets all changes to the "plan_id" field.
  28632. func (m *PaymentOrderMutation) ResetPlanID() {
  28633. m.plan_id = nil
  28634. m.addplan_id = nil
  28635. delete(m.clearedFields, paymentorder.FieldPlanID)
  28636. }
  28637. // SetSubscriptionGroupID sets the "subscription_group_id" field.
  28638. func (m *PaymentOrderMutation) SetSubscriptionGroupID(i int64) {
  28639. m.subscription_group_id = &i
  28640. m.addsubscription_group_id = nil
  28641. }
  28642. // SubscriptionGroupID returns the value of the "subscription_group_id" field in the mutation.
  28643. func (m *PaymentOrderMutation) SubscriptionGroupID() (r int64, exists bool) {
  28644. v := m.subscription_group_id
  28645. if v == nil {
  28646. return
  28647. }
  28648. return *v, true
  28649. }
  28650. // OldSubscriptionGroupID returns the old "subscription_group_id" field's value of the PaymentOrder entity.
  28651. // If the PaymentOrder object wasn't provided to the builder, the object is fetched from the database.
  28652. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28653. func (m *PaymentOrderMutation) OldSubscriptionGroupID(ctx context.Context) (v *int64, err error) {
  28654. if !m.op.Is(OpUpdateOne) {
  28655. return v, errors.New("OldSubscriptionGroupID is only allowed on UpdateOne operations")
  28656. }
  28657. if m.id == nil || m.oldValue == nil {
  28658. return v, errors.New("OldSubscriptionGroupID requires an ID field in the mutation")
  28659. }
  28660. oldValue, err := m.oldValue(ctx)
  28661. if err != nil {
  28662. return v, fmt.Errorf("querying old value for OldSubscriptionGroupID: %w", err)
  28663. }
  28664. return oldValue.SubscriptionGroupID, nil
  28665. }
  28666. // AddSubscriptionGroupID adds i to the "subscription_group_id" field.
  28667. func (m *PaymentOrderMutation) AddSubscriptionGroupID(i int64) {
  28668. if m.addsubscription_group_id != nil {
  28669. *m.addsubscription_group_id += i
  28670. } else {
  28671. m.addsubscription_group_id = &i
  28672. }
  28673. }
  28674. // AddedSubscriptionGroupID returns the value that was added to the "subscription_group_id" field in this mutation.
  28675. func (m *PaymentOrderMutation) AddedSubscriptionGroupID() (r int64, exists bool) {
  28676. v := m.addsubscription_group_id
  28677. if v == nil {
  28678. return
  28679. }
  28680. return *v, true
  28681. }
  28682. // ClearSubscriptionGroupID clears the value of the "subscription_group_id" field.
  28683. func (m *PaymentOrderMutation) ClearSubscriptionGroupID() {
  28684. m.subscription_group_id = nil
  28685. m.addsubscription_group_id = nil
  28686. m.clearedFields[paymentorder.FieldSubscriptionGroupID] = struct{}{}
  28687. }
  28688. // SubscriptionGroupIDCleared returns if the "subscription_group_id" field was cleared in this mutation.
  28689. func (m *PaymentOrderMutation) SubscriptionGroupIDCleared() bool {
  28690. _, ok := m.clearedFields[paymentorder.FieldSubscriptionGroupID]
  28691. return ok
  28692. }
  28693. // ResetSubscriptionGroupID resets all changes to the "subscription_group_id" field.
  28694. func (m *PaymentOrderMutation) ResetSubscriptionGroupID() {
  28695. m.subscription_group_id = nil
  28696. m.addsubscription_group_id = nil
  28697. delete(m.clearedFields, paymentorder.FieldSubscriptionGroupID)
  28698. }
  28699. // SetSubscriptionDays sets the "subscription_days" field.
  28700. func (m *PaymentOrderMutation) SetSubscriptionDays(i int) {
  28701. m.subscription_days = &i
  28702. m.addsubscription_days = nil
  28703. }
  28704. // SubscriptionDays returns the value of the "subscription_days" field in the mutation.
  28705. func (m *PaymentOrderMutation) SubscriptionDays() (r int, exists bool) {
  28706. v := m.subscription_days
  28707. if v == nil {
  28708. return
  28709. }
  28710. return *v, true
  28711. }
  28712. // OldSubscriptionDays returns the old "subscription_days" field's value of the PaymentOrder entity.
  28713. // If the PaymentOrder object wasn't provided to the builder, the object is fetched from the database.
  28714. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28715. func (m *PaymentOrderMutation) OldSubscriptionDays(ctx context.Context) (v *int, err error) {
  28716. if !m.op.Is(OpUpdateOne) {
  28717. return v, errors.New("OldSubscriptionDays is only allowed on UpdateOne operations")
  28718. }
  28719. if m.id == nil || m.oldValue == nil {
  28720. return v, errors.New("OldSubscriptionDays requires an ID field in the mutation")
  28721. }
  28722. oldValue, err := m.oldValue(ctx)
  28723. if err != nil {
  28724. return v, fmt.Errorf("querying old value for OldSubscriptionDays: %w", err)
  28725. }
  28726. return oldValue.SubscriptionDays, nil
  28727. }
  28728. // AddSubscriptionDays adds i to the "subscription_days" field.
  28729. func (m *PaymentOrderMutation) AddSubscriptionDays(i int) {
  28730. if m.addsubscription_days != nil {
  28731. *m.addsubscription_days += i
  28732. } else {
  28733. m.addsubscription_days = &i
  28734. }
  28735. }
  28736. // AddedSubscriptionDays returns the value that was added to the "subscription_days" field in this mutation.
  28737. func (m *PaymentOrderMutation) AddedSubscriptionDays() (r int, exists bool) {
  28738. v := m.addsubscription_days
  28739. if v == nil {
  28740. return
  28741. }
  28742. return *v, true
  28743. }
  28744. // ClearSubscriptionDays clears the value of the "subscription_days" field.
  28745. func (m *PaymentOrderMutation) ClearSubscriptionDays() {
  28746. m.subscription_days = nil
  28747. m.addsubscription_days = nil
  28748. m.clearedFields[paymentorder.FieldSubscriptionDays] = struct{}{}
  28749. }
  28750. // SubscriptionDaysCleared returns if the "subscription_days" field was cleared in this mutation.
  28751. func (m *PaymentOrderMutation) SubscriptionDaysCleared() bool {
  28752. _, ok := m.clearedFields[paymentorder.FieldSubscriptionDays]
  28753. return ok
  28754. }
  28755. // ResetSubscriptionDays resets all changes to the "subscription_days" field.
  28756. func (m *PaymentOrderMutation) ResetSubscriptionDays() {
  28757. m.subscription_days = nil
  28758. m.addsubscription_days = nil
  28759. delete(m.clearedFields, paymentorder.FieldSubscriptionDays)
  28760. }
  28761. // SetProviderInstanceID sets the "provider_instance_id" field.
  28762. func (m *PaymentOrderMutation) SetProviderInstanceID(s string) {
  28763. m.provider_instance_id = &s
  28764. }
  28765. // ProviderInstanceID returns the value of the "provider_instance_id" field in the mutation.
  28766. func (m *PaymentOrderMutation) ProviderInstanceID() (r string, exists bool) {
  28767. v := m.provider_instance_id
  28768. if v == nil {
  28769. return
  28770. }
  28771. return *v, true
  28772. }
  28773. // OldProviderInstanceID returns the old "provider_instance_id" field's value of the PaymentOrder entity.
  28774. // If the PaymentOrder object wasn't provided to the builder, the object is fetched from the database.
  28775. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28776. func (m *PaymentOrderMutation) OldProviderInstanceID(ctx context.Context) (v *string, err error) {
  28777. if !m.op.Is(OpUpdateOne) {
  28778. return v, errors.New("OldProviderInstanceID is only allowed on UpdateOne operations")
  28779. }
  28780. if m.id == nil || m.oldValue == nil {
  28781. return v, errors.New("OldProviderInstanceID requires an ID field in the mutation")
  28782. }
  28783. oldValue, err := m.oldValue(ctx)
  28784. if err != nil {
  28785. return v, fmt.Errorf("querying old value for OldProviderInstanceID: %w", err)
  28786. }
  28787. return oldValue.ProviderInstanceID, nil
  28788. }
  28789. // ClearProviderInstanceID clears the value of the "provider_instance_id" field.
  28790. func (m *PaymentOrderMutation) ClearProviderInstanceID() {
  28791. m.provider_instance_id = nil
  28792. m.clearedFields[paymentorder.FieldProviderInstanceID] = struct{}{}
  28793. }
  28794. // ProviderInstanceIDCleared returns if the "provider_instance_id" field was cleared in this mutation.
  28795. func (m *PaymentOrderMutation) ProviderInstanceIDCleared() bool {
  28796. _, ok := m.clearedFields[paymentorder.FieldProviderInstanceID]
  28797. return ok
  28798. }
  28799. // ResetProviderInstanceID resets all changes to the "provider_instance_id" field.
  28800. func (m *PaymentOrderMutation) ResetProviderInstanceID() {
  28801. m.provider_instance_id = nil
  28802. delete(m.clearedFields, paymentorder.FieldProviderInstanceID)
  28803. }
  28804. // SetProviderKey sets the "provider_key" field.
  28805. func (m *PaymentOrderMutation) SetProviderKey(s string) {
  28806. m.provider_key = &s
  28807. }
  28808. // ProviderKey returns the value of the "provider_key" field in the mutation.
  28809. func (m *PaymentOrderMutation) ProviderKey() (r string, exists bool) {
  28810. v := m.provider_key
  28811. if v == nil {
  28812. return
  28813. }
  28814. return *v, true
  28815. }
  28816. // OldProviderKey returns the old "provider_key" field's value of the PaymentOrder entity.
  28817. // If the PaymentOrder object wasn't provided to the builder, the object is fetched from the database.
  28818. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28819. func (m *PaymentOrderMutation) OldProviderKey(ctx context.Context) (v *string, err error) {
  28820. if !m.op.Is(OpUpdateOne) {
  28821. return v, errors.New("OldProviderKey is only allowed on UpdateOne operations")
  28822. }
  28823. if m.id == nil || m.oldValue == nil {
  28824. return v, errors.New("OldProviderKey requires an ID field in the mutation")
  28825. }
  28826. oldValue, err := m.oldValue(ctx)
  28827. if err != nil {
  28828. return v, fmt.Errorf("querying old value for OldProviderKey: %w", err)
  28829. }
  28830. return oldValue.ProviderKey, nil
  28831. }
  28832. // ClearProviderKey clears the value of the "provider_key" field.
  28833. func (m *PaymentOrderMutation) ClearProviderKey() {
  28834. m.provider_key = nil
  28835. m.clearedFields[paymentorder.FieldProviderKey] = struct{}{}
  28836. }
  28837. // ProviderKeyCleared returns if the "provider_key" field was cleared in this mutation.
  28838. func (m *PaymentOrderMutation) ProviderKeyCleared() bool {
  28839. _, ok := m.clearedFields[paymentorder.FieldProviderKey]
  28840. return ok
  28841. }
  28842. // ResetProviderKey resets all changes to the "provider_key" field.
  28843. func (m *PaymentOrderMutation) ResetProviderKey() {
  28844. m.provider_key = nil
  28845. delete(m.clearedFields, paymentorder.FieldProviderKey)
  28846. }
  28847. // SetProviderSnapshot sets the "provider_snapshot" field.
  28848. func (m *PaymentOrderMutation) SetProviderSnapshot(value map[string]interface{}) {
  28849. m.provider_snapshot = &value
  28850. }
  28851. // ProviderSnapshot returns the value of the "provider_snapshot" field in the mutation.
  28852. func (m *PaymentOrderMutation) ProviderSnapshot() (r map[string]interface{}, exists bool) {
  28853. v := m.provider_snapshot
  28854. if v == nil {
  28855. return
  28856. }
  28857. return *v, true
  28858. }
  28859. // OldProviderSnapshot returns the old "provider_snapshot" field's value of the PaymentOrder entity.
  28860. // If the PaymentOrder object wasn't provided to the builder, the object is fetched from the database.
  28861. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28862. func (m *PaymentOrderMutation) OldProviderSnapshot(ctx context.Context) (v map[string]interface{}, err error) {
  28863. if !m.op.Is(OpUpdateOne) {
  28864. return v, errors.New("OldProviderSnapshot is only allowed on UpdateOne operations")
  28865. }
  28866. if m.id == nil || m.oldValue == nil {
  28867. return v, errors.New("OldProviderSnapshot requires an ID field in the mutation")
  28868. }
  28869. oldValue, err := m.oldValue(ctx)
  28870. if err != nil {
  28871. return v, fmt.Errorf("querying old value for OldProviderSnapshot: %w", err)
  28872. }
  28873. return oldValue.ProviderSnapshot, nil
  28874. }
  28875. // ClearProviderSnapshot clears the value of the "provider_snapshot" field.
  28876. func (m *PaymentOrderMutation) ClearProviderSnapshot() {
  28877. m.provider_snapshot = nil
  28878. m.clearedFields[paymentorder.FieldProviderSnapshot] = struct{}{}
  28879. }
  28880. // ProviderSnapshotCleared returns if the "provider_snapshot" field was cleared in this mutation.
  28881. func (m *PaymentOrderMutation) ProviderSnapshotCleared() bool {
  28882. _, ok := m.clearedFields[paymentorder.FieldProviderSnapshot]
  28883. return ok
  28884. }
  28885. // ResetProviderSnapshot resets all changes to the "provider_snapshot" field.
  28886. func (m *PaymentOrderMutation) ResetProviderSnapshot() {
  28887. m.provider_snapshot = nil
  28888. delete(m.clearedFields, paymentorder.FieldProviderSnapshot)
  28889. }
  28890. // SetStatus sets the "status" field.
  28891. func (m *PaymentOrderMutation) SetStatus(s string) {
  28892. m.status = &s
  28893. }
  28894. // Status returns the value of the "status" field in the mutation.
  28895. func (m *PaymentOrderMutation) Status() (r string, exists bool) {
  28896. v := m.status
  28897. if v == nil {
  28898. return
  28899. }
  28900. return *v, true
  28901. }
  28902. // OldStatus returns the old "status" field's value of the PaymentOrder entity.
  28903. // If the PaymentOrder object wasn't provided to the builder, the object is fetched from the database.
  28904. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28905. func (m *PaymentOrderMutation) OldStatus(ctx context.Context) (v string, err error) {
  28906. if !m.op.Is(OpUpdateOne) {
  28907. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  28908. }
  28909. if m.id == nil || m.oldValue == nil {
  28910. return v, errors.New("OldStatus requires an ID field in the mutation")
  28911. }
  28912. oldValue, err := m.oldValue(ctx)
  28913. if err != nil {
  28914. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  28915. }
  28916. return oldValue.Status, nil
  28917. }
  28918. // ResetStatus resets all changes to the "status" field.
  28919. func (m *PaymentOrderMutation) ResetStatus() {
  28920. m.status = nil
  28921. }
  28922. // SetRefundAmount sets the "refund_amount" field.
  28923. func (m *PaymentOrderMutation) SetRefundAmount(f float64) {
  28924. m.refund_amount = &f
  28925. m.addrefund_amount = nil
  28926. }
  28927. // RefundAmount returns the value of the "refund_amount" field in the mutation.
  28928. func (m *PaymentOrderMutation) RefundAmount() (r float64, exists bool) {
  28929. v := m.refund_amount
  28930. if v == nil {
  28931. return
  28932. }
  28933. return *v, true
  28934. }
  28935. // OldRefundAmount returns the old "refund_amount" field's value of the PaymentOrder entity.
  28936. // If the PaymentOrder object wasn't provided to the builder, the object is fetched from the database.
  28937. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28938. func (m *PaymentOrderMutation) OldRefundAmount(ctx context.Context) (v float64, err error) {
  28939. if !m.op.Is(OpUpdateOne) {
  28940. return v, errors.New("OldRefundAmount is only allowed on UpdateOne operations")
  28941. }
  28942. if m.id == nil || m.oldValue == nil {
  28943. return v, errors.New("OldRefundAmount requires an ID field in the mutation")
  28944. }
  28945. oldValue, err := m.oldValue(ctx)
  28946. if err != nil {
  28947. return v, fmt.Errorf("querying old value for OldRefundAmount: %w", err)
  28948. }
  28949. return oldValue.RefundAmount, nil
  28950. }
  28951. // AddRefundAmount adds f to the "refund_amount" field.
  28952. func (m *PaymentOrderMutation) AddRefundAmount(f float64) {
  28953. if m.addrefund_amount != nil {
  28954. *m.addrefund_amount += f
  28955. } else {
  28956. m.addrefund_amount = &f
  28957. }
  28958. }
  28959. // AddedRefundAmount returns the value that was added to the "refund_amount" field in this mutation.
  28960. func (m *PaymentOrderMutation) AddedRefundAmount() (r float64, exists bool) {
  28961. v := m.addrefund_amount
  28962. if v == nil {
  28963. return
  28964. }
  28965. return *v, true
  28966. }
  28967. // ResetRefundAmount resets all changes to the "refund_amount" field.
  28968. func (m *PaymentOrderMutation) ResetRefundAmount() {
  28969. m.refund_amount = nil
  28970. m.addrefund_amount = nil
  28971. }
  28972. // SetRefundReason sets the "refund_reason" field.
  28973. func (m *PaymentOrderMutation) SetRefundReason(s string) {
  28974. m.refund_reason = &s
  28975. }
  28976. // RefundReason returns the value of the "refund_reason" field in the mutation.
  28977. func (m *PaymentOrderMutation) RefundReason() (r string, exists bool) {
  28978. v := m.refund_reason
  28979. if v == nil {
  28980. return
  28981. }
  28982. return *v, true
  28983. }
  28984. // OldRefundReason returns the old "refund_reason" field's value of the PaymentOrder entity.
  28985. // If the PaymentOrder object wasn't provided to the builder, the object is fetched from the database.
  28986. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28987. func (m *PaymentOrderMutation) OldRefundReason(ctx context.Context) (v *string, err error) {
  28988. if !m.op.Is(OpUpdateOne) {
  28989. return v, errors.New("OldRefundReason is only allowed on UpdateOne operations")
  28990. }
  28991. if m.id == nil || m.oldValue == nil {
  28992. return v, errors.New("OldRefundReason requires an ID field in the mutation")
  28993. }
  28994. oldValue, err := m.oldValue(ctx)
  28995. if err != nil {
  28996. return v, fmt.Errorf("querying old value for OldRefundReason: %w", err)
  28997. }
  28998. return oldValue.RefundReason, nil
  28999. }
  29000. // ClearRefundReason clears the value of the "refund_reason" field.
  29001. func (m *PaymentOrderMutation) ClearRefundReason() {
  29002. m.refund_reason = nil
  29003. m.clearedFields[paymentorder.FieldRefundReason] = struct{}{}
  29004. }
  29005. // RefundReasonCleared returns if the "refund_reason" field was cleared in this mutation.
  29006. func (m *PaymentOrderMutation) RefundReasonCleared() bool {
  29007. _, ok := m.clearedFields[paymentorder.FieldRefundReason]
  29008. return ok
  29009. }
  29010. // ResetRefundReason resets all changes to the "refund_reason" field.
  29011. func (m *PaymentOrderMutation) ResetRefundReason() {
  29012. m.refund_reason = nil
  29013. delete(m.clearedFields, paymentorder.FieldRefundReason)
  29014. }
  29015. // SetRefundAt sets the "refund_at" field.
  29016. func (m *PaymentOrderMutation) SetRefundAt(t time.Time) {
  29017. m.refund_at = &t
  29018. }
  29019. // RefundAt returns the value of the "refund_at" field in the mutation.
  29020. func (m *PaymentOrderMutation) RefundAt() (r time.Time, exists bool) {
  29021. v := m.refund_at
  29022. if v == nil {
  29023. return
  29024. }
  29025. return *v, true
  29026. }
  29027. // OldRefundAt returns the old "refund_at" field's value of the PaymentOrder entity.
  29028. // If the PaymentOrder object wasn't provided to the builder, the object is fetched from the database.
  29029. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29030. func (m *PaymentOrderMutation) OldRefundAt(ctx context.Context) (v *time.Time, err error) {
  29031. if !m.op.Is(OpUpdateOne) {
  29032. return v, errors.New("OldRefundAt is only allowed on UpdateOne operations")
  29033. }
  29034. if m.id == nil || m.oldValue == nil {
  29035. return v, errors.New("OldRefundAt requires an ID field in the mutation")
  29036. }
  29037. oldValue, err := m.oldValue(ctx)
  29038. if err != nil {
  29039. return v, fmt.Errorf("querying old value for OldRefundAt: %w", err)
  29040. }
  29041. return oldValue.RefundAt, nil
  29042. }
  29043. // ClearRefundAt clears the value of the "refund_at" field.
  29044. func (m *PaymentOrderMutation) ClearRefundAt() {
  29045. m.refund_at = nil
  29046. m.clearedFields[paymentorder.FieldRefundAt] = struct{}{}
  29047. }
  29048. // RefundAtCleared returns if the "refund_at" field was cleared in this mutation.
  29049. func (m *PaymentOrderMutation) RefundAtCleared() bool {
  29050. _, ok := m.clearedFields[paymentorder.FieldRefundAt]
  29051. return ok
  29052. }
  29053. // ResetRefundAt resets all changes to the "refund_at" field.
  29054. func (m *PaymentOrderMutation) ResetRefundAt() {
  29055. m.refund_at = nil
  29056. delete(m.clearedFields, paymentorder.FieldRefundAt)
  29057. }
  29058. // SetForceRefund sets the "force_refund" field.
  29059. func (m *PaymentOrderMutation) SetForceRefund(b bool) {
  29060. m.force_refund = &b
  29061. }
  29062. // ForceRefund returns the value of the "force_refund" field in the mutation.
  29063. func (m *PaymentOrderMutation) ForceRefund() (r bool, exists bool) {
  29064. v := m.force_refund
  29065. if v == nil {
  29066. return
  29067. }
  29068. return *v, true
  29069. }
  29070. // OldForceRefund returns the old "force_refund" field's value of the PaymentOrder entity.
  29071. // If the PaymentOrder object wasn't provided to the builder, the object is fetched from the database.
  29072. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29073. func (m *PaymentOrderMutation) OldForceRefund(ctx context.Context) (v bool, err error) {
  29074. if !m.op.Is(OpUpdateOne) {
  29075. return v, errors.New("OldForceRefund is only allowed on UpdateOne operations")
  29076. }
  29077. if m.id == nil || m.oldValue == nil {
  29078. return v, errors.New("OldForceRefund requires an ID field in the mutation")
  29079. }
  29080. oldValue, err := m.oldValue(ctx)
  29081. if err != nil {
  29082. return v, fmt.Errorf("querying old value for OldForceRefund: %w", err)
  29083. }
  29084. return oldValue.ForceRefund, nil
  29085. }
  29086. // ResetForceRefund resets all changes to the "force_refund" field.
  29087. func (m *PaymentOrderMutation) ResetForceRefund() {
  29088. m.force_refund = nil
  29089. }
  29090. // SetRefundRequestedAt sets the "refund_requested_at" field.
  29091. func (m *PaymentOrderMutation) SetRefundRequestedAt(t time.Time) {
  29092. m.refund_requested_at = &t
  29093. }
  29094. // RefundRequestedAt returns the value of the "refund_requested_at" field in the mutation.
  29095. func (m *PaymentOrderMutation) RefundRequestedAt() (r time.Time, exists bool) {
  29096. v := m.refund_requested_at
  29097. if v == nil {
  29098. return
  29099. }
  29100. return *v, true
  29101. }
  29102. // OldRefundRequestedAt returns the old "refund_requested_at" field's value of the PaymentOrder entity.
  29103. // If the PaymentOrder object wasn't provided to the builder, the object is fetched from the database.
  29104. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29105. func (m *PaymentOrderMutation) OldRefundRequestedAt(ctx context.Context) (v *time.Time, err error) {
  29106. if !m.op.Is(OpUpdateOne) {
  29107. return v, errors.New("OldRefundRequestedAt is only allowed on UpdateOne operations")
  29108. }
  29109. if m.id == nil || m.oldValue == nil {
  29110. return v, errors.New("OldRefundRequestedAt requires an ID field in the mutation")
  29111. }
  29112. oldValue, err := m.oldValue(ctx)
  29113. if err != nil {
  29114. return v, fmt.Errorf("querying old value for OldRefundRequestedAt: %w", err)
  29115. }
  29116. return oldValue.RefundRequestedAt, nil
  29117. }
  29118. // ClearRefundRequestedAt clears the value of the "refund_requested_at" field.
  29119. func (m *PaymentOrderMutation) ClearRefundRequestedAt() {
  29120. m.refund_requested_at = nil
  29121. m.clearedFields[paymentorder.FieldRefundRequestedAt] = struct{}{}
  29122. }
  29123. // RefundRequestedAtCleared returns if the "refund_requested_at" field was cleared in this mutation.
  29124. func (m *PaymentOrderMutation) RefundRequestedAtCleared() bool {
  29125. _, ok := m.clearedFields[paymentorder.FieldRefundRequestedAt]
  29126. return ok
  29127. }
  29128. // ResetRefundRequestedAt resets all changes to the "refund_requested_at" field.
  29129. func (m *PaymentOrderMutation) ResetRefundRequestedAt() {
  29130. m.refund_requested_at = nil
  29131. delete(m.clearedFields, paymentorder.FieldRefundRequestedAt)
  29132. }
  29133. // SetRefundRequestReason sets the "refund_request_reason" field.
  29134. func (m *PaymentOrderMutation) SetRefundRequestReason(s string) {
  29135. m.refund_request_reason = &s
  29136. }
  29137. // RefundRequestReason returns the value of the "refund_request_reason" field in the mutation.
  29138. func (m *PaymentOrderMutation) RefundRequestReason() (r string, exists bool) {
  29139. v := m.refund_request_reason
  29140. if v == nil {
  29141. return
  29142. }
  29143. return *v, true
  29144. }
  29145. // OldRefundRequestReason returns the old "refund_request_reason" field's value of the PaymentOrder entity.
  29146. // If the PaymentOrder object wasn't provided to the builder, the object is fetched from the database.
  29147. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29148. func (m *PaymentOrderMutation) OldRefundRequestReason(ctx context.Context) (v *string, err error) {
  29149. if !m.op.Is(OpUpdateOne) {
  29150. return v, errors.New("OldRefundRequestReason is only allowed on UpdateOne operations")
  29151. }
  29152. if m.id == nil || m.oldValue == nil {
  29153. return v, errors.New("OldRefundRequestReason requires an ID field in the mutation")
  29154. }
  29155. oldValue, err := m.oldValue(ctx)
  29156. if err != nil {
  29157. return v, fmt.Errorf("querying old value for OldRefundRequestReason: %w", err)
  29158. }
  29159. return oldValue.RefundRequestReason, nil
  29160. }
  29161. // ClearRefundRequestReason clears the value of the "refund_request_reason" field.
  29162. func (m *PaymentOrderMutation) ClearRefundRequestReason() {
  29163. m.refund_request_reason = nil
  29164. m.clearedFields[paymentorder.FieldRefundRequestReason] = struct{}{}
  29165. }
  29166. // RefundRequestReasonCleared returns if the "refund_request_reason" field was cleared in this mutation.
  29167. func (m *PaymentOrderMutation) RefundRequestReasonCleared() bool {
  29168. _, ok := m.clearedFields[paymentorder.FieldRefundRequestReason]
  29169. return ok
  29170. }
  29171. // ResetRefundRequestReason resets all changes to the "refund_request_reason" field.
  29172. func (m *PaymentOrderMutation) ResetRefundRequestReason() {
  29173. m.refund_request_reason = nil
  29174. delete(m.clearedFields, paymentorder.FieldRefundRequestReason)
  29175. }
  29176. // SetRefundRequestedBy sets the "refund_requested_by" field.
  29177. func (m *PaymentOrderMutation) SetRefundRequestedBy(s string) {
  29178. m.refund_requested_by = &s
  29179. }
  29180. // RefundRequestedBy returns the value of the "refund_requested_by" field in the mutation.
  29181. func (m *PaymentOrderMutation) RefundRequestedBy() (r string, exists bool) {
  29182. v := m.refund_requested_by
  29183. if v == nil {
  29184. return
  29185. }
  29186. return *v, true
  29187. }
  29188. // OldRefundRequestedBy returns the old "refund_requested_by" field's value of the PaymentOrder entity.
  29189. // If the PaymentOrder object wasn't provided to the builder, the object is fetched from the database.
  29190. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29191. func (m *PaymentOrderMutation) OldRefundRequestedBy(ctx context.Context) (v *string, err error) {
  29192. if !m.op.Is(OpUpdateOne) {
  29193. return v, errors.New("OldRefundRequestedBy is only allowed on UpdateOne operations")
  29194. }
  29195. if m.id == nil || m.oldValue == nil {
  29196. return v, errors.New("OldRefundRequestedBy requires an ID field in the mutation")
  29197. }
  29198. oldValue, err := m.oldValue(ctx)
  29199. if err != nil {
  29200. return v, fmt.Errorf("querying old value for OldRefundRequestedBy: %w", err)
  29201. }
  29202. return oldValue.RefundRequestedBy, nil
  29203. }
  29204. // ClearRefundRequestedBy clears the value of the "refund_requested_by" field.
  29205. func (m *PaymentOrderMutation) ClearRefundRequestedBy() {
  29206. m.refund_requested_by = nil
  29207. m.clearedFields[paymentorder.FieldRefundRequestedBy] = struct{}{}
  29208. }
  29209. // RefundRequestedByCleared returns if the "refund_requested_by" field was cleared in this mutation.
  29210. func (m *PaymentOrderMutation) RefundRequestedByCleared() bool {
  29211. _, ok := m.clearedFields[paymentorder.FieldRefundRequestedBy]
  29212. return ok
  29213. }
  29214. // ResetRefundRequestedBy resets all changes to the "refund_requested_by" field.
  29215. func (m *PaymentOrderMutation) ResetRefundRequestedBy() {
  29216. m.refund_requested_by = nil
  29217. delete(m.clearedFields, paymentorder.FieldRefundRequestedBy)
  29218. }
  29219. // SetExpiresAt sets the "expires_at" field.
  29220. func (m *PaymentOrderMutation) SetExpiresAt(t time.Time) {
  29221. m.expires_at = &t
  29222. }
  29223. // ExpiresAt returns the value of the "expires_at" field in the mutation.
  29224. func (m *PaymentOrderMutation) ExpiresAt() (r time.Time, exists bool) {
  29225. v := m.expires_at
  29226. if v == nil {
  29227. return
  29228. }
  29229. return *v, true
  29230. }
  29231. // OldExpiresAt returns the old "expires_at" field's value of the PaymentOrder entity.
  29232. // If the PaymentOrder object wasn't provided to the builder, the object is fetched from the database.
  29233. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29234. func (m *PaymentOrderMutation) OldExpiresAt(ctx context.Context) (v time.Time, err error) {
  29235. if !m.op.Is(OpUpdateOne) {
  29236. return v, errors.New("OldExpiresAt is only allowed on UpdateOne operations")
  29237. }
  29238. if m.id == nil || m.oldValue == nil {
  29239. return v, errors.New("OldExpiresAt requires an ID field in the mutation")
  29240. }
  29241. oldValue, err := m.oldValue(ctx)
  29242. if err != nil {
  29243. return v, fmt.Errorf("querying old value for OldExpiresAt: %w", err)
  29244. }
  29245. return oldValue.ExpiresAt, nil
  29246. }
  29247. // ResetExpiresAt resets all changes to the "expires_at" field.
  29248. func (m *PaymentOrderMutation) ResetExpiresAt() {
  29249. m.expires_at = nil
  29250. }
  29251. // SetPaidAt sets the "paid_at" field.
  29252. func (m *PaymentOrderMutation) SetPaidAt(t time.Time) {
  29253. m.paid_at = &t
  29254. }
  29255. // PaidAt returns the value of the "paid_at" field in the mutation.
  29256. func (m *PaymentOrderMutation) PaidAt() (r time.Time, exists bool) {
  29257. v := m.paid_at
  29258. if v == nil {
  29259. return
  29260. }
  29261. return *v, true
  29262. }
  29263. // OldPaidAt returns the old "paid_at" field's value of the PaymentOrder entity.
  29264. // If the PaymentOrder object wasn't provided to the builder, the object is fetched from the database.
  29265. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29266. func (m *PaymentOrderMutation) OldPaidAt(ctx context.Context) (v *time.Time, err error) {
  29267. if !m.op.Is(OpUpdateOne) {
  29268. return v, errors.New("OldPaidAt is only allowed on UpdateOne operations")
  29269. }
  29270. if m.id == nil || m.oldValue == nil {
  29271. return v, errors.New("OldPaidAt requires an ID field in the mutation")
  29272. }
  29273. oldValue, err := m.oldValue(ctx)
  29274. if err != nil {
  29275. return v, fmt.Errorf("querying old value for OldPaidAt: %w", err)
  29276. }
  29277. return oldValue.PaidAt, nil
  29278. }
  29279. // ClearPaidAt clears the value of the "paid_at" field.
  29280. func (m *PaymentOrderMutation) ClearPaidAt() {
  29281. m.paid_at = nil
  29282. m.clearedFields[paymentorder.FieldPaidAt] = struct{}{}
  29283. }
  29284. // PaidAtCleared returns if the "paid_at" field was cleared in this mutation.
  29285. func (m *PaymentOrderMutation) PaidAtCleared() bool {
  29286. _, ok := m.clearedFields[paymentorder.FieldPaidAt]
  29287. return ok
  29288. }
  29289. // ResetPaidAt resets all changes to the "paid_at" field.
  29290. func (m *PaymentOrderMutation) ResetPaidAt() {
  29291. m.paid_at = nil
  29292. delete(m.clearedFields, paymentorder.FieldPaidAt)
  29293. }
  29294. // SetCompletedAt sets the "completed_at" field.
  29295. func (m *PaymentOrderMutation) SetCompletedAt(t time.Time) {
  29296. m.completed_at = &t
  29297. }
  29298. // CompletedAt returns the value of the "completed_at" field in the mutation.
  29299. func (m *PaymentOrderMutation) CompletedAt() (r time.Time, exists bool) {
  29300. v := m.completed_at
  29301. if v == nil {
  29302. return
  29303. }
  29304. return *v, true
  29305. }
  29306. // OldCompletedAt returns the old "completed_at" field's value of the PaymentOrder entity.
  29307. // If the PaymentOrder object wasn't provided to the builder, the object is fetched from the database.
  29308. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29309. func (m *PaymentOrderMutation) OldCompletedAt(ctx context.Context) (v *time.Time, err error) {
  29310. if !m.op.Is(OpUpdateOne) {
  29311. return v, errors.New("OldCompletedAt is only allowed on UpdateOne operations")
  29312. }
  29313. if m.id == nil || m.oldValue == nil {
  29314. return v, errors.New("OldCompletedAt requires an ID field in the mutation")
  29315. }
  29316. oldValue, err := m.oldValue(ctx)
  29317. if err != nil {
  29318. return v, fmt.Errorf("querying old value for OldCompletedAt: %w", err)
  29319. }
  29320. return oldValue.CompletedAt, nil
  29321. }
  29322. // ClearCompletedAt clears the value of the "completed_at" field.
  29323. func (m *PaymentOrderMutation) ClearCompletedAt() {
  29324. m.completed_at = nil
  29325. m.clearedFields[paymentorder.FieldCompletedAt] = struct{}{}
  29326. }
  29327. // CompletedAtCleared returns if the "completed_at" field was cleared in this mutation.
  29328. func (m *PaymentOrderMutation) CompletedAtCleared() bool {
  29329. _, ok := m.clearedFields[paymentorder.FieldCompletedAt]
  29330. return ok
  29331. }
  29332. // ResetCompletedAt resets all changes to the "completed_at" field.
  29333. func (m *PaymentOrderMutation) ResetCompletedAt() {
  29334. m.completed_at = nil
  29335. delete(m.clearedFields, paymentorder.FieldCompletedAt)
  29336. }
  29337. // SetFailedAt sets the "failed_at" field.
  29338. func (m *PaymentOrderMutation) SetFailedAt(t time.Time) {
  29339. m.failed_at = &t
  29340. }
  29341. // FailedAt returns the value of the "failed_at" field in the mutation.
  29342. func (m *PaymentOrderMutation) FailedAt() (r time.Time, exists bool) {
  29343. v := m.failed_at
  29344. if v == nil {
  29345. return
  29346. }
  29347. return *v, true
  29348. }
  29349. // OldFailedAt returns the old "failed_at" field's value of the PaymentOrder entity.
  29350. // If the PaymentOrder object wasn't provided to the builder, the object is fetched from the database.
  29351. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29352. func (m *PaymentOrderMutation) OldFailedAt(ctx context.Context) (v *time.Time, err error) {
  29353. if !m.op.Is(OpUpdateOne) {
  29354. return v, errors.New("OldFailedAt is only allowed on UpdateOne operations")
  29355. }
  29356. if m.id == nil || m.oldValue == nil {
  29357. return v, errors.New("OldFailedAt requires an ID field in the mutation")
  29358. }
  29359. oldValue, err := m.oldValue(ctx)
  29360. if err != nil {
  29361. return v, fmt.Errorf("querying old value for OldFailedAt: %w", err)
  29362. }
  29363. return oldValue.FailedAt, nil
  29364. }
  29365. // ClearFailedAt clears the value of the "failed_at" field.
  29366. func (m *PaymentOrderMutation) ClearFailedAt() {
  29367. m.failed_at = nil
  29368. m.clearedFields[paymentorder.FieldFailedAt] = struct{}{}
  29369. }
  29370. // FailedAtCleared returns if the "failed_at" field was cleared in this mutation.
  29371. func (m *PaymentOrderMutation) FailedAtCleared() bool {
  29372. _, ok := m.clearedFields[paymentorder.FieldFailedAt]
  29373. return ok
  29374. }
  29375. // ResetFailedAt resets all changes to the "failed_at" field.
  29376. func (m *PaymentOrderMutation) ResetFailedAt() {
  29377. m.failed_at = nil
  29378. delete(m.clearedFields, paymentorder.FieldFailedAt)
  29379. }
  29380. // SetFailedReason sets the "failed_reason" field.
  29381. func (m *PaymentOrderMutation) SetFailedReason(s string) {
  29382. m.failed_reason = &s
  29383. }
  29384. // FailedReason returns the value of the "failed_reason" field in the mutation.
  29385. func (m *PaymentOrderMutation) FailedReason() (r string, exists bool) {
  29386. v := m.failed_reason
  29387. if v == nil {
  29388. return
  29389. }
  29390. return *v, true
  29391. }
  29392. // OldFailedReason returns the old "failed_reason" field's value of the PaymentOrder entity.
  29393. // If the PaymentOrder object wasn't provided to the builder, the object is fetched from the database.
  29394. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29395. func (m *PaymentOrderMutation) OldFailedReason(ctx context.Context) (v *string, err error) {
  29396. if !m.op.Is(OpUpdateOne) {
  29397. return v, errors.New("OldFailedReason is only allowed on UpdateOne operations")
  29398. }
  29399. if m.id == nil || m.oldValue == nil {
  29400. return v, errors.New("OldFailedReason requires an ID field in the mutation")
  29401. }
  29402. oldValue, err := m.oldValue(ctx)
  29403. if err != nil {
  29404. return v, fmt.Errorf("querying old value for OldFailedReason: %w", err)
  29405. }
  29406. return oldValue.FailedReason, nil
  29407. }
  29408. // ClearFailedReason clears the value of the "failed_reason" field.
  29409. func (m *PaymentOrderMutation) ClearFailedReason() {
  29410. m.failed_reason = nil
  29411. m.clearedFields[paymentorder.FieldFailedReason] = struct{}{}
  29412. }
  29413. // FailedReasonCleared returns if the "failed_reason" field was cleared in this mutation.
  29414. func (m *PaymentOrderMutation) FailedReasonCleared() bool {
  29415. _, ok := m.clearedFields[paymentorder.FieldFailedReason]
  29416. return ok
  29417. }
  29418. // ResetFailedReason resets all changes to the "failed_reason" field.
  29419. func (m *PaymentOrderMutation) ResetFailedReason() {
  29420. m.failed_reason = nil
  29421. delete(m.clearedFields, paymentorder.FieldFailedReason)
  29422. }
  29423. // SetClientIP sets the "client_ip" field.
  29424. func (m *PaymentOrderMutation) SetClientIP(s string) {
  29425. m.client_ip = &s
  29426. }
  29427. // ClientIP returns the value of the "client_ip" field in the mutation.
  29428. func (m *PaymentOrderMutation) ClientIP() (r string, exists bool) {
  29429. v := m.client_ip
  29430. if v == nil {
  29431. return
  29432. }
  29433. return *v, true
  29434. }
  29435. // OldClientIP returns the old "client_ip" field's value of the PaymentOrder entity.
  29436. // If the PaymentOrder object wasn't provided to the builder, the object is fetched from the database.
  29437. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29438. func (m *PaymentOrderMutation) OldClientIP(ctx context.Context) (v string, err error) {
  29439. if !m.op.Is(OpUpdateOne) {
  29440. return v, errors.New("OldClientIP is only allowed on UpdateOne operations")
  29441. }
  29442. if m.id == nil || m.oldValue == nil {
  29443. return v, errors.New("OldClientIP requires an ID field in the mutation")
  29444. }
  29445. oldValue, err := m.oldValue(ctx)
  29446. if err != nil {
  29447. return v, fmt.Errorf("querying old value for OldClientIP: %w", err)
  29448. }
  29449. return oldValue.ClientIP, nil
  29450. }
  29451. // ResetClientIP resets all changes to the "client_ip" field.
  29452. func (m *PaymentOrderMutation) ResetClientIP() {
  29453. m.client_ip = nil
  29454. }
  29455. // SetSrcHost sets the "src_host" field.
  29456. func (m *PaymentOrderMutation) SetSrcHost(s string) {
  29457. m.src_host = &s
  29458. }
  29459. // SrcHost returns the value of the "src_host" field in the mutation.
  29460. func (m *PaymentOrderMutation) SrcHost() (r string, exists bool) {
  29461. v := m.src_host
  29462. if v == nil {
  29463. return
  29464. }
  29465. return *v, true
  29466. }
  29467. // OldSrcHost returns the old "src_host" field's value of the PaymentOrder entity.
  29468. // If the PaymentOrder object wasn't provided to the builder, the object is fetched from the database.
  29469. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29470. func (m *PaymentOrderMutation) OldSrcHost(ctx context.Context) (v string, err error) {
  29471. if !m.op.Is(OpUpdateOne) {
  29472. return v, errors.New("OldSrcHost is only allowed on UpdateOne operations")
  29473. }
  29474. if m.id == nil || m.oldValue == nil {
  29475. return v, errors.New("OldSrcHost requires an ID field in the mutation")
  29476. }
  29477. oldValue, err := m.oldValue(ctx)
  29478. if err != nil {
  29479. return v, fmt.Errorf("querying old value for OldSrcHost: %w", err)
  29480. }
  29481. return oldValue.SrcHost, nil
  29482. }
  29483. // ResetSrcHost resets all changes to the "src_host" field.
  29484. func (m *PaymentOrderMutation) ResetSrcHost() {
  29485. m.src_host = nil
  29486. }
  29487. // SetSrcURL sets the "src_url" field.
  29488. func (m *PaymentOrderMutation) SetSrcURL(s string) {
  29489. m.src_url = &s
  29490. }
  29491. // SrcURL returns the value of the "src_url" field in the mutation.
  29492. func (m *PaymentOrderMutation) SrcURL() (r string, exists bool) {
  29493. v := m.src_url
  29494. if v == nil {
  29495. return
  29496. }
  29497. return *v, true
  29498. }
  29499. // OldSrcURL returns the old "src_url" field's value of the PaymentOrder entity.
  29500. // If the PaymentOrder object wasn't provided to the builder, the object is fetched from the database.
  29501. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29502. func (m *PaymentOrderMutation) OldSrcURL(ctx context.Context) (v *string, err error) {
  29503. if !m.op.Is(OpUpdateOne) {
  29504. return v, errors.New("OldSrcURL is only allowed on UpdateOne operations")
  29505. }
  29506. if m.id == nil || m.oldValue == nil {
  29507. return v, errors.New("OldSrcURL requires an ID field in the mutation")
  29508. }
  29509. oldValue, err := m.oldValue(ctx)
  29510. if err != nil {
  29511. return v, fmt.Errorf("querying old value for OldSrcURL: %w", err)
  29512. }
  29513. return oldValue.SrcURL, nil
  29514. }
  29515. // ClearSrcURL clears the value of the "src_url" field.
  29516. func (m *PaymentOrderMutation) ClearSrcURL() {
  29517. m.src_url = nil
  29518. m.clearedFields[paymentorder.FieldSrcURL] = struct{}{}
  29519. }
  29520. // SrcURLCleared returns if the "src_url" field was cleared in this mutation.
  29521. func (m *PaymentOrderMutation) SrcURLCleared() bool {
  29522. _, ok := m.clearedFields[paymentorder.FieldSrcURL]
  29523. return ok
  29524. }
  29525. // ResetSrcURL resets all changes to the "src_url" field.
  29526. func (m *PaymentOrderMutation) ResetSrcURL() {
  29527. m.src_url = nil
  29528. delete(m.clearedFields, paymentorder.FieldSrcURL)
  29529. }
  29530. // SetCreatedAt sets the "created_at" field.
  29531. func (m *PaymentOrderMutation) SetCreatedAt(t time.Time) {
  29532. m.created_at = &t
  29533. }
  29534. // CreatedAt returns the value of the "created_at" field in the mutation.
  29535. func (m *PaymentOrderMutation) CreatedAt() (r time.Time, exists bool) {
  29536. v := m.created_at
  29537. if v == nil {
  29538. return
  29539. }
  29540. return *v, true
  29541. }
  29542. // OldCreatedAt returns the old "created_at" field's value of the PaymentOrder entity.
  29543. // If the PaymentOrder object wasn't provided to the builder, the object is fetched from the database.
  29544. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29545. func (m *PaymentOrderMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  29546. if !m.op.Is(OpUpdateOne) {
  29547. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  29548. }
  29549. if m.id == nil || m.oldValue == nil {
  29550. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  29551. }
  29552. oldValue, err := m.oldValue(ctx)
  29553. if err != nil {
  29554. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  29555. }
  29556. return oldValue.CreatedAt, nil
  29557. }
  29558. // ResetCreatedAt resets all changes to the "created_at" field.
  29559. func (m *PaymentOrderMutation) ResetCreatedAt() {
  29560. m.created_at = nil
  29561. }
  29562. // SetUpdatedAt sets the "updated_at" field.
  29563. func (m *PaymentOrderMutation) SetUpdatedAt(t time.Time) {
  29564. m.updated_at = &t
  29565. }
  29566. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  29567. func (m *PaymentOrderMutation) UpdatedAt() (r time.Time, exists bool) {
  29568. v := m.updated_at
  29569. if v == nil {
  29570. return
  29571. }
  29572. return *v, true
  29573. }
  29574. // OldUpdatedAt returns the old "updated_at" field's value of the PaymentOrder entity.
  29575. // If the PaymentOrder object wasn't provided to the builder, the object is fetched from the database.
  29576. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29577. func (m *PaymentOrderMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  29578. if !m.op.Is(OpUpdateOne) {
  29579. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  29580. }
  29581. if m.id == nil || m.oldValue == nil {
  29582. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  29583. }
  29584. oldValue, err := m.oldValue(ctx)
  29585. if err != nil {
  29586. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  29587. }
  29588. return oldValue.UpdatedAt, nil
  29589. }
  29590. // ResetUpdatedAt resets all changes to the "updated_at" field.
  29591. func (m *PaymentOrderMutation) ResetUpdatedAt() {
  29592. m.updated_at = nil
  29593. }
  29594. // ClearUser clears the "user" edge to the User entity.
  29595. func (m *PaymentOrderMutation) ClearUser() {
  29596. m.cleareduser = true
  29597. m.clearedFields[paymentorder.FieldUserID] = struct{}{}
  29598. }
  29599. // UserCleared reports if the "user" edge to the User entity was cleared.
  29600. func (m *PaymentOrderMutation) UserCleared() bool {
  29601. return m.cleareduser
  29602. }
  29603. // UserIDs returns the "user" edge IDs in the mutation.
  29604. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  29605. // UserID instead. It exists only for internal usage by the builders.
  29606. func (m *PaymentOrderMutation) UserIDs() (ids []int64) {
  29607. if id := m.user; id != nil {
  29608. ids = append(ids, *id)
  29609. }
  29610. return
  29611. }
  29612. // ResetUser resets all changes to the "user" edge.
  29613. func (m *PaymentOrderMutation) ResetUser() {
  29614. m.user = nil
  29615. m.cleareduser = false
  29616. }
  29617. // Where appends a list predicates to the PaymentOrderMutation builder.
  29618. func (m *PaymentOrderMutation) Where(ps ...predicate.PaymentOrder) {
  29619. m.predicates = append(m.predicates, ps...)
  29620. }
  29621. // WhereP appends storage-level predicates to the PaymentOrderMutation builder. Using this method,
  29622. // users can use type-assertion to append predicates that do not depend on any generated package.
  29623. func (m *PaymentOrderMutation) WhereP(ps ...func(*sql.Selector)) {
  29624. p := make([]predicate.PaymentOrder, len(ps))
  29625. for i := range ps {
  29626. p[i] = ps[i]
  29627. }
  29628. m.Where(p...)
  29629. }
  29630. // Op returns the operation name.
  29631. func (m *PaymentOrderMutation) Op() Op {
  29632. return m.op
  29633. }
  29634. // SetOp allows setting the mutation operation.
  29635. func (m *PaymentOrderMutation) SetOp(op Op) {
  29636. m.op = op
  29637. }
  29638. // Type returns the node type of this mutation (PaymentOrder).
  29639. func (m *PaymentOrderMutation) Type() string {
  29640. return m.typ
  29641. }
  29642. // Fields returns all fields that were changed during this mutation. Note that in
  29643. // order to get all numeric fields that were incremented/decremented, call
  29644. // AddedFields().
  29645. func (m *PaymentOrderMutation) Fields() []string {
  29646. fields := make([]string, 0, 39)
  29647. if m.user != nil {
  29648. fields = append(fields, paymentorder.FieldUserID)
  29649. }
  29650. if m.user_email != nil {
  29651. fields = append(fields, paymentorder.FieldUserEmail)
  29652. }
  29653. if m.user_name != nil {
  29654. fields = append(fields, paymentorder.FieldUserName)
  29655. }
  29656. if m.user_notes != nil {
  29657. fields = append(fields, paymentorder.FieldUserNotes)
  29658. }
  29659. if m.amount != nil {
  29660. fields = append(fields, paymentorder.FieldAmount)
  29661. }
  29662. if m.pay_amount != nil {
  29663. fields = append(fields, paymentorder.FieldPayAmount)
  29664. }
  29665. if m.fee_rate != nil {
  29666. fields = append(fields, paymentorder.FieldFeeRate)
  29667. }
  29668. if m.recharge_code != nil {
  29669. fields = append(fields, paymentorder.FieldRechargeCode)
  29670. }
  29671. if m.out_trade_no != nil {
  29672. fields = append(fields, paymentorder.FieldOutTradeNo)
  29673. }
  29674. if m.payment_type != nil {
  29675. fields = append(fields, paymentorder.FieldPaymentType)
  29676. }
  29677. if m.payment_trade_no != nil {
  29678. fields = append(fields, paymentorder.FieldPaymentTradeNo)
  29679. }
  29680. if m.pay_url != nil {
  29681. fields = append(fields, paymentorder.FieldPayURL)
  29682. }
  29683. if m.qr_code != nil {
  29684. fields = append(fields, paymentorder.FieldQrCode)
  29685. }
  29686. if m.qr_code_img != nil {
  29687. fields = append(fields, paymentorder.FieldQrCodeImg)
  29688. }
  29689. if m.order_type != nil {
  29690. fields = append(fields, paymentorder.FieldOrderType)
  29691. }
  29692. if m.plan_id != nil {
  29693. fields = append(fields, paymentorder.FieldPlanID)
  29694. }
  29695. if m.subscription_group_id != nil {
  29696. fields = append(fields, paymentorder.FieldSubscriptionGroupID)
  29697. }
  29698. if m.subscription_days != nil {
  29699. fields = append(fields, paymentorder.FieldSubscriptionDays)
  29700. }
  29701. if m.provider_instance_id != nil {
  29702. fields = append(fields, paymentorder.FieldProviderInstanceID)
  29703. }
  29704. if m.provider_key != nil {
  29705. fields = append(fields, paymentorder.FieldProviderKey)
  29706. }
  29707. if m.provider_snapshot != nil {
  29708. fields = append(fields, paymentorder.FieldProviderSnapshot)
  29709. }
  29710. if m.status != nil {
  29711. fields = append(fields, paymentorder.FieldStatus)
  29712. }
  29713. if m.refund_amount != nil {
  29714. fields = append(fields, paymentorder.FieldRefundAmount)
  29715. }
  29716. if m.refund_reason != nil {
  29717. fields = append(fields, paymentorder.FieldRefundReason)
  29718. }
  29719. if m.refund_at != nil {
  29720. fields = append(fields, paymentorder.FieldRefundAt)
  29721. }
  29722. if m.force_refund != nil {
  29723. fields = append(fields, paymentorder.FieldForceRefund)
  29724. }
  29725. if m.refund_requested_at != nil {
  29726. fields = append(fields, paymentorder.FieldRefundRequestedAt)
  29727. }
  29728. if m.refund_request_reason != nil {
  29729. fields = append(fields, paymentorder.FieldRefundRequestReason)
  29730. }
  29731. if m.refund_requested_by != nil {
  29732. fields = append(fields, paymentorder.FieldRefundRequestedBy)
  29733. }
  29734. if m.expires_at != nil {
  29735. fields = append(fields, paymentorder.FieldExpiresAt)
  29736. }
  29737. if m.paid_at != nil {
  29738. fields = append(fields, paymentorder.FieldPaidAt)
  29739. }
  29740. if m.completed_at != nil {
  29741. fields = append(fields, paymentorder.FieldCompletedAt)
  29742. }
  29743. if m.failed_at != nil {
  29744. fields = append(fields, paymentorder.FieldFailedAt)
  29745. }
  29746. if m.failed_reason != nil {
  29747. fields = append(fields, paymentorder.FieldFailedReason)
  29748. }
  29749. if m.client_ip != nil {
  29750. fields = append(fields, paymentorder.FieldClientIP)
  29751. }
  29752. if m.src_host != nil {
  29753. fields = append(fields, paymentorder.FieldSrcHost)
  29754. }
  29755. if m.src_url != nil {
  29756. fields = append(fields, paymentorder.FieldSrcURL)
  29757. }
  29758. if m.created_at != nil {
  29759. fields = append(fields, paymentorder.FieldCreatedAt)
  29760. }
  29761. if m.updated_at != nil {
  29762. fields = append(fields, paymentorder.FieldUpdatedAt)
  29763. }
  29764. return fields
  29765. }
  29766. // Field returns the value of a field with the given name. The second boolean
  29767. // return value indicates that this field was not set, or was not defined in the
  29768. // schema.
  29769. func (m *PaymentOrderMutation) Field(name string) (ent.Value, bool) {
  29770. switch name {
  29771. case paymentorder.FieldUserID:
  29772. return m.UserID()
  29773. case paymentorder.FieldUserEmail:
  29774. return m.UserEmail()
  29775. case paymentorder.FieldUserName:
  29776. return m.UserName()
  29777. case paymentorder.FieldUserNotes:
  29778. return m.UserNotes()
  29779. case paymentorder.FieldAmount:
  29780. return m.Amount()
  29781. case paymentorder.FieldPayAmount:
  29782. return m.PayAmount()
  29783. case paymentorder.FieldFeeRate:
  29784. return m.FeeRate()
  29785. case paymentorder.FieldRechargeCode:
  29786. return m.RechargeCode()
  29787. case paymentorder.FieldOutTradeNo:
  29788. return m.OutTradeNo()
  29789. case paymentorder.FieldPaymentType:
  29790. return m.PaymentType()
  29791. case paymentorder.FieldPaymentTradeNo:
  29792. return m.PaymentTradeNo()
  29793. case paymentorder.FieldPayURL:
  29794. return m.PayURL()
  29795. case paymentorder.FieldQrCode:
  29796. return m.QrCode()
  29797. case paymentorder.FieldQrCodeImg:
  29798. return m.QrCodeImg()
  29799. case paymentorder.FieldOrderType:
  29800. return m.OrderType()
  29801. case paymentorder.FieldPlanID:
  29802. return m.PlanID()
  29803. case paymentorder.FieldSubscriptionGroupID:
  29804. return m.SubscriptionGroupID()
  29805. case paymentorder.FieldSubscriptionDays:
  29806. return m.SubscriptionDays()
  29807. case paymentorder.FieldProviderInstanceID:
  29808. return m.ProviderInstanceID()
  29809. case paymentorder.FieldProviderKey:
  29810. return m.ProviderKey()
  29811. case paymentorder.FieldProviderSnapshot:
  29812. return m.ProviderSnapshot()
  29813. case paymentorder.FieldStatus:
  29814. return m.Status()
  29815. case paymentorder.FieldRefundAmount:
  29816. return m.RefundAmount()
  29817. case paymentorder.FieldRefundReason:
  29818. return m.RefundReason()
  29819. case paymentorder.FieldRefundAt:
  29820. return m.RefundAt()
  29821. case paymentorder.FieldForceRefund:
  29822. return m.ForceRefund()
  29823. case paymentorder.FieldRefundRequestedAt:
  29824. return m.RefundRequestedAt()
  29825. case paymentorder.FieldRefundRequestReason:
  29826. return m.RefundRequestReason()
  29827. case paymentorder.FieldRefundRequestedBy:
  29828. return m.RefundRequestedBy()
  29829. case paymentorder.FieldExpiresAt:
  29830. return m.ExpiresAt()
  29831. case paymentorder.FieldPaidAt:
  29832. return m.PaidAt()
  29833. case paymentorder.FieldCompletedAt:
  29834. return m.CompletedAt()
  29835. case paymentorder.FieldFailedAt:
  29836. return m.FailedAt()
  29837. case paymentorder.FieldFailedReason:
  29838. return m.FailedReason()
  29839. case paymentorder.FieldClientIP:
  29840. return m.ClientIP()
  29841. case paymentorder.FieldSrcHost:
  29842. return m.SrcHost()
  29843. case paymentorder.FieldSrcURL:
  29844. return m.SrcURL()
  29845. case paymentorder.FieldCreatedAt:
  29846. return m.CreatedAt()
  29847. case paymentorder.FieldUpdatedAt:
  29848. return m.UpdatedAt()
  29849. }
  29850. return nil, false
  29851. }
  29852. // OldField returns the old value of the field from the database. An error is
  29853. // returned if the mutation operation is not UpdateOne, or the query to the
  29854. // database failed.
  29855. func (m *PaymentOrderMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  29856. switch name {
  29857. case paymentorder.FieldUserID:
  29858. return m.OldUserID(ctx)
  29859. case paymentorder.FieldUserEmail:
  29860. return m.OldUserEmail(ctx)
  29861. case paymentorder.FieldUserName:
  29862. return m.OldUserName(ctx)
  29863. case paymentorder.FieldUserNotes:
  29864. return m.OldUserNotes(ctx)
  29865. case paymentorder.FieldAmount:
  29866. return m.OldAmount(ctx)
  29867. case paymentorder.FieldPayAmount:
  29868. return m.OldPayAmount(ctx)
  29869. case paymentorder.FieldFeeRate:
  29870. return m.OldFeeRate(ctx)
  29871. case paymentorder.FieldRechargeCode:
  29872. return m.OldRechargeCode(ctx)
  29873. case paymentorder.FieldOutTradeNo:
  29874. return m.OldOutTradeNo(ctx)
  29875. case paymentorder.FieldPaymentType:
  29876. return m.OldPaymentType(ctx)
  29877. case paymentorder.FieldPaymentTradeNo:
  29878. return m.OldPaymentTradeNo(ctx)
  29879. case paymentorder.FieldPayURL:
  29880. return m.OldPayURL(ctx)
  29881. case paymentorder.FieldQrCode:
  29882. return m.OldQrCode(ctx)
  29883. case paymentorder.FieldQrCodeImg:
  29884. return m.OldQrCodeImg(ctx)
  29885. case paymentorder.FieldOrderType:
  29886. return m.OldOrderType(ctx)
  29887. case paymentorder.FieldPlanID:
  29888. return m.OldPlanID(ctx)
  29889. case paymentorder.FieldSubscriptionGroupID:
  29890. return m.OldSubscriptionGroupID(ctx)
  29891. case paymentorder.FieldSubscriptionDays:
  29892. return m.OldSubscriptionDays(ctx)
  29893. case paymentorder.FieldProviderInstanceID:
  29894. return m.OldProviderInstanceID(ctx)
  29895. case paymentorder.FieldProviderKey:
  29896. return m.OldProviderKey(ctx)
  29897. case paymentorder.FieldProviderSnapshot:
  29898. return m.OldProviderSnapshot(ctx)
  29899. case paymentorder.FieldStatus:
  29900. return m.OldStatus(ctx)
  29901. case paymentorder.FieldRefundAmount:
  29902. return m.OldRefundAmount(ctx)
  29903. case paymentorder.FieldRefundReason:
  29904. return m.OldRefundReason(ctx)
  29905. case paymentorder.FieldRefundAt:
  29906. return m.OldRefundAt(ctx)
  29907. case paymentorder.FieldForceRefund:
  29908. return m.OldForceRefund(ctx)
  29909. case paymentorder.FieldRefundRequestedAt:
  29910. return m.OldRefundRequestedAt(ctx)
  29911. case paymentorder.FieldRefundRequestReason:
  29912. return m.OldRefundRequestReason(ctx)
  29913. case paymentorder.FieldRefundRequestedBy:
  29914. return m.OldRefundRequestedBy(ctx)
  29915. case paymentorder.FieldExpiresAt:
  29916. return m.OldExpiresAt(ctx)
  29917. case paymentorder.FieldPaidAt:
  29918. return m.OldPaidAt(ctx)
  29919. case paymentorder.FieldCompletedAt:
  29920. return m.OldCompletedAt(ctx)
  29921. case paymentorder.FieldFailedAt:
  29922. return m.OldFailedAt(ctx)
  29923. case paymentorder.FieldFailedReason:
  29924. return m.OldFailedReason(ctx)
  29925. case paymentorder.FieldClientIP:
  29926. return m.OldClientIP(ctx)
  29927. case paymentorder.FieldSrcHost:
  29928. return m.OldSrcHost(ctx)
  29929. case paymentorder.FieldSrcURL:
  29930. return m.OldSrcURL(ctx)
  29931. case paymentorder.FieldCreatedAt:
  29932. return m.OldCreatedAt(ctx)
  29933. case paymentorder.FieldUpdatedAt:
  29934. return m.OldUpdatedAt(ctx)
  29935. }
  29936. return nil, fmt.Errorf("unknown PaymentOrder field %s", name)
  29937. }
  29938. // SetField sets the value of a field with the given name. It returns an error if
  29939. // the field is not defined in the schema, or if the type mismatched the field
  29940. // type.
  29941. func (m *PaymentOrderMutation) SetField(name string, value ent.Value) error {
  29942. switch name {
  29943. case paymentorder.FieldUserID:
  29944. v, ok := value.(int64)
  29945. if !ok {
  29946. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29947. }
  29948. m.SetUserID(v)
  29949. return nil
  29950. case paymentorder.FieldUserEmail:
  29951. v, ok := value.(string)
  29952. if !ok {
  29953. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29954. }
  29955. m.SetUserEmail(v)
  29956. return nil
  29957. case paymentorder.FieldUserName:
  29958. v, ok := value.(string)
  29959. if !ok {
  29960. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29961. }
  29962. m.SetUserName(v)
  29963. return nil
  29964. case paymentorder.FieldUserNotes:
  29965. v, ok := value.(string)
  29966. if !ok {
  29967. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29968. }
  29969. m.SetUserNotes(v)
  29970. return nil
  29971. case paymentorder.FieldAmount:
  29972. v, ok := value.(float64)
  29973. if !ok {
  29974. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29975. }
  29976. m.SetAmount(v)
  29977. return nil
  29978. case paymentorder.FieldPayAmount:
  29979. v, ok := value.(float64)
  29980. if !ok {
  29981. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29982. }
  29983. m.SetPayAmount(v)
  29984. return nil
  29985. case paymentorder.FieldFeeRate:
  29986. v, ok := value.(float64)
  29987. if !ok {
  29988. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29989. }
  29990. m.SetFeeRate(v)
  29991. return nil
  29992. case paymentorder.FieldRechargeCode:
  29993. v, ok := value.(string)
  29994. if !ok {
  29995. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29996. }
  29997. m.SetRechargeCode(v)
  29998. return nil
  29999. case paymentorder.FieldOutTradeNo:
  30000. v, ok := value.(string)
  30001. if !ok {
  30002. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30003. }
  30004. m.SetOutTradeNo(v)
  30005. return nil
  30006. case paymentorder.FieldPaymentType:
  30007. v, ok := value.(string)
  30008. if !ok {
  30009. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30010. }
  30011. m.SetPaymentType(v)
  30012. return nil
  30013. case paymentorder.FieldPaymentTradeNo:
  30014. v, ok := value.(string)
  30015. if !ok {
  30016. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30017. }
  30018. m.SetPaymentTradeNo(v)
  30019. return nil
  30020. case paymentorder.FieldPayURL:
  30021. v, ok := value.(string)
  30022. if !ok {
  30023. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30024. }
  30025. m.SetPayURL(v)
  30026. return nil
  30027. case paymentorder.FieldQrCode:
  30028. v, ok := value.(string)
  30029. if !ok {
  30030. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30031. }
  30032. m.SetQrCode(v)
  30033. return nil
  30034. case paymentorder.FieldQrCodeImg:
  30035. v, ok := value.(string)
  30036. if !ok {
  30037. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30038. }
  30039. m.SetQrCodeImg(v)
  30040. return nil
  30041. case paymentorder.FieldOrderType:
  30042. v, ok := value.(string)
  30043. if !ok {
  30044. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30045. }
  30046. m.SetOrderType(v)
  30047. return nil
  30048. case paymentorder.FieldPlanID:
  30049. v, ok := value.(int64)
  30050. if !ok {
  30051. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30052. }
  30053. m.SetPlanID(v)
  30054. return nil
  30055. case paymentorder.FieldSubscriptionGroupID:
  30056. v, ok := value.(int64)
  30057. if !ok {
  30058. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30059. }
  30060. m.SetSubscriptionGroupID(v)
  30061. return nil
  30062. case paymentorder.FieldSubscriptionDays:
  30063. v, ok := value.(int)
  30064. if !ok {
  30065. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30066. }
  30067. m.SetSubscriptionDays(v)
  30068. return nil
  30069. case paymentorder.FieldProviderInstanceID:
  30070. v, ok := value.(string)
  30071. if !ok {
  30072. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30073. }
  30074. m.SetProviderInstanceID(v)
  30075. return nil
  30076. case paymentorder.FieldProviderKey:
  30077. v, ok := value.(string)
  30078. if !ok {
  30079. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30080. }
  30081. m.SetProviderKey(v)
  30082. return nil
  30083. case paymentorder.FieldProviderSnapshot:
  30084. v, ok := value.(map[string]interface{})
  30085. if !ok {
  30086. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30087. }
  30088. m.SetProviderSnapshot(v)
  30089. return nil
  30090. case paymentorder.FieldStatus:
  30091. v, ok := value.(string)
  30092. if !ok {
  30093. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30094. }
  30095. m.SetStatus(v)
  30096. return nil
  30097. case paymentorder.FieldRefundAmount:
  30098. v, ok := value.(float64)
  30099. if !ok {
  30100. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30101. }
  30102. m.SetRefundAmount(v)
  30103. return nil
  30104. case paymentorder.FieldRefundReason:
  30105. v, ok := value.(string)
  30106. if !ok {
  30107. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30108. }
  30109. m.SetRefundReason(v)
  30110. return nil
  30111. case paymentorder.FieldRefundAt:
  30112. v, ok := value.(time.Time)
  30113. if !ok {
  30114. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30115. }
  30116. m.SetRefundAt(v)
  30117. return nil
  30118. case paymentorder.FieldForceRefund:
  30119. v, ok := value.(bool)
  30120. if !ok {
  30121. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30122. }
  30123. m.SetForceRefund(v)
  30124. return nil
  30125. case paymentorder.FieldRefundRequestedAt:
  30126. v, ok := value.(time.Time)
  30127. if !ok {
  30128. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30129. }
  30130. m.SetRefundRequestedAt(v)
  30131. return nil
  30132. case paymentorder.FieldRefundRequestReason:
  30133. v, ok := value.(string)
  30134. if !ok {
  30135. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30136. }
  30137. m.SetRefundRequestReason(v)
  30138. return nil
  30139. case paymentorder.FieldRefundRequestedBy:
  30140. v, ok := value.(string)
  30141. if !ok {
  30142. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30143. }
  30144. m.SetRefundRequestedBy(v)
  30145. return nil
  30146. case paymentorder.FieldExpiresAt:
  30147. v, ok := value.(time.Time)
  30148. if !ok {
  30149. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30150. }
  30151. m.SetExpiresAt(v)
  30152. return nil
  30153. case paymentorder.FieldPaidAt:
  30154. v, ok := value.(time.Time)
  30155. if !ok {
  30156. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30157. }
  30158. m.SetPaidAt(v)
  30159. return nil
  30160. case paymentorder.FieldCompletedAt:
  30161. v, ok := value.(time.Time)
  30162. if !ok {
  30163. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30164. }
  30165. m.SetCompletedAt(v)
  30166. return nil
  30167. case paymentorder.FieldFailedAt:
  30168. v, ok := value.(time.Time)
  30169. if !ok {
  30170. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30171. }
  30172. m.SetFailedAt(v)
  30173. return nil
  30174. case paymentorder.FieldFailedReason:
  30175. v, ok := value.(string)
  30176. if !ok {
  30177. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30178. }
  30179. m.SetFailedReason(v)
  30180. return nil
  30181. case paymentorder.FieldClientIP:
  30182. v, ok := value.(string)
  30183. if !ok {
  30184. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30185. }
  30186. m.SetClientIP(v)
  30187. return nil
  30188. case paymentorder.FieldSrcHost:
  30189. v, ok := value.(string)
  30190. if !ok {
  30191. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30192. }
  30193. m.SetSrcHost(v)
  30194. return nil
  30195. case paymentorder.FieldSrcURL:
  30196. v, ok := value.(string)
  30197. if !ok {
  30198. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30199. }
  30200. m.SetSrcURL(v)
  30201. return nil
  30202. case paymentorder.FieldCreatedAt:
  30203. v, ok := value.(time.Time)
  30204. if !ok {
  30205. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30206. }
  30207. m.SetCreatedAt(v)
  30208. return nil
  30209. case paymentorder.FieldUpdatedAt:
  30210. v, ok := value.(time.Time)
  30211. if !ok {
  30212. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30213. }
  30214. m.SetUpdatedAt(v)
  30215. return nil
  30216. }
  30217. return fmt.Errorf("unknown PaymentOrder field %s", name)
  30218. }
  30219. // AddedFields returns all numeric fields that were incremented/decremented during
  30220. // this mutation.
  30221. func (m *PaymentOrderMutation) AddedFields() []string {
  30222. var fields []string
  30223. if m.addamount != nil {
  30224. fields = append(fields, paymentorder.FieldAmount)
  30225. }
  30226. if m.addpay_amount != nil {
  30227. fields = append(fields, paymentorder.FieldPayAmount)
  30228. }
  30229. if m.addfee_rate != nil {
  30230. fields = append(fields, paymentorder.FieldFeeRate)
  30231. }
  30232. if m.addplan_id != nil {
  30233. fields = append(fields, paymentorder.FieldPlanID)
  30234. }
  30235. if m.addsubscription_group_id != nil {
  30236. fields = append(fields, paymentorder.FieldSubscriptionGroupID)
  30237. }
  30238. if m.addsubscription_days != nil {
  30239. fields = append(fields, paymentorder.FieldSubscriptionDays)
  30240. }
  30241. if m.addrefund_amount != nil {
  30242. fields = append(fields, paymentorder.FieldRefundAmount)
  30243. }
  30244. return fields
  30245. }
  30246. // AddedField returns the numeric value that was incremented/decremented on a field
  30247. // with the given name. The second boolean return value indicates that this field
  30248. // was not set, or was not defined in the schema.
  30249. func (m *PaymentOrderMutation) AddedField(name string) (ent.Value, bool) {
  30250. switch name {
  30251. case paymentorder.FieldAmount:
  30252. return m.AddedAmount()
  30253. case paymentorder.FieldPayAmount:
  30254. return m.AddedPayAmount()
  30255. case paymentorder.FieldFeeRate:
  30256. return m.AddedFeeRate()
  30257. case paymentorder.FieldPlanID:
  30258. return m.AddedPlanID()
  30259. case paymentorder.FieldSubscriptionGroupID:
  30260. return m.AddedSubscriptionGroupID()
  30261. case paymentorder.FieldSubscriptionDays:
  30262. return m.AddedSubscriptionDays()
  30263. case paymentorder.FieldRefundAmount:
  30264. return m.AddedRefundAmount()
  30265. }
  30266. return nil, false
  30267. }
  30268. // AddField adds the value to the field with the given name. It returns an error if
  30269. // the field is not defined in the schema, or if the type mismatched the field
  30270. // type.
  30271. func (m *PaymentOrderMutation) AddField(name string, value ent.Value) error {
  30272. switch name {
  30273. case paymentorder.FieldAmount:
  30274. v, ok := value.(float64)
  30275. if !ok {
  30276. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30277. }
  30278. m.AddAmount(v)
  30279. return nil
  30280. case paymentorder.FieldPayAmount:
  30281. v, ok := value.(float64)
  30282. if !ok {
  30283. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30284. }
  30285. m.AddPayAmount(v)
  30286. return nil
  30287. case paymentorder.FieldFeeRate:
  30288. v, ok := value.(float64)
  30289. if !ok {
  30290. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30291. }
  30292. m.AddFeeRate(v)
  30293. return nil
  30294. case paymentorder.FieldPlanID:
  30295. v, ok := value.(int64)
  30296. if !ok {
  30297. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30298. }
  30299. m.AddPlanID(v)
  30300. return nil
  30301. case paymentorder.FieldSubscriptionGroupID:
  30302. v, ok := value.(int64)
  30303. if !ok {
  30304. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30305. }
  30306. m.AddSubscriptionGroupID(v)
  30307. return nil
  30308. case paymentorder.FieldSubscriptionDays:
  30309. v, ok := value.(int)
  30310. if !ok {
  30311. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30312. }
  30313. m.AddSubscriptionDays(v)
  30314. return nil
  30315. case paymentorder.FieldRefundAmount:
  30316. v, ok := value.(float64)
  30317. if !ok {
  30318. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30319. }
  30320. m.AddRefundAmount(v)
  30321. return nil
  30322. }
  30323. return fmt.Errorf("unknown PaymentOrder numeric field %s", name)
  30324. }
  30325. // ClearedFields returns all nullable fields that were cleared during this
  30326. // mutation.
  30327. func (m *PaymentOrderMutation) ClearedFields() []string {
  30328. var fields []string
  30329. if m.FieldCleared(paymentorder.FieldUserNotes) {
  30330. fields = append(fields, paymentorder.FieldUserNotes)
  30331. }
  30332. if m.FieldCleared(paymentorder.FieldPayURL) {
  30333. fields = append(fields, paymentorder.FieldPayURL)
  30334. }
  30335. if m.FieldCleared(paymentorder.FieldQrCode) {
  30336. fields = append(fields, paymentorder.FieldQrCode)
  30337. }
  30338. if m.FieldCleared(paymentorder.FieldQrCodeImg) {
  30339. fields = append(fields, paymentorder.FieldQrCodeImg)
  30340. }
  30341. if m.FieldCleared(paymentorder.FieldPlanID) {
  30342. fields = append(fields, paymentorder.FieldPlanID)
  30343. }
  30344. if m.FieldCleared(paymentorder.FieldSubscriptionGroupID) {
  30345. fields = append(fields, paymentorder.FieldSubscriptionGroupID)
  30346. }
  30347. if m.FieldCleared(paymentorder.FieldSubscriptionDays) {
  30348. fields = append(fields, paymentorder.FieldSubscriptionDays)
  30349. }
  30350. if m.FieldCleared(paymentorder.FieldProviderInstanceID) {
  30351. fields = append(fields, paymentorder.FieldProviderInstanceID)
  30352. }
  30353. if m.FieldCleared(paymentorder.FieldProviderKey) {
  30354. fields = append(fields, paymentorder.FieldProviderKey)
  30355. }
  30356. if m.FieldCleared(paymentorder.FieldProviderSnapshot) {
  30357. fields = append(fields, paymentorder.FieldProviderSnapshot)
  30358. }
  30359. if m.FieldCleared(paymentorder.FieldRefundReason) {
  30360. fields = append(fields, paymentorder.FieldRefundReason)
  30361. }
  30362. if m.FieldCleared(paymentorder.FieldRefundAt) {
  30363. fields = append(fields, paymentorder.FieldRefundAt)
  30364. }
  30365. if m.FieldCleared(paymentorder.FieldRefundRequestedAt) {
  30366. fields = append(fields, paymentorder.FieldRefundRequestedAt)
  30367. }
  30368. if m.FieldCleared(paymentorder.FieldRefundRequestReason) {
  30369. fields = append(fields, paymentorder.FieldRefundRequestReason)
  30370. }
  30371. if m.FieldCleared(paymentorder.FieldRefundRequestedBy) {
  30372. fields = append(fields, paymentorder.FieldRefundRequestedBy)
  30373. }
  30374. if m.FieldCleared(paymentorder.FieldPaidAt) {
  30375. fields = append(fields, paymentorder.FieldPaidAt)
  30376. }
  30377. if m.FieldCleared(paymentorder.FieldCompletedAt) {
  30378. fields = append(fields, paymentorder.FieldCompletedAt)
  30379. }
  30380. if m.FieldCleared(paymentorder.FieldFailedAt) {
  30381. fields = append(fields, paymentorder.FieldFailedAt)
  30382. }
  30383. if m.FieldCleared(paymentorder.FieldFailedReason) {
  30384. fields = append(fields, paymentorder.FieldFailedReason)
  30385. }
  30386. if m.FieldCleared(paymentorder.FieldSrcURL) {
  30387. fields = append(fields, paymentorder.FieldSrcURL)
  30388. }
  30389. return fields
  30390. }
  30391. // FieldCleared returns a boolean indicating if a field with the given name was
  30392. // cleared in this mutation.
  30393. func (m *PaymentOrderMutation) FieldCleared(name string) bool {
  30394. _, ok := m.clearedFields[name]
  30395. return ok
  30396. }
  30397. // ClearField clears the value of the field with the given name. It returns an
  30398. // error if the field is not defined in the schema.
  30399. func (m *PaymentOrderMutation) ClearField(name string) error {
  30400. switch name {
  30401. case paymentorder.FieldUserNotes:
  30402. m.ClearUserNotes()
  30403. return nil
  30404. case paymentorder.FieldPayURL:
  30405. m.ClearPayURL()
  30406. return nil
  30407. case paymentorder.FieldQrCode:
  30408. m.ClearQrCode()
  30409. return nil
  30410. case paymentorder.FieldQrCodeImg:
  30411. m.ClearQrCodeImg()
  30412. return nil
  30413. case paymentorder.FieldPlanID:
  30414. m.ClearPlanID()
  30415. return nil
  30416. case paymentorder.FieldSubscriptionGroupID:
  30417. m.ClearSubscriptionGroupID()
  30418. return nil
  30419. case paymentorder.FieldSubscriptionDays:
  30420. m.ClearSubscriptionDays()
  30421. return nil
  30422. case paymentorder.FieldProviderInstanceID:
  30423. m.ClearProviderInstanceID()
  30424. return nil
  30425. case paymentorder.FieldProviderKey:
  30426. m.ClearProviderKey()
  30427. return nil
  30428. case paymentorder.FieldProviderSnapshot:
  30429. m.ClearProviderSnapshot()
  30430. return nil
  30431. case paymentorder.FieldRefundReason:
  30432. m.ClearRefundReason()
  30433. return nil
  30434. case paymentorder.FieldRefundAt:
  30435. m.ClearRefundAt()
  30436. return nil
  30437. case paymentorder.FieldRefundRequestedAt:
  30438. m.ClearRefundRequestedAt()
  30439. return nil
  30440. case paymentorder.FieldRefundRequestReason:
  30441. m.ClearRefundRequestReason()
  30442. return nil
  30443. case paymentorder.FieldRefundRequestedBy:
  30444. m.ClearRefundRequestedBy()
  30445. return nil
  30446. case paymentorder.FieldPaidAt:
  30447. m.ClearPaidAt()
  30448. return nil
  30449. case paymentorder.FieldCompletedAt:
  30450. m.ClearCompletedAt()
  30451. return nil
  30452. case paymentorder.FieldFailedAt:
  30453. m.ClearFailedAt()
  30454. return nil
  30455. case paymentorder.FieldFailedReason:
  30456. m.ClearFailedReason()
  30457. return nil
  30458. case paymentorder.FieldSrcURL:
  30459. m.ClearSrcURL()
  30460. return nil
  30461. }
  30462. return fmt.Errorf("unknown PaymentOrder nullable field %s", name)
  30463. }
  30464. // ResetField resets all changes in the mutation for the field with the given name.
  30465. // It returns an error if the field is not defined in the schema.
  30466. func (m *PaymentOrderMutation) ResetField(name string) error {
  30467. switch name {
  30468. case paymentorder.FieldUserID:
  30469. m.ResetUserID()
  30470. return nil
  30471. case paymentorder.FieldUserEmail:
  30472. m.ResetUserEmail()
  30473. return nil
  30474. case paymentorder.FieldUserName:
  30475. m.ResetUserName()
  30476. return nil
  30477. case paymentorder.FieldUserNotes:
  30478. m.ResetUserNotes()
  30479. return nil
  30480. case paymentorder.FieldAmount:
  30481. m.ResetAmount()
  30482. return nil
  30483. case paymentorder.FieldPayAmount:
  30484. m.ResetPayAmount()
  30485. return nil
  30486. case paymentorder.FieldFeeRate:
  30487. m.ResetFeeRate()
  30488. return nil
  30489. case paymentorder.FieldRechargeCode:
  30490. m.ResetRechargeCode()
  30491. return nil
  30492. case paymentorder.FieldOutTradeNo:
  30493. m.ResetOutTradeNo()
  30494. return nil
  30495. case paymentorder.FieldPaymentType:
  30496. m.ResetPaymentType()
  30497. return nil
  30498. case paymentorder.FieldPaymentTradeNo:
  30499. m.ResetPaymentTradeNo()
  30500. return nil
  30501. case paymentorder.FieldPayURL:
  30502. m.ResetPayURL()
  30503. return nil
  30504. case paymentorder.FieldQrCode:
  30505. m.ResetQrCode()
  30506. return nil
  30507. case paymentorder.FieldQrCodeImg:
  30508. m.ResetQrCodeImg()
  30509. return nil
  30510. case paymentorder.FieldOrderType:
  30511. m.ResetOrderType()
  30512. return nil
  30513. case paymentorder.FieldPlanID:
  30514. m.ResetPlanID()
  30515. return nil
  30516. case paymentorder.FieldSubscriptionGroupID:
  30517. m.ResetSubscriptionGroupID()
  30518. return nil
  30519. case paymentorder.FieldSubscriptionDays:
  30520. m.ResetSubscriptionDays()
  30521. return nil
  30522. case paymentorder.FieldProviderInstanceID:
  30523. m.ResetProviderInstanceID()
  30524. return nil
  30525. case paymentorder.FieldProviderKey:
  30526. m.ResetProviderKey()
  30527. return nil
  30528. case paymentorder.FieldProviderSnapshot:
  30529. m.ResetProviderSnapshot()
  30530. return nil
  30531. case paymentorder.FieldStatus:
  30532. m.ResetStatus()
  30533. return nil
  30534. case paymentorder.FieldRefundAmount:
  30535. m.ResetRefundAmount()
  30536. return nil
  30537. case paymentorder.FieldRefundReason:
  30538. m.ResetRefundReason()
  30539. return nil
  30540. case paymentorder.FieldRefundAt:
  30541. m.ResetRefundAt()
  30542. return nil
  30543. case paymentorder.FieldForceRefund:
  30544. m.ResetForceRefund()
  30545. return nil
  30546. case paymentorder.FieldRefundRequestedAt:
  30547. m.ResetRefundRequestedAt()
  30548. return nil
  30549. case paymentorder.FieldRefundRequestReason:
  30550. m.ResetRefundRequestReason()
  30551. return nil
  30552. case paymentorder.FieldRefundRequestedBy:
  30553. m.ResetRefundRequestedBy()
  30554. return nil
  30555. case paymentorder.FieldExpiresAt:
  30556. m.ResetExpiresAt()
  30557. return nil
  30558. case paymentorder.FieldPaidAt:
  30559. m.ResetPaidAt()
  30560. return nil
  30561. case paymentorder.FieldCompletedAt:
  30562. m.ResetCompletedAt()
  30563. return nil
  30564. case paymentorder.FieldFailedAt:
  30565. m.ResetFailedAt()
  30566. return nil
  30567. case paymentorder.FieldFailedReason:
  30568. m.ResetFailedReason()
  30569. return nil
  30570. case paymentorder.FieldClientIP:
  30571. m.ResetClientIP()
  30572. return nil
  30573. case paymentorder.FieldSrcHost:
  30574. m.ResetSrcHost()
  30575. return nil
  30576. case paymentorder.FieldSrcURL:
  30577. m.ResetSrcURL()
  30578. return nil
  30579. case paymentorder.FieldCreatedAt:
  30580. m.ResetCreatedAt()
  30581. return nil
  30582. case paymentorder.FieldUpdatedAt:
  30583. m.ResetUpdatedAt()
  30584. return nil
  30585. }
  30586. return fmt.Errorf("unknown PaymentOrder field %s", name)
  30587. }
  30588. // AddedEdges returns all edge names that were set/added in this mutation.
  30589. func (m *PaymentOrderMutation) AddedEdges() []string {
  30590. edges := make([]string, 0, 1)
  30591. if m.user != nil {
  30592. edges = append(edges, paymentorder.EdgeUser)
  30593. }
  30594. return edges
  30595. }
  30596. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  30597. // name in this mutation.
  30598. func (m *PaymentOrderMutation) AddedIDs(name string) []ent.Value {
  30599. switch name {
  30600. case paymentorder.EdgeUser:
  30601. if id := m.user; id != nil {
  30602. return []ent.Value{*id}
  30603. }
  30604. }
  30605. return nil
  30606. }
  30607. // RemovedEdges returns all edge names that were removed in this mutation.
  30608. func (m *PaymentOrderMutation) RemovedEdges() []string {
  30609. edges := make([]string, 0, 1)
  30610. return edges
  30611. }
  30612. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  30613. // the given name in this mutation.
  30614. func (m *PaymentOrderMutation) RemovedIDs(name string) []ent.Value {
  30615. return nil
  30616. }
  30617. // ClearedEdges returns all edge names that were cleared in this mutation.
  30618. func (m *PaymentOrderMutation) ClearedEdges() []string {
  30619. edges := make([]string, 0, 1)
  30620. if m.cleareduser {
  30621. edges = append(edges, paymentorder.EdgeUser)
  30622. }
  30623. return edges
  30624. }
  30625. // EdgeCleared returns a boolean which indicates if the edge with the given name
  30626. // was cleared in this mutation.
  30627. func (m *PaymentOrderMutation) EdgeCleared(name string) bool {
  30628. switch name {
  30629. case paymentorder.EdgeUser:
  30630. return m.cleareduser
  30631. }
  30632. return false
  30633. }
  30634. // ClearEdge clears the value of the edge with the given name. It returns an error
  30635. // if that edge is not defined in the schema.
  30636. func (m *PaymentOrderMutation) ClearEdge(name string) error {
  30637. switch name {
  30638. case paymentorder.EdgeUser:
  30639. m.ClearUser()
  30640. return nil
  30641. }
  30642. return fmt.Errorf("unknown PaymentOrder unique edge %s", name)
  30643. }
  30644. // ResetEdge resets all changes to the edge with the given name in this mutation.
  30645. // It returns an error if the edge is not defined in the schema.
  30646. func (m *PaymentOrderMutation) ResetEdge(name string) error {
  30647. switch name {
  30648. case paymentorder.EdgeUser:
  30649. m.ResetUser()
  30650. return nil
  30651. }
  30652. return fmt.Errorf("unknown PaymentOrder edge %s", name)
  30653. }
  30654. // PaymentProviderInstanceMutation represents an operation that mutates the PaymentProviderInstance nodes in the graph.
  30655. type PaymentProviderInstanceMutation struct {
  30656. config
  30657. op Op
  30658. typ string
  30659. id *int64
  30660. provider_key *string
  30661. name *string
  30662. _config *string
  30663. supported_types *string
  30664. enabled *bool
  30665. payment_mode *string
  30666. sort_order *int
  30667. addsort_order *int
  30668. limits *string
  30669. refund_enabled *bool
  30670. allow_user_refund *bool
  30671. created_at *time.Time
  30672. updated_at *time.Time
  30673. clearedFields map[string]struct{}
  30674. done bool
  30675. oldValue func(context.Context) (*PaymentProviderInstance, error)
  30676. predicates []predicate.PaymentProviderInstance
  30677. }
  30678. var _ ent.Mutation = (*PaymentProviderInstanceMutation)(nil)
  30679. // paymentproviderinstanceOption allows management of the mutation configuration using functional options.
  30680. type paymentproviderinstanceOption func(*PaymentProviderInstanceMutation)
  30681. // newPaymentProviderInstanceMutation creates new mutation for the PaymentProviderInstance entity.
  30682. func newPaymentProviderInstanceMutation(c config, op Op, opts ...paymentproviderinstanceOption) *PaymentProviderInstanceMutation {
  30683. m := &PaymentProviderInstanceMutation{
  30684. config: c,
  30685. op: op,
  30686. typ: TypePaymentProviderInstance,
  30687. clearedFields: make(map[string]struct{}),
  30688. }
  30689. for _, opt := range opts {
  30690. opt(m)
  30691. }
  30692. return m
  30693. }
  30694. // withPaymentProviderInstanceID sets the ID field of the mutation.
  30695. func withPaymentProviderInstanceID(id int64) paymentproviderinstanceOption {
  30696. return func(m *PaymentProviderInstanceMutation) {
  30697. var (
  30698. err error
  30699. once sync.Once
  30700. value *PaymentProviderInstance
  30701. )
  30702. m.oldValue = func(ctx context.Context) (*PaymentProviderInstance, error) {
  30703. once.Do(func() {
  30704. if m.done {
  30705. err = errors.New("querying old values post mutation is not allowed")
  30706. } else {
  30707. value, err = m.Client().PaymentProviderInstance.Get(ctx, id)
  30708. }
  30709. })
  30710. return value, err
  30711. }
  30712. m.id = &id
  30713. }
  30714. }
  30715. // withPaymentProviderInstance sets the old PaymentProviderInstance of the mutation.
  30716. func withPaymentProviderInstance(node *PaymentProviderInstance) paymentproviderinstanceOption {
  30717. return func(m *PaymentProviderInstanceMutation) {
  30718. m.oldValue = func(context.Context) (*PaymentProviderInstance, error) {
  30719. return node, nil
  30720. }
  30721. m.id = &node.ID
  30722. }
  30723. }
  30724. // Client returns a new `ent.Client` from the mutation. If the mutation was
  30725. // executed in a transaction (ent.Tx), a transactional client is returned.
  30726. func (m PaymentProviderInstanceMutation) Client() *Client {
  30727. client := &Client{config: m.config}
  30728. client.init()
  30729. return client
  30730. }
  30731. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  30732. // it returns an error otherwise.
  30733. func (m PaymentProviderInstanceMutation) Tx() (*Tx, error) {
  30734. if _, ok := m.driver.(*txDriver); !ok {
  30735. return nil, errors.New("ent: mutation is not running in a transaction")
  30736. }
  30737. tx := &Tx{config: m.config}
  30738. tx.init()
  30739. return tx, nil
  30740. }
  30741. // ID returns the ID value in the mutation. Note that the ID is only available
  30742. // if it was provided to the builder or after it was returned from the database.
  30743. func (m *PaymentProviderInstanceMutation) ID() (id int64, exists bool) {
  30744. if m.id == nil {
  30745. return
  30746. }
  30747. return *m.id, true
  30748. }
  30749. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  30750. // That means, if the mutation is applied within a transaction with an isolation level such
  30751. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  30752. // or updated by the mutation.
  30753. func (m *PaymentProviderInstanceMutation) IDs(ctx context.Context) ([]int64, error) {
  30754. switch {
  30755. case m.op.Is(OpUpdateOne | OpDeleteOne):
  30756. id, exists := m.ID()
  30757. if exists {
  30758. return []int64{id}, nil
  30759. }
  30760. fallthrough
  30761. case m.op.Is(OpUpdate | OpDelete):
  30762. return m.Client().PaymentProviderInstance.Query().Where(m.predicates...).IDs(ctx)
  30763. default:
  30764. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  30765. }
  30766. }
  30767. // SetProviderKey sets the "provider_key" field.
  30768. func (m *PaymentProviderInstanceMutation) SetProviderKey(s string) {
  30769. m.provider_key = &s
  30770. }
  30771. // ProviderKey returns the value of the "provider_key" field in the mutation.
  30772. func (m *PaymentProviderInstanceMutation) ProviderKey() (r string, exists bool) {
  30773. v := m.provider_key
  30774. if v == nil {
  30775. return
  30776. }
  30777. return *v, true
  30778. }
  30779. // OldProviderKey returns the old "provider_key" field's value of the PaymentProviderInstance entity.
  30780. // If the PaymentProviderInstance object wasn't provided to the builder, the object is fetched from the database.
  30781. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30782. func (m *PaymentProviderInstanceMutation) OldProviderKey(ctx context.Context) (v string, err error) {
  30783. if !m.op.Is(OpUpdateOne) {
  30784. return v, errors.New("OldProviderKey is only allowed on UpdateOne operations")
  30785. }
  30786. if m.id == nil || m.oldValue == nil {
  30787. return v, errors.New("OldProviderKey requires an ID field in the mutation")
  30788. }
  30789. oldValue, err := m.oldValue(ctx)
  30790. if err != nil {
  30791. return v, fmt.Errorf("querying old value for OldProviderKey: %w", err)
  30792. }
  30793. return oldValue.ProviderKey, nil
  30794. }
  30795. // ResetProviderKey resets all changes to the "provider_key" field.
  30796. func (m *PaymentProviderInstanceMutation) ResetProviderKey() {
  30797. m.provider_key = nil
  30798. }
  30799. // SetName sets the "name" field.
  30800. func (m *PaymentProviderInstanceMutation) SetName(s string) {
  30801. m.name = &s
  30802. }
  30803. // Name returns the value of the "name" field in the mutation.
  30804. func (m *PaymentProviderInstanceMutation) Name() (r string, exists bool) {
  30805. v := m.name
  30806. if v == nil {
  30807. return
  30808. }
  30809. return *v, true
  30810. }
  30811. // OldName returns the old "name" field's value of the PaymentProviderInstance entity.
  30812. // If the PaymentProviderInstance object wasn't provided to the builder, the object is fetched from the database.
  30813. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30814. func (m *PaymentProviderInstanceMutation) OldName(ctx context.Context) (v string, err error) {
  30815. if !m.op.Is(OpUpdateOne) {
  30816. return v, errors.New("OldName is only allowed on UpdateOne operations")
  30817. }
  30818. if m.id == nil || m.oldValue == nil {
  30819. return v, errors.New("OldName requires an ID field in the mutation")
  30820. }
  30821. oldValue, err := m.oldValue(ctx)
  30822. if err != nil {
  30823. return v, fmt.Errorf("querying old value for OldName: %w", err)
  30824. }
  30825. return oldValue.Name, nil
  30826. }
  30827. // ResetName resets all changes to the "name" field.
  30828. func (m *PaymentProviderInstanceMutation) ResetName() {
  30829. m.name = nil
  30830. }
  30831. // SetConfig sets the "config" field.
  30832. func (m *PaymentProviderInstanceMutation) SetConfig(s string) {
  30833. m._config = &s
  30834. }
  30835. // Config returns the value of the "config" field in the mutation.
  30836. func (m *PaymentProviderInstanceMutation) Config() (r string, exists bool) {
  30837. v := m._config
  30838. if v == nil {
  30839. return
  30840. }
  30841. return *v, true
  30842. }
  30843. // OldConfig returns the old "config" field's value of the PaymentProviderInstance entity.
  30844. // If the PaymentProviderInstance object wasn't provided to the builder, the object is fetched from the database.
  30845. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30846. func (m *PaymentProviderInstanceMutation) OldConfig(ctx context.Context) (v string, err error) {
  30847. if !m.op.Is(OpUpdateOne) {
  30848. return v, errors.New("OldConfig is only allowed on UpdateOne operations")
  30849. }
  30850. if m.id == nil || m.oldValue == nil {
  30851. return v, errors.New("OldConfig requires an ID field in the mutation")
  30852. }
  30853. oldValue, err := m.oldValue(ctx)
  30854. if err != nil {
  30855. return v, fmt.Errorf("querying old value for OldConfig: %w", err)
  30856. }
  30857. return oldValue.Config, nil
  30858. }
  30859. // ResetConfig resets all changes to the "config" field.
  30860. func (m *PaymentProviderInstanceMutation) ResetConfig() {
  30861. m._config = nil
  30862. }
  30863. // SetSupportedTypes sets the "supported_types" field.
  30864. func (m *PaymentProviderInstanceMutation) SetSupportedTypes(s string) {
  30865. m.supported_types = &s
  30866. }
  30867. // SupportedTypes returns the value of the "supported_types" field in the mutation.
  30868. func (m *PaymentProviderInstanceMutation) SupportedTypes() (r string, exists bool) {
  30869. v := m.supported_types
  30870. if v == nil {
  30871. return
  30872. }
  30873. return *v, true
  30874. }
  30875. // OldSupportedTypes returns the old "supported_types" field's value of the PaymentProviderInstance entity.
  30876. // If the PaymentProviderInstance object wasn't provided to the builder, the object is fetched from the database.
  30877. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30878. func (m *PaymentProviderInstanceMutation) OldSupportedTypes(ctx context.Context) (v string, err error) {
  30879. if !m.op.Is(OpUpdateOne) {
  30880. return v, errors.New("OldSupportedTypes is only allowed on UpdateOne operations")
  30881. }
  30882. if m.id == nil || m.oldValue == nil {
  30883. return v, errors.New("OldSupportedTypes requires an ID field in the mutation")
  30884. }
  30885. oldValue, err := m.oldValue(ctx)
  30886. if err != nil {
  30887. return v, fmt.Errorf("querying old value for OldSupportedTypes: %w", err)
  30888. }
  30889. return oldValue.SupportedTypes, nil
  30890. }
  30891. // ResetSupportedTypes resets all changes to the "supported_types" field.
  30892. func (m *PaymentProviderInstanceMutation) ResetSupportedTypes() {
  30893. m.supported_types = nil
  30894. }
  30895. // SetEnabled sets the "enabled" field.
  30896. func (m *PaymentProviderInstanceMutation) SetEnabled(b bool) {
  30897. m.enabled = &b
  30898. }
  30899. // Enabled returns the value of the "enabled" field in the mutation.
  30900. func (m *PaymentProviderInstanceMutation) Enabled() (r bool, exists bool) {
  30901. v := m.enabled
  30902. if v == nil {
  30903. return
  30904. }
  30905. return *v, true
  30906. }
  30907. // OldEnabled returns the old "enabled" field's value of the PaymentProviderInstance entity.
  30908. // If the PaymentProviderInstance object wasn't provided to the builder, the object is fetched from the database.
  30909. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30910. func (m *PaymentProviderInstanceMutation) OldEnabled(ctx context.Context) (v bool, err error) {
  30911. if !m.op.Is(OpUpdateOne) {
  30912. return v, errors.New("OldEnabled is only allowed on UpdateOne operations")
  30913. }
  30914. if m.id == nil || m.oldValue == nil {
  30915. return v, errors.New("OldEnabled requires an ID field in the mutation")
  30916. }
  30917. oldValue, err := m.oldValue(ctx)
  30918. if err != nil {
  30919. return v, fmt.Errorf("querying old value for OldEnabled: %w", err)
  30920. }
  30921. return oldValue.Enabled, nil
  30922. }
  30923. // ResetEnabled resets all changes to the "enabled" field.
  30924. func (m *PaymentProviderInstanceMutation) ResetEnabled() {
  30925. m.enabled = nil
  30926. }
  30927. // SetPaymentMode sets the "payment_mode" field.
  30928. func (m *PaymentProviderInstanceMutation) SetPaymentMode(s string) {
  30929. m.payment_mode = &s
  30930. }
  30931. // PaymentMode returns the value of the "payment_mode" field in the mutation.
  30932. func (m *PaymentProviderInstanceMutation) PaymentMode() (r string, exists bool) {
  30933. v := m.payment_mode
  30934. if v == nil {
  30935. return
  30936. }
  30937. return *v, true
  30938. }
  30939. // OldPaymentMode returns the old "payment_mode" field's value of the PaymentProviderInstance entity.
  30940. // If the PaymentProviderInstance object wasn't provided to the builder, the object is fetched from the database.
  30941. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30942. func (m *PaymentProviderInstanceMutation) OldPaymentMode(ctx context.Context) (v string, err error) {
  30943. if !m.op.Is(OpUpdateOne) {
  30944. return v, errors.New("OldPaymentMode is only allowed on UpdateOne operations")
  30945. }
  30946. if m.id == nil || m.oldValue == nil {
  30947. return v, errors.New("OldPaymentMode requires an ID field in the mutation")
  30948. }
  30949. oldValue, err := m.oldValue(ctx)
  30950. if err != nil {
  30951. return v, fmt.Errorf("querying old value for OldPaymentMode: %w", err)
  30952. }
  30953. return oldValue.PaymentMode, nil
  30954. }
  30955. // ResetPaymentMode resets all changes to the "payment_mode" field.
  30956. func (m *PaymentProviderInstanceMutation) ResetPaymentMode() {
  30957. m.payment_mode = nil
  30958. }
  30959. // SetSortOrder sets the "sort_order" field.
  30960. func (m *PaymentProviderInstanceMutation) SetSortOrder(i int) {
  30961. m.sort_order = &i
  30962. m.addsort_order = nil
  30963. }
  30964. // SortOrder returns the value of the "sort_order" field in the mutation.
  30965. func (m *PaymentProviderInstanceMutation) SortOrder() (r int, exists bool) {
  30966. v := m.sort_order
  30967. if v == nil {
  30968. return
  30969. }
  30970. return *v, true
  30971. }
  30972. // OldSortOrder returns the old "sort_order" field's value of the PaymentProviderInstance entity.
  30973. // If the PaymentProviderInstance object wasn't provided to the builder, the object is fetched from the database.
  30974. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30975. func (m *PaymentProviderInstanceMutation) OldSortOrder(ctx context.Context) (v int, err error) {
  30976. if !m.op.Is(OpUpdateOne) {
  30977. return v, errors.New("OldSortOrder is only allowed on UpdateOne operations")
  30978. }
  30979. if m.id == nil || m.oldValue == nil {
  30980. return v, errors.New("OldSortOrder requires an ID field in the mutation")
  30981. }
  30982. oldValue, err := m.oldValue(ctx)
  30983. if err != nil {
  30984. return v, fmt.Errorf("querying old value for OldSortOrder: %w", err)
  30985. }
  30986. return oldValue.SortOrder, nil
  30987. }
  30988. // AddSortOrder adds i to the "sort_order" field.
  30989. func (m *PaymentProviderInstanceMutation) AddSortOrder(i int) {
  30990. if m.addsort_order != nil {
  30991. *m.addsort_order += i
  30992. } else {
  30993. m.addsort_order = &i
  30994. }
  30995. }
  30996. // AddedSortOrder returns the value that was added to the "sort_order" field in this mutation.
  30997. func (m *PaymentProviderInstanceMutation) AddedSortOrder() (r int, exists bool) {
  30998. v := m.addsort_order
  30999. if v == nil {
  31000. return
  31001. }
  31002. return *v, true
  31003. }
  31004. // ResetSortOrder resets all changes to the "sort_order" field.
  31005. func (m *PaymentProviderInstanceMutation) ResetSortOrder() {
  31006. m.sort_order = nil
  31007. m.addsort_order = nil
  31008. }
  31009. // SetLimits sets the "limits" field.
  31010. func (m *PaymentProviderInstanceMutation) SetLimits(s string) {
  31011. m.limits = &s
  31012. }
  31013. // Limits returns the value of the "limits" field in the mutation.
  31014. func (m *PaymentProviderInstanceMutation) Limits() (r string, exists bool) {
  31015. v := m.limits
  31016. if v == nil {
  31017. return
  31018. }
  31019. return *v, true
  31020. }
  31021. // OldLimits returns the old "limits" field's value of the PaymentProviderInstance entity.
  31022. // If the PaymentProviderInstance object wasn't provided to the builder, the object is fetched from the database.
  31023. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31024. func (m *PaymentProviderInstanceMutation) OldLimits(ctx context.Context) (v string, err error) {
  31025. if !m.op.Is(OpUpdateOne) {
  31026. return v, errors.New("OldLimits is only allowed on UpdateOne operations")
  31027. }
  31028. if m.id == nil || m.oldValue == nil {
  31029. return v, errors.New("OldLimits requires an ID field in the mutation")
  31030. }
  31031. oldValue, err := m.oldValue(ctx)
  31032. if err != nil {
  31033. return v, fmt.Errorf("querying old value for OldLimits: %w", err)
  31034. }
  31035. return oldValue.Limits, nil
  31036. }
  31037. // ResetLimits resets all changes to the "limits" field.
  31038. func (m *PaymentProviderInstanceMutation) ResetLimits() {
  31039. m.limits = nil
  31040. }
  31041. // SetRefundEnabled sets the "refund_enabled" field.
  31042. func (m *PaymentProviderInstanceMutation) SetRefundEnabled(b bool) {
  31043. m.refund_enabled = &b
  31044. }
  31045. // RefundEnabled returns the value of the "refund_enabled" field in the mutation.
  31046. func (m *PaymentProviderInstanceMutation) RefundEnabled() (r bool, exists bool) {
  31047. v := m.refund_enabled
  31048. if v == nil {
  31049. return
  31050. }
  31051. return *v, true
  31052. }
  31053. // OldRefundEnabled returns the old "refund_enabled" field's value of the PaymentProviderInstance entity.
  31054. // If the PaymentProviderInstance object wasn't provided to the builder, the object is fetched from the database.
  31055. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31056. func (m *PaymentProviderInstanceMutation) OldRefundEnabled(ctx context.Context) (v bool, err error) {
  31057. if !m.op.Is(OpUpdateOne) {
  31058. return v, errors.New("OldRefundEnabled is only allowed on UpdateOne operations")
  31059. }
  31060. if m.id == nil || m.oldValue == nil {
  31061. return v, errors.New("OldRefundEnabled requires an ID field in the mutation")
  31062. }
  31063. oldValue, err := m.oldValue(ctx)
  31064. if err != nil {
  31065. return v, fmt.Errorf("querying old value for OldRefundEnabled: %w", err)
  31066. }
  31067. return oldValue.RefundEnabled, nil
  31068. }
  31069. // ResetRefundEnabled resets all changes to the "refund_enabled" field.
  31070. func (m *PaymentProviderInstanceMutation) ResetRefundEnabled() {
  31071. m.refund_enabled = nil
  31072. }
  31073. // SetAllowUserRefund sets the "allow_user_refund" field.
  31074. func (m *PaymentProviderInstanceMutation) SetAllowUserRefund(b bool) {
  31075. m.allow_user_refund = &b
  31076. }
  31077. // AllowUserRefund returns the value of the "allow_user_refund" field in the mutation.
  31078. func (m *PaymentProviderInstanceMutation) AllowUserRefund() (r bool, exists bool) {
  31079. v := m.allow_user_refund
  31080. if v == nil {
  31081. return
  31082. }
  31083. return *v, true
  31084. }
  31085. // OldAllowUserRefund returns the old "allow_user_refund" field's value of the PaymentProviderInstance entity.
  31086. // If the PaymentProviderInstance object wasn't provided to the builder, the object is fetched from the database.
  31087. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31088. func (m *PaymentProviderInstanceMutation) OldAllowUserRefund(ctx context.Context) (v bool, err error) {
  31089. if !m.op.Is(OpUpdateOne) {
  31090. return v, errors.New("OldAllowUserRefund is only allowed on UpdateOne operations")
  31091. }
  31092. if m.id == nil || m.oldValue == nil {
  31093. return v, errors.New("OldAllowUserRefund requires an ID field in the mutation")
  31094. }
  31095. oldValue, err := m.oldValue(ctx)
  31096. if err != nil {
  31097. return v, fmt.Errorf("querying old value for OldAllowUserRefund: %w", err)
  31098. }
  31099. return oldValue.AllowUserRefund, nil
  31100. }
  31101. // ResetAllowUserRefund resets all changes to the "allow_user_refund" field.
  31102. func (m *PaymentProviderInstanceMutation) ResetAllowUserRefund() {
  31103. m.allow_user_refund = nil
  31104. }
  31105. // SetCreatedAt sets the "created_at" field.
  31106. func (m *PaymentProviderInstanceMutation) SetCreatedAt(t time.Time) {
  31107. m.created_at = &t
  31108. }
  31109. // CreatedAt returns the value of the "created_at" field in the mutation.
  31110. func (m *PaymentProviderInstanceMutation) CreatedAt() (r time.Time, exists bool) {
  31111. v := m.created_at
  31112. if v == nil {
  31113. return
  31114. }
  31115. return *v, true
  31116. }
  31117. // OldCreatedAt returns the old "created_at" field's value of the PaymentProviderInstance entity.
  31118. // If the PaymentProviderInstance object wasn't provided to the builder, the object is fetched from the database.
  31119. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31120. func (m *PaymentProviderInstanceMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  31121. if !m.op.Is(OpUpdateOne) {
  31122. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  31123. }
  31124. if m.id == nil || m.oldValue == nil {
  31125. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  31126. }
  31127. oldValue, err := m.oldValue(ctx)
  31128. if err != nil {
  31129. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  31130. }
  31131. return oldValue.CreatedAt, nil
  31132. }
  31133. // ResetCreatedAt resets all changes to the "created_at" field.
  31134. func (m *PaymentProviderInstanceMutation) ResetCreatedAt() {
  31135. m.created_at = nil
  31136. }
  31137. // SetUpdatedAt sets the "updated_at" field.
  31138. func (m *PaymentProviderInstanceMutation) SetUpdatedAt(t time.Time) {
  31139. m.updated_at = &t
  31140. }
  31141. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  31142. func (m *PaymentProviderInstanceMutation) UpdatedAt() (r time.Time, exists bool) {
  31143. v := m.updated_at
  31144. if v == nil {
  31145. return
  31146. }
  31147. return *v, true
  31148. }
  31149. // OldUpdatedAt returns the old "updated_at" field's value of the PaymentProviderInstance entity.
  31150. // If the PaymentProviderInstance object wasn't provided to the builder, the object is fetched from the database.
  31151. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31152. func (m *PaymentProviderInstanceMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  31153. if !m.op.Is(OpUpdateOne) {
  31154. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  31155. }
  31156. if m.id == nil || m.oldValue == nil {
  31157. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  31158. }
  31159. oldValue, err := m.oldValue(ctx)
  31160. if err != nil {
  31161. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  31162. }
  31163. return oldValue.UpdatedAt, nil
  31164. }
  31165. // ResetUpdatedAt resets all changes to the "updated_at" field.
  31166. func (m *PaymentProviderInstanceMutation) ResetUpdatedAt() {
  31167. m.updated_at = nil
  31168. }
  31169. // Where appends a list predicates to the PaymentProviderInstanceMutation builder.
  31170. func (m *PaymentProviderInstanceMutation) Where(ps ...predicate.PaymentProviderInstance) {
  31171. m.predicates = append(m.predicates, ps...)
  31172. }
  31173. // WhereP appends storage-level predicates to the PaymentProviderInstanceMutation builder. Using this method,
  31174. // users can use type-assertion to append predicates that do not depend on any generated package.
  31175. func (m *PaymentProviderInstanceMutation) WhereP(ps ...func(*sql.Selector)) {
  31176. p := make([]predicate.PaymentProviderInstance, len(ps))
  31177. for i := range ps {
  31178. p[i] = ps[i]
  31179. }
  31180. m.Where(p...)
  31181. }
  31182. // Op returns the operation name.
  31183. func (m *PaymentProviderInstanceMutation) Op() Op {
  31184. return m.op
  31185. }
  31186. // SetOp allows setting the mutation operation.
  31187. func (m *PaymentProviderInstanceMutation) SetOp(op Op) {
  31188. m.op = op
  31189. }
  31190. // Type returns the node type of this mutation (PaymentProviderInstance).
  31191. func (m *PaymentProviderInstanceMutation) Type() string {
  31192. return m.typ
  31193. }
  31194. // Fields returns all fields that were changed during this mutation. Note that in
  31195. // order to get all numeric fields that were incremented/decremented, call
  31196. // AddedFields().
  31197. func (m *PaymentProviderInstanceMutation) Fields() []string {
  31198. fields := make([]string, 0, 12)
  31199. if m.provider_key != nil {
  31200. fields = append(fields, paymentproviderinstance.FieldProviderKey)
  31201. }
  31202. if m.name != nil {
  31203. fields = append(fields, paymentproviderinstance.FieldName)
  31204. }
  31205. if m._config != nil {
  31206. fields = append(fields, paymentproviderinstance.FieldConfig)
  31207. }
  31208. if m.supported_types != nil {
  31209. fields = append(fields, paymentproviderinstance.FieldSupportedTypes)
  31210. }
  31211. if m.enabled != nil {
  31212. fields = append(fields, paymentproviderinstance.FieldEnabled)
  31213. }
  31214. if m.payment_mode != nil {
  31215. fields = append(fields, paymentproviderinstance.FieldPaymentMode)
  31216. }
  31217. if m.sort_order != nil {
  31218. fields = append(fields, paymentproviderinstance.FieldSortOrder)
  31219. }
  31220. if m.limits != nil {
  31221. fields = append(fields, paymentproviderinstance.FieldLimits)
  31222. }
  31223. if m.refund_enabled != nil {
  31224. fields = append(fields, paymentproviderinstance.FieldRefundEnabled)
  31225. }
  31226. if m.allow_user_refund != nil {
  31227. fields = append(fields, paymentproviderinstance.FieldAllowUserRefund)
  31228. }
  31229. if m.created_at != nil {
  31230. fields = append(fields, paymentproviderinstance.FieldCreatedAt)
  31231. }
  31232. if m.updated_at != nil {
  31233. fields = append(fields, paymentproviderinstance.FieldUpdatedAt)
  31234. }
  31235. return fields
  31236. }
  31237. // Field returns the value of a field with the given name. The second boolean
  31238. // return value indicates that this field was not set, or was not defined in the
  31239. // schema.
  31240. func (m *PaymentProviderInstanceMutation) Field(name string) (ent.Value, bool) {
  31241. switch name {
  31242. case paymentproviderinstance.FieldProviderKey:
  31243. return m.ProviderKey()
  31244. case paymentproviderinstance.FieldName:
  31245. return m.Name()
  31246. case paymentproviderinstance.FieldConfig:
  31247. return m.Config()
  31248. case paymentproviderinstance.FieldSupportedTypes:
  31249. return m.SupportedTypes()
  31250. case paymentproviderinstance.FieldEnabled:
  31251. return m.Enabled()
  31252. case paymentproviderinstance.FieldPaymentMode:
  31253. return m.PaymentMode()
  31254. case paymentproviderinstance.FieldSortOrder:
  31255. return m.SortOrder()
  31256. case paymentproviderinstance.FieldLimits:
  31257. return m.Limits()
  31258. case paymentproviderinstance.FieldRefundEnabled:
  31259. return m.RefundEnabled()
  31260. case paymentproviderinstance.FieldAllowUserRefund:
  31261. return m.AllowUserRefund()
  31262. case paymentproviderinstance.FieldCreatedAt:
  31263. return m.CreatedAt()
  31264. case paymentproviderinstance.FieldUpdatedAt:
  31265. return m.UpdatedAt()
  31266. }
  31267. return nil, false
  31268. }
  31269. // OldField returns the old value of the field from the database. An error is
  31270. // returned if the mutation operation is not UpdateOne, or the query to the
  31271. // database failed.
  31272. func (m *PaymentProviderInstanceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  31273. switch name {
  31274. case paymentproviderinstance.FieldProviderKey:
  31275. return m.OldProviderKey(ctx)
  31276. case paymentproviderinstance.FieldName:
  31277. return m.OldName(ctx)
  31278. case paymentproviderinstance.FieldConfig:
  31279. return m.OldConfig(ctx)
  31280. case paymentproviderinstance.FieldSupportedTypes:
  31281. return m.OldSupportedTypes(ctx)
  31282. case paymentproviderinstance.FieldEnabled:
  31283. return m.OldEnabled(ctx)
  31284. case paymentproviderinstance.FieldPaymentMode:
  31285. return m.OldPaymentMode(ctx)
  31286. case paymentproviderinstance.FieldSortOrder:
  31287. return m.OldSortOrder(ctx)
  31288. case paymentproviderinstance.FieldLimits:
  31289. return m.OldLimits(ctx)
  31290. case paymentproviderinstance.FieldRefundEnabled:
  31291. return m.OldRefundEnabled(ctx)
  31292. case paymentproviderinstance.FieldAllowUserRefund:
  31293. return m.OldAllowUserRefund(ctx)
  31294. case paymentproviderinstance.FieldCreatedAt:
  31295. return m.OldCreatedAt(ctx)
  31296. case paymentproviderinstance.FieldUpdatedAt:
  31297. return m.OldUpdatedAt(ctx)
  31298. }
  31299. return nil, fmt.Errorf("unknown PaymentProviderInstance field %s", name)
  31300. }
  31301. // SetField sets the value of a field with the given name. It returns an error if
  31302. // the field is not defined in the schema, or if the type mismatched the field
  31303. // type.
  31304. func (m *PaymentProviderInstanceMutation) SetField(name string, value ent.Value) error {
  31305. switch name {
  31306. case paymentproviderinstance.FieldProviderKey:
  31307. v, ok := value.(string)
  31308. if !ok {
  31309. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31310. }
  31311. m.SetProviderKey(v)
  31312. return nil
  31313. case paymentproviderinstance.FieldName:
  31314. v, ok := value.(string)
  31315. if !ok {
  31316. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31317. }
  31318. m.SetName(v)
  31319. return nil
  31320. case paymentproviderinstance.FieldConfig:
  31321. v, ok := value.(string)
  31322. if !ok {
  31323. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31324. }
  31325. m.SetConfig(v)
  31326. return nil
  31327. case paymentproviderinstance.FieldSupportedTypes:
  31328. v, ok := value.(string)
  31329. if !ok {
  31330. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31331. }
  31332. m.SetSupportedTypes(v)
  31333. return nil
  31334. case paymentproviderinstance.FieldEnabled:
  31335. v, ok := value.(bool)
  31336. if !ok {
  31337. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31338. }
  31339. m.SetEnabled(v)
  31340. return nil
  31341. case paymentproviderinstance.FieldPaymentMode:
  31342. v, ok := value.(string)
  31343. if !ok {
  31344. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31345. }
  31346. m.SetPaymentMode(v)
  31347. return nil
  31348. case paymentproviderinstance.FieldSortOrder:
  31349. v, ok := value.(int)
  31350. if !ok {
  31351. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31352. }
  31353. m.SetSortOrder(v)
  31354. return nil
  31355. case paymentproviderinstance.FieldLimits:
  31356. v, ok := value.(string)
  31357. if !ok {
  31358. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31359. }
  31360. m.SetLimits(v)
  31361. return nil
  31362. case paymentproviderinstance.FieldRefundEnabled:
  31363. v, ok := value.(bool)
  31364. if !ok {
  31365. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31366. }
  31367. m.SetRefundEnabled(v)
  31368. return nil
  31369. case paymentproviderinstance.FieldAllowUserRefund:
  31370. v, ok := value.(bool)
  31371. if !ok {
  31372. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31373. }
  31374. m.SetAllowUserRefund(v)
  31375. return nil
  31376. case paymentproviderinstance.FieldCreatedAt:
  31377. v, ok := value.(time.Time)
  31378. if !ok {
  31379. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31380. }
  31381. m.SetCreatedAt(v)
  31382. return nil
  31383. case paymentproviderinstance.FieldUpdatedAt:
  31384. v, ok := value.(time.Time)
  31385. if !ok {
  31386. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31387. }
  31388. m.SetUpdatedAt(v)
  31389. return nil
  31390. }
  31391. return fmt.Errorf("unknown PaymentProviderInstance field %s", name)
  31392. }
  31393. // AddedFields returns all numeric fields that were incremented/decremented during
  31394. // this mutation.
  31395. func (m *PaymentProviderInstanceMutation) AddedFields() []string {
  31396. var fields []string
  31397. if m.addsort_order != nil {
  31398. fields = append(fields, paymentproviderinstance.FieldSortOrder)
  31399. }
  31400. return fields
  31401. }
  31402. // AddedField returns the numeric value that was incremented/decremented on a field
  31403. // with the given name. The second boolean return value indicates that this field
  31404. // was not set, or was not defined in the schema.
  31405. func (m *PaymentProviderInstanceMutation) AddedField(name string) (ent.Value, bool) {
  31406. switch name {
  31407. case paymentproviderinstance.FieldSortOrder:
  31408. return m.AddedSortOrder()
  31409. }
  31410. return nil, false
  31411. }
  31412. // AddField adds the value to the field with the given name. It returns an error if
  31413. // the field is not defined in the schema, or if the type mismatched the field
  31414. // type.
  31415. func (m *PaymentProviderInstanceMutation) AddField(name string, value ent.Value) error {
  31416. switch name {
  31417. case paymentproviderinstance.FieldSortOrder:
  31418. v, ok := value.(int)
  31419. if !ok {
  31420. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31421. }
  31422. m.AddSortOrder(v)
  31423. return nil
  31424. }
  31425. return fmt.Errorf("unknown PaymentProviderInstance numeric field %s", name)
  31426. }
  31427. // ClearedFields returns all nullable fields that were cleared during this
  31428. // mutation.
  31429. func (m *PaymentProviderInstanceMutation) ClearedFields() []string {
  31430. return nil
  31431. }
  31432. // FieldCleared returns a boolean indicating if a field with the given name was
  31433. // cleared in this mutation.
  31434. func (m *PaymentProviderInstanceMutation) FieldCleared(name string) bool {
  31435. _, ok := m.clearedFields[name]
  31436. return ok
  31437. }
  31438. // ClearField clears the value of the field with the given name. It returns an
  31439. // error if the field is not defined in the schema.
  31440. func (m *PaymentProviderInstanceMutation) ClearField(name string) error {
  31441. return fmt.Errorf("unknown PaymentProviderInstance nullable field %s", name)
  31442. }
  31443. // ResetField resets all changes in the mutation for the field with the given name.
  31444. // It returns an error if the field is not defined in the schema.
  31445. func (m *PaymentProviderInstanceMutation) ResetField(name string) error {
  31446. switch name {
  31447. case paymentproviderinstance.FieldProviderKey:
  31448. m.ResetProviderKey()
  31449. return nil
  31450. case paymentproviderinstance.FieldName:
  31451. m.ResetName()
  31452. return nil
  31453. case paymentproviderinstance.FieldConfig:
  31454. m.ResetConfig()
  31455. return nil
  31456. case paymentproviderinstance.FieldSupportedTypes:
  31457. m.ResetSupportedTypes()
  31458. return nil
  31459. case paymentproviderinstance.FieldEnabled:
  31460. m.ResetEnabled()
  31461. return nil
  31462. case paymentproviderinstance.FieldPaymentMode:
  31463. m.ResetPaymentMode()
  31464. return nil
  31465. case paymentproviderinstance.FieldSortOrder:
  31466. m.ResetSortOrder()
  31467. return nil
  31468. case paymentproviderinstance.FieldLimits:
  31469. m.ResetLimits()
  31470. return nil
  31471. case paymentproviderinstance.FieldRefundEnabled:
  31472. m.ResetRefundEnabled()
  31473. return nil
  31474. case paymentproviderinstance.FieldAllowUserRefund:
  31475. m.ResetAllowUserRefund()
  31476. return nil
  31477. case paymentproviderinstance.FieldCreatedAt:
  31478. m.ResetCreatedAt()
  31479. return nil
  31480. case paymentproviderinstance.FieldUpdatedAt:
  31481. m.ResetUpdatedAt()
  31482. return nil
  31483. }
  31484. return fmt.Errorf("unknown PaymentProviderInstance field %s", name)
  31485. }
  31486. // AddedEdges returns all edge names that were set/added in this mutation.
  31487. func (m *PaymentProviderInstanceMutation) AddedEdges() []string {
  31488. edges := make([]string, 0, 0)
  31489. return edges
  31490. }
  31491. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  31492. // name in this mutation.
  31493. func (m *PaymentProviderInstanceMutation) AddedIDs(name string) []ent.Value {
  31494. return nil
  31495. }
  31496. // RemovedEdges returns all edge names that were removed in this mutation.
  31497. func (m *PaymentProviderInstanceMutation) RemovedEdges() []string {
  31498. edges := make([]string, 0, 0)
  31499. return edges
  31500. }
  31501. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  31502. // the given name in this mutation.
  31503. func (m *PaymentProviderInstanceMutation) RemovedIDs(name string) []ent.Value {
  31504. return nil
  31505. }
  31506. // ClearedEdges returns all edge names that were cleared in this mutation.
  31507. func (m *PaymentProviderInstanceMutation) ClearedEdges() []string {
  31508. edges := make([]string, 0, 0)
  31509. return edges
  31510. }
  31511. // EdgeCleared returns a boolean which indicates if the edge with the given name
  31512. // was cleared in this mutation.
  31513. func (m *PaymentProviderInstanceMutation) EdgeCleared(name string) bool {
  31514. return false
  31515. }
  31516. // ClearEdge clears the value of the edge with the given name. It returns an error
  31517. // if that edge is not defined in the schema.
  31518. func (m *PaymentProviderInstanceMutation) ClearEdge(name string) error {
  31519. return fmt.Errorf("unknown PaymentProviderInstance unique edge %s", name)
  31520. }
  31521. // ResetEdge resets all changes to the edge with the given name in this mutation.
  31522. // It returns an error if the edge is not defined in the schema.
  31523. func (m *PaymentProviderInstanceMutation) ResetEdge(name string) error {
  31524. return fmt.Errorf("unknown PaymentProviderInstance edge %s", name)
  31525. }
  31526. // PendingAuthSessionMutation represents an operation that mutates the PendingAuthSession nodes in the graph.
  31527. type PendingAuthSessionMutation struct {
  31528. config
  31529. op Op
  31530. typ string
  31531. id *int64
  31532. created_at *time.Time
  31533. updated_at *time.Time
  31534. session_token *string
  31535. intent *string
  31536. provider_type *string
  31537. provider_key *string
  31538. provider_subject *string
  31539. redirect_to *string
  31540. resolved_email *string
  31541. registration_password_hash *string
  31542. upstream_identity_claims *map[string]interface{}
  31543. local_flow_state *map[string]interface{}
  31544. browser_session_key *string
  31545. completion_code_hash *string
  31546. completion_code_expires_at *time.Time
  31547. email_verified_at *time.Time
  31548. password_verified_at *time.Time
  31549. totp_verified_at *time.Time
  31550. expires_at *time.Time
  31551. consumed_at *time.Time
  31552. clearedFields map[string]struct{}
  31553. target_user *int64
  31554. clearedtarget_user bool
  31555. adoption_decision *int64
  31556. clearedadoption_decision bool
  31557. done bool
  31558. oldValue func(context.Context) (*PendingAuthSession, error)
  31559. predicates []predicate.PendingAuthSession
  31560. }
  31561. var _ ent.Mutation = (*PendingAuthSessionMutation)(nil)
  31562. // pendingauthsessionOption allows management of the mutation configuration using functional options.
  31563. type pendingauthsessionOption func(*PendingAuthSessionMutation)
  31564. // newPendingAuthSessionMutation creates new mutation for the PendingAuthSession entity.
  31565. func newPendingAuthSessionMutation(c config, op Op, opts ...pendingauthsessionOption) *PendingAuthSessionMutation {
  31566. m := &PendingAuthSessionMutation{
  31567. config: c,
  31568. op: op,
  31569. typ: TypePendingAuthSession,
  31570. clearedFields: make(map[string]struct{}),
  31571. }
  31572. for _, opt := range opts {
  31573. opt(m)
  31574. }
  31575. return m
  31576. }
  31577. // withPendingAuthSessionID sets the ID field of the mutation.
  31578. func withPendingAuthSessionID(id int64) pendingauthsessionOption {
  31579. return func(m *PendingAuthSessionMutation) {
  31580. var (
  31581. err error
  31582. once sync.Once
  31583. value *PendingAuthSession
  31584. )
  31585. m.oldValue = func(ctx context.Context) (*PendingAuthSession, error) {
  31586. once.Do(func() {
  31587. if m.done {
  31588. err = errors.New("querying old values post mutation is not allowed")
  31589. } else {
  31590. value, err = m.Client().PendingAuthSession.Get(ctx, id)
  31591. }
  31592. })
  31593. return value, err
  31594. }
  31595. m.id = &id
  31596. }
  31597. }
  31598. // withPendingAuthSession sets the old PendingAuthSession of the mutation.
  31599. func withPendingAuthSession(node *PendingAuthSession) pendingauthsessionOption {
  31600. return func(m *PendingAuthSessionMutation) {
  31601. m.oldValue = func(context.Context) (*PendingAuthSession, error) {
  31602. return node, nil
  31603. }
  31604. m.id = &node.ID
  31605. }
  31606. }
  31607. // Client returns a new `ent.Client` from the mutation. If the mutation was
  31608. // executed in a transaction (ent.Tx), a transactional client is returned.
  31609. func (m PendingAuthSessionMutation) Client() *Client {
  31610. client := &Client{config: m.config}
  31611. client.init()
  31612. return client
  31613. }
  31614. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  31615. // it returns an error otherwise.
  31616. func (m PendingAuthSessionMutation) Tx() (*Tx, error) {
  31617. if _, ok := m.driver.(*txDriver); !ok {
  31618. return nil, errors.New("ent: mutation is not running in a transaction")
  31619. }
  31620. tx := &Tx{config: m.config}
  31621. tx.init()
  31622. return tx, nil
  31623. }
  31624. // ID returns the ID value in the mutation. Note that the ID is only available
  31625. // if it was provided to the builder or after it was returned from the database.
  31626. func (m *PendingAuthSessionMutation) ID() (id int64, exists bool) {
  31627. if m.id == nil {
  31628. return
  31629. }
  31630. return *m.id, true
  31631. }
  31632. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  31633. // That means, if the mutation is applied within a transaction with an isolation level such
  31634. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  31635. // or updated by the mutation.
  31636. func (m *PendingAuthSessionMutation) IDs(ctx context.Context) ([]int64, error) {
  31637. switch {
  31638. case m.op.Is(OpUpdateOne | OpDeleteOne):
  31639. id, exists := m.ID()
  31640. if exists {
  31641. return []int64{id}, nil
  31642. }
  31643. fallthrough
  31644. case m.op.Is(OpUpdate | OpDelete):
  31645. return m.Client().PendingAuthSession.Query().Where(m.predicates...).IDs(ctx)
  31646. default:
  31647. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  31648. }
  31649. }
  31650. // SetCreatedAt sets the "created_at" field.
  31651. func (m *PendingAuthSessionMutation) SetCreatedAt(t time.Time) {
  31652. m.created_at = &t
  31653. }
  31654. // CreatedAt returns the value of the "created_at" field in the mutation.
  31655. func (m *PendingAuthSessionMutation) CreatedAt() (r time.Time, exists bool) {
  31656. v := m.created_at
  31657. if v == nil {
  31658. return
  31659. }
  31660. return *v, true
  31661. }
  31662. // OldCreatedAt returns the old "created_at" field's value of the PendingAuthSession entity.
  31663. // If the PendingAuthSession object wasn't provided to the builder, the object is fetched from the database.
  31664. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31665. func (m *PendingAuthSessionMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  31666. if !m.op.Is(OpUpdateOne) {
  31667. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  31668. }
  31669. if m.id == nil || m.oldValue == nil {
  31670. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  31671. }
  31672. oldValue, err := m.oldValue(ctx)
  31673. if err != nil {
  31674. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  31675. }
  31676. return oldValue.CreatedAt, nil
  31677. }
  31678. // ResetCreatedAt resets all changes to the "created_at" field.
  31679. func (m *PendingAuthSessionMutation) ResetCreatedAt() {
  31680. m.created_at = nil
  31681. }
  31682. // SetUpdatedAt sets the "updated_at" field.
  31683. func (m *PendingAuthSessionMutation) SetUpdatedAt(t time.Time) {
  31684. m.updated_at = &t
  31685. }
  31686. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  31687. func (m *PendingAuthSessionMutation) UpdatedAt() (r time.Time, exists bool) {
  31688. v := m.updated_at
  31689. if v == nil {
  31690. return
  31691. }
  31692. return *v, true
  31693. }
  31694. // OldUpdatedAt returns the old "updated_at" field's value of the PendingAuthSession entity.
  31695. // If the PendingAuthSession object wasn't provided to the builder, the object is fetched from the database.
  31696. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31697. func (m *PendingAuthSessionMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  31698. if !m.op.Is(OpUpdateOne) {
  31699. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  31700. }
  31701. if m.id == nil || m.oldValue == nil {
  31702. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  31703. }
  31704. oldValue, err := m.oldValue(ctx)
  31705. if err != nil {
  31706. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  31707. }
  31708. return oldValue.UpdatedAt, nil
  31709. }
  31710. // ResetUpdatedAt resets all changes to the "updated_at" field.
  31711. func (m *PendingAuthSessionMutation) ResetUpdatedAt() {
  31712. m.updated_at = nil
  31713. }
  31714. // SetSessionToken sets the "session_token" field.
  31715. func (m *PendingAuthSessionMutation) SetSessionToken(s string) {
  31716. m.session_token = &s
  31717. }
  31718. // SessionToken returns the value of the "session_token" field in the mutation.
  31719. func (m *PendingAuthSessionMutation) SessionToken() (r string, exists bool) {
  31720. v := m.session_token
  31721. if v == nil {
  31722. return
  31723. }
  31724. return *v, true
  31725. }
  31726. // OldSessionToken returns the old "session_token" field's value of the PendingAuthSession entity.
  31727. // If the PendingAuthSession object wasn't provided to the builder, the object is fetched from the database.
  31728. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31729. func (m *PendingAuthSessionMutation) OldSessionToken(ctx context.Context) (v string, err error) {
  31730. if !m.op.Is(OpUpdateOne) {
  31731. return v, errors.New("OldSessionToken is only allowed on UpdateOne operations")
  31732. }
  31733. if m.id == nil || m.oldValue == nil {
  31734. return v, errors.New("OldSessionToken requires an ID field in the mutation")
  31735. }
  31736. oldValue, err := m.oldValue(ctx)
  31737. if err != nil {
  31738. return v, fmt.Errorf("querying old value for OldSessionToken: %w", err)
  31739. }
  31740. return oldValue.SessionToken, nil
  31741. }
  31742. // ResetSessionToken resets all changes to the "session_token" field.
  31743. func (m *PendingAuthSessionMutation) ResetSessionToken() {
  31744. m.session_token = nil
  31745. }
  31746. // SetIntent sets the "intent" field.
  31747. func (m *PendingAuthSessionMutation) SetIntent(s string) {
  31748. m.intent = &s
  31749. }
  31750. // Intent returns the value of the "intent" field in the mutation.
  31751. func (m *PendingAuthSessionMutation) Intent() (r string, exists bool) {
  31752. v := m.intent
  31753. if v == nil {
  31754. return
  31755. }
  31756. return *v, true
  31757. }
  31758. // OldIntent returns the old "intent" field's value of the PendingAuthSession entity.
  31759. // If the PendingAuthSession object wasn't provided to the builder, the object is fetched from the database.
  31760. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31761. func (m *PendingAuthSessionMutation) OldIntent(ctx context.Context) (v string, err error) {
  31762. if !m.op.Is(OpUpdateOne) {
  31763. return v, errors.New("OldIntent is only allowed on UpdateOne operations")
  31764. }
  31765. if m.id == nil || m.oldValue == nil {
  31766. return v, errors.New("OldIntent requires an ID field in the mutation")
  31767. }
  31768. oldValue, err := m.oldValue(ctx)
  31769. if err != nil {
  31770. return v, fmt.Errorf("querying old value for OldIntent: %w", err)
  31771. }
  31772. return oldValue.Intent, nil
  31773. }
  31774. // ResetIntent resets all changes to the "intent" field.
  31775. func (m *PendingAuthSessionMutation) ResetIntent() {
  31776. m.intent = nil
  31777. }
  31778. // SetProviderType sets the "provider_type" field.
  31779. func (m *PendingAuthSessionMutation) SetProviderType(s string) {
  31780. m.provider_type = &s
  31781. }
  31782. // ProviderType returns the value of the "provider_type" field in the mutation.
  31783. func (m *PendingAuthSessionMutation) ProviderType() (r string, exists bool) {
  31784. v := m.provider_type
  31785. if v == nil {
  31786. return
  31787. }
  31788. return *v, true
  31789. }
  31790. // OldProviderType returns the old "provider_type" field's value of the PendingAuthSession entity.
  31791. // If the PendingAuthSession object wasn't provided to the builder, the object is fetched from the database.
  31792. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31793. func (m *PendingAuthSessionMutation) OldProviderType(ctx context.Context) (v string, err error) {
  31794. if !m.op.Is(OpUpdateOne) {
  31795. return v, errors.New("OldProviderType is only allowed on UpdateOne operations")
  31796. }
  31797. if m.id == nil || m.oldValue == nil {
  31798. return v, errors.New("OldProviderType requires an ID field in the mutation")
  31799. }
  31800. oldValue, err := m.oldValue(ctx)
  31801. if err != nil {
  31802. return v, fmt.Errorf("querying old value for OldProviderType: %w", err)
  31803. }
  31804. return oldValue.ProviderType, nil
  31805. }
  31806. // ResetProviderType resets all changes to the "provider_type" field.
  31807. func (m *PendingAuthSessionMutation) ResetProviderType() {
  31808. m.provider_type = nil
  31809. }
  31810. // SetProviderKey sets the "provider_key" field.
  31811. func (m *PendingAuthSessionMutation) SetProviderKey(s string) {
  31812. m.provider_key = &s
  31813. }
  31814. // ProviderKey returns the value of the "provider_key" field in the mutation.
  31815. func (m *PendingAuthSessionMutation) ProviderKey() (r string, exists bool) {
  31816. v := m.provider_key
  31817. if v == nil {
  31818. return
  31819. }
  31820. return *v, true
  31821. }
  31822. // OldProviderKey returns the old "provider_key" field's value of the PendingAuthSession entity.
  31823. // If the PendingAuthSession object wasn't provided to the builder, the object is fetched from the database.
  31824. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31825. func (m *PendingAuthSessionMutation) OldProviderKey(ctx context.Context) (v string, err error) {
  31826. if !m.op.Is(OpUpdateOne) {
  31827. return v, errors.New("OldProviderKey is only allowed on UpdateOne operations")
  31828. }
  31829. if m.id == nil || m.oldValue == nil {
  31830. return v, errors.New("OldProviderKey requires an ID field in the mutation")
  31831. }
  31832. oldValue, err := m.oldValue(ctx)
  31833. if err != nil {
  31834. return v, fmt.Errorf("querying old value for OldProviderKey: %w", err)
  31835. }
  31836. return oldValue.ProviderKey, nil
  31837. }
  31838. // ResetProviderKey resets all changes to the "provider_key" field.
  31839. func (m *PendingAuthSessionMutation) ResetProviderKey() {
  31840. m.provider_key = nil
  31841. }
  31842. // SetProviderSubject sets the "provider_subject" field.
  31843. func (m *PendingAuthSessionMutation) SetProviderSubject(s string) {
  31844. m.provider_subject = &s
  31845. }
  31846. // ProviderSubject returns the value of the "provider_subject" field in the mutation.
  31847. func (m *PendingAuthSessionMutation) ProviderSubject() (r string, exists bool) {
  31848. v := m.provider_subject
  31849. if v == nil {
  31850. return
  31851. }
  31852. return *v, true
  31853. }
  31854. // OldProviderSubject returns the old "provider_subject" field's value of the PendingAuthSession entity.
  31855. // If the PendingAuthSession object wasn't provided to the builder, the object is fetched from the database.
  31856. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31857. func (m *PendingAuthSessionMutation) OldProviderSubject(ctx context.Context) (v string, err error) {
  31858. if !m.op.Is(OpUpdateOne) {
  31859. return v, errors.New("OldProviderSubject is only allowed on UpdateOne operations")
  31860. }
  31861. if m.id == nil || m.oldValue == nil {
  31862. return v, errors.New("OldProviderSubject requires an ID field in the mutation")
  31863. }
  31864. oldValue, err := m.oldValue(ctx)
  31865. if err != nil {
  31866. return v, fmt.Errorf("querying old value for OldProviderSubject: %w", err)
  31867. }
  31868. return oldValue.ProviderSubject, nil
  31869. }
  31870. // ResetProviderSubject resets all changes to the "provider_subject" field.
  31871. func (m *PendingAuthSessionMutation) ResetProviderSubject() {
  31872. m.provider_subject = nil
  31873. }
  31874. // SetTargetUserID sets the "target_user_id" field.
  31875. func (m *PendingAuthSessionMutation) SetTargetUserID(i int64) {
  31876. m.target_user = &i
  31877. }
  31878. // TargetUserID returns the value of the "target_user_id" field in the mutation.
  31879. func (m *PendingAuthSessionMutation) TargetUserID() (r int64, exists bool) {
  31880. v := m.target_user
  31881. if v == nil {
  31882. return
  31883. }
  31884. return *v, true
  31885. }
  31886. // OldTargetUserID returns the old "target_user_id" field's value of the PendingAuthSession entity.
  31887. // If the PendingAuthSession object wasn't provided to the builder, the object is fetched from the database.
  31888. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31889. func (m *PendingAuthSessionMutation) OldTargetUserID(ctx context.Context) (v *int64, err error) {
  31890. if !m.op.Is(OpUpdateOne) {
  31891. return v, errors.New("OldTargetUserID is only allowed on UpdateOne operations")
  31892. }
  31893. if m.id == nil || m.oldValue == nil {
  31894. return v, errors.New("OldTargetUserID requires an ID field in the mutation")
  31895. }
  31896. oldValue, err := m.oldValue(ctx)
  31897. if err != nil {
  31898. return v, fmt.Errorf("querying old value for OldTargetUserID: %w", err)
  31899. }
  31900. return oldValue.TargetUserID, nil
  31901. }
  31902. // ClearTargetUserID clears the value of the "target_user_id" field.
  31903. func (m *PendingAuthSessionMutation) ClearTargetUserID() {
  31904. m.target_user = nil
  31905. m.clearedFields[pendingauthsession.FieldTargetUserID] = struct{}{}
  31906. }
  31907. // TargetUserIDCleared returns if the "target_user_id" field was cleared in this mutation.
  31908. func (m *PendingAuthSessionMutation) TargetUserIDCleared() bool {
  31909. _, ok := m.clearedFields[pendingauthsession.FieldTargetUserID]
  31910. return ok
  31911. }
  31912. // ResetTargetUserID resets all changes to the "target_user_id" field.
  31913. func (m *PendingAuthSessionMutation) ResetTargetUserID() {
  31914. m.target_user = nil
  31915. delete(m.clearedFields, pendingauthsession.FieldTargetUserID)
  31916. }
  31917. // SetRedirectTo sets the "redirect_to" field.
  31918. func (m *PendingAuthSessionMutation) SetRedirectTo(s string) {
  31919. m.redirect_to = &s
  31920. }
  31921. // RedirectTo returns the value of the "redirect_to" field in the mutation.
  31922. func (m *PendingAuthSessionMutation) RedirectTo() (r string, exists bool) {
  31923. v := m.redirect_to
  31924. if v == nil {
  31925. return
  31926. }
  31927. return *v, true
  31928. }
  31929. // OldRedirectTo returns the old "redirect_to" field's value of the PendingAuthSession entity.
  31930. // If the PendingAuthSession object wasn't provided to the builder, the object is fetched from the database.
  31931. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31932. func (m *PendingAuthSessionMutation) OldRedirectTo(ctx context.Context) (v string, err error) {
  31933. if !m.op.Is(OpUpdateOne) {
  31934. return v, errors.New("OldRedirectTo is only allowed on UpdateOne operations")
  31935. }
  31936. if m.id == nil || m.oldValue == nil {
  31937. return v, errors.New("OldRedirectTo requires an ID field in the mutation")
  31938. }
  31939. oldValue, err := m.oldValue(ctx)
  31940. if err != nil {
  31941. return v, fmt.Errorf("querying old value for OldRedirectTo: %w", err)
  31942. }
  31943. return oldValue.RedirectTo, nil
  31944. }
  31945. // ResetRedirectTo resets all changes to the "redirect_to" field.
  31946. func (m *PendingAuthSessionMutation) ResetRedirectTo() {
  31947. m.redirect_to = nil
  31948. }
  31949. // SetResolvedEmail sets the "resolved_email" field.
  31950. func (m *PendingAuthSessionMutation) SetResolvedEmail(s string) {
  31951. m.resolved_email = &s
  31952. }
  31953. // ResolvedEmail returns the value of the "resolved_email" field in the mutation.
  31954. func (m *PendingAuthSessionMutation) ResolvedEmail() (r string, exists bool) {
  31955. v := m.resolved_email
  31956. if v == nil {
  31957. return
  31958. }
  31959. return *v, true
  31960. }
  31961. // OldResolvedEmail returns the old "resolved_email" field's value of the PendingAuthSession entity.
  31962. // If the PendingAuthSession object wasn't provided to the builder, the object is fetched from the database.
  31963. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31964. func (m *PendingAuthSessionMutation) OldResolvedEmail(ctx context.Context) (v string, err error) {
  31965. if !m.op.Is(OpUpdateOne) {
  31966. return v, errors.New("OldResolvedEmail is only allowed on UpdateOne operations")
  31967. }
  31968. if m.id == nil || m.oldValue == nil {
  31969. return v, errors.New("OldResolvedEmail requires an ID field in the mutation")
  31970. }
  31971. oldValue, err := m.oldValue(ctx)
  31972. if err != nil {
  31973. return v, fmt.Errorf("querying old value for OldResolvedEmail: %w", err)
  31974. }
  31975. return oldValue.ResolvedEmail, nil
  31976. }
  31977. // ResetResolvedEmail resets all changes to the "resolved_email" field.
  31978. func (m *PendingAuthSessionMutation) ResetResolvedEmail() {
  31979. m.resolved_email = nil
  31980. }
  31981. // SetRegistrationPasswordHash sets the "registration_password_hash" field.
  31982. func (m *PendingAuthSessionMutation) SetRegistrationPasswordHash(s string) {
  31983. m.registration_password_hash = &s
  31984. }
  31985. // RegistrationPasswordHash returns the value of the "registration_password_hash" field in the mutation.
  31986. func (m *PendingAuthSessionMutation) RegistrationPasswordHash() (r string, exists bool) {
  31987. v := m.registration_password_hash
  31988. if v == nil {
  31989. return
  31990. }
  31991. return *v, true
  31992. }
  31993. // OldRegistrationPasswordHash returns the old "registration_password_hash" field's value of the PendingAuthSession entity.
  31994. // If the PendingAuthSession object wasn't provided to the builder, the object is fetched from the database.
  31995. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31996. func (m *PendingAuthSessionMutation) OldRegistrationPasswordHash(ctx context.Context) (v string, err error) {
  31997. if !m.op.Is(OpUpdateOne) {
  31998. return v, errors.New("OldRegistrationPasswordHash is only allowed on UpdateOne operations")
  31999. }
  32000. if m.id == nil || m.oldValue == nil {
  32001. return v, errors.New("OldRegistrationPasswordHash requires an ID field in the mutation")
  32002. }
  32003. oldValue, err := m.oldValue(ctx)
  32004. if err != nil {
  32005. return v, fmt.Errorf("querying old value for OldRegistrationPasswordHash: %w", err)
  32006. }
  32007. return oldValue.RegistrationPasswordHash, nil
  32008. }
  32009. // ResetRegistrationPasswordHash resets all changes to the "registration_password_hash" field.
  32010. func (m *PendingAuthSessionMutation) ResetRegistrationPasswordHash() {
  32011. m.registration_password_hash = nil
  32012. }
  32013. // SetUpstreamIdentityClaims sets the "upstream_identity_claims" field.
  32014. func (m *PendingAuthSessionMutation) SetUpstreamIdentityClaims(value map[string]interface{}) {
  32015. m.upstream_identity_claims = &value
  32016. }
  32017. // UpstreamIdentityClaims returns the value of the "upstream_identity_claims" field in the mutation.
  32018. func (m *PendingAuthSessionMutation) UpstreamIdentityClaims() (r map[string]interface{}, exists bool) {
  32019. v := m.upstream_identity_claims
  32020. if v == nil {
  32021. return
  32022. }
  32023. return *v, true
  32024. }
  32025. // OldUpstreamIdentityClaims returns the old "upstream_identity_claims" field's value of the PendingAuthSession entity.
  32026. // If the PendingAuthSession object wasn't provided to the builder, the object is fetched from the database.
  32027. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32028. func (m *PendingAuthSessionMutation) OldUpstreamIdentityClaims(ctx context.Context) (v map[string]interface{}, err error) {
  32029. if !m.op.Is(OpUpdateOne) {
  32030. return v, errors.New("OldUpstreamIdentityClaims is only allowed on UpdateOne operations")
  32031. }
  32032. if m.id == nil || m.oldValue == nil {
  32033. return v, errors.New("OldUpstreamIdentityClaims requires an ID field in the mutation")
  32034. }
  32035. oldValue, err := m.oldValue(ctx)
  32036. if err != nil {
  32037. return v, fmt.Errorf("querying old value for OldUpstreamIdentityClaims: %w", err)
  32038. }
  32039. return oldValue.UpstreamIdentityClaims, nil
  32040. }
  32041. // ResetUpstreamIdentityClaims resets all changes to the "upstream_identity_claims" field.
  32042. func (m *PendingAuthSessionMutation) ResetUpstreamIdentityClaims() {
  32043. m.upstream_identity_claims = nil
  32044. }
  32045. // SetLocalFlowState sets the "local_flow_state" field.
  32046. func (m *PendingAuthSessionMutation) SetLocalFlowState(value map[string]interface{}) {
  32047. m.local_flow_state = &value
  32048. }
  32049. // LocalFlowState returns the value of the "local_flow_state" field in the mutation.
  32050. func (m *PendingAuthSessionMutation) LocalFlowState() (r map[string]interface{}, exists bool) {
  32051. v := m.local_flow_state
  32052. if v == nil {
  32053. return
  32054. }
  32055. return *v, true
  32056. }
  32057. // OldLocalFlowState returns the old "local_flow_state" field's value of the PendingAuthSession entity.
  32058. // If the PendingAuthSession object wasn't provided to the builder, the object is fetched from the database.
  32059. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32060. func (m *PendingAuthSessionMutation) OldLocalFlowState(ctx context.Context) (v map[string]interface{}, err error) {
  32061. if !m.op.Is(OpUpdateOne) {
  32062. return v, errors.New("OldLocalFlowState is only allowed on UpdateOne operations")
  32063. }
  32064. if m.id == nil || m.oldValue == nil {
  32065. return v, errors.New("OldLocalFlowState requires an ID field in the mutation")
  32066. }
  32067. oldValue, err := m.oldValue(ctx)
  32068. if err != nil {
  32069. return v, fmt.Errorf("querying old value for OldLocalFlowState: %w", err)
  32070. }
  32071. return oldValue.LocalFlowState, nil
  32072. }
  32073. // ResetLocalFlowState resets all changes to the "local_flow_state" field.
  32074. func (m *PendingAuthSessionMutation) ResetLocalFlowState() {
  32075. m.local_flow_state = nil
  32076. }
  32077. // SetBrowserSessionKey sets the "browser_session_key" field.
  32078. func (m *PendingAuthSessionMutation) SetBrowserSessionKey(s string) {
  32079. m.browser_session_key = &s
  32080. }
  32081. // BrowserSessionKey returns the value of the "browser_session_key" field in the mutation.
  32082. func (m *PendingAuthSessionMutation) BrowserSessionKey() (r string, exists bool) {
  32083. v := m.browser_session_key
  32084. if v == nil {
  32085. return
  32086. }
  32087. return *v, true
  32088. }
  32089. // OldBrowserSessionKey returns the old "browser_session_key" field's value of the PendingAuthSession entity.
  32090. // If the PendingAuthSession object wasn't provided to the builder, the object is fetched from the database.
  32091. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32092. func (m *PendingAuthSessionMutation) OldBrowserSessionKey(ctx context.Context) (v string, err error) {
  32093. if !m.op.Is(OpUpdateOne) {
  32094. return v, errors.New("OldBrowserSessionKey is only allowed on UpdateOne operations")
  32095. }
  32096. if m.id == nil || m.oldValue == nil {
  32097. return v, errors.New("OldBrowserSessionKey requires an ID field in the mutation")
  32098. }
  32099. oldValue, err := m.oldValue(ctx)
  32100. if err != nil {
  32101. return v, fmt.Errorf("querying old value for OldBrowserSessionKey: %w", err)
  32102. }
  32103. return oldValue.BrowserSessionKey, nil
  32104. }
  32105. // ResetBrowserSessionKey resets all changes to the "browser_session_key" field.
  32106. func (m *PendingAuthSessionMutation) ResetBrowserSessionKey() {
  32107. m.browser_session_key = nil
  32108. }
  32109. // SetCompletionCodeHash sets the "completion_code_hash" field.
  32110. func (m *PendingAuthSessionMutation) SetCompletionCodeHash(s string) {
  32111. m.completion_code_hash = &s
  32112. }
  32113. // CompletionCodeHash returns the value of the "completion_code_hash" field in the mutation.
  32114. func (m *PendingAuthSessionMutation) CompletionCodeHash() (r string, exists bool) {
  32115. v := m.completion_code_hash
  32116. if v == nil {
  32117. return
  32118. }
  32119. return *v, true
  32120. }
  32121. // OldCompletionCodeHash returns the old "completion_code_hash" field's value of the PendingAuthSession entity.
  32122. // If the PendingAuthSession object wasn't provided to the builder, the object is fetched from the database.
  32123. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32124. func (m *PendingAuthSessionMutation) OldCompletionCodeHash(ctx context.Context) (v string, err error) {
  32125. if !m.op.Is(OpUpdateOne) {
  32126. return v, errors.New("OldCompletionCodeHash is only allowed on UpdateOne operations")
  32127. }
  32128. if m.id == nil || m.oldValue == nil {
  32129. return v, errors.New("OldCompletionCodeHash requires an ID field in the mutation")
  32130. }
  32131. oldValue, err := m.oldValue(ctx)
  32132. if err != nil {
  32133. return v, fmt.Errorf("querying old value for OldCompletionCodeHash: %w", err)
  32134. }
  32135. return oldValue.CompletionCodeHash, nil
  32136. }
  32137. // ResetCompletionCodeHash resets all changes to the "completion_code_hash" field.
  32138. func (m *PendingAuthSessionMutation) ResetCompletionCodeHash() {
  32139. m.completion_code_hash = nil
  32140. }
  32141. // SetCompletionCodeExpiresAt sets the "completion_code_expires_at" field.
  32142. func (m *PendingAuthSessionMutation) SetCompletionCodeExpiresAt(t time.Time) {
  32143. m.completion_code_expires_at = &t
  32144. }
  32145. // CompletionCodeExpiresAt returns the value of the "completion_code_expires_at" field in the mutation.
  32146. func (m *PendingAuthSessionMutation) CompletionCodeExpiresAt() (r time.Time, exists bool) {
  32147. v := m.completion_code_expires_at
  32148. if v == nil {
  32149. return
  32150. }
  32151. return *v, true
  32152. }
  32153. // OldCompletionCodeExpiresAt returns the old "completion_code_expires_at" field's value of the PendingAuthSession entity.
  32154. // If the PendingAuthSession object wasn't provided to the builder, the object is fetched from the database.
  32155. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32156. func (m *PendingAuthSessionMutation) OldCompletionCodeExpiresAt(ctx context.Context) (v *time.Time, err error) {
  32157. if !m.op.Is(OpUpdateOne) {
  32158. return v, errors.New("OldCompletionCodeExpiresAt is only allowed on UpdateOne operations")
  32159. }
  32160. if m.id == nil || m.oldValue == nil {
  32161. return v, errors.New("OldCompletionCodeExpiresAt requires an ID field in the mutation")
  32162. }
  32163. oldValue, err := m.oldValue(ctx)
  32164. if err != nil {
  32165. return v, fmt.Errorf("querying old value for OldCompletionCodeExpiresAt: %w", err)
  32166. }
  32167. return oldValue.CompletionCodeExpiresAt, nil
  32168. }
  32169. // ClearCompletionCodeExpiresAt clears the value of the "completion_code_expires_at" field.
  32170. func (m *PendingAuthSessionMutation) ClearCompletionCodeExpiresAt() {
  32171. m.completion_code_expires_at = nil
  32172. m.clearedFields[pendingauthsession.FieldCompletionCodeExpiresAt] = struct{}{}
  32173. }
  32174. // CompletionCodeExpiresAtCleared returns if the "completion_code_expires_at" field was cleared in this mutation.
  32175. func (m *PendingAuthSessionMutation) CompletionCodeExpiresAtCleared() bool {
  32176. _, ok := m.clearedFields[pendingauthsession.FieldCompletionCodeExpiresAt]
  32177. return ok
  32178. }
  32179. // ResetCompletionCodeExpiresAt resets all changes to the "completion_code_expires_at" field.
  32180. func (m *PendingAuthSessionMutation) ResetCompletionCodeExpiresAt() {
  32181. m.completion_code_expires_at = nil
  32182. delete(m.clearedFields, pendingauthsession.FieldCompletionCodeExpiresAt)
  32183. }
  32184. // SetEmailVerifiedAt sets the "email_verified_at" field.
  32185. func (m *PendingAuthSessionMutation) SetEmailVerifiedAt(t time.Time) {
  32186. m.email_verified_at = &t
  32187. }
  32188. // EmailVerifiedAt returns the value of the "email_verified_at" field in the mutation.
  32189. func (m *PendingAuthSessionMutation) EmailVerifiedAt() (r time.Time, exists bool) {
  32190. v := m.email_verified_at
  32191. if v == nil {
  32192. return
  32193. }
  32194. return *v, true
  32195. }
  32196. // OldEmailVerifiedAt returns the old "email_verified_at" field's value of the PendingAuthSession entity.
  32197. // If the PendingAuthSession object wasn't provided to the builder, the object is fetched from the database.
  32198. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32199. func (m *PendingAuthSessionMutation) OldEmailVerifiedAt(ctx context.Context) (v *time.Time, err error) {
  32200. if !m.op.Is(OpUpdateOne) {
  32201. return v, errors.New("OldEmailVerifiedAt is only allowed on UpdateOne operations")
  32202. }
  32203. if m.id == nil || m.oldValue == nil {
  32204. return v, errors.New("OldEmailVerifiedAt requires an ID field in the mutation")
  32205. }
  32206. oldValue, err := m.oldValue(ctx)
  32207. if err != nil {
  32208. return v, fmt.Errorf("querying old value for OldEmailVerifiedAt: %w", err)
  32209. }
  32210. return oldValue.EmailVerifiedAt, nil
  32211. }
  32212. // ClearEmailVerifiedAt clears the value of the "email_verified_at" field.
  32213. func (m *PendingAuthSessionMutation) ClearEmailVerifiedAt() {
  32214. m.email_verified_at = nil
  32215. m.clearedFields[pendingauthsession.FieldEmailVerifiedAt] = struct{}{}
  32216. }
  32217. // EmailVerifiedAtCleared returns if the "email_verified_at" field was cleared in this mutation.
  32218. func (m *PendingAuthSessionMutation) EmailVerifiedAtCleared() bool {
  32219. _, ok := m.clearedFields[pendingauthsession.FieldEmailVerifiedAt]
  32220. return ok
  32221. }
  32222. // ResetEmailVerifiedAt resets all changes to the "email_verified_at" field.
  32223. func (m *PendingAuthSessionMutation) ResetEmailVerifiedAt() {
  32224. m.email_verified_at = nil
  32225. delete(m.clearedFields, pendingauthsession.FieldEmailVerifiedAt)
  32226. }
  32227. // SetPasswordVerifiedAt sets the "password_verified_at" field.
  32228. func (m *PendingAuthSessionMutation) SetPasswordVerifiedAt(t time.Time) {
  32229. m.password_verified_at = &t
  32230. }
  32231. // PasswordVerifiedAt returns the value of the "password_verified_at" field in the mutation.
  32232. func (m *PendingAuthSessionMutation) PasswordVerifiedAt() (r time.Time, exists bool) {
  32233. v := m.password_verified_at
  32234. if v == nil {
  32235. return
  32236. }
  32237. return *v, true
  32238. }
  32239. // OldPasswordVerifiedAt returns the old "password_verified_at" field's value of the PendingAuthSession entity.
  32240. // If the PendingAuthSession object wasn't provided to the builder, the object is fetched from the database.
  32241. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32242. func (m *PendingAuthSessionMutation) OldPasswordVerifiedAt(ctx context.Context) (v *time.Time, err error) {
  32243. if !m.op.Is(OpUpdateOne) {
  32244. return v, errors.New("OldPasswordVerifiedAt is only allowed on UpdateOne operations")
  32245. }
  32246. if m.id == nil || m.oldValue == nil {
  32247. return v, errors.New("OldPasswordVerifiedAt requires an ID field in the mutation")
  32248. }
  32249. oldValue, err := m.oldValue(ctx)
  32250. if err != nil {
  32251. return v, fmt.Errorf("querying old value for OldPasswordVerifiedAt: %w", err)
  32252. }
  32253. return oldValue.PasswordVerifiedAt, nil
  32254. }
  32255. // ClearPasswordVerifiedAt clears the value of the "password_verified_at" field.
  32256. func (m *PendingAuthSessionMutation) ClearPasswordVerifiedAt() {
  32257. m.password_verified_at = nil
  32258. m.clearedFields[pendingauthsession.FieldPasswordVerifiedAt] = struct{}{}
  32259. }
  32260. // PasswordVerifiedAtCleared returns if the "password_verified_at" field was cleared in this mutation.
  32261. func (m *PendingAuthSessionMutation) PasswordVerifiedAtCleared() bool {
  32262. _, ok := m.clearedFields[pendingauthsession.FieldPasswordVerifiedAt]
  32263. return ok
  32264. }
  32265. // ResetPasswordVerifiedAt resets all changes to the "password_verified_at" field.
  32266. func (m *PendingAuthSessionMutation) ResetPasswordVerifiedAt() {
  32267. m.password_verified_at = nil
  32268. delete(m.clearedFields, pendingauthsession.FieldPasswordVerifiedAt)
  32269. }
  32270. // SetTotpVerifiedAt sets the "totp_verified_at" field.
  32271. func (m *PendingAuthSessionMutation) SetTotpVerifiedAt(t time.Time) {
  32272. m.totp_verified_at = &t
  32273. }
  32274. // TotpVerifiedAt returns the value of the "totp_verified_at" field in the mutation.
  32275. func (m *PendingAuthSessionMutation) TotpVerifiedAt() (r time.Time, exists bool) {
  32276. v := m.totp_verified_at
  32277. if v == nil {
  32278. return
  32279. }
  32280. return *v, true
  32281. }
  32282. // OldTotpVerifiedAt returns the old "totp_verified_at" field's value of the PendingAuthSession entity.
  32283. // If the PendingAuthSession object wasn't provided to the builder, the object is fetched from the database.
  32284. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32285. func (m *PendingAuthSessionMutation) OldTotpVerifiedAt(ctx context.Context) (v *time.Time, err error) {
  32286. if !m.op.Is(OpUpdateOne) {
  32287. return v, errors.New("OldTotpVerifiedAt is only allowed on UpdateOne operations")
  32288. }
  32289. if m.id == nil || m.oldValue == nil {
  32290. return v, errors.New("OldTotpVerifiedAt requires an ID field in the mutation")
  32291. }
  32292. oldValue, err := m.oldValue(ctx)
  32293. if err != nil {
  32294. return v, fmt.Errorf("querying old value for OldTotpVerifiedAt: %w", err)
  32295. }
  32296. return oldValue.TotpVerifiedAt, nil
  32297. }
  32298. // ClearTotpVerifiedAt clears the value of the "totp_verified_at" field.
  32299. func (m *PendingAuthSessionMutation) ClearTotpVerifiedAt() {
  32300. m.totp_verified_at = nil
  32301. m.clearedFields[pendingauthsession.FieldTotpVerifiedAt] = struct{}{}
  32302. }
  32303. // TotpVerifiedAtCleared returns if the "totp_verified_at" field was cleared in this mutation.
  32304. func (m *PendingAuthSessionMutation) TotpVerifiedAtCleared() bool {
  32305. _, ok := m.clearedFields[pendingauthsession.FieldTotpVerifiedAt]
  32306. return ok
  32307. }
  32308. // ResetTotpVerifiedAt resets all changes to the "totp_verified_at" field.
  32309. func (m *PendingAuthSessionMutation) ResetTotpVerifiedAt() {
  32310. m.totp_verified_at = nil
  32311. delete(m.clearedFields, pendingauthsession.FieldTotpVerifiedAt)
  32312. }
  32313. // SetExpiresAt sets the "expires_at" field.
  32314. func (m *PendingAuthSessionMutation) SetExpiresAt(t time.Time) {
  32315. m.expires_at = &t
  32316. }
  32317. // ExpiresAt returns the value of the "expires_at" field in the mutation.
  32318. func (m *PendingAuthSessionMutation) ExpiresAt() (r time.Time, exists bool) {
  32319. v := m.expires_at
  32320. if v == nil {
  32321. return
  32322. }
  32323. return *v, true
  32324. }
  32325. // OldExpiresAt returns the old "expires_at" field's value of the PendingAuthSession entity.
  32326. // If the PendingAuthSession object wasn't provided to the builder, the object is fetched from the database.
  32327. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32328. func (m *PendingAuthSessionMutation) OldExpiresAt(ctx context.Context) (v time.Time, err error) {
  32329. if !m.op.Is(OpUpdateOne) {
  32330. return v, errors.New("OldExpiresAt is only allowed on UpdateOne operations")
  32331. }
  32332. if m.id == nil || m.oldValue == nil {
  32333. return v, errors.New("OldExpiresAt requires an ID field in the mutation")
  32334. }
  32335. oldValue, err := m.oldValue(ctx)
  32336. if err != nil {
  32337. return v, fmt.Errorf("querying old value for OldExpiresAt: %w", err)
  32338. }
  32339. return oldValue.ExpiresAt, nil
  32340. }
  32341. // ResetExpiresAt resets all changes to the "expires_at" field.
  32342. func (m *PendingAuthSessionMutation) ResetExpiresAt() {
  32343. m.expires_at = nil
  32344. }
  32345. // SetConsumedAt sets the "consumed_at" field.
  32346. func (m *PendingAuthSessionMutation) SetConsumedAt(t time.Time) {
  32347. m.consumed_at = &t
  32348. }
  32349. // ConsumedAt returns the value of the "consumed_at" field in the mutation.
  32350. func (m *PendingAuthSessionMutation) ConsumedAt() (r time.Time, exists bool) {
  32351. v := m.consumed_at
  32352. if v == nil {
  32353. return
  32354. }
  32355. return *v, true
  32356. }
  32357. // OldConsumedAt returns the old "consumed_at" field's value of the PendingAuthSession entity.
  32358. // If the PendingAuthSession object wasn't provided to the builder, the object is fetched from the database.
  32359. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32360. func (m *PendingAuthSessionMutation) OldConsumedAt(ctx context.Context) (v *time.Time, err error) {
  32361. if !m.op.Is(OpUpdateOne) {
  32362. return v, errors.New("OldConsumedAt is only allowed on UpdateOne operations")
  32363. }
  32364. if m.id == nil || m.oldValue == nil {
  32365. return v, errors.New("OldConsumedAt requires an ID field in the mutation")
  32366. }
  32367. oldValue, err := m.oldValue(ctx)
  32368. if err != nil {
  32369. return v, fmt.Errorf("querying old value for OldConsumedAt: %w", err)
  32370. }
  32371. return oldValue.ConsumedAt, nil
  32372. }
  32373. // ClearConsumedAt clears the value of the "consumed_at" field.
  32374. func (m *PendingAuthSessionMutation) ClearConsumedAt() {
  32375. m.consumed_at = nil
  32376. m.clearedFields[pendingauthsession.FieldConsumedAt] = struct{}{}
  32377. }
  32378. // ConsumedAtCleared returns if the "consumed_at" field was cleared in this mutation.
  32379. func (m *PendingAuthSessionMutation) ConsumedAtCleared() bool {
  32380. _, ok := m.clearedFields[pendingauthsession.FieldConsumedAt]
  32381. return ok
  32382. }
  32383. // ResetConsumedAt resets all changes to the "consumed_at" field.
  32384. func (m *PendingAuthSessionMutation) ResetConsumedAt() {
  32385. m.consumed_at = nil
  32386. delete(m.clearedFields, pendingauthsession.FieldConsumedAt)
  32387. }
  32388. // ClearTargetUser clears the "target_user" edge to the User entity.
  32389. func (m *PendingAuthSessionMutation) ClearTargetUser() {
  32390. m.clearedtarget_user = true
  32391. m.clearedFields[pendingauthsession.FieldTargetUserID] = struct{}{}
  32392. }
  32393. // TargetUserCleared reports if the "target_user" edge to the User entity was cleared.
  32394. func (m *PendingAuthSessionMutation) TargetUserCleared() bool {
  32395. return m.TargetUserIDCleared() || m.clearedtarget_user
  32396. }
  32397. // TargetUserIDs returns the "target_user" edge IDs in the mutation.
  32398. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  32399. // TargetUserID instead. It exists only for internal usage by the builders.
  32400. func (m *PendingAuthSessionMutation) TargetUserIDs() (ids []int64) {
  32401. if id := m.target_user; id != nil {
  32402. ids = append(ids, *id)
  32403. }
  32404. return
  32405. }
  32406. // ResetTargetUser resets all changes to the "target_user" edge.
  32407. func (m *PendingAuthSessionMutation) ResetTargetUser() {
  32408. m.target_user = nil
  32409. m.clearedtarget_user = false
  32410. }
  32411. // SetAdoptionDecisionID sets the "adoption_decision" edge to the IdentityAdoptionDecision entity by id.
  32412. func (m *PendingAuthSessionMutation) SetAdoptionDecisionID(id int64) {
  32413. m.adoption_decision = &id
  32414. }
  32415. // ClearAdoptionDecision clears the "adoption_decision" edge to the IdentityAdoptionDecision entity.
  32416. func (m *PendingAuthSessionMutation) ClearAdoptionDecision() {
  32417. m.clearedadoption_decision = true
  32418. }
  32419. // AdoptionDecisionCleared reports if the "adoption_decision" edge to the IdentityAdoptionDecision entity was cleared.
  32420. func (m *PendingAuthSessionMutation) AdoptionDecisionCleared() bool {
  32421. return m.clearedadoption_decision
  32422. }
  32423. // AdoptionDecisionID returns the "adoption_decision" edge ID in the mutation.
  32424. func (m *PendingAuthSessionMutation) AdoptionDecisionID() (id int64, exists bool) {
  32425. if m.adoption_decision != nil {
  32426. return *m.adoption_decision, true
  32427. }
  32428. return
  32429. }
  32430. // AdoptionDecisionIDs returns the "adoption_decision" edge IDs in the mutation.
  32431. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  32432. // AdoptionDecisionID instead. It exists only for internal usage by the builders.
  32433. func (m *PendingAuthSessionMutation) AdoptionDecisionIDs() (ids []int64) {
  32434. if id := m.adoption_decision; id != nil {
  32435. ids = append(ids, *id)
  32436. }
  32437. return
  32438. }
  32439. // ResetAdoptionDecision resets all changes to the "adoption_decision" edge.
  32440. func (m *PendingAuthSessionMutation) ResetAdoptionDecision() {
  32441. m.adoption_decision = nil
  32442. m.clearedadoption_decision = false
  32443. }
  32444. // Where appends a list predicates to the PendingAuthSessionMutation builder.
  32445. func (m *PendingAuthSessionMutation) Where(ps ...predicate.PendingAuthSession) {
  32446. m.predicates = append(m.predicates, ps...)
  32447. }
  32448. // WhereP appends storage-level predicates to the PendingAuthSessionMutation builder. Using this method,
  32449. // users can use type-assertion to append predicates that do not depend on any generated package.
  32450. func (m *PendingAuthSessionMutation) WhereP(ps ...func(*sql.Selector)) {
  32451. p := make([]predicate.PendingAuthSession, len(ps))
  32452. for i := range ps {
  32453. p[i] = ps[i]
  32454. }
  32455. m.Where(p...)
  32456. }
  32457. // Op returns the operation name.
  32458. func (m *PendingAuthSessionMutation) Op() Op {
  32459. return m.op
  32460. }
  32461. // SetOp allows setting the mutation operation.
  32462. func (m *PendingAuthSessionMutation) SetOp(op Op) {
  32463. m.op = op
  32464. }
  32465. // Type returns the node type of this mutation (PendingAuthSession).
  32466. func (m *PendingAuthSessionMutation) Type() string {
  32467. return m.typ
  32468. }
  32469. // Fields returns all fields that were changed during this mutation. Note that in
  32470. // order to get all numeric fields that were incremented/decremented, call
  32471. // AddedFields().
  32472. func (m *PendingAuthSessionMutation) Fields() []string {
  32473. fields := make([]string, 0, 21)
  32474. if m.created_at != nil {
  32475. fields = append(fields, pendingauthsession.FieldCreatedAt)
  32476. }
  32477. if m.updated_at != nil {
  32478. fields = append(fields, pendingauthsession.FieldUpdatedAt)
  32479. }
  32480. if m.session_token != nil {
  32481. fields = append(fields, pendingauthsession.FieldSessionToken)
  32482. }
  32483. if m.intent != nil {
  32484. fields = append(fields, pendingauthsession.FieldIntent)
  32485. }
  32486. if m.provider_type != nil {
  32487. fields = append(fields, pendingauthsession.FieldProviderType)
  32488. }
  32489. if m.provider_key != nil {
  32490. fields = append(fields, pendingauthsession.FieldProviderKey)
  32491. }
  32492. if m.provider_subject != nil {
  32493. fields = append(fields, pendingauthsession.FieldProviderSubject)
  32494. }
  32495. if m.target_user != nil {
  32496. fields = append(fields, pendingauthsession.FieldTargetUserID)
  32497. }
  32498. if m.redirect_to != nil {
  32499. fields = append(fields, pendingauthsession.FieldRedirectTo)
  32500. }
  32501. if m.resolved_email != nil {
  32502. fields = append(fields, pendingauthsession.FieldResolvedEmail)
  32503. }
  32504. if m.registration_password_hash != nil {
  32505. fields = append(fields, pendingauthsession.FieldRegistrationPasswordHash)
  32506. }
  32507. if m.upstream_identity_claims != nil {
  32508. fields = append(fields, pendingauthsession.FieldUpstreamIdentityClaims)
  32509. }
  32510. if m.local_flow_state != nil {
  32511. fields = append(fields, pendingauthsession.FieldLocalFlowState)
  32512. }
  32513. if m.browser_session_key != nil {
  32514. fields = append(fields, pendingauthsession.FieldBrowserSessionKey)
  32515. }
  32516. if m.completion_code_hash != nil {
  32517. fields = append(fields, pendingauthsession.FieldCompletionCodeHash)
  32518. }
  32519. if m.completion_code_expires_at != nil {
  32520. fields = append(fields, pendingauthsession.FieldCompletionCodeExpiresAt)
  32521. }
  32522. if m.email_verified_at != nil {
  32523. fields = append(fields, pendingauthsession.FieldEmailVerifiedAt)
  32524. }
  32525. if m.password_verified_at != nil {
  32526. fields = append(fields, pendingauthsession.FieldPasswordVerifiedAt)
  32527. }
  32528. if m.totp_verified_at != nil {
  32529. fields = append(fields, pendingauthsession.FieldTotpVerifiedAt)
  32530. }
  32531. if m.expires_at != nil {
  32532. fields = append(fields, pendingauthsession.FieldExpiresAt)
  32533. }
  32534. if m.consumed_at != nil {
  32535. fields = append(fields, pendingauthsession.FieldConsumedAt)
  32536. }
  32537. return fields
  32538. }
  32539. // Field returns the value of a field with the given name. The second boolean
  32540. // return value indicates that this field was not set, or was not defined in the
  32541. // schema.
  32542. func (m *PendingAuthSessionMutation) Field(name string) (ent.Value, bool) {
  32543. switch name {
  32544. case pendingauthsession.FieldCreatedAt:
  32545. return m.CreatedAt()
  32546. case pendingauthsession.FieldUpdatedAt:
  32547. return m.UpdatedAt()
  32548. case pendingauthsession.FieldSessionToken:
  32549. return m.SessionToken()
  32550. case pendingauthsession.FieldIntent:
  32551. return m.Intent()
  32552. case pendingauthsession.FieldProviderType:
  32553. return m.ProviderType()
  32554. case pendingauthsession.FieldProviderKey:
  32555. return m.ProviderKey()
  32556. case pendingauthsession.FieldProviderSubject:
  32557. return m.ProviderSubject()
  32558. case pendingauthsession.FieldTargetUserID:
  32559. return m.TargetUserID()
  32560. case pendingauthsession.FieldRedirectTo:
  32561. return m.RedirectTo()
  32562. case pendingauthsession.FieldResolvedEmail:
  32563. return m.ResolvedEmail()
  32564. case pendingauthsession.FieldRegistrationPasswordHash:
  32565. return m.RegistrationPasswordHash()
  32566. case pendingauthsession.FieldUpstreamIdentityClaims:
  32567. return m.UpstreamIdentityClaims()
  32568. case pendingauthsession.FieldLocalFlowState:
  32569. return m.LocalFlowState()
  32570. case pendingauthsession.FieldBrowserSessionKey:
  32571. return m.BrowserSessionKey()
  32572. case pendingauthsession.FieldCompletionCodeHash:
  32573. return m.CompletionCodeHash()
  32574. case pendingauthsession.FieldCompletionCodeExpiresAt:
  32575. return m.CompletionCodeExpiresAt()
  32576. case pendingauthsession.FieldEmailVerifiedAt:
  32577. return m.EmailVerifiedAt()
  32578. case pendingauthsession.FieldPasswordVerifiedAt:
  32579. return m.PasswordVerifiedAt()
  32580. case pendingauthsession.FieldTotpVerifiedAt:
  32581. return m.TotpVerifiedAt()
  32582. case pendingauthsession.FieldExpiresAt:
  32583. return m.ExpiresAt()
  32584. case pendingauthsession.FieldConsumedAt:
  32585. return m.ConsumedAt()
  32586. }
  32587. return nil, false
  32588. }
  32589. // OldField returns the old value of the field from the database. An error is
  32590. // returned if the mutation operation is not UpdateOne, or the query to the
  32591. // database failed.
  32592. func (m *PendingAuthSessionMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  32593. switch name {
  32594. case pendingauthsession.FieldCreatedAt:
  32595. return m.OldCreatedAt(ctx)
  32596. case pendingauthsession.FieldUpdatedAt:
  32597. return m.OldUpdatedAt(ctx)
  32598. case pendingauthsession.FieldSessionToken:
  32599. return m.OldSessionToken(ctx)
  32600. case pendingauthsession.FieldIntent:
  32601. return m.OldIntent(ctx)
  32602. case pendingauthsession.FieldProviderType:
  32603. return m.OldProviderType(ctx)
  32604. case pendingauthsession.FieldProviderKey:
  32605. return m.OldProviderKey(ctx)
  32606. case pendingauthsession.FieldProviderSubject:
  32607. return m.OldProviderSubject(ctx)
  32608. case pendingauthsession.FieldTargetUserID:
  32609. return m.OldTargetUserID(ctx)
  32610. case pendingauthsession.FieldRedirectTo:
  32611. return m.OldRedirectTo(ctx)
  32612. case pendingauthsession.FieldResolvedEmail:
  32613. return m.OldResolvedEmail(ctx)
  32614. case pendingauthsession.FieldRegistrationPasswordHash:
  32615. return m.OldRegistrationPasswordHash(ctx)
  32616. case pendingauthsession.FieldUpstreamIdentityClaims:
  32617. return m.OldUpstreamIdentityClaims(ctx)
  32618. case pendingauthsession.FieldLocalFlowState:
  32619. return m.OldLocalFlowState(ctx)
  32620. case pendingauthsession.FieldBrowserSessionKey:
  32621. return m.OldBrowserSessionKey(ctx)
  32622. case pendingauthsession.FieldCompletionCodeHash:
  32623. return m.OldCompletionCodeHash(ctx)
  32624. case pendingauthsession.FieldCompletionCodeExpiresAt:
  32625. return m.OldCompletionCodeExpiresAt(ctx)
  32626. case pendingauthsession.FieldEmailVerifiedAt:
  32627. return m.OldEmailVerifiedAt(ctx)
  32628. case pendingauthsession.FieldPasswordVerifiedAt:
  32629. return m.OldPasswordVerifiedAt(ctx)
  32630. case pendingauthsession.FieldTotpVerifiedAt:
  32631. return m.OldTotpVerifiedAt(ctx)
  32632. case pendingauthsession.FieldExpiresAt:
  32633. return m.OldExpiresAt(ctx)
  32634. case pendingauthsession.FieldConsumedAt:
  32635. return m.OldConsumedAt(ctx)
  32636. }
  32637. return nil, fmt.Errorf("unknown PendingAuthSession field %s", name)
  32638. }
  32639. // SetField sets the value of a field with the given name. It returns an error if
  32640. // the field is not defined in the schema, or if the type mismatched the field
  32641. // type.
  32642. func (m *PendingAuthSessionMutation) SetField(name string, value ent.Value) error {
  32643. switch name {
  32644. case pendingauthsession.FieldCreatedAt:
  32645. v, ok := value.(time.Time)
  32646. if !ok {
  32647. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32648. }
  32649. m.SetCreatedAt(v)
  32650. return nil
  32651. case pendingauthsession.FieldUpdatedAt:
  32652. v, ok := value.(time.Time)
  32653. if !ok {
  32654. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32655. }
  32656. m.SetUpdatedAt(v)
  32657. return nil
  32658. case pendingauthsession.FieldSessionToken:
  32659. v, ok := value.(string)
  32660. if !ok {
  32661. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32662. }
  32663. m.SetSessionToken(v)
  32664. return nil
  32665. case pendingauthsession.FieldIntent:
  32666. v, ok := value.(string)
  32667. if !ok {
  32668. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32669. }
  32670. m.SetIntent(v)
  32671. return nil
  32672. case pendingauthsession.FieldProviderType:
  32673. v, ok := value.(string)
  32674. if !ok {
  32675. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32676. }
  32677. m.SetProviderType(v)
  32678. return nil
  32679. case pendingauthsession.FieldProviderKey:
  32680. v, ok := value.(string)
  32681. if !ok {
  32682. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32683. }
  32684. m.SetProviderKey(v)
  32685. return nil
  32686. case pendingauthsession.FieldProviderSubject:
  32687. v, ok := value.(string)
  32688. if !ok {
  32689. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32690. }
  32691. m.SetProviderSubject(v)
  32692. return nil
  32693. case pendingauthsession.FieldTargetUserID:
  32694. v, ok := value.(int64)
  32695. if !ok {
  32696. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32697. }
  32698. m.SetTargetUserID(v)
  32699. return nil
  32700. case pendingauthsession.FieldRedirectTo:
  32701. v, ok := value.(string)
  32702. if !ok {
  32703. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32704. }
  32705. m.SetRedirectTo(v)
  32706. return nil
  32707. case pendingauthsession.FieldResolvedEmail:
  32708. v, ok := value.(string)
  32709. if !ok {
  32710. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32711. }
  32712. m.SetResolvedEmail(v)
  32713. return nil
  32714. case pendingauthsession.FieldRegistrationPasswordHash:
  32715. v, ok := value.(string)
  32716. if !ok {
  32717. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32718. }
  32719. m.SetRegistrationPasswordHash(v)
  32720. return nil
  32721. case pendingauthsession.FieldUpstreamIdentityClaims:
  32722. v, ok := value.(map[string]interface{})
  32723. if !ok {
  32724. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32725. }
  32726. m.SetUpstreamIdentityClaims(v)
  32727. return nil
  32728. case pendingauthsession.FieldLocalFlowState:
  32729. v, ok := value.(map[string]interface{})
  32730. if !ok {
  32731. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32732. }
  32733. m.SetLocalFlowState(v)
  32734. return nil
  32735. case pendingauthsession.FieldBrowserSessionKey:
  32736. v, ok := value.(string)
  32737. if !ok {
  32738. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32739. }
  32740. m.SetBrowserSessionKey(v)
  32741. return nil
  32742. case pendingauthsession.FieldCompletionCodeHash:
  32743. v, ok := value.(string)
  32744. if !ok {
  32745. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32746. }
  32747. m.SetCompletionCodeHash(v)
  32748. return nil
  32749. case pendingauthsession.FieldCompletionCodeExpiresAt:
  32750. v, ok := value.(time.Time)
  32751. if !ok {
  32752. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32753. }
  32754. m.SetCompletionCodeExpiresAt(v)
  32755. return nil
  32756. case pendingauthsession.FieldEmailVerifiedAt:
  32757. v, ok := value.(time.Time)
  32758. if !ok {
  32759. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32760. }
  32761. m.SetEmailVerifiedAt(v)
  32762. return nil
  32763. case pendingauthsession.FieldPasswordVerifiedAt:
  32764. v, ok := value.(time.Time)
  32765. if !ok {
  32766. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32767. }
  32768. m.SetPasswordVerifiedAt(v)
  32769. return nil
  32770. case pendingauthsession.FieldTotpVerifiedAt:
  32771. v, ok := value.(time.Time)
  32772. if !ok {
  32773. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32774. }
  32775. m.SetTotpVerifiedAt(v)
  32776. return nil
  32777. case pendingauthsession.FieldExpiresAt:
  32778. v, ok := value.(time.Time)
  32779. if !ok {
  32780. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32781. }
  32782. m.SetExpiresAt(v)
  32783. return nil
  32784. case pendingauthsession.FieldConsumedAt:
  32785. v, ok := value.(time.Time)
  32786. if !ok {
  32787. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32788. }
  32789. m.SetConsumedAt(v)
  32790. return nil
  32791. }
  32792. return fmt.Errorf("unknown PendingAuthSession field %s", name)
  32793. }
  32794. // AddedFields returns all numeric fields that were incremented/decremented during
  32795. // this mutation.
  32796. func (m *PendingAuthSessionMutation) AddedFields() []string {
  32797. var fields []string
  32798. return fields
  32799. }
  32800. // AddedField returns the numeric value that was incremented/decremented on a field
  32801. // with the given name. The second boolean return value indicates that this field
  32802. // was not set, or was not defined in the schema.
  32803. func (m *PendingAuthSessionMutation) AddedField(name string) (ent.Value, bool) {
  32804. switch name {
  32805. }
  32806. return nil, false
  32807. }
  32808. // AddField adds the value to the field with the given name. It returns an error if
  32809. // the field is not defined in the schema, or if the type mismatched the field
  32810. // type.
  32811. func (m *PendingAuthSessionMutation) AddField(name string, value ent.Value) error {
  32812. switch name {
  32813. }
  32814. return fmt.Errorf("unknown PendingAuthSession numeric field %s", name)
  32815. }
  32816. // ClearedFields returns all nullable fields that were cleared during this
  32817. // mutation.
  32818. func (m *PendingAuthSessionMutation) ClearedFields() []string {
  32819. var fields []string
  32820. if m.FieldCleared(pendingauthsession.FieldTargetUserID) {
  32821. fields = append(fields, pendingauthsession.FieldTargetUserID)
  32822. }
  32823. if m.FieldCleared(pendingauthsession.FieldCompletionCodeExpiresAt) {
  32824. fields = append(fields, pendingauthsession.FieldCompletionCodeExpiresAt)
  32825. }
  32826. if m.FieldCleared(pendingauthsession.FieldEmailVerifiedAt) {
  32827. fields = append(fields, pendingauthsession.FieldEmailVerifiedAt)
  32828. }
  32829. if m.FieldCleared(pendingauthsession.FieldPasswordVerifiedAt) {
  32830. fields = append(fields, pendingauthsession.FieldPasswordVerifiedAt)
  32831. }
  32832. if m.FieldCleared(pendingauthsession.FieldTotpVerifiedAt) {
  32833. fields = append(fields, pendingauthsession.FieldTotpVerifiedAt)
  32834. }
  32835. if m.FieldCleared(pendingauthsession.FieldConsumedAt) {
  32836. fields = append(fields, pendingauthsession.FieldConsumedAt)
  32837. }
  32838. return fields
  32839. }
  32840. // FieldCleared returns a boolean indicating if a field with the given name was
  32841. // cleared in this mutation.
  32842. func (m *PendingAuthSessionMutation) FieldCleared(name string) bool {
  32843. _, ok := m.clearedFields[name]
  32844. return ok
  32845. }
  32846. // ClearField clears the value of the field with the given name. It returns an
  32847. // error if the field is not defined in the schema.
  32848. func (m *PendingAuthSessionMutation) ClearField(name string) error {
  32849. switch name {
  32850. case pendingauthsession.FieldTargetUserID:
  32851. m.ClearTargetUserID()
  32852. return nil
  32853. case pendingauthsession.FieldCompletionCodeExpiresAt:
  32854. m.ClearCompletionCodeExpiresAt()
  32855. return nil
  32856. case pendingauthsession.FieldEmailVerifiedAt:
  32857. m.ClearEmailVerifiedAt()
  32858. return nil
  32859. case pendingauthsession.FieldPasswordVerifiedAt:
  32860. m.ClearPasswordVerifiedAt()
  32861. return nil
  32862. case pendingauthsession.FieldTotpVerifiedAt:
  32863. m.ClearTotpVerifiedAt()
  32864. return nil
  32865. case pendingauthsession.FieldConsumedAt:
  32866. m.ClearConsumedAt()
  32867. return nil
  32868. }
  32869. return fmt.Errorf("unknown PendingAuthSession nullable field %s", name)
  32870. }
  32871. // ResetField resets all changes in the mutation for the field with the given name.
  32872. // It returns an error if the field is not defined in the schema.
  32873. func (m *PendingAuthSessionMutation) ResetField(name string) error {
  32874. switch name {
  32875. case pendingauthsession.FieldCreatedAt:
  32876. m.ResetCreatedAt()
  32877. return nil
  32878. case pendingauthsession.FieldUpdatedAt:
  32879. m.ResetUpdatedAt()
  32880. return nil
  32881. case pendingauthsession.FieldSessionToken:
  32882. m.ResetSessionToken()
  32883. return nil
  32884. case pendingauthsession.FieldIntent:
  32885. m.ResetIntent()
  32886. return nil
  32887. case pendingauthsession.FieldProviderType:
  32888. m.ResetProviderType()
  32889. return nil
  32890. case pendingauthsession.FieldProviderKey:
  32891. m.ResetProviderKey()
  32892. return nil
  32893. case pendingauthsession.FieldProviderSubject:
  32894. m.ResetProviderSubject()
  32895. return nil
  32896. case pendingauthsession.FieldTargetUserID:
  32897. m.ResetTargetUserID()
  32898. return nil
  32899. case pendingauthsession.FieldRedirectTo:
  32900. m.ResetRedirectTo()
  32901. return nil
  32902. case pendingauthsession.FieldResolvedEmail:
  32903. m.ResetResolvedEmail()
  32904. return nil
  32905. case pendingauthsession.FieldRegistrationPasswordHash:
  32906. m.ResetRegistrationPasswordHash()
  32907. return nil
  32908. case pendingauthsession.FieldUpstreamIdentityClaims:
  32909. m.ResetUpstreamIdentityClaims()
  32910. return nil
  32911. case pendingauthsession.FieldLocalFlowState:
  32912. m.ResetLocalFlowState()
  32913. return nil
  32914. case pendingauthsession.FieldBrowserSessionKey:
  32915. m.ResetBrowserSessionKey()
  32916. return nil
  32917. case pendingauthsession.FieldCompletionCodeHash:
  32918. m.ResetCompletionCodeHash()
  32919. return nil
  32920. case pendingauthsession.FieldCompletionCodeExpiresAt:
  32921. m.ResetCompletionCodeExpiresAt()
  32922. return nil
  32923. case pendingauthsession.FieldEmailVerifiedAt:
  32924. m.ResetEmailVerifiedAt()
  32925. return nil
  32926. case pendingauthsession.FieldPasswordVerifiedAt:
  32927. m.ResetPasswordVerifiedAt()
  32928. return nil
  32929. case pendingauthsession.FieldTotpVerifiedAt:
  32930. m.ResetTotpVerifiedAt()
  32931. return nil
  32932. case pendingauthsession.FieldExpiresAt:
  32933. m.ResetExpiresAt()
  32934. return nil
  32935. case pendingauthsession.FieldConsumedAt:
  32936. m.ResetConsumedAt()
  32937. return nil
  32938. }
  32939. return fmt.Errorf("unknown PendingAuthSession field %s", name)
  32940. }
  32941. // AddedEdges returns all edge names that were set/added in this mutation.
  32942. func (m *PendingAuthSessionMutation) AddedEdges() []string {
  32943. edges := make([]string, 0, 2)
  32944. if m.target_user != nil {
  32945. edges = append(edges, pendingauthsession.EdgeTargetUser)
  32946. }
  32947. if m.adoption_decision != nil {
  32948. edges = append(edges, pendingauthsession.EdgeAdoptionDecision)
  32949. }
  32950. return edges
  32951. }
  32952. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  32953. // name in this mutation.
  32954. func (m *PendingAuthSessionMutation) AddedIDs(name string) []ent.Value {
  32955. switch name {
  32956. case pendingauthsession.EdgeTargetUser:
  32957. if id := m.target_user; id != nil {
  32958. return []ent.Value{*id}
  32959. }
  32960. case pendingauthsession.EdgeAdoptionDecision:
  32961. if id := m.adoption_decision; id != nil {
  32962. return []ent.Value{*id}
  32963. }
  32964. }
  32965. return nil
  32966. }
  32967. // RemovedEdges returns all edge names that were removed in this mutation.
  32968. func (m *PendingAuthSessionMutation) RemovedEdges() []string {
  32969. edges := make([]string, 0, 2)
  32970. return edges
  32971. }
  32972. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  32973. // the given name in this mutation.
  32974. func (m *PendingAuthSessionMutation) RemovedIDs(name string) []ent.Value {
  32975. return nil
  32976. }
  32977. // ClearedEdges returns all edge names that were cleared in this mutation.
  32978. func (m *PendingAuthSessionMutation) ClearedEdges() []string {
  32979. edges := make([]string, 0, 2)
  32980. if m.clearedtarget_user {
  32981. edges = append(edges, pendingauthsession.EdgeTargetUser)
  32982. }
  32983. if m.clearedadoption_decision {
  32984. edges = append(edges, pendingauthsession.EdgeAdoptionDecision)
  32985. }
  32986. return edges
  32987. }
  32988. // EdgeCleared returns a boolean which indicates if the edge with the given name
  32989. // was cleared in this mutation.
  32990. func (m *PendingAuthSessionMutation) EdgeCleared(name string) bool {
  32991. switch name {
  32992. case pendingauthsession.EdgeTargetUser:
  32993. return m.clearedtarget_user
  32994. case pendingauthsession.EdgeAdoptionDecision:
  32995. return m.clearedadoption_decision
  32996. }
  32997. return false
  32998. }
  32999. // ClearEdge clears the value of the edge with the given name. It returns an error
  33000. // if that edge is not defined in the schema.
  33001. func (m *PendingAuthSessionMutation) ClearEdge(name string) error {
  33002. switch name {
  33003. case pendingauthsession.EdgeTargetUser:
  33004. m.ClearTargetUser()
  33005. return nil
  33006. case pendingauthsession.EdgeAdoptionDecision:
  33007. m.ClearAdoptionDecision()
  33008. return nil
  33009. }
  33010. return fmt.Errorf("unknown PendingAuthSession unique edge %s", name)
  33011. }
  33012. // ResetEdge resets all changes to the edge with the given name in this mutation.
  33013. // It returns an error if the edge is not defined in the schema.
  33014. func (m *PendingAuthSessionMutation) ResetEdge(name string) error {
  33015. switch name {
  33016. case pendingauthsession.EdgeTargetUser:
  33017. m.ResetTargetUser()
  33018. return nil
  33019. case pendingauthsession.EdgeAdoptionDecision:
  33020. m.ResetAdoptionDecision()
  33021. return nil
  33022. }
  33023. return fmt.Errorf("unknown PendingAuthSession edge %s", name)
  33024. }
  33025. // PromoCodeMutation represents an operation that mutates the PromoCode nodes in the graph.
  33026. type PromoCodeMutation struct {
  33027. config
  33028. op Op
  33029. typ string
  33030. id *int64
  33031. code *string
  33032. bonus_amount *float64
  33033. addbonus_amount *float64
  33034. max_uses *int
  33035. addmax_uses *int
  33036. used_count *int
  33037. addused_count *int
  33038. status *string
  33039. expires_at *time.Time
  33040. notes *string
  33041. created_at *time.Time
  33042. updated_at *time.Time
  33043. clearedFields map[string]struct{}
  33044. usage_records map[int64]struct{}
  33045. removedusage_records map[int64]struct{}
  33046. clearedusage_records bool
  33047. done bool
  33048. oldValue func(context.Context) (*PromoCode, error)
  33049. predicates []predicate.PromoCode
  33050. }
  33051. var _ ent.Mutation = (*PromoCodeMutation)(nil)
  33052. // promocodeOption allows management of the mutation configuration using functional options.
  33053. type promocodeOption func(*PromoCodeMutation)
  33054. // newPromoCodeMutation creates new mutation for the PromoCode entity.
  33055. func newPromoCodeMutation(c config, op Op, opts ...promocodeOption) *PromoCodeMutation {
  33056. m := &PromoCodeMutation{
  33057. config: c,
  33058. op: op,
  33059. typ: TypePromoCode,
  33060. clearedFields: make(map[string]struct{}),
  33061. }
  33062. for _, opt := range opts {
  33063. opt(m)
  33064. }
  33065. return m
  33066. }
  33067. // withPromoCodeID sets the ID field of the mutation.
  33068. func withPromoCodeID(id int64) promocodeOption {
  33069. return func(m *PromoCodeMutation) {
  33070. var (
  33071. err error
  33072. once sync.Once
  33073. value *PromoCode
  33074. )
  33075. m.oldValue = func(ctx context.Context) (*PromoCode, error) {
  33076. once.Do(func() {
  33077. if m.done {
  33078. err = errors.New("querying old values post mutation is not allowed")
  33079. } else {
  33080. value, err = m.Client().PromoCode.Get(ctx, id)
  33081. }
  33082. })
  33083. return value, err
  33084. }
  33085. m.id = &id
  33086. }
  33087. }
  33088. // withPromoCode sets the old PromoCode of the mutation.
  33089. func withPromoCode(node *PromoCode) promocodeOption {
  33090. return func(m *PromoCodeMutation) {
  33091. m.oldValue = func(context.Context) (*PromoCode, error) {
  33092. return node, nil
  33093. }
  33094. m.id = &node.ID
  33095. }
  33096. }
  33097. // Client returns a new `ent.Client` from the mutation. If the mutation was
  33098. // executed in a transaction (ent.Tx), a transactional client is returned.
  33099. func (m PromoCodeMutation) Client() *Client {
  33100. client := &Client{config: m.config}
  33101. client.init()
  33102. return client
  33103. }
  33104. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  33105. // it returns an error otherwise.
  33106. func (m PromoCodeMutation) Tx() (*Tx, error) {
  33107. if _, ok := m.driver.(*txDriver); !ok {
  33108. return nil, errors.New("ent: mutation is not running in a transaction")
  33109. }
  33110. tx := &Tx{config: m.config}
  33111. tx.init()
  33112. return tx, nil
  33113. }
  33114. // ID returns the ID value in the mutation. Note that the ID is only available
  33115. // if it was provided to the builder or after it was returned from the database.
  33116. func (m *PromoCodeMutation) ID() (id int64, exists bool) {
  33117. if m.id == nil {
  33118. return
  33119. }
  33120. return *m.id, true
  33121. }
  33122. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  33123. // That means, if the mutation is applied within a transaction with an isolation level such
  33124. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  33125. // or updated by the mutation.
  33126. func (m *PromoCodeMutation) IDs(ctx context.Context) ([]int64, error) {
  33127. switch {
  33128. case m.op.Is(OpUpdateOne | OpDeleteOne):
  33129. id, exists := m.ID()
  33130. if exists {
  33131. return []int64{id}, nil
  33132. }
  33133. fallthrough
  33134. case m.op.Is(OpUpdate | OpDelete):
  33135. return m.Client().PromoCode.Query().Where(m.predicates...).IDs(ctx)
  33136. default:
  33137. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  33138. }
  33139. }
  33140. // SetCode sets the "code" field.
  33141. func (m *PromoCodeMutation) SetCode(s string) {
  33142. m.code = &s
  33143. }
  33144. // Code returns the value of the "code" field in the mutation.
  33145. func (m *PromoCodeMutation) Code() (r string, exists bool) {
  33146. v := m.code
  33147. if v == nil {
  33148. return
  33149. }
  33150. return *v, true
  33151. }
  33152. // OldCode returns the old "code" field's value of the PromoCode entity.
  33153. // If the PromoCode object wasn't provided to the builder, the object is fetched from the database.
  33154. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33155. func (m *PromoCodeMutation) OldCode(ctx context.Context) (v string, err error) {
  33156. if !m.op.Is(OpUpdateOne) {
  33157. return v, errors.New("OldCode is only allowed on UpdateOne operations")
  33158. }
  33159. if m.id == nil || m.oldValue == nil {
  33160. return v, errors.New("OldCode requires an ID field in the mutation")
  33161. }
  33162. oldValue, err := m.oldValue(ctx)
  33163. if err != nil {
  33164. return v, fmt.Errorf("querying old value for OldCode: %w", err)
  33165. }
  33166. return oldValue.Code, nil
  33167. }
  33168. // ResetCode resets all changes to the "code" field.
  33169. func (m *PromoCodeMutation) ResetCode() {
  33170. m.code = nil
  33171. }
  33172. // SetBonusAmount sets the "bonus_amount" field.
  33173. func (m *PromoCodeMutation) SetBonusAmount(f float64) {
  33174. m.bonus_amount = &f
  33175. m.addbonus_amount = nil
  33176. }
  33177. // BonusAmount returns the value of the "bonus_amount" field in the mutation.
  33178. func (m *PromoCodeMutation) BonusAmount() (r float64, exists bool) {
  33179. v := m.bonus_amount
  33180. if v == nil {
  33181. return
  33182. }
  33183. return *v, true
  33184. }
  33185. // OldBonusAmount returns the old "bonus_amount" field's value of the PromoCode entity.
  33186. // If the PromoCode object wasn't provided to the builder, the object is fetched from the database.
  33187. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33188. func (m *PromoCodeMutation) OldBonusAmount(ctx context.Context) (v float64, err error) {
  33189. if !m.op.Is(OpUpdateOne) {
  33190. return v, errors.New("OldBonusAmount is only allowed on UpdateOne operations")
  33191. }
  33192. if m.id == nil || m.oldValue == nil {
  33193. return v, errors.New("OldBonusAmount requires an ID field in the mutation")
  33194. }
  33195. oldValue, err := m.oldValue(ctx)
  33196. if err != nil {
  33197. return v, fmt.Errorf("querying old value for OldBonusAmount: %w", err)
  33198. }
  33199. return oldValue.BonusAmount, nil
  33200. }
  33201. // AddBonusAmount adds f to the "bonus_amount" field.
  33202. func (m *PromoCodeMutation) AddBonusAmount(f float64) {
  33203. if m.addbonus_amount != nil {
  33204. *m.addbonus_amount += f
  33205. } else {
  33206. m.addbonus_amount = &f
  33207. }
  33208. }
  33209. // AddedBonusAmount returns the value that was added to the "bonus_amount" field in this mutation.
  33210. func (m *PromoCodeMutation) AddedBonusAmount() (r float64, exists bool) {
  33211. v := m.addbonus_amount
  33212. if v == nil {
  33213. return
  33214. }
  33215. return *v, true
  33216. }
  33217. // ResetBonusAmount resets all changes to the "bonus_amount" field.
  33218. func (m *PromoCodeMutation) ResetBonusAmount() {
  33219. m.bonus_amount = nil
  33220. m.addbonus_amount = nil
  33221. }
  33222. // SetMaxUses sets the "max_uses" field.
  33223. func (m *PromoCodeMutation) SetMaxUses(i int) {
  33224. m.max_uses = &i
  33225. m.addmax_uses = nil
  33226. }
  33227. // MaxUses returns the value of the "max_uses" field in the mutation.
  33228. func (m *PromoCodeMutation) MaxUses() (r int, exists bool) {
  33229. v := m.max_uses
  33230. if v == nil {
  33231. return
  33232. }
  33233. return *v, true
  33234. }
  33235. // OldMaxUses returns the old "max_uses" field's value of the PromoCode entity.
  33236. // If the PromoCode object wasn't provided to the builder, the object is fetched from the database.
  33237. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33238. func (m *PromoCodeMutation) OldMaxUses(ctx context.Context) (v int, err error) {
  33239. if !m.op.Is(OpUpdateOne) {
  33240. return v, errors.New("OldMaxUses is only allowed on UpdateOne operations")
  33241. }
  33242. if m.id == nil || m.oldValue == nil {
  33243. return v, errors.New("OldMaxUses requires an ID field in the mutation")
  33244. }
  33245. oldValue, err := m.oldValue(ctx)
  33246. if err != nil {
  33247. return v, fmt.Errorf("querying old value for OldMaxUses: %w", err)
  33248. }
  33249. return oldValue.MaxUses, nil
  33250. }
  33251. // AddMaxUses adds i to the "max_uses" field.
  33252. func (m *PromoCodeMutation) AddMaxUses(i int) {
  33253. if m.addmax_uses != nil {
  33254. *m.addmax_uses += i
  33255. } else {
  33256. m.addmax_uses = &i
  33257. }
  33258. }
  33259. // AddedMaxUses returns the value that was added to the "max_uses" field in this mutation.
  33260. func (m *PromoCodeMutation) AddedMaxUses() (r int, exists bool) {
  33261. v := m.addmax_uses
  33262. if v == nil {
  33263. return
  33264. }
  33265. return *v, true
  33266. }
  33267. // ResetMaxUses resets all changes to the "max_uses" field.
  33268. func (m *PromoCodeMutation) ResetMaxUses() {
  33269. m.max_uses = nil
  33270. m.addmax_uses = nil
  33271. }
  33272. // SetUsedCount sets the "used_count" field.
  33273. func (m *PromoCodeMutation) SetUsedCount(i int) {
  33274. m.used_count = &i
  33275. m.addused_count = nil
  33276. }
  33277. // UsedCount returns the value of the "used_count" field in the mutation.
  33278. func (m *PromoCodeMutation) UsedCount() (r int, exists bool) {
  33279. v := m.used_count
  33280. if v == nil {
  33281. return
  33282. }
  33283. return *v, true
  33284. }
  33285. // OldUsedCount returns the old "used_count" field's value of the PromoCode entity.
  33286. // If the PromoCode object wasn't provided to the builder, the object is fetched from the database.
  33287. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33288. func (m *PromoCodeMutation) OldUsedCount(ctx context.Context) (v int, err error) {
  33289. if !m.op.Is(OpUpdateOne) {
  33290. return v, errors.New("OldUsedCount is only allowed on UpdateOne operations")
  33291. }
  33292. if m.id == nil || m.oldValue == nil {
  33293. return v, errors.New("OldUsedCount requires an ID field in the mutation")
  33294. }
  33295. oldValue, err := m.oldValue(ctx)
  33296. if err != nil {
  33297. return v, fmt.Errorf("querying old value for OldUsedCount: %w", err)
  33298. }
  33299. return oldValue.UsedCount, nil
  33300. }
  33301. // AddUsedCount adds i to the "used_count" field.
  33302. func (m *PromoCodeMutation) AddUsedCount(i int) {
  33303. if m.addused_count != nil {
  33304. *m.addused_count += i
  33305. } else {
  33306. m.addused_count = &i
  33307. }
  33308. }
  33309. // AddedUsedCount returns the value that was added to the "used_count" field in this mutation.
  33310. func (m *PromoCodeMutation) AddedUsedCount() (r int, exists bool) {
  33311. v := m.addused_count
  33312. if v == nil {
  33313. return
  33314. }
  33315. return *v, true
  33316. }
  33317. // ResetUsedCount resets all changes to the "used_count" field.
  33318. func (m *PromoCodeMutation) ResetUsedCount() {
  33319. m.used_count = nil
  33320. m.addused_count = nil
  33321. }
  33322. // SetStatus sets the "status" field.
  33323. func (m *PromoCodeMutation) SetStatus(s string) {
  33324. m.status = &s
  33325. }
  33326. // Status returns the value of the "status" field in the mutation.
  33327. func (m *PromoCodeMutation) Status() (r string, exists bool) {
  33328. v := m.status
  33329. if v == nil {
  33330. return
  33331. }
  33332. return *v, true
  33333. }
  33334. // OldStatus returns the old "status" field's value of the PromoCode entity.
  33335. // If the PromoCode object wasn't provided to the builder, the object is fetched from the database.
  33336. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33337. func (m *PromoCodeMutation) OldStatus(ctx context.Context) (v string, err error) {
  33338. if !m.op.Is(OpUpdateOne) {
  33339. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  33340. }
  33341. if m.id == nil || m.oldValue == nil {
  33342. return v, errors.New("OldStatus requires an ID field in the mutation")
  33343. }
  33344. oldValue, err := m.oldValue(ctx)
  33345. if err != nil {
  33346. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  33347. }
  33348. return oldValue.Status, nil
  33349. }
  33350. // ResetStatus resets all changes to the "status" field.
  33351. func (m *PromoCodeMutation) ResetStatus() {
  33352. m.status = nil
  33353. }
  33354. // SetExpiresAt sets the "expires_at" field.
  33355. func (m *PromoCodeMutation) SetExpiresAt(t time.Time) {
  33356. m.expires_at = &t
  33357. }
  33358. // ExpiresAt returns the value of the "expires_at" field in the mutation.
  33359. func (m *PromoCodeMutation) ExpiresAt() (r time.Time, exists bool) {
  33360. v := m.expires_at
  33361. if v == nil {
  33362. return
  33363. }
  33364. return *v, true
  33365. }
  33366. // OldExpiresAt returns the old "expires_at" field's value of the PromoCode entity.
  33367. // If the PromoCode object wasn't provided to the builder, the object is fetched from the database.
  33368. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33369. func (m *PromoCodeMutation) OldExpiresAt(ctx context.Context) (v *time.Time, err error) {
  33370. if !m.op.Is(OpUpdateOne) {
  33371. return v, errors.New("OldExpiresAt is only allowed on UpdateOne operations")
  33372. }
  33373. if m.id == nil || m.oldValue == nil {
  33374. return v, errors.New("OldExpiresAt requires an ID field in the mutation")
  33375. }
  33376. oldValue, err := m.oldValue(ctx)
  33377. if err != nil {
  33378. return v, fmt.Errorf("querying old value for OldExpiresAt: %w", err)
  33379. }
  33380. return oldValue.ExpiresAt, nil
  33381. }
  33382. // ClearExpiresAt clears the value of the "expires_at" field.
  33383. func (m *PromoCodeMutation) ClearExpiresAt() {
  33384. m.expires_at = nil
  33385. m.clearedFields[promocode.FieldExpiresAt] = struct{}{}
  33386. }
  33387. // ExpiresAtCleared returns if the "expires_at" field was cleared in this mutation.
  33388. func (m *PromoCodeMutation) ExpiresAtCleared() bool {
  33389. _, ok := m.clearedFields[promocode.FieldExpiresAt]
  33390. return ok
  33391. }
  33392. // ResetExpiresAt resets all changes to the "expires_at" field.
  33393. func (m *PromoCodeMutation) ResetExpiresAt() {
  33394. m.expires_at = nil
  33395. delete(m.clearedFields, promocode.FieldExpiresAt)
  33396. }
  33397. // SetNotes sets the "notes" field.
  33398. func (m *PromoCodeMutation) SetNotes(s string) {
  33399. m.notes = &s
  33400. }
  33401. // Notes returns the value of the "notes" field in the mutation.
  33402. func (m *PromoCodeMutation) Notes() (r string, exists bool) {
  33403. v := m.notes
  33404. if v == nil {
  33405. return
  33406. }
  33407. return *v, true
  33408. }
  33409. // OldNotes returns the old "notes" field's value of the PromoCode entity.
  33410. // If the PromoCode object wasn't provided to the builder, the object is fetched from the database.
  33411. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33412. func (m *PromoCodeMutation) OldNotes(ctx context.Context) (v *string, err error) {
  33413. if !m.op.Is(OpUpdateOne) {
  33414. return v, errors.New("OldNotes is only allowed on UpdateOne operations")
  33415. }
  33416. if m.id == nil || m.oldValue == nil {
  33417. return v, errors.New("OldNotes requires an ID field in the mutation")
  33418. }
  33419. oldValue, err := m.oldValue(ctx)
  33420. if err != nil {
  33421. return v, fmt.Errorf("querying old value for OldNotes: %w", err)
  33422. }
  33423. return oldValue.Notes, nil
  33424. }
  33425. // ClearNotes clears the value of the "notes" field.
  33426. func (m *PromoCodeMutation) ClearNotes() {
  33427. m.notes = nil
  33428. m.clearedFields[promocode.FieldNotes] = struct{}{}
  33429. }
  33430. // NotesCleared returns if the "notes" field was cleared in this mutation.
  33431. func (m *PromoCodeMutation) NotesCleared() bool {
  33432. _, ok := m.clearedFields[promocode.FieldNotes]
  33433. return ok
  33434. }
  33435. // ResetNotes resets all changes to the "notes" field.
  33436. func (m *PromoCodeMutation) ResetNotes() {
  33437. m.notes = nil
  33438. delete(m.clearedFields, promocode.FieldNotes)
  33439. }
  33440. // SetCreatedAt sets the "created_at" field.
  33441. func (m *PromoCodeMutation) SetCreatedAt(t time.Time) {
  33442. m.created_at = &t
  33443. }
  33444. // CreatedAt returns the value of the "created_at" field in the mutation.
  33445. func (m *PromoCodeMutation) CreatedAt() (r time.Time, exists bool) {
  33446. v := m.created_at
  33447. if v == nil {
  33448. return
  33449. }
  33450. return *v, true
  33451. }
  33452. // OldCreatedAt returns the old "created_at" field's value of the PromoCode entity.
  33453. // If the PromoCode object wasn't provided to the builder, the object is fetched from the database.
  33454. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33455. func (m *PromoCodeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  33456. if !m.op.Is(OpUpdateOne) {
  33457. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  33458. }
  33459. if m.id == nil || m.oldValue == nil {
  33460. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  33461. }
  33462. oldValue, err := m.oldValue(ctx)
  33463. if err != nil {
  33464. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  33465. }
  33466. return oldValue.CreatedAt, nil
  33467. }
  33468. // ResetCreatedAt resets all changes to the "created_at" field.
  33469. func (m *PromoCodeMutation) ResetCreatedAt() {
  33470. m.created_at = nil
  33471. }
  33472. // SetUpdatedAt sets the "updated_at" field.
  33473. func (m *PromoCodeMutation) SetUpdatedAt(t time.Time) {
  33474. m.updated_at = &t
  33475. }
  33476. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  33477. func (m *PromoCodeMutation) UpdatedAt() (r time.Time, exists bool) {
  33478. v := m.updated_at
  33479. if v == nil {
  33480. return
  33481. }
  33482. return *v, true
  33483. }
  33484. // OldUpdatedAt returns the old "updated_at" field's value of the PromoCode entity.
  33485. // If the PromoCode object wasn't provided to the builder, the object is fetched from the database.
  33486. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33487. func (m *PromoCodeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  33488. if !m.op.Is(OpUpdateOne) {
  33489. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  33490. }
  33491. if m.id == nil || m.oldValue == nil {
  33492. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  33493. }
  33494. oldValue, err := m.oldValue(ctx)
  33495. if err != nil {
  33496. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  33497. }
  33498. return oldValue.UpdatedAt, nil
  33499. }
  33500. // ResetUpdatedAt resets all changes to the "updated_at" field.
  33501. func (m *PromoCodeMutation) ResetUpdatedAt() {
  33502. m.updated_at = nil
  33503. }
  33504. // AddUsageRecordIDs adds the "usage_records" edge to the PromoCodeUsage entity by ids.
  33505. func (m *PromoCodeMutation) AddUsageRecordIDs(ids ...int64) {
  33506. if m.usage_records == nil {
  33507. m.usage_records = make(map[int64]struct{})
  33508. }
  33509. for i := range ids {
  33510. m.usage_records[ids[i]] = struct{}{}
  33511. }
  33512. }
  33513. // ClearUsageRecords clears the "usage_records" edge to the PromoCodeUsage entity.
  33514. func (m *PromoCodeMutation) ClearUsageRecords() {
  33515. m.clearedusage_records = true
  33516. }
  33517. // UsageRecordsCleared reports if the "usage_records" edge to the PromoCodeUsage entity was cleared.
  33518. func (m *PromoCodeMutation) UsageRecordsCleared() bool {
  33519. return m.clearedusage_records
  33520. }
  33521. // RemoveUsageRecordIDs removes the "usage_records" edge to the PromoCodeUsage entity by IDs.
  33522. func (m *PromoCodeMutation) RemoveUsageRecordIDs(ids ...int64) {
  33523. if m.removedusage_records == nil {
  33524. m.removedusage_records = make(map[int64]struct{})
  33525. }
  33526. for i := range ids {
  33527. delete(m.usage_records, ids[i])
  33528. m.removedusage_records[ids[i]] = struct{}{}
  33529. }
  33530. }
  33531. // RemovedUsageRecords returns the removed IDs of the "usage_records" edge to the PromoCodeUsage entity.
  33532. func (m *PromoCodeMutation) RemovedUsageRecordsIDs() (ids []int64) {
  33533. for id := range m.removedusage_records {
  33534. ids = append(ids, id)
  33535. }
  33536. return
  33537. }
  33538. // UsageRecordsIDs returns the "usage_records" edge IDs in the mutation.
  33539. func (m *PromoCodeMutation) UsageRecordsIDs() (ids []int64) {
  33540. for id := range m.usage_records {
  33541. ids = append(ids, id)
  33542. }
  33543. return
  33544. }
  33545. // ResetUsageRecords resets all changes to the "usage_records" edge.
  33546. func (m *PromoCodeMutation) ResetUsageRecords() {
  33547. m.usage_records = nil
  33548. m.clearedusage_records = false
  33549. m.removedusage_records = nil
  33550. }
  33551. // Where appends a list predicates to the PromoCodeMutation builder.
  33552. func (m *PromoCodeMutation) Where(ps ...predicate.PromoCode) {
  33553. m.predicates = append(m.predicates, ps...)
  33554. }
  33555. // WhereP appends storage-level predicates to the PromoCodeMutation builder. Using this method,
  33556. // users can use type-assertion to append predicates that do not depend on any generated package.
  33557. func (m *PromoCodeMutation) WhereP(ps ...func(*sql.Selector)) {
  33558. p := make([]predicate.PromoCode, len(ps))
  33559. for i := range ps {
  33560. p[i] = ps[i]
  33561. }
  33562. m.Where(p...)
  33563. }
  33564. // Op returns the operation name.
  33565. func (m *PromoCodeMutation) Op() Op {
  33566. return m.op
  33567. }
  33568. // SetOp allows setting the mutation operation.
  33569. func (m *PromoCodeMutation) SetOp(op Op) {
  33570. m.op = op
  33571. }
  33572. // Type returns the node type of this mutation (PromoCode).
  33573. func (m *PromoCodeMutation) Type() string {
  33574. return m.typ
  33575. }
  33576. // Fields returns all fields that were changed during this mutation. Note that in
  33577. // order to get all numeric fields that were incremented/decremented, call
  33578. // AddedFields().
  33579. func (m *PromoCodeMutation) Fields() []string {
  33580. fields := make([]string, 0, 9)
  33581. if m.code != nil {
  33582. fields = append(fields, promocode.FieldCode)
  33583. }
  33584. if m.bonus_amount != nil {
  33585. fields = append(fields, promocode.FieldBonusAmount)
  33586. }
  33587. if m.max_uses != nil {
  33588. fields = append(fields, promocode.FieldMaxUses)
  33589. }
  33590. if m.used_count != nil {
  33591. fields = append(fields, promocode.FieldUsedCount)
  33592. }
  33593. if m.status != nil {
  33594. fields = append(fields, promocode.FieldStatus)
  33595. }
  33596. if m.expires_at != nil {
  33597. fields = append(fields, promocode.FieldExpiresAt)
  33598. }
  33599. if m.notes != nil {
  33600. fields = append(fields, promocode.FieldNotes)
  33601. }
  33602. if m.created_at != nil {
  33603. fields = append(fields, promocode.FieldCreatedAt)
  33604. }
  33605. if m.updated_at != nil {
  33606. fields = append(fields, promocode.FieldUpdatedAt)
  33607. }
  33608. return fields
  33609. }
  33610. // Field returns the value of a field with the given name. The second boolean
  33611. // return value indicates that this field was not set, or was not defined in the
  33612. // schema.
  33613. func (m *PromoCodeMutation) Field(name string) (ent.Value, bool) {
  33614. switch name {
  33615. case promocode.FieldCode:
  33616. return m.Code()
  33617. case promocode.FieldBonusAmount:
  33618. return m.BonusAmount()
  33619. case promocode.FieldMaxUses:
  33620. return m.MaxUses()
  33621. case promocode.FieldUsedCount:
  33622. return m.UsedCount()
  33623. case promocode.FieldStatus:
  33624. return m.Status()
  33625. case promocode.FieldExpiresAt:
  33626. return m.ExpiresAt()
  33627. case promocode.FieldNotes:
  33628. return m.Notes()
  33629. case promocode.FieldCreatedAt:
  33630. return m.CreatedAt()
  33631. case promocode.FieldUpdatedAt:
  33632. return m.UpdatedAt()
  33633. }
  33634. return nil, false
  33635. }
  33636. // OldField returns the old value of the field from the database. An error is
  33637. // returned if the mutation operation is not UpdateOne, or the query to the
  33638. // database failed.
  33639. func (m *PromoCodeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  33640. switch name {
  33641. case promocode.FieldCode:
  33642. return m.OldCode(ctx)
  33643. case promocode.FieldBonusAmount:
  33644. return m.OldBonusAmount(ctx)
  33645. case promocode.FieldMaxUses:
  33646. return m.OldMaxUses(ctx)
  33647. case promocode.FieldUsedCount:
  33648. return m.OldUsedCount(ctx)
  33649. case promocode.FieldStatus:
  33650. return m.OldStatus(ctx)
  33651. case promocode.FieldExpiresAt:
  33652. return m.OldExpiresAt(ctx)
  33653. case promocode.FieldNotes:
  33654. return m.OldNotes(ctx)
  33655. case promocode.FieldCreatedAt:
  33656. return m.OldCreatedAt(ctx)
  33657. case promocode.FieldUpdatedAt:
  33658. return m.OldUpdatedAt(ctx)
  33659. }
  33660. return nil, fmt.Errorf("unknown PromoCode field %s", name)
  33661. }
  33662. // SetField sets the value of a field with the given name. It returns an error if
  33663. // the field is not defined in the schema, or if the type mismatched the field
  33664. // type.
  33665. func (m *PromoCodeMutation) SetField(name string, value ent.Value) error {
  33666. switch name {
  33667. case promocode.FieldCode:
  33668. v, ok := value.(string)
  33669. if !ok {
  33670. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33671. }
  33672. m.SetCode(v)
  33673. return nil
  33674. case promocode.FieldBonusAmount:
  33675. v, ok := value.(float64)
  33676. if !ok {
  33677. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33678. }
  33679. m.SetBonusAmount(v)
  33680. return nil
  33681. case promocode.FieldMaxUses:
  33682. v, ok := value.(int)
  33683. if !ok {
  33684. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33685. }
  33686. m.SetMaxUses(v)
  33687. return nil
  33688. case promocode.FieldUsedCount:
  33689. v, ok := value.(int)
  33690. if !ok {
  33691. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33692. }
  33693. m.SetUsedCount(v)
  33694. return nil
  33695. case promocode.FieldStatus:
  33696. v, ok := value.(string)
  33697. if !ok {
  33698. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33699. }
  33700. m.SetStatus(v)
  33701. return nil
  33702. case promocode.FieldExpiresAt:
  33703. v, ok := value.(time.Time)
  33704. if !ok {
  33705. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33706. }
  33707. m.SetExpiresAt(v)
  33708. return nil
  33709. case promocode.FieldNotes:
  33710. v, ok := value.(string)
  33711. if !ok {
  33712. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33713. }
  33714. m.SetNotes(v)
  33715. return nil
  33716. case promocode.FieldCreatedAt:
  33717. v, ok := value.(time.Time)
  33718. if !ok {
  33719. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33720. }
  33721. m.SetCreatedAt(v)
  33722. return nil
  33723. case promocode.FieldUpdatedAt:
  33724. v, ok := value.(time.Time)
  33725. if !ok {
  33726. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33727. }
  33728. m.SetUpdatedAt(v)
  33729. return nil
  33730. }
  33731. return fmt.Errorf("unknown PromoCode field %s", name)
  33732. }
  33733. // AddedFields returns all numeric fields that were incremented/decremented during
  33734. // this mutation.
  33735. func (m *PromoCodeMutation) AddedFields() []string {
  33736. var fields []string
  33737. if m.addbonus_amount != nil {
  33738. fields = append(fields, promocode.FieldBonusAmount)
  33739. }
  33740. if m.addmax_uses != nil {
  33741. fields = append(fields, promocode.FieldMaxUses)
  33742. }
  33743. if m.addused_count != nil {
  33744. fields = append(fields, promocode.FieldUsedCount)
  33745. }
  33746. return fields
  33747. }
  33748. // AddedField returns the numeric value that was incremented/decremented on a field
  33749. // with the given name. The second boolean return value indicates that this field
  33750. // was not set, or was not defined in the schema.
  33751. func (m *PromoCodeMutation) AddedField(name string) (ent.Value, bool) {
  33752. switch name {
  33753. case promocode.FieldBonusAmount:
  33754. return m.AddedBonusAmount()
  33755. case promocode.FieldMaxUses:
  33756. return m.AddedMaxUses()
  33757. case promocode.FieldUsedCount:
  33758. return m.AddedUsedCount()
  33759. }
  33760. return nil, false
  33761. }
  33762. // AddField adds the value to the field with the given name. It returns an error if
  33763. // the field is not defined in the schema, or if the type mismatched the field
  33764. // type.
  33765. func (m *PromoCodeMutation) AddField(name string, value ent.Value) error {
  33766. switch name {
  33767. case promocode.FieldBonusAmount:
  33768. v, ok := value.(float64)
  33769. if !ok {
  33770. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33771. }
  33772. m.AddBonusAmount(v)
  33773. return nil
  33774. case promocode.FieldMaxUses:
  33775. v, ok := value.(int)
  33776. if !ok {
  33777. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33778. }
  33779. m.AddMaxUses(v)
  33780. return nil
  33781. case promocode.FieldUsedCount:
  33782. v, ok := value.(int)
  33783. if !ok {
  33784. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33785. }
  33786. m.AddUsedCount(v)
  33787. return nil
  33788. }
  33789. return fmt.Errorf("unknown PromoCode numeric field %s", name)
  33790. }
  33791. // ClearedFields returns all nullable fields that were cleared during this
  33792. // mutation.
  33793. func (m *PromoCodeMutation) ClearedFields() []string {
  33794. var fields []string
  33795. if m.FieldCleared(promocode.FieldExpiresAt) {
  33796. fields = append(fields, promocode.FieldExpiresAt)
  33797. }
  33798. if m.FieldCleared(promocode.FieldNotes) {
  33799. fields = append(fields, promocode.FieldNotes)
  33800. }
  33801. return fields
  33802. }
  33803. // FieldCleared returns a boolean indicating if a field with the given name was
  33804. // cleared in this mutation.
  33805. func (m *PromoCodeMutation) FieldCleared(name string) bool {
  33806. _, ok := m.clearedFields[name]
  33807. return ok
  33808. }
  33809. // ClearField clears the value of the field with the given name. It returns an
  33810. // error if the field is not defined in the schema.
  33811. func (m *PromoCodeMutation) ClearField(name string) error {
  33812. switch name {
  33813. case promocode.FieldExpiresAt:
  33814. m.ClearExpiresAt()
  33815. return nil
  33816. case promocode.FieldNotes:
  33817. m.ClearNotes()
  33818. return nil
  33819. }
  33820. return fmt.Errorf("unknown PromoCode nullable field %s", name)
  33821. }
  33822. // ResetField resets all changes in the mutation for the field with the given name.
  33823. // It returns an error if the field is not defined in the schema.
  33824. func (m *PromoCodeMutation) ResetField(name string) error {
  33825. switch name {
  33826. case promocode.FieldCode:
  33827. m.ResetCode()
  33828. return nil
  33829. case promocode.FieldBonusAmount:
  33830. m.ResetBonusAmount()
  33831. return nil
  33832. case promocode.FieldMaxUses:
  33833. m.ResetMaxUses()
  33834. return nil
  33835. case promocode.FieldUsedCount:
  33836. m.ResetUsedCount()
  33837. return nil
  33838. case promocode.FieldStatus:
  33839. m.ResetStatus()
  33840. return nil
  33841. case promocode.FieldExpiresAt:
  33842. m.ResetExpiresAt()
  33843. return nil
  33844. case promocode.FieldNotes:
  33845. m.ResetNotes()
  33846. return nil
  33847. case promocode.FieldCreatedAt:
  33848. m.ResetCreatedAt()
  33849. return nil
  33850. case promocode.FieldUpdatedAt:
  33851. m.ResetUpdatedAt()
  33852. return nil
  33853. }
  33854. return fmt.Errorf("unknown PromoCode field %s", name)
  33855. }
  33856. // AddedEdges returns all edge names that were set/added in this mutation.
  33857. func (m *PromoCodeMutation) AddedEdges() []string {
  33858. edges := make([]string, 0, 1)
  33859. if m.usage_records != nil {
  33860. edges = append(edges, promocode.EdgeUsageRecords)
  33861. }
  33862. return edges
  33863. }
  33864. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  33865. // name in this mutation.
  33866. func (m *PromoCodeMutation) AddedIDs(name string) []ent.Value {
  33867. switch name {
  33868. case promocode.EdgeUsageRecords:
  33869. ids := make([]ent.Value, 0, len(m.usage_records))
  33870. for id := range m.usage_records {
  33871. ids = append(ids, id)
  33872. }
  33873. return ids
  33874. }
  33875. return nil
  33876. }
  33877. // RemovedEdges returns all edge names that were removed in this mutation.
  33878. func (m *PromoCodeMutation) RemovedEdges() []string {
  33879. edges := make([]string, 0, 1)
  33880. if m.removedusage_records != nil {
  33881. edges = append(edges, promocode.EdgeUsageRecords)
  33882. }
  33883. return edges
  33884. }
  33885. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  33886. // the given name in this mutation.
  33887. func (m *PromoCodeMutation) RemovedIDs(name string) []ent.Value {
  33888. switch name {
  33889. case promocode.EdgeUsageRecords:
  33890. ids := make([]ent.Value, 0, len(m.removedusage_records))
  33891. for id := range m.removedusage_records {
  33892. ids = append(ids, id)
  33893. }
  33894. return ids
  33895. }
  33896. return nil
  33897. }
  33898. // ClearedEdges returns all edge names that were cleared in this mutation.
  33899. func (m *PromoCodeMutation) ClearedEdges() []string {
  33900. edges := make([]string, 0, 1)
  33901. if m.clearedusage_records {
  33902. edges = append(edges, promocode.EdgeUsageRecords)
  33903. }
  33904. return edges
  33905. }
  33906. // EdgeCleared returns a boolean which indicates if the edge with the given name
  33907. // was cleared in this mutation.
  33908. func (m *PromoCodeMutation) EdgeCleared(name string) bool {
  33909. switch name {
  33910. case promocode.EdgeUsageRecords:
  33911. return m.clearedusage_records
  33912. }
  33913. return false
  33914. }
  33915. // ClearEdge clears the value of the edge with the given name. It returns an error
  33916. // if that edge is not defined in the schema.
  33917. func (m *PromoCodeMutation) ClearEdge(name string) error {
  33918. switch name {
  33919. }
  33920. return fmt.Errorf("unknown PromoCode unique edge %s", name)
  33921. }
  33922. // ResetEdge resets all changes to the edge with the given name in this mutation.
  33923. // It returns an error if the edge is not defined in the schema.
  33924. func (m *PromoCodeMutation) ResetEdge(name string) error {
  33925. switch name {
  33926. case promocode.EdgeUsageRecords:
  33927. m.ResetUsageRecords()
  33928. return nil
  33929. }
  33930. return fmt.Errorf("unknown PromoCode edge %s", name)
  33931. }
  33932. // PromoCodeUsageMutation represents an operation that mutates the PromoCodeUsage nodes in the graph.
  33933. type PromoCodeUsageMutation struct {
  33934. config
  33935. op Op
  33936. typ string
  33937. id *int64
  33938. bonus_amount *float64
  33939. addbonus_amount *float64
  33940. used_at *time.Time
  33941. clearedFields map[string]struct{}
  33942. promo_code *int64
  33943. clearedpromo_code bool
  33944. user *int64
  33945. cleareduser bool
  33946. done bool
  33947. oldValue func(context.Context) (*PromoCodeUsage, error)
  33948. predicates []predicate.PromoCodeUsage
  33949. }
  33950. var _ ent.Mutation = (*PromoCodeUsageMutation)(nil)
  33951. // promocodeusageOption allows management of the mutation configuration using functional options.
  33952. type promocodeusageOption func(*PromoCodeUsageMutation)
  33953. // newPromoCodeUsageMutation creates new mutation for the PromoCodeUsage entity.
  33954. func newPromoCodeUsageMutation(c config, op Op, opts ...promocodeusageOption) *PromoCodeUsageMutation {
  33955. m := &PromoCodeUsageMutation{
  33956. config: c,
  33957. op: op,
  33958. typ: TypePromoCodeUsage,
  33959. clearedFields: make(map[string]struct{}),
  33960. }
  33961. for _, opt := range opts {
  33962. opt(m)
  33963. }
  33964. return m
  33965. }
  33966. // withPromoCodeUsageID sets the ID field of the mutation.
  33967. func withPromoCodeUsageID(id int64) promocodeusageOption {
  33968. return func(m *PromoCodeUsageMutation) {
  33969. var (
  33970. err error
  33971. once sync.Once
  33972. value *PromoCodeUsage
  33973. )
  33974. m.oldValue = func(ctx context.Context) (*PromoCodeUsage, error) {
  33975. once.Do(func() {
  33976. if m.done {
  33977. err = errors.New("querying old values post mutation is not allowed")
  33978. } else {
  33979. value, err = m.Client().PromoCodeUsage.Get(ctx, id)
  33980. }
  33981. })
  33982. return value, err
  33983. }
  33984. m.id = &id
  33985. }
  33986. }
  33987. // withPromoCodeUsage sets the old PromoCodeUsage of the mutation.
  33988. func withPromoCodeUsage(node *PromoCodeUsage) promocodeusageOption {
  33989. return func(m *PromoCodeUsageMutation) {
  33990. m.oldValue = func(context.Context) (*PromoCodeUsage, error) {
  33991. return node, nil
  33992. }
  33993. m.id = &node.ID
  33994. }
  33995. }
  33996. // Client returns a new `ent.Client` from the mutation. If the mutation was
  33997. // executed in a transaction (ent.Tx), a transactional client is returned.
  33998. func (m PromoCodeUsageMutation) Client() *Client {
  33999. client := &Client{config: m.config}
  34000. client.init()
  34001. return client
  34002. }
  34003. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  34004. // it returns an error otherwise.
  34005. func (m PromoCodeUsageMutation) Tx() (*Tx, error) {
  34006. if _, ok := m.driver.(*txDriver); !ok {
  34007. return nil, errors.New("ent: mutation is not running in a transaction")
  34008. }
  34009. tx := &Tx{config: m.config}
  34010. tx.init()
  34011. return tx, nil
  34012. }
  34013. // ID returns the ID value in the mutation. Note that the ID is only available
  34014. // if it was provided to the builder or after it was returned from the database.
  34015. func (m *PromoCodeUsageMutation) ID() (id int64, exists bool) {
  34016. if m.id == nil {
  34017. return
  34018. }
  34019. return *m.id, true
  34020. }
  34021. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  34022. // That means, if the mutation is applied within a transaction with an isolation level such
  34023. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  34024. // or updated by the mutation.
  34025. func (m *PromoCodeUsageMutation) IDs(ctx context.Context) ([]int64, error) {
  34026. switch {
  34027. case m.op.Is(OpUpdateOne | OpDeleteOne):
  34028. id, exists := m.ID()
  34029. if exists {
  34030. return []int64{id}, nil
  34031. }
  34032. fallthrough
  34033. case m.op.Is(OpUpdate | OpDelete):
  34034. return m.Client().PromoCodeUsage.Query().Where(m.predicates...).IDs(ctx)
  34035. default:
  34036. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  34037. }
  34038. }
  34039. // SetPromoCodeID sets the "promo_code_id" field.
  34040. func (m *PromoCodeUsageMutation) SetPromoCodeID(i int64) {
  34041. m.promo_code = &i
  34042. }
  34043. // PromoCodeID returns the value of the "promo_code_id" field in the mutation.
  34044. func (m *PromoCodeUsageMutation) PromoCodeID() (r int64, exists bool) {
  34045. v := m.promo_code
  34046. if v == nil {
  34047. return
  34048. }
  34049. return *v, true
  34050. }
  34051. // OldPromoCodeID returns the old "promo_code_id" field's value of the PromoCodeUsage entity.
  34052. // If the PromoCodeUsage object wasn't provided to the builder, the object is fetched from the database.
  34053. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34054. func (m *PromoCodeUsageMutation) OldPromoCodeID(ctx context.Context) (v int64, err error) {
  34055. if !m.op.Is(OpUpdateOne) {
  34056. return v, errors.New("OldPromoCodeID is only allowed on UpdateOne operations")
  34057. }
  34058. if m.id == nil || m.oldValue == nil {
  34059. return v, errors.New("OldPromoCodeID requires an ID field in the mutation")
  34060. }
  34061. oldValue, err := m.oldValue(ctx)
  34062. if err != nil {
  34063. return v, fmt.Errorf("querying old value for OldPromoCodeID: %w", err)
  34064. }
  34065. return oldValue.PromoCodeID, nil
  34066. }
  34067. // ResetPromoCodeID resets all changes to the "promo_code_id" field.
  34068. func (m *PromoCodeUsageMutation) ResetPromoCodeID() {
  34069. m.promo_code = nil
  34070. }
  34071. // SetUserID sets the "user_id" field.
  34072. func (m *PromoCodeUsageMutation) SetUserID(i int64) {
  34073. m.user = &i
  34074. }
  34075. // UserID returns the value of the "user_id" field in the mutation.
  34076. func (m *PromoCodeUsageMutation) UserID() (r int64, exists bool) {
  34077. v := m.user
  34078. if v == nil {
  34079. return
  34080. }
  34081. return *v, true
  34082. }
  34083. // OldUserID returns the old "user_id" field's value of the PromoCodeUsage entity.
  34084. // If the PromoCodeUsage object wasn't provided to the builder, the object is fetched from the database.
  34085. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34086. func (m *PromoCodeUsageMutation) OldUserID(ctx context.Context) (v int64, err error) {
  34087. if !m.op.Is(OpUpdateOne) {
  34088. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  34089. }
  34090. if m.id == nil || m.oldValue == nil {
  34091. return v, errors.New("OldUserID requires an ID field in the mutation")
  34092. }
  34093. oldValue, err := m.oldValue(ctx)
  34094. if err != nil {
  34095. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  34096. }
  34097. return oldValue.UserID, nil
  34098. }
  34099. // ResetUserID resets all changes to the "user_id" field.
  34100. func (m *PromoCodeUsageMutation) ResetUserID() {
  34101. m.user = nil
  34102. }
  34103. // SetBonusAmount sets the "bonus_amount" field.
  34104. func (m *PromoCodeUsageMutation) SetBonusAmount(f float64) {
  34105. m.bonus_amount = &f
  34106. m.addbonus_amount = nil
  34107. }
  34108. // BonusAmount returns the value of the "bonus_amount" field in the mutation.
  34109. func (m *PromoCodeUsageMutation) BonusAmount() (r float64, exists bool) {
  34110. v := m.bonus_amount
  34111. if v == nil {
  34112. return
  34113. }
  34114. return *v, true
  34115. }
  34116. // OldBonusAmount returns the old "bonus_amount" field's value of the PromoCodeUsage entity.
  34117. // If the PromoCodeUsage object wasn't provided to the builder, the object is fetched from the database.
  34118. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34119. func (m *PromoCodeUsageMutation) OldBonusAmount(ctx context.Context) (v float64, err error) {
  34120. if !m.op.Is(OpUpdateOne) {
  34121. return v, errors.New("OldBonusAmount is only allowed on UpdateOne operations")
  34122. }
  34123. if m.id == nil || m.oldValue == nil {
  34124. return v, errors.New("OldBonusAmount requires an ID field in the mutation")
  34125. }
  34126. oldValue, err := m.oldValue(ctx)
  34127. if err != nil {
  34128. return v, fmt.Errorf("querying old value for OldBonusAmount: %w", err)
  34129. }
  34130. return oldValue.BonusAmount, nil
  34131. }
  34132. // AddBonusAmount adds f to the "bonus_amount" field.
  34133. func (m *PromoCodeUsageMutation) AddBonusAmount(f float64) {
  34134. if m.addbonus_amount != nil {
  34135. *m.addbonus_amount += f
  34136. } else {
  34137. m.addbonus_amount = &f
  34138. }
  34139. }
  34140. // AddedBonusAmount returns the value that was added to the "bonus_amount" field in this mutation.
  34141. func (m *PromoCodeUsageMutation) AddedBonusAmount() (r float64, exists bool) {
  34142. v := m.addbonus_amount
  34143. if v == nil {
  34144. return
  34145. }
  34146. return *v, true
  34147. }
  34148. // ResetBonusAmount resets all changes to the "bonus_amount" field.
  34149. func (m *PromoCodeUsageMutation) ResetBonusAmount() {
  34150. m.bonus_amount = nil
  34151. m.addbonus_amount = nil
  34152. }
  34153. // SetUsedAt sets the "used_at" field.
  34154. func (m *PromoCodeUsageMutation) SetUsedAt(t time.Time) {
  34155. m.used_at = &t
  34156. }
  34157. // UsedAt returns the value of the "used_at" field in the mutation.
  34158. func (m *PromoCodeUsageMutation) UsedAt() (r time.Time, exists bool) {
  34159. v := m.used_at
  34160. if v == nil {
  34161. return
  34162. }
  34163. return *v, true
  34164. }
  34165. // OldUsedAt returns the old "used_at" field's value of the PromoCodeUsage entity.
  34166. // If the PromoCodeUsage object wasn't provided to the builder, the object is fetched from the database.
  34167. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34168. func (m *PromoCodeUsageMutation) OldUsedAt(ctx context.Context) (v time.Time, err error) {
  34169. if !m.op.Is(OpUpdateOne) {
  34170. return v, errors.New("OldUsedAt is only allowed on UpdateOne operations")
  34171. }
  34172. if m.id == nil || m.oldValue == nil {
  34173. return v, errors.New("OldUsedAt requires an ID field in the mutation")
  34174. }
  34175. oldValue, err := m.oldValue(ctx)
  34176. if err != nil {
  34177. return v, fmt.Errorf("querying old value for OldUsedAt: %w", err)
  34178. }
  34179. return oldValue.UsedAt, nil
  34180. }
  34181. // ResetUsedAt resets all changes to the "used_at" field.
  34182. func (m *PromoCodeUsageMutation) ResetUsedAt() {
  34183. m.used_at = nil
  34184. }
  34185. // ClearPromoCode clears the "promo_code" edge to the PromoCode entity.
  34186. func (m *PromoCodeUsageMutation) ClearPromoCode() {
  34187. m.clearedpromo_code = true
  34188. m.clearedFields[promocodeusage.FieldPromoCodeID] = struct{}{}
  34189. }
  34190. // PromoCodeCleared reports if the "promo_code" edge to the PromoCode entity was cleared.
  34191. func (m *PromoCodeUsageMutation) PromoCodeCleared() bool {
  34192. return m.clearedpromo_code
  34193. }
  34194. // PromoCodeIDs returns the "promo_code" edge IDs in the mutation.
  34195. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  34196. // PromoCodeID instead. It exists only for internal usage by the builders.
  34197. func (m *PromoCodeUsageMutation) PromoCodeIDs() (ids []int64) {
  34198. if id := m.promo_code; id != nil {
  34199. ids = append(ids, *id)
  34200. }
  34201. return
  34202. }
  34203. // ResetPromoCode resets all changes to the "promo_code" edge.
  34204. func (m *PromoCodeUsageMutation) ResetPromoCode() {
  34205. m.promo_code = nil
  34206. m.clearedpromo_code = false
  34207. }
  34208. // ClearUser clears the "user" edge to the User entity.
  34209. func (m *PromoCodeUsageMutation) ClearUser() {
  34210. m.cleareduser = true
  34211. m.clearedFields[promocodeusage.FieldUserID] = struct{}{}
  34212. }
  34213. // UserCleared reports if the "user" edge to the User entity was cleared.
  34214. func (m *PromoCodeUsageMutation) UserCleared() bool {
  34215. return m.cleareduser
  34216. }
  34217. // UserIDs returns the "user" edge IDs in the mutation.
  34218. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  34219. // UserID instead. It exists only for internal usage by the builders.
  34220. func (m *PromoCodeUsageMutation) UserIDs() (ids []int64) {
  34221. if id := m.user; id != nil {
  34222. ids = append(ids, *id)
  34223. }
  34224. return
  34225. }
  34226. // ResetUser resets all changes to the "user" edge.
  34227. func (m *PromoCodeUsageMutation) ResetUser() {
  34228. m.user = nil
  34229. m.cleareduser = false
  34230. }
  34231. // Where appends a list predicates to the PromoCodeUsageMutation builder.
  34232. func (m *PromoCodeUsageMutation) Where(ps ...predicate.PromoCodeUsage) {
  34233. m.predicates = append(m.predicates, ps...)
  34234. }
  34235. // WhereP appends storage-level predicates to the PromoCodeUsageMutation builder. Using this method,
  34236. // users can use type-assertion to append predicates that do not depend on any generated package.
  34237. func (m *PromoCodeUsageMutation) WhereP(ps ...func(*sql.Selector)) {
  34238. p := make([]predicate.PromoCodeUsage, len(ps))
  34239. for i := range ps {
  34240. p[i] = ps[i]
  34241. }
  34242. m.Where(p...)
  34243. }
  34244. // Op returns the operation name.
  34245. func (m *PromoCodeUsageMutation) Op() Op {
  34246. return m.op
  34247. }
  34248. // SetOp allows setting the mutation operation.
  34249. func (m *PromoCodeUsageMutation) SetOp(op Op) {
  34250. m.op = op
  34251. }
  34252. // Type returns the node type of this mutation (PromoCodeUsage).
  34253. func (m *PromoCodeUsageMutation) Type() string {
  34254. return m.typ
  34255. }
  34256. // Fields returns all fields that were changed during this mutation. Note that in
  34257. // order to get all numeric fields that were incremented/decremented, call
  34258. // AddedFields().
  34259. func (m *PromoCodeUsageMutation) Fields() []string {
  34260. fields := make([]string, 0, 4)
  34261. if m.promo_code != nil {
  34262. fields = append(fields, promocodeusage.FieldPromoCodeID)
  34263. }
  34264. if m.user != nil {
  34265. fields = append(fields, promocodeusage.FieldUserID)
  34266. }
  34267. if m.bonus_amount != nil {
  34268. fields = append(fields, promocodeusage.FieldBonusAmount)
  34269. }
  34270. if m.used_at != nil {
  34271. fields = append(fields, promocodeusage.FieldUsedAt)
  34272. }
  34273. return fields
  34274. }
  34275. // Field returns the value of a field with the given name. The second boolean
  34276. // return value indicates that this field was not set, or was not defined in the
  34277. // schema.
  34278. func (m *PromoCodeUsageMutation) Field(name string) (ent.Value, bool) {
  34279. switch name {
  34280. case promocodeusage.FieldPromoCodeID:
  34281. return m.PromoCodeID()
  34282. case promocodeusage.FieldUserID:
  34283. return m.UserID()
  34284. case promocodeusage.FieldBonusAmount:
  34285. return m.BonusAmount()
  34286. case promocodeusage.FieldUsedAt:
  34287. return m.UsedAt()
  34288. }
  34289. return nil, false
  34290. }
  34291. // OldField returns the old value of the field from the database. An error is
  34292. // returned if the mutation operation is not UpdateOne, or the query to the
  34293. // database failed.
  34294. func (m *PromoCodeUsageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  34295. switch name {
  34296. case promocodeusage.FieldPromoCodeID:
  34297. return m.OldPromoCodeID(ctx)
  34298. case promocodeusage.FieldUserID:
  34299. return m.OldUserID(ctx)
  34300. case promocodeusage.FieldBonusAmount:
  34301. return m.OldBonusAmount(ctx)
  34302. case promocodeusage.FieldUsedAt:
  34303. return m.OldUsedAt(ctx)
  34304. }
  34305. return nil, fmt.Errorf("unknown PromoCodeUsage field %s", name)
  34306. }
  34307. // SetField sets the value of a field with the given name. It returns an error if
  34308. // the field is not defined in the schema, or if the type mismatched the field
  34309. // type.
  34310. func (m *PromoCodeUsageMutation) SetField(name string, value ent.Value) error {
  34311. switch name {
  34312. case promocodeusage.FieldPromoCodeID:
  34313. v, ok := value.(int64)
  34314. if !ok {
  34315. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34316. }
  34317. m.SetPromoCodeID(v)
  34318. return nil
  34319. case promocodeusage.FieldUserID:
  34320. v, ok := value.(int64)
  34321. if !ok {
  34322. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34323. }
  34324. m.SetUserID(v)
  34325. return nil
  34326. case promocodeusage.FieldBonusAmount:
  34327. v, ok := value.(float64)
  34328. if !ok {
  34329. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34330. }
  34331. m.SetBonusAmount(v)
  34332. return nil
  34333. case promocodeusage.FieldUsedAt:
  34334. v, ok := value.(time.Time)
  34335. if !ok {
  34336. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34337. }
  34338. m.SetUsedAt(v)
  34339. return nil
  34340. }
  34341. return fmt.Errorf("unknown PromoCodeUsage field %s", name)
  34342. }
  34343. // AddedFields returns all numeric fields that were incremented/decremented during
  34344. // this mutation.
  34345. func (m *PromoCodeUsageMutation) AddedFields() []string {
  34346. var fields []string
  34347. if m.addbonus_amount != nil {
  34348. fields = append(fields, promocodeusage.FieldBonusAmount)
  34349. }
  34350. return fields
  34351. }
  34352. // AddedField returns the numeric value that was incremented/decremented on a field
  34353. // with the given name. The second boolean return value indicates that this field
  34354. // was not set, or was not defined in the schema.
  34355. func (m *PromoCodeUsageMutation) AddedField(name string) (ent.Value, bool) {
  34356. switch name {
  34357. case promocodeusage.FieldBonusAmount:
  34358. return m.AddedBonusAmount()
  34359. }
  34360. return nil, false
  34361. }
  34362. // AddField adds the value to the field with the given name. It returns an error if
  34363. // the field is not defined in the schema, or if the type mismatched the field
  34364. // type.
  34365. func (m *PromoCodeUsageMutation) AddField(name string, value ent.Value) error {
  34366. switch name {
  34367. case promocodeusage.FieldBonusAmount:
  34368. v, ok := value.(float64)
  34369. if !ok {
  34370. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34371. }
  34372. m.AddBonusAmount(v)
  34373. return nil
  34374. }
  34375. return fmt.Errorf("unknown PromoCodeUsage numeric field %s", name)
  34376. }
  34377. // ClearedFields returns all nullable fields that were cleared during this
  34378. // mutation.
  34379. func (m *PromoCodeUsageMutation) ClearedFields() []string {
  34380. return nil
  34381. }
  34382. // FieldCleared returns a boolean indicating if a field with the given name was
  34383. // cleared in this mutation.
  34384. func (m *PromoCodeUsageMutation) FieldCleared(name string) bool {
  34385. _, ok := m.clearedFields[name]
  34386. return ok
  34387. }
  34388. // ClearField clears the value of the field with the given name. It returns an
  34389. // error if the field is not defined in the schema.
  34390. func (m *PromoCodeUsageMutation) ClearField(name string) error {
  34391. return fmt.Errorf("unknown PromoCodeUsage nullable field %s", name)
  34392. }
  34393. // ResetField resets all changes in the mutation for the field with the given name.
  34394. // It returns an error if the field is not defined in the schema.
  34395. func (m *PromoCodeUsageMutation) ResetField(name string) error {
  34396. switch name {
  34397. case promocodeusage.FieldPromoCodeID:
  34398. m.ResetPromoCodeID()
  34399. return nil
  34400. case promocodeusage.FieldUserID:
  34401. m.ResetUserID()
  34402. return nil
  34403. case promocodeusage.FieldBonusAmount:
  34404. m.ResetBonusAmount()
  34405. return nil
  34406. case promocodeusage.FieldUsedAt:
  34407. m.ResetUsedAt()
  34408. return nil
  34409. }
  34410. return fmt.Errorf("unknown PromoCodeUsage field %s", name)
  34411. }
  34412. // AddedEdges returns all edge names that were set/added in this mutation.
  34413. func (m *PromoCodeUsageMutation) AddedEdges() []string {
  34414. edges := make([]string, 0, 2)
  34415. if m.promo_code != nil {
  34416. edges = append(edges, promocodeusage.EdgePromoCode)
  34417. }
  34418. if m.user != nil {
  34419. edges = append(edges, promocodeusage.EdgeUser)
  34420. }
  34421. return edges
  34422. }
  34423. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  34424. // name in this mutation.
  34425. func (m *PromoCodeUsageMutation) AddedIDs(name string) []ent.Value {
  34426. switch name {
  34427. case promocodeusage.EdgePromoCode:
  34428. if id := m.promo_code; id != nil {
  34429. return []ent.Value{*id}
  34430. }
  34431. case promocodeusage.EdgeUser:
  34432. if id := m.user; id != nil {
  34433. return []ent.Value{*id}
  34434. }
  34435. }
  34436. return nil
  34437. }
  34438. // RemovedEdges returns all edge names that were removed in this mutation.
  34439. func (m *PromoCodeUsageMutation) RemovedEdges() []string {
  34440. edges := make([]string, 0, 2)
  34441. return edges
  34442. }
  34443. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  34444. // the given name in this mutation.
  34445. func (m *PromoCodeUsageMutation) RemovedIDs(name string) []ent.Value {
  34446. return nil
  34447. }
  34448. // ClearedEdges returns all edge names that were cleared in this mutation.
  34449. func (m *PromoCodeUsageMutation) ClearedEdges() []string {
  34450. edges := make([]string, 0, 2)
  34451. if m.clearedpromo_code {
  34452. edges = append(edges, promocodeusage.EdgePromoCode)
  34453. }
  34454. if m.cleareduser {
  34455. edges = append(edges, promocodeusage.EdgeUser)
  34456. }
  34457. return edges
  34458. }
  34459. // EdgeCleared returns a boolean which indicates if the edge with the given name
  34460. // was cleared in this mutation.
  34461. func (m *PromoCodeUsageMutation) EdgeCleared(name string) bool {
  34462. switch name {
  34463. case promocodeusage.EdgePromoCode:
  34464. return m.clearedpromo_code
  34465. case promocodeusage.EdgeUser:
  34466. return m.cleareduser
  34467. }
  34468. return false
  34469. }
  34470. // ClearEdge clears the value of the edge with the given name. It returns an error
  34471. // if that edge is not defined in the schema.
  34472. func (m *PromoCodeUsageMutation) ClearEdge(name string) error {
  34473. switch name {
  34474. case promocodeusage.EdgePromoCode:
  34475. m.ClearPromoCode()
  34476. return nil
  34477. case promocodeusage.EdgeUser:
  34478. m.ClearUser()
  34479. return nil
  34480. }
  34481. return fmt.Errorf("unknown PromoCodeUsage unique edge %s", name)
  34482. }
  34483. // ResetEdge resets all changes to the edge with the given name in this mutation.
  34484. // It returns an error if the edge is not defined in the schema.
  34485. func (m *PromoCodeUsageMutation) ResetEdge(name string) error {
  34486. switch name {
  34487. case promocodeusage.EdgePromoCode:
  34488. m.ResetPromoCode()
  34489. return nil
  34490. case promocodeusage.EdgeUser:
  34491. m.ResetUser()
  34492. return nil
  34493. }
  34494. return fmt.Errorf("unknown PromoCodeUsage edge %s", name)
  34495. }
  34496. // ProxyMutation represents an operation that mutates the Proxy nodes in the graph.
  34497. type ProxyMutation struct {
  34498. config
  34499. op Op
  34500. typ string
  34501. id *int64
  34502. created_at *time.Time
  34503. updated_at *time.Time
  34504. deleted_at *time.Time
  34505. name *string
  34506. protocol *string
  34507. host *string
  34508. port *int
  34509. addport *int
  34510. username *string
  34511. password *string
  34512. status *string
  34513. expires_at *time.Time
  34514. fallback_mode *string
  34515. expiry_warn_days *int
  34516. addexpiry_warn_days *int
  34517. clearedFields map[string]struct{}
  34518. accounts map[int64]struct{}
  34519. removedaccounts map[int64]struct{}
  34520. clearedaccounts bool
  34521. primary_proxies map[int64]struct{}
  34522. removedprimary_proxies map[int64]struct{}
  34523. clearedprimary_proxies bool
  34524. backup_proxy *int64
  34525. clearedbackup_proxy bool
  34526. done bool
  34527. oldValue func(context.Context) (*Proxy, error)
  34528. predicates []predicate.Proxy
  34529. }
  34530. var _ ent.Mutation = (*ProxyMutation)(nil)
  34531. // proxyOption allows management of the mutation configuration using functional options.
  34532. type proxyOption func(*ProxyMutation)
  34533. // newProxyMutation creates new mutation for the Proxy entity.
  34534. func newProxyMutation(c config, op Op, opts ...proxyOption) *ProxyMutation {
  34535. m := &ProxyMutation{
  34536. config: c,
  34537. op: op,
  34538. typ: TypeProxy,
  34539. clearedFields: make(map[string]struct{}),
  34540. }
  34541. for _, opt := range opts {
  34542. opt(m)
  34543. }
  34544. return m
  34545. }
  34546. // withProxyID sets the ID field of the mutation.
  34547. func withProxyID(id int64) proxyOption {
  34548. return func(m *ProxyMutation) {
  34549. var (
  34550. err error
  34551. once sync.Once
  34552. value *Proxy
  34553. )
  34554. m.oldValue = func(ctx context.Context) (*Proxy, error) {
  34555. once.Do(func() {
  34556. if m.done {
  34557. err = errors.New("querying old values post mutation is not allowed")
  34558. } else {
  34559. value, err = m.Client().Proxy.Get(ctx, id)
  34560. }
  34561. })
  34562. return value, err
  34563. }
  34564. m.id = &id
  34565. }
  34566. }
  34567. // withProxy sets the old Proxy of the mutation.
  34568. func withProxy(node *Proxy) proxyOption {
  34569. return func(m *ProxyMutation) {
  34570. m.oldValue = func(context.Context) (*Proxy, error) {
  34571. return node, nil
  34572. }
  34573. m.id = &node.ID
  34574. }
  34575. }
  34576. // Client returns a new `ent.Client` from the mutation. If the mutation was
  34577. // executed in a transaction (ent.Tx), a transactional client is returned.
  34578. func (m ProxyMutation) Client() *Client {
  34579. client := &Client{config: m.config}
  34580. client.init()
  34581. return client
  34582. }
  34583. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  34584. // it returns an error otherwise.
  34585. func (m ProxyMutation) Tx() (*Tx, error) {
  34586. if _, ok := m.driver.(*txDriver); !ok {
  34587. return nil, errors.New("ent: mutation is not running in a transaction")
  34588. }
  34589. tx := &Tx{config: m.config}
  34590. tx.init()
  34591. return tx, nil
  34592. }
  34593. // ID returns the ID value in the mutation. Note that the ID is only available
  34594. // if it was provided to the builder or after it was returned from the database.
  34595. func (m *ProxyMutation) ID() (id int64, exists bool) {
  34596. if m.id == nil {
  34597. return
  34598. }
  34599. return *m.id, true
  34600. }
  34601. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  34602. // That means, if the mutation is applied within a transaction with an isolation level such
  34603. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  34604. // or updated by the mutation.
  34605. func (m *ProxyMutation) IDs(ctx context.Context) ([]int64, error) {
  34606. switch {
  34607. case m.op.Is(OpUpdateOne | OpDeleteOne):
  34608. id, exists := m.ID()
  34609. if exists {
  34610. return []int64{id}, nil
  34611. }
  34612. fallthrough
  34613. case m.op.Is(OpUpdate | OpDelete):
  34614. return m.Client().Proxy.Query().Where(m.predicates...).IDs(ctx)
  34615. default:
  34616. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  34617. }
  34618. }
  34619. // SetCreatedAt sets the "created_at" field.
  34620. func (m *ProxyMutation) SetCreatedAt(t time.Time) {
  34621. m.created_at = &t
  34622. }
  34623. // CreatedAt returns the value of the "created_at" field in the mutation.
  34624. func (m *ProxyMutation) CreatedAt() (r time.Time, exists bool) {
  34625. v := m.created_at
  34626. if v == nil {
  34627. return
  34628. }
  34629. return *v, true
  34630. }
  34631. // OldCreatedAt returns the old "created_at" field's value of the Proxy entity.
  34632. // If the Proxy object wasn't provided to the builder, the object is fetched from the database.
  34633. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34634. func (m *ProxyMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  34635. if !m.op.Is(OpUpdateOne) {
  34636. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  34637. }
  34638. if m.id == nil || m.oldValue == nil {
  34639. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  34640. }
  34641. oldValue, err := m.oldValue(ctx)
  34642. if err != nil {
  34643. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  34644. }
  34645. return oldValue.CreatedAt, nil
  34646. }
  34647. // ResetCreatedAt resets all changes to the "created_at" field.
  34648. func (m *ProxyMutation) ResetCreatedAt() {
  34649. m.created_at = nil
  34650. }
  34651. // SetUpdatedAt sets the "updated_at" field.
  34652. func (m *ProxyMutation) SetUpdatedAt(t time.Time) {
  34653. m.updated_at = &t
  34654. }
  34655. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  34656. func (m *ProxyMutation) UpdatedAt() (r time.Time, exists bool) {
  34657. v := m.updated_at
  34658. if v == nil {
  34659. return
  34660. }
  34661. return *v, true
  34662. }
  34663. // OldUpdatedAt returns the old "updated_at" field's value of the Proxy entity.
  34664. // If the Proxy object wasn't provided to the builder, the object is fetched from the database.
  34665. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34666. func (m *ProxyMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  34667. if !m.op.Is(OpUpdateOne) {
  34668. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  34669. }
  34670. if m.id == nil || m.oldValue == nil {
  34671. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  34672. }
  34673. oldValue, err := m.oldValue(ctx)
  34674. if err != nil {
  34675. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  34676. }
  34677. return oldValue.UpdatedAt, nil
  34678. }
  34679. // ResetUpdatedAt resets all changes to the "updated_at" field.
  34680. func (m *ProxyMutation) ResetUpdatedAt() {
  34681. m.updated_at = nil
  34682. }
  34683. // SetDeletedAt sets the "deleted_at" field.
  34684. func (m *ProxyMutation) SetDeletedAt(t time.Time) {
  34685. m.deleted_at = &t
  34686. }
  34687. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  34688. func (m *ProxyMutation) DeletedAt() (r time.Time, exists bool) {
  34689. v := m.deleted_at
  34690. if v == nil {
  34691. return
  34692. }
  34693. return *v, true
  34694. }
  34695. // OldDeletedAt returns the old "deleted_at" field's value of the Proxy entity.
  34696. // If the Proxy object wasn't provided to the builder, the object is fetched from the database.
  34697. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34698. func (m *ProxyMutation) OldDeletedAt(ctx context.Context) (v *time.Time, err error) {
  34699. if !m.op.Is(OpUpdateOne) {
  34700. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  34701. }
  34702. if m.id == nil || m.oldValue == nil {
  34703. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  34704. }
  34705. oldValue, err := m.oldValue(ctx)
  34706. if err != nil {
  34707. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  34708. }
  34709. return oldValue.DeletedAt, nil
  34710. }
  34711. // ClearDeletedAt clears the value of the "deleted_at" field.
  34712. func (m *ProxyMutation) ClearDeletedAt() {
  34713. m.deleted_at = nil
  34714. m.clearedFields[proxy.FieldDeletedAt] = struct{}{}
  34715. }
  34716. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  34717. func (m *ProxyMutation) DeletedAtCleared() bool {
  34718. _, ok := m.clearedFields[proxy.FieldDeletedAt]
  34719. return ok
  34720. }
  34721. // ResetDeletedAt resets all changes to the "deleted_at" field.
  34722. func (m *ProxyMutation) ResetDeletedAt() {
  34723. m.deleted_at = nil
  34724. delete(m.clearedFields, proxy.FieldDeletedAt)
  34725. }
  34726. // SetName sets the "name" field.
  34727. func (m *ProxyMutation) SetName(s string) {
  34728. m.name = &s
  34729. }
  34730. // Name returns the value of the "name" field in the mutation.
  34731. func (m *ProxyMutation) Name() (r string, exists bool) {
  34732. v := m.name
  34733. if v == nil {
  34734. return
  34735. }
  34736. return *v, true
  34737. }
  34738. // OldName returns the old "name" field's value of the Proxy entity.
  34739. // If the Proxy object wasn't provided to the builder, the object is fetched from the database.
  34740. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34741. func (m *ProxyMutation) OldName(ctx context.Context) (v string, err error) {
  34742. if !m.op.Is(OpUpdateOne) {
  34743. return v, errors.New("OldName is only allowed on UpdateOne operations")
  34744. }
  34745. if m.id == nil || m.oldValue == nil {
  34746. return v, errors.New("OldName requires an ID field in the mutation")
  34747. }
  34748. oldValue, err := m.oldValue(ctx)
  34749. if err != nil {
  34750. return v, fmt.Errorf("querying old value for OldName: %w", err)
  34751. }
  34752. return oldValue.Name, nil
  34753. }
  34754. // ResetName resets all changes to the "name" field.
  34755. func (m *ProxyMutation) ResetName() {
  34756. m.name = nil
  34757. }
  34758. // SetProtocol sets the "protocol" field.
  34759. func (m *ProxyMutation) SetProtocol(s string) {
  34760. m.protocol = &s
  34761. }
  34762. // Protocol returns the value of the "protocol" field in the mutation.
  34763. func (m *ProxyMutation) Protocol() (r string, exists bool) {
  34764. v := m.protocol
  34765. if v == nil {
  34766. return
  34767. }
  34768. return *v, true
  34769. }
  34770. // OldProtocol returns the old "protocol" field's value of the Proxy entity.
  34771. // If the Proxy object wasn't provided to the builder, the object is fetched from the database.
  34772. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34773. func (m *ProxyMutation) OldProtocol(ctx context.Context) (v string, err error) {
  34774. if !m.op.Is(OpUpdateOne) {
  34775. return v, errors.New("OldProtocol is only allowed on UpdateOne operations")
  34776. }
  34777. if m.id == nil || m.oldValue == nil {
  34778. return v, errors.New("OldProtocol requires an ID field in the mutation")
  34779. }
  34780. oldValue, err := m.oldValue(ctx)
  34781. if err != nil {
  34782. return v, fmt.Errorf("querying old value for OldProtocol: %w", err)
  34783. }
  34784. return oldValue.Protocol, nil
  34785. }
  34786. // ResetProtocol resets all changes to the "protocol" field.
  34787. func (m *ProxyMutation) ResetProtocol() {
  34788. m.protocol = nil
  34789. }
  34790. // SetHost sets the "host" field.
  34791. func (m *ProxyMutation) SetHost(s string) {
  34792. m.host = &s
  34793. }
  34794. // Host returns the value of the "host" field in the mutation.
  34795. func (m *ProxyMutation) Host() (r string, exists bool) {
  34796. v := m.host
  34797. if v == nil {
  34798. return
  34799. }
  34800. return *v, true
  34801. }
  34802. // OldHost returns the old "host" field's value of the Proxy entity.
  34803. // If the Proxy object wasn't provided to the builder, the object is fetched from the database.
  34804. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34805. func (m *ProxyMutation) OldHost(ctx context.Context) (v string, err error) {
  34806. if !m.op.Is(OpUpdateOne) {
  34807. return v, errors.New("OldHost is only allowed on UpdateOne operations")
  34808. }
  34809. if m.id == nil || m.oldValue == nil {
  34810. return v, errors.New("OldHost requires an ID field in the mutation")
  34811. }
  34812. oldValue, err := m.oldValue(ctx)
  34813. if err != nil {
  34814. return v, fmt.Errorf("querying old value for OldHost: %w", err)
  34815. }
  34816. return oldValue.Host, nil
  34817. }
  34818. // ResetHost resets all changes to the "host" field.
  34819. func (m *ProxyMutation) ResetHost() {
  34820. m.host = nil
  34821. }
  34822. // SetPort sets the "port" field.
  34823. func (m *ProxyMutation) SetPort(i int) {
  34824. m.port = &i
  34825. m.addport = nil
  34826. }
  34827. // Port returns the value of the "port" field in the mutation.
  34828. func (m *ProxyMutation) Port() (r int, exists bool) {
  34829. v := m.port
  34830. if v == nil {
  34831. return
  34832. }
  34833. return *v, true
  34834. }
  34835. // OldPort returns the old "port" field's value of the Proxy entity.
  34836. // If the Proxy object wasn't provided to the builder, the object is fetched from the database.
  34837. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34838. func (m *ProxyMutation) OldPort(ctx context.Context) (v int, err error) {
  34839. if !m.op.Is(OpUpdateOne) {
  34840. return v, errors.New("OldPort is only allowed on UpdateOne operations")
  34841. }
  34842. if m.id == nil || m.oldValue == nil {
  34843. return v, errors.New("OldPort requires an ID field in the mutation")
  34844. }
  34845. oldValue, err := m.oldValue(ctx)
  34846. if err != nil {
  34847. return v, fmt.Errorf("querying old value for OldPort: %w", err)
  34848. }
  34849. return oldValue.Port, nil
  34850. }
  34851. // AddPort adds i to the "port" field.
  34852. func (m *ProxyMutation) AddPort(i int) {
  34853. if m.addport != nil {
  34854. *m.addport += i
  34855. } else {
  34856. m.addport = &i
  34857. }
  34858. }
  34859. // AddedPort returns the value that was added to the "port" field in this mutation.
  34860. func (m *ProxyMutation) AddedPort() (r int, exists bool) {
  34861. v := m.addport
  34862. if v == nil {
  34863. return
  34864. }
  34865. return *v, true
  34866. }
  34867. // ResetPort resets all changes to the "port" field.
  34868. func (m *ProxyMutation) ResetPort() {
  34869. m.port = nil
  34870. m.addport = nil
  34871. }
  34872. // SetUsername sets the "username" field.
  34873. func (m *ProxyMutation) SetUsername(s string) {
  34874. m.username = &s
  34875. }
  34876. // Username returns the value of the "username" field in the mutation.
  34877. func (m *ProxyMutation) Username() (r string, exists bool) {
  34878. v := m.username
  34879. if v == nil {
  34880. return
  34881. }
  34882. return *v, true
  34883. }
  34884. // OldUsername returns the old "username" field's value of the Proxy entity.
  34885. // If the Proxy object wasn't provided to the builder, the object is fetched from the database.
  34886. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34887. func (m *ProxyMutation) OldUsername(ctx context.Context) (v *string, err error) {
  34888. if !m.op.Is(OpUpdateOne) {
  34889. return v, errors.New("OldUsername is only allowed on UpdateOne operations")
  34890. }
  34891. if m.id == nil || m.oldValue == nil {
  34892. return v, errors.New("OldUsername requires an ID field in the mutation")
  34893. }
  34894. oldValue, err := m.oldValue(ctx)
  34895. if err != nil {
  34896. return v, fmt.Errorf("querying old value for OldUsername: %w", err)
  34897. }
  34898. return oldValue.Username, nil
  34899. }
  34900. // ClearUsername clears the value of the "username" field.
  34901. func (m *ProxyMutation) ClearUsername() {
  34902. m.username = nil
  34903. m.clearedFields[proxy.FieldUsername] = struct{}{}
  34904. }
  34905. // UsernameCleared returns if the "username" field was cleared in this mutation.
  34906. func (m *ProxyMutation) UsernameCleared() bool {
  34907. _, ok := m.clearedFields[proxy.FieldUsername]
  34908. return ok
  34909. }
  34910. // ResetUsername resets all changes to the "username" field.
  34911. func (m *ProxyMutation) ResetUsername() {
  34912. m.username = nil
  34913. delete(m.clearedFields, proxy.FieldUsername)
  34914. }
  34915. // SetPassword sets the "password" field.
  34916. func (m *ProxyMutation) SetPassword(s string) {
  34917. m.password = &s
  34918. }
  34919. // Password returns the value of the "password" field in the mutation.
  34920. func (m *ProxyMutation) Password() (r string, exists bool) {
  34921. v := m.password
  34922. if v == nil {
  34923. return
  34924. }
  34925. return *v, true
  34926. }
  34927. // OldPassword returns the old "password" field's value of the Proxy entity.
  34928. // If the Proxy object wasn't provided to the builder, the object is fetched from the database.
  34929. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34930. func (m *ProxyMutation) OldPassword(ctx context.Context) (v *string, err error) {
  34931. if !m.op.Is(OpUpdateOne) {
  34932. return v, errors.New("OldPassword is only allowed on UpdateOne operations")
  34933. }
  34934. if m.id == nil || m.oldValue == nil {
  34935. return v, errors.New("OldPassword requires an ID field in the mutation")
  34936. }
  34937. oldValue, err := m.oldValue(ctx)
  34938. if err != nil {
  34939. return v, fmt.Errorf("querying old value for OldPassword: %w", err)
  34940. }
  34941. return oldValue.Password, nil
  34942. }
  34943. // ClearPassword clears the value of the "password" field.
  34944. func (m *ProxyMutation) ClearPassword() {
  34945. m.password = nil
  34946. m.clearedFields[proxy.FieldPassword] = struct{}{}
  34947. }
  34948. // PasswordCleared returns if the "password" field was cleared in this mutation.
  34949. func (m *ProxyMutation) PasswordCleared() bool {
  34950. _, ok := m.clearedFields[proxy.FieldPassword]
  34951. return ok
  34952. }
  34953. // ResetPassword resets all changes to the "password" field.
  34954. func (m *ProxyMutation) ResetPassword() {
  34955. m.password = nil
  34956. delete(m.clearedFields, proxy.FieldPassword)
  34957. }
  34958. // SetStatus sets the "status" field.
  34959. func (m *ProxyMutation) SetStatus(s string) {
  34960. m.status = &s
  34961. }
  34962. // Status returns the value of the "status" field in the mutation.
  34963. func (m *ProxyMutation) Status() (r string, exists bool) {
  34964. v := m.status
  34965. if v == nil {
  34966. return
  34967. }
  34968. return *v, true
  34969. }
  34970. // OldStatus returns the old "status" field's value of the Proxy entity.
  34971. // If the Proxy object wasn't provided to the builder, the object is fetched from the database.
  34972. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34973. func (m *ProxyMutation) OldStatus(ctx context.Context) (v string, err error) {
  34974. if !m.op.Is(OpUpdateOne) {
  34975. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  34976. }
  34977. if m.id == nil || m.oldValue == nil {
  34978. return v, errors.New("OldStatus requires an ID field in the mutation")
  34979. }
  34980. oldValue, err := m.oldValue(ctx)
  34981. if err != nil {
  34982. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  34983. }
  34984. return oldValue.Status, nil
  34985. }
  34986. // ResetStatus resets all changes to the "status" field.
  34987. func (m *ProxyMutation) ResetStatus() {
  34988. m.status = nil
  34989. }
  34990. // SetExpiresAt sets the "expires_at" field.
  34991. func (m *ProxyMutation) SetExpiresAt(t time.Time) {
  34992. m.expires_at = &t
  34993. }
  34994. // ExpiresAt returns the value of the "expires_at" field in the mutation.
  34995. func (m *ProxyMutation) ExpiresAt() (r time.Time, exists bool) {
  34996. v := m.expires_at
  34997. if v == nil {
  34998. return
  34999. }
  35000. return *v, true
  35001. }
  35002. // OldExpiresAt returns the old "expires_at" field's value of the Proxy entity.
  35003. // If the Proxy object wasn't provided to the builder, the object is fetched from the database.
  35004. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35005. func (m *ProxyMutation) OldExpiresAt(ctx context.Context) (v *time.Time, err error) {
  35006. if !m.op.Is(OpUpdateOne) {
  35007. return v, errors.New("OldExpiresAt is only allowed on UpdateOne operations")
  35008. }
  35009. if m.id == nil || m.oldValue == nil {
  35010. return v, errors.New("OldExpiresAt requires an ID field in the mutation")
  35011. }
  35012. oldValue, err := m.oldValue(ctx)
  35013. if err != nil {
  35014. return v, fmt.Errorf("querying old value for OldExpiresAt: %w", err)
  35015. }
  35016. return oldValue.ExpiresAt, nil
  35017. }
  35018. // ClearExpiresAt clears the value of the "expires_at" field.
  35019. func (m *ProxyMutation) ClearExpiresAt() {
  35020. m.expires_at = nil
  35021. m.clearedFields[proxy.FieldExpiresAt] = struct{}{}
  35022. }
  35023. // ExpiresAtCleared returns if the "expires_at" field was cleared in this mutation.
  35024. func (m *ProxyMutation) ExpiresAtCleared() bool {
  35025. _, ok := m.clearedFields[proxy.FieldExpiresAt]
  35026. return ok
  35027. }
  35028. // ResetExpiresAt resets all changes to the "expires_at" field.
  35029. func (m *ProxyMutation) ResetExpiresAt() {
  35030. m.expires_at = nil
  35031. delete(m.clearedFields, proxy.FieldExpiresAt)
  35032. }
  35033. // SetFallbackMode sets the "fallback_mode" field.
  35034. func (m *ProxyMutation) SetFallbackMode(s string) {
  35035. m.fallback_mode = &s
  35036. }
  35037. // FallbackMode returns the value of the "fallback_mode" field in the mutation.
  35038. func (m *ProxyMutation) FallbackMode() (r string, exists bool) {
  35039. v := m.fallback_mode
  35040. if v == nil {
  35041. return
  35042. }
  35043. return *v, true
  35044. }
  35045. // OldFallbackMode returns the old "fallback_mode" field's value of the Proxy entity.
  35046. // If the Proxy object wasn't provided to the builder, the object is fetched from the database.
  35047. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35048. func (m *ProxyMutation) OldFallbackMode(ctx context.Context) (v string, err error) {
  35049. if !m.op.Is(OpUpdateOne) {
  35050. return v, errors.New("OldFallbackMode is only allowed on UpdateOne operations")
  35051. }
  35052. if m.id == nil || m.oldValue == nil {
  35053. return v, errors.New("OldFallbackMode requires an ID field in the mutation")
  35054. }
  35055. oldValue, err := m.oldValue(ctx)
  35056. if err != nil {
  35057. return v, fmt.Errorf("querying old value for OldFallbackMode: %w", err)
  35058. }
  35059. return oldValue.FallbackMode, nil
  35060. }
  35061. // ResetFallbackMode resets all changes to the "fallback_mode" field.
  35062. func (m *ProxyMutation) ResetFallbackMode() {
  35063. m.fallback_mode = nil
  35064. }
  35065. // SetBackupProxyID sets the "backup_proxy_id" field.
  35066. func (m *ProxyMutation) SetBackupProxyID(i int64) {
  35067. m.backup_proxy = &i
  35068. }
  35069. // BackupProxyID returns the value of the "backup_proxy_id" field in the mutation.
  35070. func (m *ProxyMutation) BackupProxyID() (r int64, exists bool) {
  35071. v := m.backup_proxy
  35072. if v == nil {
  35073. return
  35074. }
  35075. return *v, true
  35076. }
  35077. // OldBackupProxyID returns the old "backup_proxy_id" field's value of the Proxy entity.
  35078. // If the Proxy object wasn't provided to the builder, the object is fetched from the database.
  35079. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35080. func (m *ProxyMutation) OldBackupProxyID(ctx context.Context) (v *int64, err error) {
  35081. if !m.op.Is(OpUpdateOne) {
  35082. return v, errors.New("OldBackupProxyID is only allowed on UpdateOne operations")
  35083. }
  35084. if m.id == nil || m.oldValue == nil {
  35085. return v, errors.New("OldBackupProxyID requires an ID field in the mutation")
  35086. }
  35087. oldValue, err := m.oldValue(ctx)
  35088. if err != nil {
  35089. return v, fmt.Errorf("querying old value for OldBackupProxyID: %w", err)
  35090. }
  35091. return oldValue.BackupProxyID, nil
  35092. }
  35093. // ClearBackupProxyID clears the value of the "backup_proxy_id" field.
  35094. func (m *ProxyMutation) ClearBackupProxyID() {
  35095. m.backup_proxy = nil
  35096. m.clearedFields[proxy.FieldBackupProxyID] = struct{}{}
  35097. }
  35098. // BackupProxyIDCleared returns if the "backup_proxy_id" field was cleared in this mutation.
  35099. func (m *ProxyMutation) BackupProxyIDCleared() bool {
  35100. _, ok := m.clearedFields[proxy.FieldBackupProxyID]
  35101. return ok
  35102. }
  35103. // ResetBackupProxyID resets all changes to the "backup_proxy_id" field.
  35104. func (m *ProxyMutation) ResetBackupProxyID() {
  35105. m.backup_proxy = nil
  35106. delete(m.clearedFields, proxy.FieldBackupProxyID)
  35107. }
  35108. // SetExpiryWarnDays sets the "expiry_warn_days" field.
  35109. func (m *ProxyMutation) SetExpiryWarnDays(i int) {
  35110. m.expiry_warn_days = &i
  35111. m.addexpiry_warn_days = nil
  35112. }
  35113. // ExpiryWarnDays returns the value of the "expiry_warn_days" field in the mutation.
  35114. func (m *ProxyMutation) ExpiryWarnDays() (r int, exists bool) {
  35115. v := m.expiry_warn_days
  35116. if v == nil {
  35117. return
  35118. }
  35119. return *v, true
  35120. }
  35121. // OldExpiryWarnDays returns the old "expiry_warn_days" field's value of the Proxy entity.
  35122. // If the Proxy object wasn't provided to the builder, the object is fetched from the database.
  35123. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35124. func (m *ProxyMutation) OldExpiryWarnDays(ctx context.Context) (v int, err error) {
  35125. if !m.op.Is(OpUpdateOne) {
  35126. return v, errors.New("OldExpiryWarnDays is only allowed on UpdateOne operations")
  35127. }
  35128. if m.id == nil || m.oldValue == nil {
  35129. return v, errors.New("OldExpiryWarnDays requires an ID field in the mutation")
  35130. }
  35131. oldValue, err := m.oldValue(ctx)
  35132. if err != nil {
  35133. return v, fmt.Errorf("querying old value for OldExpiryWarnDays: %w", err)
  35134. }
  35135. return oldValue.ExpiryWarnDays, nil
  35136. }
  35137. // AddExpiryWarnDays adds i to the "expiry_warn_days" field.
  35138. func (m *ProxyMutation) AddExpiryWarnDays(i int) {
  35139. if m.addexpiry_warn_days != nil {
  35140. *m.addexpiry_warn_days += i
  35141. } else {
  35142. m.addexpiry_warn_days = &i
  35143. }
  35144. }
  35145. // AddedExpiryWarnDays returns the value that was added to the "expiry_warn_days" field in this mutation.
  35146. func (m *ProxyMutation) AddedExpiryWarnDays() (r int, exists bool) {
  35147. v := m.addexpiry_warn_days
  35148. if v == nil {
  35149. return
  35150. }
  35151. return *v, true
  35152. }
  35153. // ResetExpiryWarnDays resets all changes to the "expiry_warn_days" field.
  35154. func (m *ProxyMutation) ResetExpiryWarnDays() {
  35155. m.expiry_warn_days = nil
  35156. m.addexpiry_warn_days = nil
  35157. }
  35158. // AddAccountIDs adds the "accounts" edge to the Account entity by ids.
  35159. func (m *ProxyMutation) AddAccountIDs(ids ...int64) {
  35160. if m.accounts == nil {
  35161. m.accounts = make(map[int64]struct{})
  35162. }
  35163. for i := range ids {
  35164. m.accounts[ids[i]] = struct{}{}
  35165. }
  35166. }
  35167. // ClearAccounts clears the "accounts" edge to the Account entity.
  35168. func (m *ProxyMutation) ClearAccounts() {
  35169. m.clearedaccounts = true
  35170. }
  35171. // AccountsCleared reports if the "accounts" edge to the Account entity was cleared.
  35172. func (m *ProxyMutation) AccountsCleared() bool {
  35173. return m.clearedaccounts
  35174. }
  35175. // RemoveAccountIDs removes the "accounts" edge to the Account entity by IDs.
  35176. func (m *ProxyMutation) RemoveAccountIDs(ids ...int64) {
  35177. if m.removedaccounts == nil {
  35178. m.removedaccounts = make(map[int64]struct{})
  35179. }
  35180. for i := range ids {
  35181. delete(m.accounts, ids[i])
  35182. m.removedaccounts[ids[i]] = struct{}{}
  35183. }
  35184. }
  35185. // RemovedAccounts returns the removed IDs of the "accounts" edge to the Account entity.
  35186. func (m *ProxyMutation) RemovedAccountsIDs() (ids []int64) {
  35187. for id := range m.removedaccounts {
  35188. ids = append(ids, id)
  35189. }
  35190. return
  35191. }
  35192. // AccountsIDs returns the "accounts" edge IDs in the mutation.
  35193. func (m *ProxyMutation) AccountsIDs() (ids []int64) {
  35194. for id := range m.accounts {
  35195. ids = append(ids, id)
  35196. }
  35197. return
  35198. }
  35199. // ResetAccounts resets all changes to the "accounts" edge.
  35200. func (m *ProxyMutation) ResetAccounts() {
  35201. m.accounts = nil
  35202. m.clearedaccounts = false
  35203. m.removedaccounts = nil
  35204. }
  35205. // AddPrimaryProxyIDs adds the "primary_proxies" edge to the Proxy entity by ids.
  35206. func (m *ProxyMutation) AddPrimaryProxyIDs(ids ...int64) {
  35207. if m.primary_proxies == nil {
  35208. m.primary_proxies = make(map[int64]struct{})
  35209. }
  35210. for i := range ids {
  35211. m.primary_proxies[ids[i]] = struct{}{}
  35212. }
  35213. }
  35214. // ClearPrimaryProxies clears the "primary_proxies" edge to the Proxy entity.
  35215. func (m *ProxyMutation) ClearPrimaryProxies() {
  35216. m.clearedprimary_proxies = true
  35217. }
  35218. // PrimaryProxiesCleared reports if the "primary_proxies" edge to the Proxy entity was cleared.
  35219. func (m *ProxyMutation) PrimaryProxiesCleared() bool {
  35220. return m.clearedprimary_proxies
  35221. }
  35222. // RemovePrimaryProxyIDs removes the "primary_proxies" edge to the Proxy entity by IDs.
  35223. func (m *ProxyMutation) RemovePrimaryProxyIDs(ids ...int64) {
  35224. if m.removedprimary_proxies == nil {
  35225. m.removedprimary_proxies = make(map[int64]struct{})
  35226. }
  35227. for i := range ids {
  35228. delete(m.primary_proxies, ids[i])
  35229. m.removedprimary_proxies[ids[i]] = struct{}{}
  35230. }
  35231. }
  35232. // RemovedPrimaryProxies returns the removed IDs of the "primary_proxies" edge to the Proxy entity.
  35233. func (m *ProxyMutation) RemovedPrimaryProxiesIDs() (ids []int64) {
  35234. for id := range m.removedprimary_proxies {
  35235. ids = append(ids, id)
  35236. }
  35237. return
  35238. }
  35239. // PrimaryProxiesIDs returns the "primary_proxies" edge IDs in the mutation.
  35240. func (m *ProxyMutation) PrimaryProxiesIDs() (ids []int64) {
  35241. for id := range m.primary_proxies {
  35242. ids = append(ids, id)
  35243. }
  35244. return
  35245. }
  35246. // ResetPrimaryProxies resets all changes to the "primary_proxies" edge.
  35247. func (m *ProxyMutation) ResetPrimaryProxies() {
  35248. m.primary_proxies = nil
  35249. m.clearedprimary_proxies = false
  35250. m.removedprimary_proxies = nil
  35251. }
  35252. // ClearBackupProxy clears the "backup_proxy" edge to the Proxy entity.
  35253. func (m *ProxyMutation) ClearBackupProxy() {
  35254. m.clearedbackup_proxy = true
  35255. m.clearedFields[proxy.FieldBackupProxyID] = struct{}{}
  35256. }
  35257. // BackupProxyCleared reports if the "backup_proxy" edge to the Proxy entity was cleared.
  35258. func (m *ProxyMutation) BackupProxyCleared() bool {
  35259. return m.BackupProxyIDCleared() || m.clearedbackup_proxy
  35260. }
  35261. // BackupProxyIDs returns the "backup_proxy" edge IDs in the mutation.
  35262. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  35263. // BackupProxyID instead. It exists only for internal usage by the builders.
  35264. func (m *ProxyMutation) BackupProxyIDs() (ids []int64) {
  35265. if id := m.backup_proxy; id != nil {
  35266. ids = append(ids, *id)
  35267. }
  35268. return
  35269. }
  35270. // ResetBackupProxy resets all changes to the "backup_proxy" edge.
  35271. func (m *ProxyMutation) ResetBackupProxy() {
  35272. m.backup_proxy = nil
  35273. m.clearedbackup_proxy = false
  35274. }
  35275. // Where appends a list predicates to the ProxyMutation builder.
  35276. func (m *ProxyMutation) Where(ps ...predicate.Proxy) {
  35277. m.predicates = append(m.predicates, ps...)
  35278. }
  35279. // WhereP appends storage-level predicates to the ProxyMutation builder. Using this method,
  35280. // users can use type-assertion to append predicates that do not depend on any generated package.
  35281. func (m *ProxyMutation) WhereP(ps ...func(*sql.Selector)) {
  35282. p := make([]predicate.Proxy, len(ps))
  35283. for i := range ps {
  35284. p[i] = ps[i]
  35285. }
  35286. m.Where(p...)
  35287. }
  35288. // Op returns the operation name.
  35289. func (m *ProxyMutation) Op() Op {
  35290. return m.op
  35291. }
  35292. // SetOp allows setting the mutation operation.
  35293. func (m *ProxyMutation) SetOp(op Op) {
  35294. m.op = op
  35295. }
  35296. // Type returns the node type of this mutation (Proxy).
  35297. func (m *ProxyMutation) Type() string {
  35298. return m.typ
  35299. }
  35300. // Fields returns all fields that were changed during this mutation. Note that in
  35301. // order to get all numeric fields that were incremented/decremented, call
  35302. // AddedFields().
  35303. func (m *ProxyMutation) Fields() []string {
  35304. fields := make([]string, 0, 14)
  35305. if m.created_at != nil {
  35306. fields = append(fields, proxy.FieldCreatedAt)
  35307. }
  35308. if m.updated_at != nil {
  35309. fields = append(fields, proxy.FieldUpdatedAt)
  35310. }
  35311. if m.deleted_at != nil {
  35312. fields = append(fields, proxy.FieldDeletedAt)
  35313. }
  35314. if m.name != nil {
  35315. fields = append(fields, proxy.FieldName)
  35316. }
  35317. if m.protocol != nil {
  35318. fields = append(fields, proxy.FieldProtocol)
  35319. }
  35320. if m.host != nil {
  35321. fields = append(fields, proxy.FieldHost)
  35322. }
  35323. if m.port != nil {
  35324. fields = append(fields, proxy.FieldPort)
  35325. }
  35326. if m.username != nil {
  35327. fields = append(fields, proxy.FieldUsername)
  35328. }
  35329. if m.password != nil {
  35330. fields = append(fields, proxy.FieldPassword)
  35331. }
  35332. if m.status != nil {
  35333. fields = append(fields, proxy.FieldStatus)
  35334. }
  35335. if m.expires_at != nil {
  35336. fields = append(fields, proxy.FieldExpiresAt)
  35337. }
  35338. if m.fallback_mode != nil {
  35339. fields = append(fields, proxy.FieldFallbackMode)
  35340. }
  35341. if m.backup_proxy != nil {
  35342. fields = append(fields, proxy.FieldBackupProxyID)
  35343. }
  35344. if m.expiry_warn_days != nil {
  35345. fields = append(fields, proxy.FieldExpiryWarnDays)
  35346. }
  35347. return fields
  35348. }
  35349. // Field returns the value of a field with the given name. The second boolean
  35350. // return value indicates that this field was not set, or was not defined in the
  35351. // schema.
  35352. func (m *ProxyMutation) Field(name string) (ent.Value, bool) {
  35353. switch name {
  35354. case proxy.FieldCreatedAt:
  35355. return m.CreatedAt()
  35356. case proxy.FieldUpdatedAt:
  35357. return m.UpdatedAt()
  35358. case proxy.FieldDeletedAt:
  35359. return m.DeletedAt()
  35360. case proxy.FieldName:
  35361. return m.Name()
  35362. case proxy.FieldProtocol:
  35363. return m.Protocol()
  35364. case proxy.FieldHost:
  35365. return m.Host()
  35366. case proxy.FieldPort:
  35367. return m.Port()
  35368. case proxy.FieldUsername:
  35369. return m.Username()
  35370. case proxy.FieldPassword:
  35371. return m.Password()
  35372. case proxy.FieldStatus:
  35373. return m.Status()
  35374. case proxy.FieldExpiresAt:
  35375. return m.ExpiresAt()
  35376. case proxy.FieldFallbackMode:
  35377. return m.FallbackMode()
  35378. case proxy.FieldBackupProxyID:
  35379. return m.BackupProxyID()
  35380. case proxy.FieldExpiryWarnDays:
  35381. return m.ExpiryWarnDays()
  35382. }
  35383. return nil, false
  35384. }
  35385. // OldField returns the old value of the field from the database. An error is
  35386. // returned if the mutation operation is not UpdateOne, or the query to the
  35387. // database failed.
  35388. func (m *ProxyMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  35389. switch name {
  35390. case proxy.FieldCreatedAt:
  35391. return m.OldCreatedAt(ctx)
  35392. case proxy.FieldUpdatedAt:
  35393. return m.OldUpdatedAt(ctx)
  35394. case proxy.FieldDeletedAt:
  35395. return m.OldDeletedAt(ctx)
  35396. case proxy.FieldName:
  35397. return m.OldName(ctx)
  35398. case proxy.FieldProtocol:
  35399. return m.OldProtocol(ctx)
  35400. case proxy.FieldHost:
  35401. return m.OldHost(ctx)
  35402. case proxy.FieldPort:
  35403. return m.OldPort(ctx)
  35404. case proxy.FieldUsername:
  35405. return m.OldUsername(ctx)
  35406. case proxy.FieldPassword:
  35407. return m.OldPassword(ctx)
  35408. case proxy.FieldStatus:
  35409. return m.OldStatus(ctx)
  35410. case proxy.FieldExpiresAt:
  35411. return m.OldExpiresAt(ctx)
  35412. case proxy.FieldFallbackMode:
  35413. return m.OldFallbackMode(ctx)
  35414. case proxy.FieldBackupProxyID:
  35415. return m.OldBackupProxyID(ctx)
  35416. case proxy.FieldExpiryWarnDays:
  35417. return m.OldExpiryWarnDays(ctx)
  35418. }
  35419. return nil, fmt.Errorf("unknown Proxy field %s", name)
  35420. }
  35421. // SetField sets the value of a field with the given name. It returns an error if
  35422. // the field is not defined in the schema, or if the type mismatched the field
  35423. // type.
  35424. func (m *ProxyMutation) SetField(name string, value ent.Value) error {
  35425. switch name {
  35426. case proxy.FieldCreatedAt:
  35427. v, ok := value.(time.Time)
  35428. if !ok {
  35429. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35430. }
  35431. m.SetCreatedAt(v)
  35432. return nil
  35433. case proxy.FieldUpdatedAt:
  35434. v, ok := value.(time.Time)
  35435. if !ok {
  35436. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35437. }
  35438. m.SetUpdatedAt(v)
  35439. return nil
  35440. case proxy.FieldDeletedAt:
  35441. v, ok := value.(time.Time)
  35442. if !ok {
  35443. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35444. }
  35445. m.SetDeletedAt(v)
  35446. return nil
  35447. case proxy.FieldName:
  35448. v, ok := value.(string)
  35449. if !ok {
  35450. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35451. }
  35452. m.SetName(v)
  35453. return nil
  35454. case proxy.FieldProtocol:
  35455. v, ok := value.(string)
  35456. if !ok {
  35457. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35458. }
  35459. m.SetProtocol(v)
  35460. return nil
  35461. case proxy.FieldHost:
  35462. v, ok := value.(string)
  35463. if !ok {
  35464. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35465. }
  35466. m.SetHost(v)
  35467. return nil
  35468. case proxy.FieldPort:
  35469. v, ok := value.(int)
  35470. if !ok {
  35471. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35472. }
  35473. m.SetPort(v)
  35474. return nil
  35475. case proxy.FieldUsername:
  35476. v, ok := value.(string)
  35477. if !ok {
  35478. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35479. }
  35480. m.SetUsername(v)
  35481. return nil
  35482. case proxy.FieldPassword:
  35483. v, ok := value.(string)
  35484. if !ok {
  35485. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35486. }
  35487. m.SetPassword(v)
  35488. return nil
  35489. case proxy.FieldStatus:
  35490. v, ok := value.(string)
  35491. if !ok {
  35492. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35493. }
  35494. m.SetStatus(v)
  35495. return nil
  35496. case proxy.FieldExpiresAt:
  35497. v, ok := value.(time.Time)
  35498. if !ok {
  35499. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35500. }
  35501. m.SetExpiresAt(v)
  35502. return nil
  35503. case proxy.FieldFallbackMode:
  35504. v, ok := value.(string)
  35505. if !ok {
  35506. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35507. }
  35508. m.SetFallbackMode(v)
  35509. return nil
  35510. case proxy.FieldBackupProxyID:
  35511. v, ok := value.(int64)
  35512. if !ok {
  35513. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35514. }
  35515. m.SetBackupProxyID(v)
  35516. return nil
  35517. case proxy.FieldExpiryWarnDays:
  35518. v, ok := value.(int)
  35519. if !ok {
  35520. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35521. }
  35522. m.SetExpiryWarnDays(v)
  35523. return nil
  35524. }
  35525. return fmt.Errorf("unknown Proxy field %s", name)
  35526. }
  35527. // AddedFields returns all numeric fields that were incremented/decremented during
  35528. // this mutation.
  35529. func (m *ProxyMutation) AddedFields() []string {
  35530. var fields []string
  35531. if m.addport != nil {
  35532. fields = append(fields, proxy.FieldPort)
  35533. }
  35534. if m.addexpiry_warn_days != nil {
  35535. fields = append(fields, proxy.FieldExpiryWarnDays)
  35536. }
  35537. return fields
  35538. }
  35539. // AddedField returns the numeric value that was incremented/decremented on a field
  35540. // with the given name. The second boolean return value indicates that this field
  35541. // was not set, or was not defined in the schema.
  35542. func (m *ProxyMutation) AddedField(name string) (ent.Value, bool) {
  35543. switch name {
  35544. case proxy.FieldPort:
  35545. return m.AddedPort()
  35546. case proxy.FieldExpiryWarnDays:
  35547. return m.AddedExpiryWarnDays()
  35548. }
  35549. return nil, false
  35550. }
  35551. // AddField adds the value to the field with the given name. It returns an error if
  35552. // the field is not defined in the schema, or if the type mismatched the field
  35553. // type.
  35554. func (m *ProxyMutation) AddField(name string, value ent.Value) error {
  35555. switch name {
  35556. case proxy.FieldPort:
  35557. v, ok := value.(int)
  35558. if !ok {
  35559. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35560. }
  35561. m.AddPort(v)
  35562. return nil
  35563. case proxy.FieldExpiryWarnDays:
  35564. v, ok := value.(int)
  35565. if !ok {
  35566. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35567. }
  35568. m.AddExpiryWarnDays(v)
  35569. return nil
  35570. }
  35571. return fmt.Errorf("unknown Proxy numeric field %s", name)
  35572. }
  35573. // ClearedFields returns all nullable fields that were cleared during this
  35574. // mutation.
  35575. func (m *ProxyMutation) ClearedFields() []string {
  35576. var fields []string
  35577. if m.FieldCleared(proxy.FieldDeletedAt) {
  35578. fields = append(fields, proxy.FieldDeletedAt)
  35579. }
  35580. if m.FieldCleared(proxy.FieldUsername) {
  35581. fields = append(fields, proxy.FieldUsername)
  35582. }
  35583. if m.FieldCleared(proxy.FieldPassword) {
  35584. fields = append(fields, proxy.FieldPassword)
  35585. }
  35586. if m.FieldCleared(proxy.FieldExpiresAt) {
  35587. fields = append(fields, proxy.FieldExpiresAt)
  35588. }
  35589. if m.FieldCleared(proxy.FieldBackupProxyID) {
  35590. fields = append(fields, proxy.FieldBackupProxyID)
  35591. }
  35592. return fields
  35593. }
  35594. // FieldCleared returns a boolean indicating if a field with the given name was
  35595. // cleared in this mutation.
  35596. func (m *ProxyMutation) FieldCleared(name string) bool {
  35597. _, ok := m.clearedFields[name]
  35598. return ok
  35599. }
  35600. // ClearField clears the value of the field with the given name. It returns an
  35601. // error if the field is not defined in the schema.
  35602. func (m *ProxyMutation) ClearField(name string) error {
  35603. switch name {
  35604. case proxy.FieldDeletedAt:
  35605. m.ClearDeletedAt()
  35606. return nil
  35607. case proxy.FieldUsername:
  35608. m.ClearUsername()
  35609. return nil
  35610. case proxy.FieldPassword:
  35611. m.ClearPassword()
  35612. return nil
  35613. case proxy.FieldExpiresAt:
  35614. m.ClearExpiresAt()
  35615. return nil
  35616. case proxy.FieldBackupProxyID:
  35617. m.ClearBackupProxyID()
  35618. return nil
  35619. }
  35620. return fmt.Errorf("unknown Proxy nullable field %s", name)
  35621. }
  35622. // ResetField resets all changes in the mutation for the field with the given name.
  35623. // It returns an error if the field is not defined in the schema.
  35624. func (m *ProxyMutation) ResetField(name string) error {
  35625. switch name {
  35626. case proxy.FieldCreatedAt:
  35627. m.ResetCreatedAt()
  35628. return nil
  35629. case proxy.FieldUpdatedAt:
  35630. m.ResetUpdatedAt()
  35631. return nil
  35632. case proxy.FieldDeletedAt:
  35633. m.ResetDeletedAt()
  35634. return nil
  35635. case proxy.FieldName:
  35636. m.ResetName()
  35637. return nil
  35638. case proxy.FieldProtocol:
  35639. m.ResetProtocol()
  35640. return nil
  35641. case proxy.FieldHost:
  35642. m.ResetHost()
  35643. return nil
  35644. case proxy.FieldPort:
  35645. m.ResetPort()
  35646. return nil
  35647. case proxy.FieldUsername:
  35648. m.ResetUsername()
  35649. return nil
  35650. case proxy.FieldPassword:
  35651. m.ResetPassword()
  35652. return nil
  35653. case proxy.FieldStatus:
  35654. m.ResetStatus()
  35655. return nil
  35656. case proxy.FieldExpiresAt:
  35657. m.ResetExpiresAt()
  35658. return nil
  35659. case proxy.FieldFallbackMode:
  35660. m.ResetFallbackMode()
  35661. return nil
  35662. case proxy.FieldBackupProxyID:
  35663. m.ResetBackupProxyID()
  35664. return nil
  35665. case proxy.FieldExpiryWarnDays:
  35666. m.ResetExpiryWarnDays()
  35667. return nil
  35668. }
  35669. return fmt.Errorf("unknown Proxy field %s", name)
  35670. }
  35671. // AddedEdges returns all edge names that were set/added in this mutation.
  35672. func (m *ProxyMutation) AddedEdges() []string {
  35673. edges := make([]string, 0, 3)
  35674. if m.accounts != nil {
  35675. edges = append(edges, proxy.EdgeAccounts)
  35676. }
  35677. if m.primary_proxies != nil {
  35678. edges = append(edges, proxy.EdgePrimaryProxies)
  35679. }
  35680. if m.backup_proxy != nil {
  35681. edges = append(edges, proxy.EdgeBackupProxy)
  35682. }
  35683. return edges
  35684. }
  35685. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  35686. // name in this mutation.
  35687. func (m *ProxyMutation) AddedIDs(name string) []ent.Value {
  35688. switch name {
  35689. case proxy.EdgeAccounts:
  35690. ids := make([]ent.Value, 0, len(m.accounts))
  35691. for id := range m.accounts {
  35692. ids = append(ids, id)
  35693. }
  35694. return ids
  35695. case proxy.EdgePrimaryProxies:
  35696. ids := make([]ent.Value, 0, len(m.primary_proxies))
  35697. for id := range m.primary_proxies {
  35698. ids = append(ids, id)
  35699. }
  35700. return ids
  35701. case proxy.EdgeBackupProxy:
  35702. if id := m.backup_proxy; id != nil {
  35703. return []ent.Value{*id}
  35704. }
  35705. }
  35706. return nil
  35707. }
  35708. // RemovedEdges returns all edge names that were removed in this mutation.
  35709. func (m *ProxyMutation) RemovedEdges() []string {
  35710. edges := make([]string, 0, 3)
  35711. if m.removedaccounts != nil {
  35712. edges = append(edges, proxy.EdgeAccounts)
  35713. }
  35714. if m.removedprimary_proxies != nil {
  35715. edges = append(edges, proxy.EdgePrimaryProxies)
  35716. }
  35717. return edges
  35718. }
  35719. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  35720. // the given name in this mutation.
  35721. func (m *ProxyMutation) RemovedIDs(name string) []ent.Value {
  35722. switch name {
  35723. case proxy.EdgeAccounts:
  35724. ids := make([]ent.Value, 0, len(m.removedaccounts))
  35725. for id := range m.removedaccounts {
  35726. ids = append(ids, id)
  35727. }
  35728. return ids
  35729. case proxy.EdgePrimaryProxies:
  35730. ids := make([]ent.Value, 0, len(m.removedprimary_proxies))
  35731. for id := range m.removedprimary_proxies {
  35732. ids = append(ids, id)
  35733. }
  35734. return ids
  35735. }
  35736. return nil
  35737. }
  35738. // ClearedEdges returns all edge names that were cleared in this mutation.
  35739. func (m *ProxyMutation) ClearedEdges() []string {
  35740. edges := make([]string, 0, 3)
  35741. if m.clearedaccounts {
  35742. edges = append(edges, proxy.EdgeAccounts)
  35743. }
  35744. if m.clearedprimary_proxies {
  35745. edges = append(edges, proxy.EdgePrimaryProxies)
  35746. }
  35747. if m.clearedbackup_proxy {
  35748. edges = append(edges, proxy.EdgeBackupProxy)
  35749. }
  35750. return edges
  35751. }
  35752. // EdgeCleared returns a boolean which indicates if the edge with the given name
  35753. // was cleared in this mutation.
  35754. func (m *ProxyMutation) EdgeCleared(name string) bool {
  35755. switch name {
  35756. case proxy.EdgeAccounts:
  35757. return m.clearedaccounts
  35758. case proxy.EdgePrimaryProxies:
  35759. return m.clearedprimary_proxies
  35760. case proxy.EdgeBackupProxy:
  35761. return m.clearedbackup_proxy
  35762. }
  35763. return false
  35764. }
  35765. // ClearEdge clears the value of the edge with the given name. It returns an error
  35766. // if that edge is not defined in the schema.
  35767. func (m *ProxyMutation) ClearEdge(name string) error {
  35768. switch name {
  35769. case proxy.EdgeBackupProxy:
  35770. m.ClearBackupProxy()
  35771. return nil
  35772. }
  35773. return fmt.Errorf("unknown Proxy unique edge %s", name)
  35774. }
  35775. // ResetEdge resets all changes to the edge with the given name in this mutation.
  35776. // It returns an error if the edge is not defined in the schema.
  35777. func (m *ProxyMutation) ResetEdge(name string) error {
  35778. switch name {
  35779. case proxy.EdgeAccounts:
  35780. m.ResetAccounts()
  35781. return nil
  35782. case proxy.EdgePrimaryProxies:
  35783. m.ResetPrimaryProxies()
  35784. return nil
  35785. case proxy.EdgeBackupProxy:
  35786. m.ResetBackupProxy()
  35787. return nil
  35788. }
  35789. return fmt.Errorf("unknown Proxy edge %s", name)
  35790. }
  35791. // RedeemCodeMutation represents an operation that mutates the RedeemCode nodes in the graph.
  35792. type RedeemCodeMutation struct {
  35793. config
  35794. op Op
  35795. typ string
  35796. id *int64
  35797. code *string
  35798. _type *string
  35799. value *float64
  35800. addvalue *float64
  35801. status *string
  35802. used_at *time.Time
  35803. notes *string
  35804. created_at *time.Time
  35805. expires_at *time.Time
  35806. validity_days *int
  35807. addvalidity_days *int
  35808. clearedFields map[string]struct{}
  35809. user *int64
  35810. cleareduser bool
  35811. group *int64
  35812. clearedgroup bool
  35813. done bool
  35814. oldValue func(context.Context) (*RedeemCode, error)
  35815. predicates []predicate.RedeemCode
  35816. }
  35817. var _ ent.Mutation = (*RedeemCodeMutation)(nil)
  35818. // redeemcodeOption allows management of the mutation configuration using functional options.
  35819. type redeemcodeOption func(*RedeemCodeMutation)
  35820. // newRedeemCodeMutation creates new mutation for the RedeemCode entity.
  35821. func newRedeemCodeMutation(c config, op Op, opts ...redeemcodeOption) *RedeemCodeMutation {
  35822. m := &RedeemCodeMutation{
  35823. config: c,
  35824. op: op,
  35825. typ: TypeRedeemCode,
  35826. clearedFields: make(map[string]struct{}),
  35827. }
  35828. for _, opt := range opts {
  35829. opt(m)
  35830. }
  35831. return m
  35832. }
  35833. // withRedeemCodeID sets the ID field of the mutation.
  35834. func withRedeemCodeID(id int64) redeemcodeOption {
  35835. return func(m *RedeemCodeMutation) {
  35836. var (
  35837. err error
  35838. once sync.Once
  35839. value *RedeemCode
  35840. )
  35841. m.oldValue = func(ctx context.Context) (*RedeemCode, error) {
  35842. once.Do(func() {
  35843. if m.done {
  35844. err = errors.New("querying old values post mutation is not allowed")
  35845. } else {
  35846. value, err = m.Client().RedeemCode.Get(ctx, id)
  35847. }
  35848. })
  35849. return value, err
  35850. }
  35851. m.id = &id
  35852. }
  35853. }
  35854. // withRedeemCode sets the old RedeemCode of the mutation.
  35855. func withRedeemCode(node *RedeemCode) redeemcodeOption {
  35856. return func(m *RedeemCodeMutation) {
  35857. m.oldValue = func(context.Context) (*RedeemCode, error) {
  35858. return node, nil
  35859. }
  35860. m.id = &node.ID
  35861. }
  35862. }
  35863. // Client returns a new `ent.Client` from the mutation. If the mutation was
  35864. // executed in a transaction (ent.Tx), a transactional client is returned.
  35865. func (m RedeemCodeMutation) Client() *Client {
  35866. client := &Client{config: m.config}
  35867. client.init()
  35868. return client
  35869. }
  35870. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  35871. // it returns an error otherwise.
  35872. func (m RedeemCodeMutation) Tx() (*Tx, error) {
  35873. if _, ok := m.driver.(*txDriver); !ok {
  35874. return nil, errors.New("ent: mutation is not running in a transaction")
  35875. }
  35876. tx := &Tx{config: m.config}
  35877. tx.init()
  35878. return tx, nil
  35879. }
  35880. // ID returns the ID value in the mutation. Note that the ID is only available
  35881. // if it was provided to the builder or after it was returned from the database.
  35882. func (m *RedeemCodeMutation) ID() (id int64, exists bool) {
  35883. if m.id == nil {
  35884. return
  35885. }
  35886. return *m.id, true
  35887. }
  35888. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  35889. // That means, if the mutation is applied within a transaction with an isolation level such
  35890. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  35891. // or updated by the mutation.
  35892. func (m *RedeemCodeMutation) IDs(ctx context.Context) ([]int64, error) {
  35893. switch {
  35894. case m.op.Is(OpUpdateOne | OpDeleteOne):
  35895. id, exists := m.ID()
  35896. if exists {
  35897. return []int64{id}, nil
  35898. }
  35899. fallthrough
  35900. case m.op.Is(OpUpdate | OpDelete):
  35901. return m.Client().RedeemCode.Query().Where(m.predicates...).IDs(ctx)
  35902. default:
  35903. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  35904. }
  35905. }
  35906. // SetCode sets the "code" field.
  35907. func (m *RedeemCodeMutation) SetCode(s string) {
  35908. m.code = &s
  35909. }
  35910. // Code returns the value of the "code" field in the mutation.
  35911. func (m *RedeemCodeMutation) Code() (r string, exists bool) {
  35912. v := m.code
  35913. if v == nil {
  35914. return
  35915. }
  35916. return *v, true
  35917. }
  35918. // OldCode returns the old "code" field's value of the RedeemCode entity.
  35919. // If the RedeemCode object wasn't provided to the builder, the object is fetched from the database.
  35920. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35921. func (m *RedeemCodeMutation) OldCode(ctx context.Context) (v string, err error) {
  35922. if !m.op.Is(OpUpdateOne) {
  35923. return v, errors.New("OldCode is only allowed on UpdateOne operations")
  35924. }
  35925. if m.id == nil || m.oldValue == nil {
  35926. return v, errors.New("OldCode requires an ID field in the mutation")
  35927. }
  35928. oldValue, err := m.oldValue(ctx)
  35929. if err != nil {
  35930. return v, fmt.Errorf("querying old value for OldCode: %w", err)
  35931. }
  35932. return oldValue.Code, nil
  35933. }
  35934. // ResetCode resets all changes to the "code" field.
  35935. func (m *RedeemCodeMutation) ResetCode() {
  35936. m.code = nil
  35937. }
  35938. // SetType sets the "type" field.
  35939. func (m *RedeemCodeMutation) SetType(s string) {
  35940. m._type = &s
  35941. }
  35942. // GetType returns the value of the "type" field in the mutation.
  35943. func (m *RedeemCodeMutation) GetType() (r string, exists bool) {
  35944. v := m._type
  35945. if v == nil {
  35946. return
  35947. }
  35948. return *v, true
  35949. }
  35950. // OldType returns the old "type" field's value of the RedeemCode entity.
  35951. // If the RedeemCode object wasn't provided to the builder, the object is fetched from the database.
  35952. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35953. func (m *RedeemCodeMutation) OldType(ctx context.Context) (v string, err error) {
  35954. if !m.op.Is(OpUpdateOne) {
  35955. return v, errors.New("OldType is only allowed on UpdateOne operations")
  35956. }
  35957. if m.id == nil || m.oldValue == nil {
  35958. return v, errors.New("OldType requires an ID field in the mutation")
  35959. }
  35960. oldValue, err := m.oldValue(ctx)
  35961. if err != nil {
  35962. return v, fmt.Errorf("querying old value for OldType: %w", err)
  35963. }
  35964. return oldValue.Type, nil
  35965. }
  35966. // ResetType resets all changes to the "type" field.
  35967. func (m *RedeemCodeMutation) ResetType() {
  35968. m._type = nil
  35969. }
  35970. // SetValue sets the "value" field.
  35971. func (m *RedeemCodeMutation) SetValue(f float64) {
  35972. m.value = &f
  35973. m.addvalue = nil
  35974. }
  35975. // Value returns the value of the "value" field in the mutation.
  35976. func (m *RedeemCodeMutation) Value() (r float64, exists bool) {
  35977. v := m.value
  35978. if v == nil {
  35979. return
  35980. }
  35981. return *v, true
  35982. }
  35983. // OldValue returns the old "value" field's value of the RedeemCode entity.
  35984. // If the RedeemCode object wasn't provided to the builder, the object is fetched from the database.
  35985. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35986. func (m *RedeemCodeMutation) OldValue(ctx context.Context) (v float64, err error) {
  35987. if !m.op.Is(OpUpdateOne) {
  35988. return v, errors.New("OldValue is only allowed on UpdateOne operations")
  35989. }
  35990. if m.id == nil || m.oldValue == nil {
  35991. return v, errors.New("OldValue requires an ID field in the mutation")
  35992. }
  35993. oldValue, err := m.oldValue(ctx)
  35994. if err != nil {
  35995. return v, fmt.Errorf("querying old value for OldValue: %w", err)
  35996. }
  35997. return oldValue.Value, nil
  35998. }
  35999. // AddValue adds f to the "value" field.
  36000. func (m *RedeemCodeMutation) AddValue(f float64) {
  36001. if m.addvalue != nil {
  36002. *m.addvalue += f
  36003. } else {
  36004. m.addvalue = &f
  36005. }
  36006. }
  36007. // AddedValue returns the value that was added to the "value" field in this mutation.
  36008. func (m *RedeemCodeMutation) AddedValue() (r float64, exists bool) {
  36009. v := m.addvalue
  36010. if v == nil {
  36011. return
  36012. }
  36013. return *v, true
  36014. }
  36015. // ResetValue resets all changes to the "value" field.
  36016. func (m *RedeemCodeMutation) ResetValue() {
  36017. m.value = nil
  36018. m.addvalue = nil
  36019. }
  36020. // SetStatus sets the "status" field.
  36021. func (m *RedeemCodeMutation) SetStatus(s string) {
  36022. m.status = &s
  36023. }
  36024. // Status returns the value of the "status" field in the mutation.
  36025. func (m *RedeemCodeMutation) Status() (r string, exists bool) {
  36026. v := m.status
  36027. if v == nil {
  36028. return
  36029. }
  36030. return *v, true
  36031. }
  36032. // OldStatus returns the old "status" field's value of the RedeemCode entity.
  36033. // If the RedeemCode object wasn't provided to the builder, the object is fetched from the database.
  36034. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36035. func (m *RedeemCodeMutation) OldStatus(ctx context.Context) (v string, err error) {
  36036. if !m.op.Is(OpUpdateOne) {
  36037. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  36038. }
  36039. if m.id == nil || m.oldValue == nil {
  36040. return v, errors.New("OldStatus requires an ID field in the mutation")
  36041. }
  36042. oldValue, err := m.oldValue(ctx)
  36043. if err != nil {
  36044. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  36045. }
  36046. return oldValue.Status, nil
  36047. }
  36048. // ResetStatus resets all changes to the "status" field.
  36049. func (m *RedeemCodeMutation) ResetStatus() {
  36050. m.status = nil
  36051. }
  36052. // SetUsedBy sets the "used_by" field.
  36053. func (m *RedeemCodeMutation) SetUsedBy(i int64) {
  36054. m.user = &i
  36055. }
  36056. // UsedBy returns the value of the "used_by" field in the mutation.
  36057. func (m *RedeemCodeMutation) UsedBy() (r int64, exists bool) {
  36058. v := m.user
  36059. if v == nil {
  36060. return
  36061. }
  36062. return *v, true
  36063. }
  36064. // OldUsedBy returns the old "used_by" field's value of the RedeemCode entity.
  36065. // If the RedeemCode object wasn't provided to the builder, the object is fetched from the database.
  36066. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36067. func (m *RedeemCodeMutation) OldUsedBy(ctx context.Context) (v *int64, err error) {
  36068. if !m.op.Is(OpUpdateOne) {
  36069. return v, errors.New("OldUsedBy is only allowed on UpdateOne operations")
  36070. }
  36071. if m.id == nil || m.oldValue == nil {
  36072. return v, errors.New("OldUsedBy requires an ID field in the mutation")
  36073. }
  36074. oldValue, err := m.oldValue(ctx)
  36075. if err != nil {
  36076. return v, fmt.Errorf("querying old value for OldUsedBy: %w", err)
  36077. }
  36078. return oldValue.UsedBy, nil
  36079. }
  36080. // ClearUsedBy clears the value of the "used_by" field.
  36081. func (m *RedeemCodeMutation) ClearUsedBy() {
  36082. m.user = nil
  36083. m.clearedFields[redeemcode.FieldUsedBy] = struct{}{}
  36084. }
  36085. // UsedByCleared returns if the "used_by" field was cleared in this mutation.
  36086. func (m *RedeemCodeMutation) UsedByCleared() bool {
  36087. _, ok := m.clearedFields[redeemcode.FieldUsedBy]
  36088. return ok
  36089. }
  36090. // ResetUsedBy resets all changes to the "used_by" field.
  36091. func (m *RedeemCodeMutation) ResetUsedBy() {
  36092. m.user = nil
  36093. delete(m.clearedFields, redeemcode.FieldUsedBy)
  36094. }
  36095. // SetUsedAt sets the "used_at" field.
  36096. func (m *RedeemCodeMutation) SetUsedAt(t time.Time) {
  36097. m.used_at = &t
  36098. }
  36099. // UsedAt returns the value of the "used_at" field in the mutation.
  36100. func (m *RedeemCodeMutation) UsedAt() (r time.Time, exists bool) {
  36101. v := m.used_at
  36102. if v == nil {
  36103. return
  36104. }
  36105. return *v, true
  36106. }
  36107. // OldUsedAt returns the old "used_at" field's value of the RedeemCode entity.
  36108. // If the RedeemCode object wasn't provided to the builder, the object is fetched from the database.
  36109. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36110. func (m *RedeemCodeMutation) OldUsedAt(ctx context.Context) (v *time.Time, err error) {
  36111. if !m.op.Is(OpUpdateOne) {
  36112. return v, errors.New("OldUsedAt is only allowed on UpdateOne operations")
  36113. }
  36114. if m.id == nil || m.oldValue == nil {
  36115. return v, errors.New("OldUsedAt requires an ID field in the mutation")
  36116. }
  36117. oldValue, err := m.oldValue(ctx)
  36118. if err != nil {
  36119. return v, fmt.Errorf("querying old value for OldUsedAt: %w", err)
  36120. }
  36121. return oldValue.UsedAt, nil
  36122. }
  36123. // ClearUsedAt clears the value of the "used_at" field.
  36124. func (m *RedeemCodeMutation) ClearUsedAt() {
  36125. m.used_at = nil
  36126. m.clearedFields[redeemcode.FieldUsedAt] = struct{}{}
  36127. }
  36128. // UsedAtCleared returns if the "used_at" field was cleared in this mutation.
  36129. func (m *RedeemCodeMutation) UsedAtCleared() bool {
  36130. _, ok := m.clearedFields[redeemcode.FieldUsedAt]
  36131. return ok
  36132. }
  36133. // ResetUsedAt resets all changes to the "used_at" field.
  36134. func (m *RedeemCodeMutation) ResetUsedAt() {
  36135. m.used_at = nil
  36136. delete(m.clearedFields, redeemcode.FieldUsedAt)
  36137. }
  36138. // SetNotes sets the "notes" field.
  36139. func (m *RedeemCodeMutation) SetNotes(s string) {
  36140. m.notes = &s
  36141. }
  36142. // Notes returns the value of the "notes" field in the mutation.
  36143. func (m *RedeemCodeMutation) Notes() (r string, exists bool) {
  36144. v := m.notes
  36145. if v == nil {
  36146. return
  36147. }
  36148. return *v, true
  36149. }
  36150. // OldNotes returns the old "notes" field's value of the RedeemCode entity.
  36151. // If the RedeemCode object wasn't provided to the builder, the object is fetched from the database.
  36152. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36153. func (m *RedeemCodeMutation) OldNotes(ctx context.Context) (v *string, err error) {
  36154. if !m.op.Is(OpUpdateOne) {
  36155. return v, errors.New("OldNotes is only allowed on UpdateOne operations")
  36156. }
  36157. if m.id == nil || m.oldValue == nil {
  36158. return v, errors.New("OldNotes requires an ID field in the mutation")
  36159. }
  36160. oldValue, err := m.oldValue(ctx)
  36161. if err != nil {
  36162. return v, fmt.Errorf("querying old value for OldNotes: %w", err)
  36163. }
  36164. return oldValue.Notes, nil
  36165. }
  36166. // ClearNotes clears the value of the "notes" field.
  36167. func (m *RedeemCodeMutation) ClearNotes() {
  36168. m.notes = nil
  36169. m.clearedFields[redeemcode.FieldNotes] = struct{}{}
  36170. }
  36171. // NotesCleared returns if the "notes" field was cleared in this mutation.
  36172. func (m *RedeemCodeMutation) NotesCleared() bool {
  36173. _, ok := m.clearedFields[redeemcode.FieldNotes]
  36174. return ok
  36175. }
  36176. // ResetNotes resets all changes to the "notes" field.
  36177. func (m *RedeemCodeMutation) ResetNotes() {
  36178. m.notes = nil
  36179. delete(m.clearedFields, redeemcode.FieldNotes)
  36180. }
  36181. // SetCreatedAt sets the "created_at" field.
  36182. func (m *RedeemCodeMutation) SetCreatedAt(t time.Time) {
  36183. m.created_at = &t
  36184. }
  36185. // CreatedAt returns the value of the "created_at" field in the mutation.
  36186. func (m *RedeemCodeMutation) CreatedAt() (r time.Time, exists bool) {
  36187. v := m.created_at
  36188. if v == nil {
  36189. return
  36190. }
  36191. return *v, true
  36192. }
  36193. // OldCreatedAt returns the old "created_at" field's value of the RedeemCode entity.
  36194. // If the RedeemCode object wasn't provided to the builder, the object is fetched from the database.
  36195. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36196. func (m *RedeemCodeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  36197. if !m.op.Is(OpUpdateOne) {
  36198. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  36199. }
  36200. if m.id == nil || m.oldValue == nil {
  36201. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  36202. }
  36203. oldValue, err := m.oldValue(ctx)
  36204. if err != nil {
  36205. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  36206. }
  36207. return oldValue.CreatedAt, nil
  36208. }
  36209. // ResetCreatedAt resets all changes to the "created_at" field.
  36210. func (m *RedeemCodeMutation) ResetCreatedAt() {
  36211. m.created_at = nil
  36212. }
  36213. // SetExpiresAt sets the "expires_at" field.
  36214. func (m *RedeemCodeMutation) SetExpiresAt(t time.Time) {
  36215. m.expires_at = &t
  36216. }
  36217. // ExpiresAt returns the value of the "expires_at" field in the mutation.
  36218. func (m *RedeemCodeMutation) ExpiresAt() (r time.Time, exists bool) {
  36219. v := m.expires_at
  36220. if v == nil {
  36221. return
  36222. }
  36223. return *v, true
  36224. }
  36225. // OldExpiresAt returns the old "expires_at" field's value of the RedeemCode entity.
  36226. // If the RedeemCode object wasn't provided to the builder, the object is fetched from the database.
  36227. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36228. func (m *RedeemCodeMutation) OldExpiresAt(ctx context.Context) (v *time.Time, err error) {
  36229. if !m.op.Is(OpUpdateOne) {
  36230. return v, errors.New("OldExpiresAt is only allowed on UpdateOne operations")
  36231. }
  36232. if m.id == nil || m.oldValue == nil {
  36233. return v, errors.New("OldExpiresAt requires an ID field in the mutation")
  36234. }
  36235. oldValue, err := m.oldValue(ctx)
  36236. if err != nil {
  36237. return v, fmt.Errorf("querying old value for OldExpiresAt: %w", err)
  36238. }
  36239. return oldValue.ExpiresAt, nil
  36240. }
  36241. // ClearExpiresAt clears the value of the "expires_at" field.
  36242. func (m *RedeemCodeMutation) ClearExpiresAt() {
  36243. m.expires_at = nil
  36244. m.clearedFields[redeemcode.FieldExpiresAt] = struct{}{}
  36245. }
  36246. // ExpiresAtCleared returns if the "expires_at" field was cleared in this mutation.
  36247. func (m *RedeemCodeMutation) ExpiresAtCleared() bool {
  36248. _, ok := m.clearedFields[redeemcode.FieldExpiresAt]
  36249. return ok
  36250. }
  36251. // ResetExpiresAt resets all changes to the "expires_at" field.
  36252. func (m *RedeemCodeMutation) ResetExpiresAt() {
  36253. m.expires_at = nil
  36254. delete(m.clearedFields, redeemcode.FieldExpiresAt)
  36255. }
  36256. // SetGroupID sets the "group_id" field.
  36257. func (m *RedeemCodeMutation) SetGroupID(i int64) {
  36258. m.group = &i
  36259. }
  36260. // GroupID returns the value of the "group_id" field in the mutation.
  36261. func (m *RedeemCodeMutation) GroupID() (r int64, exists bool) {
  36262. v := m.group
  36263. if v == nil {
  36264. return
  36265. }
  36266. return *v, true
  36267. }
  36268. // OldGroupID returns the old "group_id" field's value of the RedeemCode entity.
  36269. // If the RedeemCode object wasn't provided to the builder, the object is fetched from the database.
  36270. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36271. func (m *RedeemCodeMutation) OldGroupID(ctx context.Context) (v *int64, err error) {
  36272. if !m.op.Is(OpUpdateOne) {
  36273. return v, errors.New("OldGroupID is only allowed on UpdateOne operations")
  36274. }
  36275. if m.id == nil || m.oldValue == nil {
  36276. return v, errors.New("OldGroupID requires an ID field in the mutation")
  36277. }
  36278. oldValue, err := m.oldValue(ctx)
  36279. if err != nil {
  36280. return v, fmt.Errorf("querying old value for OldGroupID: %w", err)
  36281. }
  36282. return oldValue.GroupID, nil
  36283. }
  36284. // ClearGroupID clears the value of the "group_id" field.
  36285. func (m *RedeemCodeMutation) ClearGroupID() {
  36286. m.group = nil
  36287. m.clearedFields[redeemcode.FieldGroupID] = struct{}{}
  36288. }
  36289. // GroupIDCleared returns if the "group_id" field was cleared in this mutation.
  36290. func (m *RedeemCodeMutation) GroupIDCleared() bool {
  36291. _, ok := m.clearedFields[redeemcode.FieldGroupID]
  36292. return ok
  36293. }
  36294. // ResetGroupID resets all changes to the "group_id" field.
  36295. func (m *RedeemCodeMutation) ResetGroupID() {
  36296. m.group = nil
  36297. delete(m.clearedFields, redeemcode.FieldGroupID)
  36298. }
  36299. // SetValidityDays sets the "validity_days" field.
  36300. func (m *RedeemCodeMutation) SetValidityDays(i int) {
  36301. m.validity_days = &i
  36302. m.addvalidity_days = nil
  36303. }
  36304. // ValidityDays returns the value of the "validity_days" field in the mutation.
  36305. func (m *RedeemCodeMutation) ValidityDays() (r int, exists bool) {
  36306. v := m.validity_days
  36307. if v == nil {
  36308. return
  36309. }
  36310. return *v, true
  36311. }
  36312. // OldValidityDays returns the old "validity_days" field's value of the RedeemCode entity.
  36313. // If the RedeemCode object wasn't provided to the builder, the object is fetched from the database.
  36314. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36315. func (m *RedeemCodeMutation) OldValidityDays(ctx context.Context) (v int, err error) {
  36316. if !m.op.Is(OpUpdateOne) {
  36317. return v, errors.New("OldValidityDays is only allowed on UpdateOne operations")
  36318. }
  36319. if m.id == nil || m.oldValue == nil {
  36320. return v, errors.New("OldValidityDays requires an ID field in the mutation")
  36321. }
  36322. oldValue, err := m.oldValue(ctx)
  36323. if err != nil {
  36324. return v, fmt.Errorf("querying old value for OldValidityDays: %w", err)
  36325. }
  36326. return oldValue.ValidityDays, nil
  36327. }
  36328. // AddValidityDays adds i to the "validity_days" field.
  36329. func (m *RedeemCodeMutation) AddValidityDays(i int) {
  36330. if m.addvalidity_days != nil {
  36331. *m.addvalidity_days += i
  36332. } else {
  36333. m.addvalidity_days = &i
  36334. }
  36335. }
  36336. // AddedValidityDays returns the value that was added to the "validity_days" field in this mutation.
  36337. func (m *RedeemCodeMutation) AddedValidityDays() (r int, exists bool) {
  36338. v := m.addvalidity_days
  36339. if v == nil {
  36340. return
  36341. }
  36342. return *v, true
  36343. }
  36344. // ResetValidityDays resets all changes to the "validity_days" field.
  36345. func (m *RedeemCodeMutation) ResetValidityDays() {
  36346. m.validity_days = nil
  36347. m.addvalidity_days = nil
  36348. }
  36349. // SetUserID sets the "user" edge to the User entity by id.
  36350. func (m *RedeemCodeMutation) SetUserID(id int64) {
  36351. m.user = &id
  36352. }
  36353. // ClearUser clears the "user" edge to the User entity.
  36354. func (m *RedeemCodeMutation) ClearUser() {
  36355. m.cleareduser = true
  36356. m.clearedFields[redeemcode.FieldUsedBy] = struct{}{}
  36357. }
  36358. // UserCleared reports if the "user" edge to the User entity was cleared.
  36359. func (m *RedeemCodeMutation) UserCleared() bool {
  36360. return m.UsedByCleared() || m.cleareduser
  36361. }
  36362. // UserID returns the "user" edge ID in the mutation.
  36363. func (m *RedeemCodeMutation) UserID() (id int64, exists bool) {
  36364. if m.user != nil {
  36365. return *m.user, true
  36366. }
  36367. return
  36368. }
  36369. // UserIDs returns the "user" edge IDs in the mutation.
  36370. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  36371. // UserID instead. It exists only for internal usage by the builders.
  36372. func (m *RedeemCodeMutation) UserIDs() (ids []int64) {
  36373. if id := m.user; id != nil {
  36374. ids = append(ids, *id)
  36375. }
  36376. return
  36377. }
  36378. // ResetUser resets all changes to the "user" edge.
  36379. func (m *RedeemCodeMutation) ResetUser() {
  36380. m.user = nil
  36381. m.cleareduser = false
  36382. }
  36383. // ClearGroup clears the "group" edge to the Group entity.
  36384. func (m *RedeemCodeMutation) ClearGroup() {
  36385. m.clearedgroup = true
  36386. m.clearedFields[redeemcode.FieldGroupID] = struct{}{}
  36387. }
  36388. // GroupCleared reports if the "group" edge to the Group entity was cleared.
  36389. func (m *RedeemCodeMutation) GroupCleared() bool {
  36390. return m.GroupIDCleared() || m.clearedgroup
  36391. }
  36392. // GroupIDs returns the "group" edge IDs in the mutation.
  36393. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  36394. // GroupID instead. It exists only for internal usage by the builders.
  36395. func (m *RedeemCodeMutation) GroupIDs() (ids []int64) {
  36396. if id := m.group; id != nil {
  36397. ids = append(ids, *id)
  36398. }
  36399. return
  36400. }
  36401. // ResetGroup resets all changes to the "group" edge.
  36402. func (m *RedeemCodeMutation) ResetGroup() {
  36403. m.group = nil
  36404. m.clearedgroup = false
  36405. }
  36406. // Where appends a list predicates to the RedeemCodeMutation builder.
  36407. func (m *RedeemCodeMutation) Where(ps ...predicate.RedeemCode) {
  36408. m.predicates = append(m.predicates, ps...)
  36409. }
  36410. // WhereP appends storage-level predicates to the RedeemCodeMutation builder. Using this method,
  36411. // users can use type-assertion to append predicates that do not depend on any generated package.
  36412. func (m *RedeemCodeMutation) WhereP(ps ...func(*sql.Selector)) {
  36413. p := make([]predicate.RedeemCode, len(ps))
  36414. for i := range ps {
  36415. p[i] = ps[i]
  36416. }
  36417. m.Where(p...)
  36418. }
  36419. // Op returns the operation name.
  36420. func (m *RedeemCodeMutation) Op() Op {
  36421. return m.op
  36422. }
  36423. // SetOp allows setting the mutation operation.
  36424. func (m *RedeemCodeMutation) SetOp(op Op) {
  36425. m.op = op
  36426. }
  36427. // Type returns the node type of this mutation (RedeemCode).
  36428. func (m *RedeemCodeMutation) Type() string {
  36429. return m.typ
  36430. }
  36431. // Fields returns all fields that were changed during this mutation. Note that in
  36432. // order to get all numeric fields that were incremented/decremented, call
  36433. // AddedFields().
  36434. func (m *RedeemCodeMutation) Fields() []string {
  36435. fields := make([]string, 0, 11)
  36436. if m.code != nil {
  36437. fields = append(fields, redeemcode.FieldCode)
  36438. }
  36439. if m._type != nil {
  36440. fields = append(fields, redeemcode.FieldType)
  36441. }
  36442. if m.value != nil {
  36443. fields = append(fields, redeemcode.FieldValue)
  36444. }
  36445. if m.status != nil {
  36446. fields = append(fields, redeemcode.FieldStatus)
  36447. }
  36448. if m.user != nil {
  36449. fields = append(fields, redeemcode.FieldUsedBy)
  36450. }
  36451. if m.used_at != nil {
  36452. fields = append(fields, redeemcode.FieldUsedAt)
  36453. }
  36454. if m.notes != nil {
  36455. fields = append(fields, redeemcode.FieldNotes)
  36456. }
  36457. if m.created_at != nil {
  36458. fields = append(fields, redeemcode.FieldCreatedAt)
  36459. }
  36460. if m.expires_at != nil {
  36461. fields = append(fields, redeemcode.FieldExpiresAt)
  36462. }
  36463. if m.group != nil {
  36464. fields = append(fields, redeemcode.FieldGroupID)
  36465. }
  36466. if m.validity_days != nil {
  36467. fields = append(fields, redeemcode.FieldValidityDays)
  36468. }
  36469. return fields
  36470. }
  36471. // Field returns the value of a field with the given name. The second boolean
  36472. // return value indicates that this field was not set, or was not defined in the
  36473. // schema.
  36474. func (m *RedeemCodeMutation) Field(name string) (ent.Value, bool) {
  36475. switch name {
  36476. case redeemcode.FieldCode:
  36477. return m.Code()
  36478. case redeemcode.FieldType:
  36479. return m.GetType()
  36480. case redeemcode.FieldValue:
  36481. return m.Value()
  36482. case redeemcode.FieldStatus:
  36483. return m.Status()
  36484. case redeemcode.FieldUsedBy:
  36485. return m.UsedBy()
  36486. case redeemcode.FieldUsedAt:
  36487. return m.UsedAt()
  36488. case redeemcode.FieldNotes:
  36489. return m.Notes()
  36490. case redeemcode.FieldCreatedAt:
  36491. return m.CreatedAt()
  36492. case redeemcode.FieldExpiresAt:
  36493. return m.ExpiresAt()
  36494. case redeemcode.FieldGroupID:
  36495. return m.GroupID()
  36496. case redeemcode.FieldValidityDays:
  36497. return m.ValidityDays()
  36498. }
  36499. return nil, false
  36500. }
  36501. // OldField returns the old value of the field from the database. An error is
  36502. // returned if the mutation operation is not UpdateOne, or the query to the
  36503. // database failed.
  36504. func (m *RedeemCodeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  36505. switch name {
  36506. case redeemcode.FieldCode:
  36507. return m.OldCode(ctx)
  36508. case redeemcode.FieldType:
  36509. return m.OldType(ctx)
  36510. case redeemcode.FieldValue:
  36511. return m.OldValue(ctx)
  36512. case redeemcode.FieldStatus:
  36513. return m.OldStatus(ctx)
  36514. case redeemcode.FieldUsedBy:
  36515. return m.OldUsedBy(ctx)
  36516. case redeemcode.FieldUsedAt:
  36517. return m.OldUsedAt(ctx)
  36518. case redeemcode.FieldNotes:
  36519. return m.OldNotes(ctx)
  36520. case redeemcode.FieldCreatedAt:
  36521. return m.OldCreatedAt(ctx)
  36522. case redeemcode.FieldExpiresAt:
  36523. return m.OldExpiresAt(ctx)
  36524. case redeemcode.FieldGroupID:
  36525. return m.OldGroupID(ctx)
  36526. case redeemcode.FieldValidityDays:
  36527. return m.OldValidityDays(ctx)
  36528. }
  36529. return nil, fmt.Errorf("unknown RedeemCode field %s", name)
  36530. }
  36531. // SetField sets the value of a field with the given name. It returns an error if
  36532. // the field is not defined in the schema, or if the type mismatched the field
  36533. // type.
  36534. func (m *RedeemCodeMutation) SetField(name string, value ent.Value) error {
  36535. switch name {
  36536. case redeemcode.FieldCode:
  36537. v, ok := value.(string)
  36538. if !ok {
  36539. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36540. }
  36541. m.SetCode(v)
  36542. return nil
  36543. case redeemcode.FieldType:
  36544. v, ok := value.(string)
  36545. if !ok {
  36546. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36547. }
  36548. m.SetType(v)
  36549. return nil
  36550. case redeemcode.FieldValue:
  36551. v, ok := value.(float64)
  36552. if !ok {
  36553. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36554. }
  36555. m.SetValue(v)
  36556. return nil
  36557. case redeemcode.FieldStatus:
  36558. v, ok := value.(string)
  36559. if !ok {
  36560. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36561. }
  36562. m.SetStatus(v)
  36563. return nil
  36564. case redeemcode.FieldUsedBy:
  36565. v, ok := value.(int64)
  36566. if !ok {
  36567. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36568. }
  36569. m.SetUsedBy(v)
  36570. return nil
  36571. case redeemcode.FieldUsedAt:
  36572. v, ok := value.(time.Time)
  36573. if !ok {
  36574. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36575. }
  36576. m.SetUsedAt(v)
  36577. return nil
  36578. case redeemcode.FieldNotes:
  36579. v, ok := value.(string)
  36580. if !ok {
  36581. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36582. }
  36583. m.SetNotes(v)
  36584. return nil
  36585. case redeemcode.FieldCreatedAt:
  36586. v, ok := value.(time.Time)
  36587. if !ok {
  36588. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36589. }
  36590. m.SetCreatedAt(v)
  36591. return nil
  36592. case redeemcode.FieldExpiresAt:
  36593. v, ok := value.(time.Time)
  36594. if !ok {
  36595. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36596. }
  36597. m.SetExpiresAt(v)
  36598. return nil
  36599. case redeemcode.FieldGroupID:
  36600. v, ok := value.(int64)
  36601. if !ok {
  36602. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36603. }
  36604. m.SetGroupID(v)
  36605. return nil
  36606. case redeemcode.FieldValidityDays:
  36607. v, ok := value.(int)
  36608. if !ok {
  36609. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36610. }
  36611. m.SetValidityDays(v)
  36612. return nil
  36613. }
  36614. return fmt.Errorf("unknown RedeemCode field %s", name)
  36615. }
  36616. // AddedFields returns all numeric fields that were incremented/decremented during
  36617. // this mutation.
  36618. func (m *RedeemCodeMutation) AddedFields() []string {
  36619. var fields []string
  36620. if m.addvalue != nil {
  36621. fields = append(fields, redeemcode.FieldValue)
  36622. }
  36623. if m.addvalidity_days != nil {
  36624. fields = append(fields, redeemcode.FieldValidityDays)
  36625. }
  36626. return fields
  36627. }
  36628. // AddedField returns the numeric value that was incremented/decremented on a field
  36629. // with the given name. The second boolean return value indicates that this field
  36630. // was not set, or was not defined in the schema.
  36631. func (m *RedeemCodeMutation) AddedField(name string) (ent.Value, bool) {
  36632. switch name {
  36633. case redeemcode.FieldValue:
  36634. return m.AddedValue()
  36635. case redeemcode.FieldValidityDays:
  36636. return m.AddedValidityDays()
  36637. }
  36638. return nil, false
  36639. }
  36640. // AddField adds the value to the field with the given name. It returns an error if
  36641. // the field is not defined in the schema, or if the type mismatched the field
  36642. // type.
  36643. func (m *RedeemCodeMutation) AddField(name string, value ent.Value) error {
  36644. switch name {
  36645. case redeemcode.FieldValue:
  36646. v, ok := value.(float64)
  36647. if !ok {
  36648. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36649. }
  36650. m.AddValue(v)
  36651. return nil
  36652. case redeemcode.FieldValidityDays:
  36653. v, ok := value.(int)
  36654. if !ok {
  36655. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36656. }
  36657. m.AddValidityDays(v)
  36658. return nil
  36659. }
  36660. return fmt.Errorf("unknown RedeemCode numeric field %s", name)
  36661. }
  36662. // ClearedFields returns all nullable fields that were cleared during this
  36663. // mutation.
  36664. func (m *RedeemCodeMutation) ClearedFields() []string {
  36665. var fields []string
  36666. if m.FieldCleared(redeemcode.FieldUsedBy) {
  36667. fields = append(fields, redeemcode.FieldUsedBy)
  36668. }
  36669. if m.FieldCleared(redeemcode.FieldUsedAt) {
  36670. fields = append(fields, redeemcode.FieldUsedAt)
  36671. }
  36672. if m.FieldCleared(redeemcode.FieldNotes) {
  36673. fields = append(fields, redeemcode.FieldNotes)
  36674. }
  36675. if m.FieldCleared(redeemcode.FieldExpiresAt) {
  36676. fields = append(fields, redeemcode.FieldExpiresAt)
  36677. }
  36678. if m.FieldCleared(redeemcode.FieldGroupID) {
  36679. fields = append(fields, redeemcode.FieldGroupID)
  36680. }
  36681. return fields
  36682. }
  36683. // FieldCleared returns a boolean indicating if a field with the given name was
  36684. // cleared in this mutation.
  36685. func (m *RedeemCodeMutation) FieldCleared(name string) bool {
  36686. _, ok := m.clearedFields[name]
  36687. return ok
  36688. }
  36689. // ClearField clears the value of the field with the given name. It returns an
  36690. // error if the field is not defined in the schema.
  36691. func (m *RedeemCodeMutation) ClearField(name string) error {
  36692. switch name {
  36693. case redeemcode.FieldUsedBy:
  36694. m.ClearUsedBy()
  36695. return nil
  36696. case redeemcode.FieldUsedAt:
  36697. m.ClearUsedAt()
  36698. return nil
  36699. case redeemcode.FieldNotes:
  36700. m.ClearNotes()
  36701. return nil
  36702. case redeemcode.FieldExpiresAt:
  36703. m.ClearExpiresAt()
  36704. return nil
  36705. case redeemcode.FieldGroupID:
  36706. m.ClearGroupID()
  36707. return nil
  36708. }
  36709. return fmt.Errorf("unknown RedeemCode nullable field %s", name)
  36710. }
  36711. // ResetField resets all changes in the mutation for the field with the given name.
  36712. // It returns an error if the field is not defined in the schema.
  36713. func (m *RedeemCodeMutation) ResetField(name string) error {
  36714. switch name {
  36715. case redeemcode.FieldCode:
  36716. m.ResetCode()
  36717. return nil
  36718. case redeemcode.FieldType:
  36719. m.ResetType()
  36720. return nil
  36721. case redeemcode.FieldValue:
  36722. m.ResetValue()
  36723. return nil
  36724. case redeemcode.FieldStatus:
  36725. m.ResetStatus()
  36726. return nil
  36727. case redeemcode.FieldUsedBy:
  36728. m.ResetUsedBy()
  36729. return nil
  36730. case redeemcode.FieldUsedAt:
  36731. m.ResetUsedAt()
  36732. return nil
  36733. case redeemcode.FieldNotes:
  36734. m.ResetNotes()
  36735. return nil
  36736. case redeemcode.FieldCreatedAt:
  36737. m.ResetCreatedAt()
  36738. return nil
  36739. case redeemcode.FieldExpiresAt:
  36740. m.ResetExpiresAt()
  36741. return nil
  36742. case redeemcode.FieldGroupID:
  36743. m.ResetGroupID()
  36744. return nil
  36745. case redeemcode.FieldValidityDays:
  36746. m.ResetValidityDays()
  36747. return nil
  36748. }
  36749. return fmt.Errorf("unknown RedeemCode field %s", name)
  36750. }
  36751. // AddedEdges returns all edge names that were set/added in this mutation.
  36752. func (m *RedeemCodeMutation) AddedEdges() []string {
  36753. edges := make([]string, 0, 2)
  36754. if m.user != nil {
  36755. edges = append(edges, redeemcode.EdgeUser)
  36756. }
  36757. if m.group != nil {
  36758. edges = append(edges, redeemcode.EdgeGroup)
  36759. }
  36760. return edges
  36761. }
  36762. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  36763. // name in this mutation.
  36764. func (m *RedeemCodeMutation) AddedIDs(name string) []ent.Value {
  36765. switch name {
  36766. case redeemcode.EdgeUser:
  36767. if id := m.user; id != nil {
  36768. return []ent.Value{*id}
  36769. }
  36770. case redeemcode.EdgeGroup:
  36771. if id := m.group; id != nil {
  36772. return []ent.Value{*id}
  36773. }
  36774. }
  36775. return nil
  36776. }
  36777. // RemovedEdges returns all edge names that were removed in this mutation.
  36778. func (m *RedeemCodeMutation) RemovedEdges() []string {
  36779. edges := make([]string, 0, 2)
  36780. return edges
  36781. }
  36782. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  36783. // the given name in this mutation.
  36784. func (m *RedeemCodeMutation) RemovedIDs(name string) []ent.Value {
  36785. return nil
  36786. }
  36787. // ClearedEdges returns all edge names that were cleared in this mutation.
  36788. func (m *RedeemCodeMutation) ClearedEdges() []string {
  36789. edges := make([]string, 0, 2)
  36790. if m.cleareduser {
  36791. edges = append(edges, redeemcode.EdgeUser)
  36792. }
  36793. if m.clearedgroup {
  36794. edges = append(edges, redeemcode.EdgeGroup)
  36795. }
  36796. return edges
  36797. }
  36798. // EdgeCleared returns a boolean which indicates if the edge with the given name
  36799. // was cleared in this mutation.
  36800. func (m *RedeemCodeMutation) EdgeCleared(name string) bool {
  36801. switch name {
  36802. case redeemcode.EdgeUser:
  36803. return m.cleareduser
  36804. case redeemcode.EdgeGroup:
  36805. return m.clearedgroup
  36806. }
  36807. return false
  36808. }
  36809. // ClearEdge clears the value of the edge with the given name. It returns an error
  36810. // if that edge is not defined in the schema.
  36811. func (m *RedeemCodeMutation) ClearEdge(name string) error {
  36812. switch name {
  36813. case redeemcode.EdgeUser:
  36814. m.ClearUser()
  36815. return nil
  36816. case redeemcode.EdgeGroup:
  36817. m.ClearGroup()
  36818. return nil
  36819. }
  36820. return fmt.Errorf("unknown RedeemCode unique edge %s", name)
  36821. }
  36822. // ResetEdge resets all changes to the edge with the given name in this mutation.
  36823. // It returns an error if the edge is not defined in the schema.
  36824. func (m *RedeemCodeMutation) ResetEdge(name string) error {
  36825. switch name {
  36826. case redeemcode.EdgeUser:
  36827. m.ResetUser()
  36828. return nil
  36829. case redeemcode.EdgeGroup:
  36830. m.ResetGroup()
  36831. return nil
  36832. }
  36833. return fmt.Errorf("unknown RedeemCode edge %s", name)
  36834. }
  36835. // SecurityPolicyKeywordMutation represents an operation that mutates the SecurityPolicyKeyword nodes in the graph.
  36836. type SecurityPolicyKeywordMutation struct {
  36837. config
  36838. op Op
  36839. typ string
  36840. id *int64
  36841. created_at *time.Time
  36842. updated_at *time.Time
  36843. deleted_at *time.Time
  36844. keyword *string
  36845. category *string
  36846. enabled *bool
  36847. clearedFields map[string]struct{}
  36848. group *int64
  36849. clearedgroup bool
  36850. done bool
  36851. oldValue func(context.Context) (*SecurityPolicyKeyword, error)
  36852. predicates []predicate.SecurityPolicyKeyword
  36853. }
  36854. var _ ent.Mutation = (*SecurityPolicyKeywordMutation)(nil)
  36855. // securitypolicykeywordOption allows management of the mutation configuration using functional options.
  36856. type securitypolicykeywordOption func(*SecurityPolicyKeywordMutation)
  36857. // newSecurityPolicyKeywordMutation creates new mutation for the SecurityPolicyKeyword entity.
  36858. func newSecurityPolicyKeywordMutation(c config, op Op, opts ...securitypolicykeywordOption) *SecurityPolicyKeywordMutation {
  36859. m := &SecurityPolicyKeywordMutation{
  36860. config: c,
  36861. op: op,
  36862. typ: TypeSecurityPolicyKeyword,
  36863. clearedFields: make(map[string]struct{}),
  36864. }
  36865. for _, opt := range opts {
  36866. opt(m)
  36867. }
  36868. return m
  36869. }
  36870. // withSecurityPolicyKeywordID sets the ID field of the mutation.
  36871. func withSecurityPolicyKeywordID(id int64) securitypolicykeywordOption {
  36872. return func(m *SecurityPolicyKeywordMutation) {
  36873. var (
  36874. err error
  36875. once sync.Once
  36876. value *SecurityPolicyKeyword
  36877. )
  36878. m.oldValue = func(ctx context.Context) (*SecurityPolicyKeyword, error) {
  36879. once.Do(func() {
  36880. if m.done {
  36881. err = errors.New("querying old values post mutation is not allowed")
  36882. } else {
  36883. value, err = m.Client().SecurityPolicyKeyword.Get(ctx, id)
  36884. }
  36885. })
  36886. return value, err
  36887. }
  36888. m.id = &id
  36889. }
  36890. }
  36891. // withSecurityPolicyKeyword sets the old SecurityPolicyKeyword of the mutation.
  36892. func withSecurityPolicyKeyword(node *SecurityPolicyKeyword) securitypolicykeywordOption {
  36893. return func(m *SecurityPolicyKeywordMutation) {
  36894. m.oldValue = func(context.Context) (*SecurityPolicyKeyword, error) {
  36895. return node, nil
  36896. }
  36897. m.id = &node.ID
  36898. }
  36899. }
  36900. // Client returns a new `ent.Client` from the mutation. If the mutation was
  36901. // executed in a transaction (ent.Tx), a transactional client is returned.
  36902. func (m SecurityPolicyKeywordMutation) Client() *Client {
  36903. client := &Client{config: m.config}
  36904. client.init()
  36905. return client
  36906. }
  36907. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  36908. // it returns an error otherwise.
  36909. func (m SecurityPolicyKeywordMutation) Tx() (*Tx, error) {
  36910. if _, ok := m.driver.(*txDriver); !ok {
  36911. return nil, errors.New("ent: mutation is not running in a transaction")
  36912. }
  36913. tx := &Tx{config: m.config}
  36914. tx.init()
  36915. return tx, nil
  36916. }
  36917. // ID returns the ID value in the mutation. Note that the ID is only available
  36918. // if it was provided to the builder or after it was returned from the database.
  36919. func (m *SecurityPolicyKeywordMutation) ID() (id int64, exists bool) {
  36920. if m.id == nil {
  36921. return
  36922. }
  36923. return *m.id, true
  36924. }
  36925. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  36926. // That means, if the mutation is applied within a transaction with an isolation level such
  36927. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  36928. // or updated by the mutation.
  36929. func (m *SecurityPolicyKeywordMutation) IDs(ctx context.Context) ([]int64, error) {
  36930. switch {
  36931. case m.op.Is(OpUpdateOne | OpDeleteOne):
  36932. id, exists := m.ID()
  36933. if exists {
  36934. return []int64{id}, nil
  36935. }
  36936. fallthrough
  36937. case m.op.Is(OpUpdate | OpDelete):
  36938. return m.Client().SecurityPolicyKeyword.Query().Where(m.predicates...).IDs(ctx)
  36939. default:
  36940. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  36941. }
  36942. }
  36943. // SetCreatedAt sets the "created_at" field.
  36944. func (m *SecurityPolicyKeywordMutation) SetCreatedAt(t time.Time) {
  36945. m.created_at = &t
  36946. }
  36947. // CreatedAt returns the value of the "created_at" field in the mutation.
  36948. func (m *SecurityPolicyKeywordMutation) CreatedAt() (r time.Time, exists bool) {
  36949. v := m.created_at
  36950. if v == nil {
  36951. return
  36952. }
  36953. return *v, true
  36954. }
  36955. // OldCreatedAt returns the old "created_at" field's value of the SecurityPolicyKeyword entity.
  36956. // If the SecurityPolicyKeyword object wasn't provided to the builder, the object is fetched from the database.
  36957. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36958. func (m *SecurityPolicyKeywordMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  36959. if !m.op.Is(OpUpdateOne) {
  36960. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  36961. }
  36962. if m.id == nil || m.oldValue == nil {
  36963. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  36964. }
  36965. oldValue, err := m.oldValue(ctx)
  36966. if err != nil {
  36967. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  36968. }
  36969. return oldValue.CreatedAt, nil
  36970. }
  36971. // ResetCreatedAt resets all changes to the "created_at" field.
  36972. func (m *SecurityPolicyKeywordMutation) ResetCreatedAt() {
  36973. m.created_at = nil
  36974. }
  36975. // SetUpdatedAt sets the "updated_at" field.
  36976. func (m *SecurityPolicyKeywordMutation) SetUpdatedAt(t time.Time) {
  36977. m.updated_at = &t
  36978. }
  36979. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  36980. func (m *SecurityPolicyKeywordMutation) UpdatedAt() (r time.Time, exists bool) {
  36981. v := m.updated_at
  36982. if v == nil {
  36983. return
  36984. }
  36985. return *v, true
  36986. }
  36987. // OldUpdatedAt returns the old "updated_at" field's value of the SecurityPolicyKeyword entity.
  36988. // If the SecurityPolicyKeyword object wasn't provided to the builder, the object is fetched from the database.
  36989. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36990. func (m *SecurityPolicyKeywordMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  36991. if !m.op.Is(OpUpdateOne) {
  36992. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  36993. }
  36994. if m.id == nil || m.oldValue == nil {
  36995. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  36996. }
  36997. oldValue, err := m.oldValue(ctx)
  36998. if err != nil {
  36999. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  37000. }
  37001. return oldValue.UpdatedAt, nil
  37002. }
  37003. // ResetUpdatedAt resets all changes to the "updated_at" field.
  37004. func (m *SecurityPolicyKeywordMutation) ResetUpdatedAt() {
  37005. m.updated_at = nil
  37006. }
  37007. // SetDeletedAt sets the "deleted_at" field.
  37008. func (m *SecurityPolicyKeywordMutation) SetDeletedAt(t time.Time) {
  37009. m.deleted_at = &t
  37010. }
  37011. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  37012. func (m *SecurityPolicyKeywordMutation) DeletedAt() (r time.Time, exists bool) {
  37013. v := m.deleted_at
  37014. if v == nil {
  37015. return
  37016. }
  37017. return *v, true
  37018. }
  37019. // OldDeletedAt returns the old "deleted_at" field's value of the SecurityPolicyKeyword entity.
  37020. // If the SecurityPolicyKeyword object wasn't provided to the builder, the object is fetched from the database.
  37021. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37022. func (m *SecurityPolicyKeywordMutation) OldDeletedAt(ctx context.Context) (v *time.Time, err error) {
  37023. if !m.op.Is(OpUpdateOne) {
  37024. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  37025. }
  37026. if m.id == nil || m.oldValue == nil {
  37027. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  37028. }
  37029. oldValue, err := m.oldValue(ctx)
  37030. if err != nil {
  37031. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  37032. }
  37033. return oldValue.DeletedAt, nil
  37034. }
  37035. // ClearDeletedAt clears the value of the "deleted_at" field.
  37036. func (m *SecurityPolicyKeywordMutation) ClearDeletedAt() {
  37037. m.deleted_at = nil
  37038. m.clearedFields[securitypolicykeyword.FieldDeletedAt] = struct{}{}
  37039. }
  37040. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  37041. func (m *SecurityPolicyKeywordMutation) DeletedAtCleared() bool {
  37042. _, ok := m.clearedFields[securitypolicykeyword.FieldDeletedAt]
  37043. return ok
  37044. }
  37045. // ResetDeletedAt resets all changes to the "deleted_at" field.
  37046. func (m *SecurityPolicyKeywordMutation) ResetDeletedAt() {
  37047. m.deleted_at = nil
  37048. delete(m.clearedFields, securitypolicykeyword.FieldDeletedAt)
  37049. }
  37050. // SetGroupID sets the "group_id" field.
  37051. func (m *SecurityPolicyKeywordMutation) SetGroupID(i int64) {
  37052. m.group = &i
  37053. }
  37054. // GroupID returns the value of the "group_id" field in the mutation.
  37055. func (m *SecurityPolicyKeywordMutation) GroupID() (r int64, exists bool) {
  37056. v := m.group
  37057. if v == nil {
  37058. return
  37059. }
  37060. return *v, true
  37061. }
  37062. // OldGroupID returns the old "group_id" field's value of the SecurityPolicyKeyword entity.
  37063. // If the SecurityPolicyKeyword object wasn't provided to the builder, the object is fetched from the database.
  37064. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37065. func (m *SecurityPolicyKeywordMutation) OldGroupID(ctx context.Context) (v *int64, err error) {
  37066. if !m.op.Is(OpUpdateOne) {
  37067. return v, errors.New("OldGroupID is only allowed on UpdateOne operations")
  37068. }
  37069. if m.id == nil || m.oldValue == nil {
  37070. return v, errors.New("OldGroupID requires an ID field in the mutation")
  37071. }
  37072. oldValue, err := m.oldValue(ctx)
  37073. if err != nil {
  37074. return v, fmt.Errorf("querying old value for OldGroupID: %w", err)
  37075. }
  37076. return oldValue.GroupID, nil
  37077. }
  37078. // ClearGroupID clears the value of the "group_id" field.
  37079. func (m *SecurityPolicyKeywordMutation) ClearGroupID() {
  37080. m.group = nil
  37081. m.clearedFields[securitypolicykeyword.FieldGroupID] = struct{}{}
  37082. }
  37083. // GroupIDCleared returns if the "group_id" field was cleared in this mutation.
  37084. func (m *SecurityPolicyKeywordMutation) GroupIDCleared() bool {
  37085. _, ok := m.clearedFields[securitypolicykeyword.FieldGroupID]
  37086. return ok
  37087. }
  37088. // ResetGroupID resets all changes to the "group_id" field.
  37089. func (m *SecurityPolicyKeywordMutation) ResetGroupID() {
  37090. m.group = nil
  37091. delete(m.clearedFields, securitypolicykeyword.FieldGroupID)
  37092. }
  37093. // SetKeyword sets the "keyword" field.
  37094. func (m *SecurityPolicyKeywordMutation) SetKeyword(s string) {
  37095. m.keyword = &s
  37096. }
  37097. // Keyword returns the value of the "keyword" field in the mutation.
  37098. func (m *SecurityPolicyKeywordMutation) Keyword() (r string, exists bool) {
  37099. v := m.keyword
  37100. if v == nil {
  37101. return
  37102. }
  37103. return *v, true
  37104. }
  37105. // OldKeyword returns the old "keyword" field's value of the SecurityPolicyKeyword entity.
  37106. // If the SecurityPolicyKeyword object wasn't provided to the builder, the object is fetched from the database.
  37107. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37108. func (m *SecurityPolicyKeywordMutation) OldKeyword(ctx context.Context) (v string, err error) {
  37109. if !m.op.Is(OpUpdateOne) {
  37110. return v, errors.New("OldKeyword is only allowed on UpdateOne operations")
  37111. }
  37112. if m.id == nil || m.oldValue == nil {
  37113. return v, errors.New("OldKeyword requires an ID field in the mutation")
  37114. }
  37115. oldValue, err := m.oldValue(ctx)
  37116. if err != nil {
  37117. return v, fmt.Errorf("querying old value for OldKeyword: %w", err)
  37118. }
  37119. return oldValue.Keyword, nil
  37120. }
  37121. // ResetKeyword resets all changes to the "keyword" field.
  37122. func (m *SecurityPolicyKeywordMutation) ResetKeyword() {
  37123. m.keyword = nil
  37124. }
  37125. // SetCategory sets the "category" field.
  37126. func (m *SecurityPolicyKeywordMutation) SetCategory(s string) {
  37127. m.category = &s
  37128. }
  37129. // Category returns the value of the "category" field in the mutation.
  37130. func (m *SecurityPolicyKeywordMutation) Category() (r string, exists bool) {
  37131. v := m.category
  37132. if v == nil {
  37133. return
  37134. }
  37135. return *v, true
  37136. }
  37137. // OldCategory returns the old "category" field's value of the SecurityPolicyKeyword entity.
  37138. // If the SecurityPolicyKeyword object wasn't provided to the builder, the object is fetched from the database.
  37139. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37140. func (m *SecurityPolicyKeywordMutation) OldCategory(ctx context.Context) (v string, err error) {
  37141. if !m.op.Is(OpUpdateOne) {
  37142. return v, errors.New("OldCategory is only allowed on UpdateOne operations")
  37143. }
  37144. if m.id == nil || m.oldValue == nil {
  37145. return v, errors.New("OldCategory requires an ID field in the mutation")
  37146. }
  37147. oldValue, err := m.oldValue(ctx)
  37148. if err != nil {
  37149. return v, fmt.Errorf("querying old value for OldCategory: %w", err)
  37150. }
  37151. return oldValue.Category, nil
  37152. }
  37153. // ResetCategory resets all changes to the "category" field.
  37154. func (m *SecurityPolicyKeywordMutation) ResetCategory() {
  37155. m.category = nil
  37156. }
  37157. // SetEnabled sets the "enabled" field.
  37158. func (m *SecurityPolicyKeywordMutation) SetEnabled(b bool) {
  37159. m.enabled = &b
  37160. }
  37161. // Enabled returns the value of the "enabled" field in the mutation.
  37162. func (m *SecurityPolicyKeywordMutation) Enabled() (r bool, exists bool) {
  37163. v := m.enabled
  37164. if v == nil {
  37165. return
  37166. }
  37167. return *v, true
  37168. }
  37169. // OldEnabled returns the old "enabled" field's value of the SecurityPolicyKeyword entity.
  37170. // If the SecurityPolicyKeyword object wasn't provided to the builder, the object is fetched from the database.
  37171. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37172. func (m *SecurityPolicyKeywordMutation) OldEnabled(ctx context.Context) (v bool, err error) {
  37173. if !m.op.Is(OpUpdateOne) {
  37174. return v, errors.New("OldEnabled is only allowed on UpdateOne operations")
  37175. }
  37176. if m.id == nil || m.oldValue == nil {
  37177. return v, errors.New("OldEnabled requires an ID field in the mutation")
  37178. }
  37179. oldValue, err := m.oldValue(ctx)
  37180. if err != nil {
  37181. return v, fmt.Errorf("querying old value for OldEnabled: %w", err)
  37182. }
  37183. return oldValue.Enabled, nil
  37184. }
  37185. // ResetEnabled resets all changes to the "enabled" field.
  37186. func (m *SecurityPolicyKeywordMutation) ResetEnabled() {
  37187. m.enabled = nil
  37188. }
  37189. // ClearGroup clears the "group" edge to the Group entity.
  37190. func (m *SecurityPolicyKeywordMutation) ClearGroup() {
  37191. m.clearedgroup = true
  37192. m.clearedFields[securitypolicykeyword.FieldGroupID] = struct{}{}
  37193. }
  37194. // GroupCleared reports if the "group" edge to the Group entity was cleared.
  37195. func (m *SecurityPolicyKeywordMutation) GroupCleared() bool {
  37196. return m.GroupIDCleared() || m.clearedgroup
  37197. }
  37198. // GroupIDs returns the "group" edge IDs in the mutation.
  37199. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  37200. // GroupID instead. It exists only for internal usage by the builders.
  37201. func (m *SecurityPolicyKeywordMutation) GroupIDs() (ids []int64) {
  37202. if id := m.group; id != nil {
  37203. ids = append(ids, *id)
  37204. }
  37205. return
  37206. }
  37207. // ResetGroup resets all changes to the "group" edge.
  37208. func (m *SecurityPolicyKeywordMutation) ResetGroup() {
  37209. m.group = nil
  37210. m.clearedgroup = false
  37211. }
  37212. // Where appends a list predicates to the SecurityPolicyKeywordMutation builder.
  37213. func (m *SecurityPolicyKeywordMutation) Where(ps ...predicate.SecurityPolicyKeyword) {
  37214. m.predicates = append(m.predicates, ps...)
  37215. }
  37216. // WhereP appends storage-level predicates to the SecurityPolicyKeywordMutation builder. Using this method,
  37217. // users can use type-assertion to append predicates that do not depend on any generated package.
  37218. func (m *SecurityPolicyKeywordMutation) WhereP(ps ...func(*sql.Selector)) {
  37219. p := make([]predicate.SecurityPolicyKeyword, len(ps))
  37220. for i := range ps {
  37221. p[i] = ps[i]
  37222. }
  37223. m.Where(p...)
  37224. }
  37225. // Op returns the operation name.
  37226. func (m *SecurityPolicyKeywordMutation) Op() Op {
  37227. return m.op
  37228. }
  37229. // SetOp allows setting the mutation operation.
  37230. func (m *SecurityPolicyKeywordMutation) SetOp(op Op) {
  37231. m.op = op
  37232. }
  37233. // Type returns the node type of this mutation (SecurityPolicyKeyword).
  37234. func (m *SecurityPolicyKeywordMutation) Type() string {
  37235. return m.typ
  37236. }
  37237. // Fields returns all fields that were changed during this mutation. Note that in
  37238. // order to get all numeric fields that were incremented/decremented, call
  37239. // AddedFields().
  37240. func (m *SecurityPolicyKeywordMutation) Fields() []string {
  37241. fields := make([]string, 0, 7)
  37242. if m.created_at != nil {
  37243. fields = append(fields, securitypolicykeyword.FieldCreatedAt)
  37244. }
  37245. if m.updated_at != nil {
  37246. fields = append(fields, securitypolicykeyword.FieldUpdatedAt)
  37247. }
  37248. if m.deleted_at != nil {
  37249. fields = append(fields, securitypolicykeyword.FieldDeletedAt)
  37250. }
  37251. if m.group != nil {
  37252. fields = append(fields, securitypolicykeyword.FieldGroupID)
  37253. }
  37254. if m.keyword != nil {
  37255. fields = append(fields, securitypolicykeyword.FieldKeyword)
  37256. }
  37257. if m.category != nil {
  37258. fields = append(fields, securitypolicykeyword.FieldCategory)
  37259. }
  37260. if m.enabled != nil {
  37261. fields = append(fields, securitypolicykeyword.FieldEnabled)
  37262. }
  37263. return fields
  37264. }
  37265. // Field returns the value of a field with the given name. The second boolean
  37266. // return value indicates that this field was not set, or was not defined in the
  37267. // schema.
  37268. func (m *SecurityPolicyKeywordMutation) Field(name string) (ent.Value, bool) {
  37269. switch name {
  37270. case securitypolicykeyword.FieldCreatedAt:
  37271. return m.CreatedAt()
  37272. case securitypolicykeyword.FieldUpdatedAt:
  37273. return m.UpdatedAt()
  37274. case securitypolicykeyword.FieldDeletedAt:
  37275. return m.DeletedAt()
  37276. case securitypolicykeyword.FieldGroupID:
  37277. return m.GroupID()
  37278. case securitypolicykeyword.FieldKeyword:
  37279. return m.Keyword()
  37280. case securitypolicykeyword.FieldCategory:
  37281. return m.Category()
  37282. case securitypolicykeyword.FieldEnabled:
  37283. return m.Enabled()
  37284. }
  37285. return nil, false
  37286. }
  37287. // OldField returns the old value of the field from the database. An error is
  37288. // returned if the mutation operation is not UpdateOne, or the query to the
  37289. // database failed.
  37290. func (m *SecurityPolicyKeywordMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  37291. switch name {
  37292. case securitypolicykeyword.FieldCreatedAt:
  37293. return m.OldCreatedAt(ctx)
  37294. case securitypolicykeyword.FieldUpdatedAt:
  37295. return m.OldUpdatedAt(ctx)
  37296. case securitypolicykeyword.FieldDeletedAt:
  37297. return m.OldDeletedAt(ctx)
  37298. case securitypolicykeyword.FieldGroupID:
  37299. return m.OldGroupID(ctx)
  37300. case securitypolicykeyword.FieldKeyword:
  37301. return m.OldKeyword(ctx)
  37302. case securitypolicykeyword.FieldCategory:
  37303. return m.OldCategory(ctx)
  37304. case securitypolicykeyword.FieldEnabled:
  37305. return m.OldEnabled(ctx)
  37306. }
  37307. return nil, fmt.Errorf("unknown SecurityPolicyKeyword field %s", name)
  37308. }
  37309. // SetField sets the value of a field with the given name. It returns an error if
  37310. // the field is not defined in the schema, or if the type mismatched the field
  37311. // type.
  37312. func (m *SecurityPolicyKeywordMutation) SetField(name string, value ent.Value) error {
  37313. switch name {
  37314. case securitypolicykeyword.FieldCreatedAt:
  37315. v, ok := value.(time.Time)
  37316. if !ok {
  37317. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37318. }
  37319. m.SetCreatedAt(v)
  37320. return nil
  37321. case securitypolicykeyword.FieldUpdatedAt:
  37322. v, ok := value.(time.Time)
  37323. if !ok {
  37324. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37325. }
  37326. m.SetUpdatedAt(v)
  37327. return nil
  37328. case securitypolicykeyword.FieldDeletedAt:
  37329. v, ok := value.(time.Time)
  37330. if !ok {
  37331. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37332. }
  37333. m.SetDeletedAt(v)
  37334. return nil
  37335. case securitypolicykeyword.FieldGroupID:
  37336. v, ok := value.(int64)
  37337. if !ok {
  37338. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37339. }
  37340. m.SetGroupID(v)
  37341. return nil
  37342. case securitypolicykeyword.FieldKeyword:
  37343. v, ok := value.(string)
  37344. if !ok {
  37345. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37346. }
  37347. m.SetKeyword(v)
  37348. return nil
  37349. case securitypolicykeyword.FieldCategory:
  37350. v, ok := value.(string)
  37351. if !ok {
  37352. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37353. }
  37354. m.SetCategory(v)
  37355. return nil
  37356. case securitypolicykeyword.FieldEnabled:
  37357. v, ok := value.(bool)
  37358. if !ok {
  37359. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37360. }
  37361. m.SetEnabled(v)
  37362. return nil
  37363. }
  37364. return fmt.Errorf("unknown SecurityPolicyKeyword field %s", name)
  37365. }
  37366. // AddedFields returns all numeric fields that were incremented/decremented during
  37367. // this mutation.
  37368. func (m *SecurityPolicyKeywordMutation) AddedFields() []string {
  37369. var fields []string
  37370. return fields
  37371. }
  37372. // AddedField returns the numeric value that was incremented/decremented on a field
  37373. // with the given name. The second boolean return value indicates that this field
  37374. // was not set, or was not defined in the schema.
  37375. func (m *SecurityPolicyKeywordMutation) AddedField(name string) (ent.Value, bool) {
  37376. switch name {
  37377. }
  37378. return nil, false
  37379. }
  37380. // AddField adds the value to the field with the given name. It returns an error if
  37381. // the field is not defined in the schema, or if the type mismatched the field
  37382. // type.
  37383. func (m *SecurityPolicyKeywordMutation) AddField(name string, value ent.Value) error {
  37384. switch name {
  37385. }
  37386. return fmt.Errorf("unknown SecurityPolicyKeyword numeric field %s", name)
  37387. }
  37388. // ClearedFields returns all nullable fields that were cleared during this
  37389. // mutation.
  37390. func (m *SecurityPolicyKeywordMutation) ClearedFields() []string {
  37391. var fields []string
  37392. if m.FieldCleared(securitypolicykeyword.FieldDeletedAt) {
  37393. fields = append(fields, securitypolicykeyword.FieldDeletedAt)
  37394. }
  37395. if m.FieldCleared(securitypolicykeyword.FieldGroupID) {
  37396. fields = append(fields, securitypolicykeyword.FieldGroupID)
  37397. }
  37398. return fields
  37399. }
  37400. // FieldCleared returns a boolean indicating if a field with the given name was
  37401. // cleared in this mutation.
  37402. func (m *SecurityPolicyKeywordMutation) FieldCleared(name string) bool {
  37403. _, ok := m.clearedFields[name]
  37404. return ok
  37405. }
  37406. // ClearField clears the value of the field with the given name. It returns an
  37407. // error if the field is not defined in the schema.
  37408. func (m *SecurityPolicyKeywordMutation) ClearField(name string) error {
  37409. switch name {
  37410. case securitypolicykeyword.FieldDeletedAt:
  37411. m.ClearDeletedAt()
  37412. return nil
  37413. case securitypolicykeyword.FieldGroupID:
  37414. m.ClearGroupID()
  37415. return nil
  37416. }
  37417. return fmt.Errorf("unknown SecurityPolicyKeyword nullable field %s", name)
  37418. }
  37419. // ResetField resets all changes in the mutation for the field with the given name.
  37420. // It returns an error if the field is not defined in the schema.
  37421. func (m *SecurityPolicyKeywordMutation) ResetField(name string) error {
  37422. switch name {
  37423. case securitypolicykeyword.FieldCreatedAt:
  37424. m.ResetCreatedAt()
  37425. return nil
  37426. case securitypolicykeyword.FieldUpdatedAt:
  37427. m.ResetUpdatedAt()
  37428. return nil
  37429. case securitypolicykeyword.FieldDeletedAt:
  37430. m.ResetDeletedAt()
  37431. return nil
  37432. case securitypolicykeyword.FieldGroupID:
  37433. m.ResetGroupID()
  37434. return nil
  37435. case securitypolicykeyword.FieldKeyword:
  37436. m.ResetKeyword()
  37437. return nil
  37438. case securitypolicykeyword.FieldCategory:
  37439. m.ResetCategory()
  37440. return nil
  37441. case securitypolicykeyword.FieldEnabled:
  37442. m.ResetEnabled()
  37443. return nil
  37444. }
  37445. return fmt.Errorf("unknown SecurityPolicyKeyword field %s", name)
  37446. }
  37447. // AddedEdges returns all edge names that were set/added in this mutation.
  37448. func (m *SecurityPolicyKeywordMutation) AddedEdges() []string {
  37449. edges := make([]string, 0, 1)
  37450. if m.group != nil {
  37451. edges = append(edges, securitypolicykeyword.EdgeGroup)
  37452. }
  37453. return edges
  37454. }
  37455. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  37456. // name in this mutation.
  37457. func (m *SecurityPolicyKeywordMutation) AddedIDs(name string) []ent.Value {
  37458. switch name {
  37459. case securitypolicykeyword.EdgeGroup:
  37460. if id := m.group; id != nil {
  37461. return []ent.Value{*id}
  37462. }
  37463. }
  37464. return nil
  37465. }
  37466. // RemovedEdges returns all edge names that were removed in this mutation.
  37467. func (m *SecurityPolicyKeywordMutation) RemovedEdges() []string {
  37468. edges := make([]string, 0, 1)
  37469. return edges
  37470. }
  37471. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  37472. // the given name in this mutation.
  37473. func (m *SecurityPolicyKeywordMutation) RemovedIDs(name string) []ent.Value {
  37474. return nil
  37475. }
  37476. // ClearedEdges returns all edge names that were cleared in this mutation.
  37477. func (m *SecurityPolicyKeywordMutation) ClearedEdges() []string {
  37478. edges := make([]string, 0, 1)
  37479. if m.clearedgroup {
  37480. edges = append(edges, securitypolicykeyword.EdgeGroup)
  37481. }
  37482. return edges
  37483. }
  37484. // EdgeCleared returns a boolean which indicates if the edge with the given name
  37485. // was cleared in this mutation.
  37486. func (m *SecurityPolicyKeywordMutation) EdgeCleared(name string) bool {
  37487. switch name {
  37488. case securitypolicykeyword.EdgeGroup:
  37489. return m.clearedgroup
  37490. }
  37491. return false
  37492. }
  37493. // ClearEdge clears the value of the edge with the given name. It returns an error
  37494. // if that edge is not defined in the schema.
  37495. func (m *SecurityPolicyKeywordMutation) ClearEdge(name string) error {
  37496. switch name {
  37497. case securitypolicykeyword.EdgeGroup:
  37498. m.ClearGroup()
  37499. return nil
  37500. }
  37501. return fmt.Errorf("unknown SecurityPolicyKeyword unique edge %s", name)
  37502. }
  37503. // ResetEdge resets all changes to the edge with the given name in this mutation.
  37504. // It returns an error if the edge is not defined in the schema.
  37505. func (m *SecurityPolicyKeywordMutation) ResetEdge(name string) error {
  37506. switch name {
  37507. case securitypolicykeyword.EdgeGroup:
  37508. m.ResetGroup()
  37509. return nil
  37510. }
  37511. return fmt.Errorf("unknown SecurityPolicyKeyword edge %s", name)
  37512. }
  37513. // SecuritySecretMutation represents an operation that mutates the SecuritySecret nodes in the graph.
  37514. type SecuritySecretMutation struct {
  37515. config
  37516. op Op
  37517. typ string
  37518. id *int64
  37519. created_at *time.Time
  37520. updated_at *time.Time
  37521. key *string
  37522. value *string
  37523. clearedFields map[string]struct{}
  37524. done bool
  37525. oldValue func(context.Context) (*SecuritySecret, error)
  37526. predicates []predicate.SecuritySecret
  37527. }
  37528. var _ ent.Mutation = (*SecuritySecretMutation)(nil)
  37529. // securitysecretOption allows management of the mutation configuration using functional options.
  37530. type securitysecretOption func(*SecuritySecretMutation)
  37531. // newSecuritySecretMutation creates new mutation for the SecuritySecret entity.
  37532. func newSecuritySecretMutation(c config, op Op, opts ...securitysecretOption) *SecuritySecretMutation {
  37533. m := &SecuritySecretMutation{
  37534. config: c,
  37535. op: op,
  37536. typ: TypeSecuritySecret,
  37537. clearedFields: make(map[string]struct{}),
  37538. }
  37539. for _, opt := range opts {
  37540. opt(m)
  37541. }
  37542. return m
  37543. }
  37544. // withSecuritySecretID sets the ID field of the mutation.
  37545. func withSecuritySecretID(id int64) securitysecretOption {
  37546. return func(m *SecuritySecretMutation) {
  37547. var (
  37548. err error
  37549. once sync.Once
  37550. value *SecuritySecret
  37551. )
  37552. m.oldValue = func(ctx context.Context) (*SecuritySecret, error) {
  37553. once.Do(func() {
  37554. if m.done {
  37555. err = errors.New("querying old values post mutation is not allowed")
  37556. } else {
  37557. value, err = m.Client().SecuritySecret.Get(ctx, id)
  37558. }
  37559. })
  37560. return value, err
  37561. }
  37562. m.id = &id
  37563. }
  37564. }
  37565. // withSecuritySecret sets the old SecuritySecret of the mutation.
  37566. func withSecuritySecret(node *SecuritySecret) securitysecretOption {
  37567. return func(m *SecuritySecretMutation) {
  37568. m.oldValue = func(context.Context) (*SecuritySecret, error) {
  37569. return node, nil
  37570. }
  37571. m.id = &node.ID
  37572. }
  37573. }
  37574. // Client returns a new `ent.Client` from the mutation. If the mutation was
  37575. // executed in a transaction (ent.Tx), a transactional client is returned.
  37576. func (m SecuritySecretMutation) Client() *Client {
  37577. client := &Client{config: m.config}
  37578. client.init()
  37579. return client
  37580. }
  37581. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  37582. // it returns an error otherwise.
  37583. func (m SecuritySecretMutation) Tx() (*Tx, error) {
  37584. if _, ok := m.driver.(*txDriver); !ok {
  37585. return nil, errors.New("ent: mutation is not running in a transaction")
  37586. }
  37587. tx := &Tx{config: m.config}
  37588. tx.init()
  37589. return tx, nil
  37590. }
  37591. // ID returns the ID value in the mutation. Note that the ID is only available
  37592. // if it was provided to the builder or after it was returned from the database.
  37593. func (m *SecuritySecretMutation) ID() (id int64, exists bool) {
  37594. if m.id == nil {
  37595. return
  37596. }
  37597. return *m.id, true
  37598. }
  37599. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  37600. // That means, if the mutation is applied within a transaction with an isolation level such
  37601. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  37602. // or updated by the mutation.
  37603. func (m *SecuritySecretMutation) IDs(ctx context.Context) ([]int64, error) {
  37604. switch {
  37605. case m.op.Is(OpUpdateOne | OpDeleteOne):
  37606. id, exists := m.ID()
  37607. if exists {
  37608. return []int64{id}, nil
  37609. }
  37610. fallthrough
  37611. case m.op.Is(OpUpdate | OpDelete):
  37612. return m.Client().SecuritySecret.Query().Where(m.predicates...).IDs(ctx)
  37613. default:
  37614. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  37615. }
  37616. }
  37617. // SetCreatedAt sets the "created_at" field.
  37618. func (m *SecuritySecretMutation) SetCreatedAt(t time.Time) {
  37619. m.created_at = &t
  37620. }
  37621. // CreatedAt returns the value of the "created_at" field in the mutation.
  37622. func (m *SecuritySecretMutation) CreatedAt() (r time.Time, exists bool) {
  37623. v := m.created_at
  37624. if v == nil {
  37625. return
  37626. }
  37627. return *v, true
  37628. }
  37629. // OldCreatedAt returns the old "created_at" field's value of the SecuritySecret entity.
  37630. // If the SecuritySecret object wasn't provided to the builder, the object is fetched from the database.
  37631. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37632. func (m *SecuritySecretMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  37633. if !m.op.Is(OpUpdateOne) {
  37634. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  37635. }
  37636. if m.id == nil || m.oldValue == nil {
  37637. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  37638. }
  37639. oldValue, err := m.oldValue(ctx)
  37640. if err != nil {
  37641. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  37642. }
  37643. return oldValue.CreatedAt, nil
  37644. }
  37645. // ResetCreatedAt resets all changes to the "created_at" field.
  37646. func (m *SecuritySecretMutation) ResetCreatedAt() {
  37647. m.created_at = nil
  37648. }
  37649. // SetUpdatedAt sets the "updated_at" field.
  37650. func (m *SecuritySecretMutation) SetUpdatedAt(t time.Time) {
  37651. m.updated_at = &t
  37652. }
  37653. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  37654. func (m *SecuritySecretMutation) UpdatedAt() (r time.Time, exists bool) {
  37655. v := m.updated_at
  37656. if v == nil {
  37657. return
  37658. }
  37659. return *v, true
  37660. }
  37661. // OldUpdatedAt returns the old "updated_at" field's value of the SecuritySecret entity.
  37662. // If the SecuritySecret object wasn't provided to the builder, the object is fetched from the database.
  37663. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37664. func (m *SecuritySecretMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  37665. if !m.op.Is(OpUpdateOne) {
  37666. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  37667. }
  37668. if m.id == nil || m.oldValue == nil {
  37669. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  37670. }
  37671. oldValue, err := m.oldValue(ctx)
  37672. if err != nil {
  37673. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  37674. }
  37675. return oldValue.UpdatedAt, nil
  37676. }
  37677. // ResetUpdatedAt resets all changes to the "updated_at" field.
  37678. func (m *SecuritySecretMutation) ResetUpdatedAt() {
  37679. m.updated_at = nil
  37680. }
  37681. // SetKey sets the "key" field.
  37682. func (m *SecuritySecretMutation) SetKey(s string) {
  37683. m.key = &s
  37684. }
  37685. // Key returns the value of the "key" field in the mutation.
  37686. func (m *SecuritySecretMutation) Key() (r string, exists bool) {
  37687. v := m.key
  37688. if v == nil {
  37689. return
  37690. }
  37691. return *v, true
  37692. }
  37693. // OldKey returns the old "key" field's value of the SecuritySecret entity.
  37694. // If the SecuritySecret object wasn't provided to the builder, the object is fetched from the database.
  37695. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37696. func (m *SecuritySecretMutation) OldKey(ctx context.Context) (v string, err error) {
  37697. if !m.op.Is(OpUpdateOne) {
  37698. return v, errors.New("OldKey is only allowed on UpdateOne operations")
  37699. }
  37700. if m.id == nil || m.oldValue == nil {
  37701. return v, errors.New("OldKey requires an ID field in the mutation")
  37702. }
  37703. oldValue, err := m.oldValue(ctx)
  37704. if err != nil {
  37705. return v, fmt.Errorf("querying old value for OldKey: %w", err)
  37706. }
  37707. return oldValue.Key, nil
  37708. }
  37709. // ResetKey resets all changes to the "key" field.
  37710. func (m *SecuritySecretMutation) ResetKey() {
  37711. m.key = nil
  37712. }
  37713. // SetValue sets the "value" field.
  37714. func (m *SecuritySecretMutation) SetValue(s string) {
  37715. m.value = &s
  37716. }
  37717. // Value returns the value of the "value" field in the mutation.
  37718. func (m *SecuritySecretMutation) Value() (r string, exists bool) {
  37719. v := m.value
  37720. if v == nil {
  37721. return
  37722. }
  37723. return *v, true
  37724. }
  37725. // OldValue returns the old "value" field's value of the SecuritySecret entity.
  37726. // If the SecuritySecret object wasn't provided to the builder, the object is fetched from the database.
  37727. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37728. func (m *SecuritySecretMutation) OldValue(ctx context.Context) (v string, err error) {
  37729. if !m.op.Is(OpUpdateOne) {
  37730. return v, errors.New("OldValue is only allowed on UpdateOne operations")
  37731. }
  37732. if m.id == nil || m.oldValue == nil {
  37733. return v, errors.New("OldValue requires an ID field in the mutation")
  37734. }
  37735. oldValue, err := m.oldValue(ctx)
  37736. if err != nil {
  37737. return v, fmt.Errorf("querying old value for OldValue: %w", err)
  37738. }
  37739. return oldValue.Value, nil
  37740. }
  37741. // ResetValue resets all changes to the "value" field.
  37742. func (m *SecuritySecretMutation) ResetValue() {
  37743. m.value = nil
  37744. }
  37745. // Where appends a list predicates to the SecuritySecretMutation builder.
  37746. func (m *SecuritySecretMutation) Where(ps ...predicate.SecuritySecret) {
  37747. m.predicates = append(m.predicates, ps...)
  37748. }
  37749. // WhereP appends storage-level predicates to the SecuritySecretMutation builder. Using this method,
  37750. // users can use type-assertion to append predicates that do not depend on any generated package.
  37751. func (m *SecuritySecretMutation) WhereP(ps ...func(*sql.Selector)) {
  37752. p := make([]predicate.SecuritySecret, len(ps))
  37753. for i := range ps {
  37754. p[i] = ps[i]
  37755. }
  37756. m.Where(p...)
  37757. }
  37758. // Op returns the operation name.
  37759. func (m *SecuritySecretMutation) Op() Op {
  37760. return m.op
  37761. }
  37762. // SetOp allows setting the mutation operation.
  37763. func (m *SecuritySecretMutation) SetOp(op Op) {
  37764. m.op = op
  37765. }
  37766. // Type returns the node type of this mutation (SecuritySecret).
  37767. func (m *SecuritySecretMutation) Type() string {
  37768. return m.typ
  37769. }
  37770. // Fields returns all fields that were changed during this mutation. Note that in
  37771. // order to get all numeric fields that were incremented/decremented, call
  37772. // AddedFields().
  37773. func (m *SecuritySecretMutation) Fields() []string {
  37774. fields := make([]string, 0, 4)
  37775. if m.created_at != nil {
  37776. fields = append(fields, securitysecret.FieldCreatedAt)
  37777. }
  37778. if m.updated_at != nil {
  37779. fields = append(fields, securitysecret.FieldUpdatedAt)
  37780. }
  37781. if m.key != nil {
  37782. fields = append(fields, securitysecret.FieldKey)
  37783. }
  37784. if m.value != nil {
  37785. fields = append(fields, securitysecret.FieldValue)
  37786. }
  37787. return fields
  37788. }
  37789. // Field returns the value of a field with the given name. The second boolean
  37790. // return value indicates that this field was not set, or was not defined in the
  37791. // schema.
  37792. func (m *SecuritySecretMutation) Field(name string) (ent.Value, bool) {
  37793. switch name {
  37794. case securitysecret.FieldCreatedAt:
  37795. return m.CreatedAt()
  37796. case securitysecret.FieldUpdatedAt:
  37797. return m.UpdatedAt()
  37798. case securitysecret.FieldKey:
  37799. return m.Key()
  37800. case securitysecret.FieldValue:
  37801. return m.Value()
  37802. }
  37803. return nil, false
  37804. }
  37805. // OldField returns the old value of the field from the database. An error is
  37806. // returned if the mutation operation is not UpdateOne, or the query to the
  37807. // database failed.
  37808. func (m *SecuritySecretMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  37809. switch name {
  37810. case securitysecret.FieldCreatedAt:
  37811. return m.OldCreatedAt(ctx)
  37812. case securitysecret.FieldUpdatedAt:
  37813. return m.OldUpdatedAt(ctx)
  37814. case securitysecret.FieldKey:
  37815. return m.OldKey(ctx)
  37816. case securitysecret.FieldValue:
  37817. return m.OldValue(ctx)
  37818. }
  37819. return nil, fmt.Errorf("unknown SecuritySecret field %s", name)
  37820. }
  37821. // SetField sets the value of a field with the given name. It returns an error if
  37822. // the field is not defined in the schema, or if the type mismatched the field
  37823. // type.
  37824. func (m *SecuritySecretMutation) SetField(name string, value ent.Value) error {
  37825. switch name {
  37826. case securitysecret.FieldCreatedAt:
  37827. v, ok := value.(time.Time)
  37828. if !ok {
  37829. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37830. }
  37831. m.SetCreatedAt(v)
  37832. return nil
  37833. case securitysecret.FieldUpdatedAt:
  37834. v, ok := value.(time.Time)
  37835. if !ok {
  37836. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37837. }
  37838. m.SetUpdatedAt(v)
  37839. return nil
  37840. case securitysecret.FieldKey:
  37841. v, ok := value.(string)
  37842. if !ok {
  37843. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37844. }
  37845. m.SetKey(v)
  37846. return nil
  37847. case securitysecret.FieldValue:
  37848. v, ok := value.(string)
  37849. if !ok {
  37850. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37851. }
  37852. m.SetValue(v)
  37853. return nil
  37854. }
  37855. return fmt.Errorf("unknown SecuritySecret field %s", name)
  37856. }
  37857. // AddedFields returns all numeric fields that were incremented/decremented during
  37858. // this mutation.
  37859. func (m *SecuritySecretMutation) AddedFields() []string {
  37860. return nil
  37861. }
  37862. // AddedField returns the numeric value that was incremented/decremented on a field
  37863. // with the given name. The second boolean return value indicates that this field
  37864. // was not set, or was not defined in the schema.
  37865. func (m *SecuritySecretMutation) AddedField(name string) (ent.Value, bool) {
  37866. return nil, false
  37867. }
  37868. // AddField adds the value to the field with the given name. It returns an error if
  37869. // the field is not defined in the schema, or if the type mismatched the field
  37870. // type.
  37871. func (m *SecuritySecretMutation) AddField(name string, value ent.Value) error {
  37872. switch name {
  37873. }
  37874. return fmt.Errorf("unknown SecuritySecret numeric field %s", name)
  37875. }
  37876. // ClearedFields returns all nullable fields that were cleared during this
  37877. // mutation.
  37878. func (m *SecuritySecretMutation) ClearedFields() []string {
  37879. return nil
  37880. }
  37881. // FieldCleared returns a boolean indicating if a field with the given name was
  37882. // cleared in this mutation.
  37883. func (m *SecuritySecretMutation) FieldCleared(name string) bool {
  37884. _, ok := m.clearedFields[name]
  37885. return ok
  37886. }
  37887. // ClearField clears the value of the field with the given name. It returns an
  37888. // error if the field is not defined in the schema.
  37889. func (m *SecuritySecretMutation) ClearField(name string) error {
  37890. return fmt.Errorf("unknown SecuritySecret nullable field %s", name)
  37891. }
  37892. // ResetField resets all changes in the mutation for the field with the given name.
  37893. // It returns an error if the field is not defined in the schema.
  37894. func (m *SecuritySecretMutation) ResetField(name string) error {
  37895. switch name {
  37896. case securitysecret.FieldCreatedAt:
  37897. m.ResetCreatedAt()
  37898. return nil
  37899. case securitysecret.FieldUpdatedAt:
  37900. m.ResetUpdatedAt()
  37901. return nil
  37902. case securitysecret.FieldKey:
  37903. m.ResetKey()
  37904. return nil
  37905. case securitysecret.FieldValue:
  37906. m.ResetValue()
  37907. return nil
  37908. }
  37909. return fmt.Errorf("unknown SecuritySecret field %s", name)
  37910. }
  37911. // AddedEdges returns all edge names that were set/added in this mutation.
  37912. func (m *SecuritySecretMutation) AddedEdges() []string {
  37913. edges := make([]string, 0, 0)
  37914. return edges
  37915. }
  37916. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  37917. // name in this mutation.
  37918. func (m *SecuritySecretMutation) AddedIDs(name string) []ent.Value {
  37919. return nil
  37920. }
  37921. // RemovedEdges returns all edge names that were removed in this mutation.
  37922. func (m *SecuritySecretMutation) RemovedEdges() []string {
  37923. edges := make([]string, 0, 0)
  37924. return edges
  37925. }
  37926. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  37927. // the given name in this mutation.
  37928. func (m *SecuritySecretMutation) RemovedIDs(name string) []ent.Value {
  37929. return nil
  37930. }
  37931. // ClearedEdges returns all edge names that were cleared in this mutation.
  37932. func (m *SecuritySecretMutation) ClearedEdges() []string {
  37933. edges := make([]string, 0, 0)
  37934. return edges
  37935. }
  37936. // EdgeCleared returns a boolean which indicates if the edge with the given name
  37937. // was cleared in this mutation.
  37938. func (m *SecuritySecretMutation) EdgeCleared(name string) bool {
  37939. return false
  37940. }
  37941. // ClearEdge clears the value of the edge with the given name. It returns an error
  37942. // if that edge is not defined in the schema.
  37943. func (m *SecuritySecretMutation) ClearEdge(name string) error {
  37944. return fmt.Errorf("unknown SecuritySecret unique edge %s", name)
  37945. }
  37946. // ResetEdge resets all changes to the edge with the given name in this mutation.
  37947. // It returns an error if the edge is not defined in the schema.
  37948. func (m *SecuritySecretMutation) ResetEdge(name string) error {
  37949. return fmt.Errorf("unknown SecuritySecret edge %s", name)
  37950. }
  37951. // SettingMutation represents an operation that mutates the Setting nodes in the graph.
  37952. type SettingMutation struct {
  37953. config
  37954. op Op
  37955. typ string
  37956. id *int64
  37957. key *string
  37958. value *string
  37959. updated_at *time.Time
  37960. clearedFields map[string]struct{}
  37961. done bool
  37962. oldValue func(context.Context) (*Setting, error)
  37963. predicates []predicate.Setting
  37964. }
  37965. var _ ent.Mutation = (*SettingMutation)(nil)
  37966. // settingOption allows management of the mutation configuration using functional options.
  37967. type settingOption func(*SettingMutation)
  37968. // newSettingMutation creates new mutation for the Setting entity.
  37969. func newSettingMutation(c config, op Op, opts ...settingOption) *SettingMutation {
  37970. m := &SettingMutation{
  37971. config: c,
  37972. op: op,
  37973. typ: TypeSetting,
  37974. clearedFields: make(map[string]struct{}),
  37975. }
  37976. for _, opt := range opts {
  37977. opt(m)
  37978. }
  37979. return m
  37980. }
  37981. // withSettingID sets the ID field of the mutation.
  37982. func withSettingID(id int64) settingOption {
  37983. return func(m *SettingMutation) {
  37984. var (
  37985. err error
  37986. once sync.Once
  37987. value *Setting
  37988. )
  37989. m.oldValue = func(ctx context.Context) (*Setting, error) {
  37990. once.Do(func() {
  37991. if m.done {
  37992. err = errors.New("querying old values post mutation is not allowed")
  37993. } else {
  37994. value, err = m.Client().Setting.Get(ctx, id)
  37995. }
  37996. })
  37997. return value, err
  37998. }
  37999. m.id = &id
  38000. }
  38001. }
  38002. // withSetting sets the old Setting of the mutation.
  38003. func withSetting(node *Setting) settingOption {
  38004. return func(m *SettingMutation) {
  38005. m.oldValue = func(context.Context) (*Setting, error) {
  38006. return node, nil
  38007. }
  38008. m.id = &node.ID
  38009. }
  38010. }
  38011. // Client returns a new `ent.Client` from the mutation. If the mutation was
  38012. // executed in a transaction (ent.Tx), a transactional client is returned.
  38013. func (m SettingMutation) Client() *Client {
  38014. client := &Client{config: m.config}
  38015. client.init()
  38016. return client
  38017. }
  38018. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  38019. // it returns an error otherwise.
  38020. func (m SettingMutation) Tx() (*Tx, error) {
  38021. if _, ok := m.driver.(*txDriver); !ok {
  38022. return nil, errors.New("ent: mutation is not running in a transaction")
  38023. }
  38024. tx := &Tx{config: m.config}
  38025. tx.init()
  38026. return tx, nil
  38027. }
  38028. // ID returns the ID value in the mutation. Note that the ID is only available
  38029. // if it was provided to the builder or after it was returned from the database.
  38030. func (m *SettingMutation) ID() (id int64, exists bool) {
  38031. if m.id == nil {
  38032. return
  38033. }
  38034. return *m.id, true
  38035. }
  38036. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  38037. // That means, if the mutation is applied within a transaction with an isolation level such
  38038. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  38039. // or updated by the mutation.
  38040. func (m *SettingMutation) IDs(ctx context.Context) ([]int64, error) {
  38041. switch {
  38042. case m.op.Is(OpUpdateOne | OpDeleteOne):
  38043. id, exists := m.ID()
  38044. if exists {
  38045. return []int64{id}, nil
  38046. }
  38047. fallthrough
  38048. case m.op.Is(OpUpdate | OpDelete):
  38049. return m.Client().Setting.Query().Where(m.predicates...).IDs(ctx)
  38050. default:
  38051. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  38052. }
  38053. }
  38054. // SetKey sets the "key" field.
  38055. func (m *SettingMutation) SetKey(s string) {
  38056. m.key = &s
  38057. }
  38058. // Key returns the value of the "key" field in the mutation.
  38059. func (m *SettingMutation) Key() (r string, exists bool) {
  38060. v := m.key
  38061. if v == nil {
  38062. return
  38063. }
  38064. return *v, true
  38065. }
  38066. // OldKey returns the old "key" field's value of the Setting entity.
  38067. // If the Setting object wasn't provided to the builder, the object is fetched from the database.
  38068. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38069. func (m *SettingMutation) OldKey(ctx context.Context) (v string, err error) {
  38070. if !m.op.Is(OpUpdateOne) {
  38071. return v, errors.New("OldKey is only allowed on UpdateOne operations")
  38072. }
  38073. if m.id == nil || m.oldValue == nil {
  38074. return v, errors.New("OldKey requires an ID field in the mutation")
  38075. }
  38076. oldValue, err := m.oldValue(ctx)
  38077. if err != nil {
  38078. return v, fmt.Errorf("querying old value for OldKey: %w", err)
  38079. }
  38080. return oldValue.Key, nil
  38081. }
  38082. // ResetKey resets all changes to the "key" field.
  38083. func (m *SettingMutation) ResetKey() {
  38084. m.key = nil
  38085. }
  38086. // SetValue sets the "value" field.
  38087. func (m *SettingMutation) SetValue(s string) {
  38088. m.value = &s
  38089. }
  38090. // Value returns the value of the "value" field in the mutation.
  38091. func (m *SettingMutation) Value() (r string, exists bool) {
  38092. v := m.value
  38093. if v == nil {
  38094. return
  38095. }
  38096. return *v, true
  38097. }
  38098. // OldValue returns the old "value" field's value of the Setting entity.
  38099. // If the Setting object wasn't provided to the builder, the object is fetched from the database.
  38100. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38101. func (m *SettingMutation) OldValue(ctx context.Context) (v string, err error) {
  38102. if !m.op.Is(OpUpdateOne) {
  38103. return v, errors.New("OldValue is only allowed on UpdateOne operations")
  38104. }
  38105. if m.id == nil || m.oldValue == nil {
  38106. return v, errors.New("OldValue requires an ID field in the mutation")
  38107. }
  38108. oldValue, err := m.oldValue(ctx)
  38109. if err != nil {
  38110. return v, fmt.Errorf("querying old value for OldValue: %w", err)
  38111. }
  38112. return oldValue.Value, nil
  38113. }
  38114. // ResetValue resets all changes to the "value" field.
  38115. func (m *SettingMutation) ResetValue() {
  38116. m.value = nil
  38117. }
  38118. // SetUpdatedAt sets the "updated_at" field.
  38119. func (m *SettingMutation) SetUpdatedAt(t time.Time) {
  38120. m.updated_at = &t
  38121. }
  38122. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  38123. func (m *SettingMutation) UpdatedAt() (r time.Time, exists bool) {
  38124. v := m.updated_at
  38125. if v == nil {
  38126. return
  38127. }
  38128. return *v, true
  38129. }
  38130. // OldUpdatedAt returns the old "updated_at" field's value of the Setting entity.
  38131. // If the Setting object wasn't provided to the builder, the object is fetched from the database.
  38132. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38133. func (m *SettingMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  38134. if !m.op.Is(OpUpdateOne) {
  38135. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  38136. }
  38137. if m.id == nil || m.oldValue == nil {
  38138. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  38139. }
  38140. oldValue, err := m.oldValue(ctx)
  38141. if err != nil {
  38142. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  38143. }
  38144. return oldValue.UpdatedAt, nil
  38145. }
  38146. // ResetUpdatedAt resets all changes to the "updated_at" field.
  38147. func (m *SettingMutation) ResetUpdatedAt() {
  38148. m.updated_at = nil
  38149. }
  38150. // Where appends a list predicates to the SettingMutation builder.
  38151. func (m *SettingMutation) Where(ps ...predicate.Setting) {
  38152. m.predicates = append(m.predicates, ps...)
  38153. }
  38154. // WhereP appends storage-level predicates to the SettingMutation builder. Using this method,
  38155. // users can use type-assertion to append predicates that do not depend on any generated package.
  38156. func (m *SettingMutation) WhereP(ps ...func(*sql.Selector)) {
  38157. p := make([]predicate.Setting, len(ps))
  38158. for i := range ps {
  38159. p[i] = ps[i]
  38160. }
  38161. m.Where(p...)
  38162. }
  38163. // Op returns the operation name.
  38164. func (m *SettingMutation) Op() Op {
  38165. return m.op
  38166. }
  38167. // SetOp allows setting the mutation operation.
  38168. func (m *SettingMutation) SetOp(op Op) {
  38169. m.op = op
  38170. }
  38171. // Type returns the node type of this mutation (Setting).
  38172. func (m *SettingMutation) Type() string {
  38173. return m.typ
  38174. }
  38175. // Fields returns all fields that were changed during this mutation. Note that in
  38176. // order to get all numeric fields that were incremented/decremented, call
  38177. // AddedFields().
  38178. func (m *SettingMutation) Fields() []string {
  38179. fields := make([]string, 0, 3)
  38180. if m.key != nil {
  38181. fields = append(fields, setting.FieldKey)
  38182. }
  38183. if m.value != nil {
  38184. fields = append(fields, setting.FieldValue)
  38185. }
  38186. if m.updated_at != nil {
  38187. fields = append(fields, setting.FieldUpdatedAt)
  38188. }
  38189. return fields
  38190. }
  38191. // Field returns the value of a field with the given name. The second boolean
  38192. // return value indicates that this field was not set, or was not defined in the
  38193. // schema.
  38194. func (m *SettingMutation) Field(name string) (ent.Value, bool) {
  38195. switch name {
  38196. case setting.FieldKey:
  38197. return m.Key()
  38198. case setting.FieldValue:
  38199. return m.Value()
  38200. case setting.FieldUpdatedAt:
  38201. return m.UpdatedAt()
  38202. }
  38203. return nil, false
  38204. }
  38205. // OldField returns the old value of the field from the database. An error is
  38206. // returned if the mutation operation is not UpdateOne, or the query to the
  38207. // database failed.
  38208. func (m *SettingMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  38209. switch name {
  38210. case setting.FieldKey:
  38211. return m.OldKey(ctx)
  38212. case setting.FieldValue:
  38213. return m.OldValue(ctx)
  38214. case setting.FieldUpdatedAt:
  38215. return m.OldUpdatedAt(ctx)
  38216. }
  38217. return nil, fmt.Errorf("unknown Setting field %s", name)
  38218. }
  38219. // SetField sets the value of a field with the given name. It returns an error if
  38220. // the field is not defined in the schema, or if the type mismatched the field
  38221. // type.
  38222. func (m *SettingMutation) SetField(name string, value ent.Value) error {
  38223. switch name {
  38224. case setting.FieldKey:
  38225. v, ok := value.(string)
  38226. if !ok {
  38227. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38228. }
  38229. m.SetKey(v)
  38230. return nil
  38231. case setting.FieldValue:
  38232. v, ok := value.(string)
  38233. if !ok {
  38234. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38235. }
  38236. m.SetValue(v)
  38237. return nil
  38238. case setting.FieldUpdatedAt:
  38239. v, ok := value.(time.Time)
  38240. if !ok {
  38241. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38242. }
  38243. m.SetUpdatedAt(v)
  38244. return nil
  38245. }
  38246. return fmt.Errorf("unknown Setting field %s", name)
  38247. }
  38248. // AddedFields returns all numeric fields that were incremented/decremented during
  38249. // this mutation.
  38250. func (m *SettingMutation) AddedFields() []string {
  38251. return nil
  38252. }
  38253. // AddedField returns the numeric value that was incremented/decremented on a field
  38254. // with the given name. The second boolean return value indicates that this field
  38255. // was not set, or was not defined in the schema.
  38256. func (m *SettingMutation) AddedField(name string) (ent.Value, bool) {
  38257. return nil, false
  38258. }
  38259. // AddField adds the value to the field with the given name. It returns an error if
  38260. // the field is not defined in the schema, or if the type mismatched the field
  38261. // type.
  38262. func (m *SettingMutation) AddField(name string, value ent.Value) error {
  38263. switch name {
  38264. }
  38265. return fmt.Errorf("unknown Setting numeric field %s", name)
  38266. }
  38267. // ClearedFields returns all nullable fields that were cleared during this
  38268. // mutation.
  38269. func (m *SettingMutation) ClearedFields() []string {
  38270. return nil
  38271. }
  38272. // FieldCleared returns a boolean indicating if a field with the given name was
  38273. // cleared in this mutation.
  38274. func (m *SettingMutation) FieldCleared(name string) bool {
  38275. _, ok := m.clearedFields[name]
  38276. return ok
  38277. }
  38278. // ClearField clears the value of the field with the given name. It returns an
  38279. // error if the field is not defined in the schema.
  38280. func (m *SettingMutation) ClearField(name string) error {
  38281. return fmt.Errorf("unknown Setting nullable field %s", name)
  38282. }
  38283. // ResetField resets all changes in the mutation for the field with the given name.
  38284. // It returns an error if the field is not defined in the schema.
  38285. func (m *SettingMutation) ResetField(name string) error {
  38286. switch name {
  38287. case setting.FieldKey:
  38288. m.ResetKey()
  38289. return nil
  38290. case setting.FieldValue:
  38291. m.ResetValue()
  38292. return nil
  38293. case setting.FieldUpdatedAt:
  38294. m.ResetUpdatedAt()
  38295. return nil
  38296. }
  38297. return fmt.Errorf("unknown Setting field %s", name)
  38298. }
  38299. // AddedEdges returns all edge names that were set/added in this mutation.
  38300. func (m *SettingMutation) AddedEdges() []string {
  38301. edges := make([]string, 0, 0)
  38302. return edges
  38303. }
  38304. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  38305. // name in this mutation.
  38306. func (m *SettingMutation) AddedIDs(name string) []ent.Value {
  38307. return nil
  38308. }
  38309. // RemovedEdges returns all edge names that were removed in this mutation.
  38310. func (m *SettingMutation) RemovedEdges() []string {
  38311. edges := make([]string, 0, 0)
  38312. return edges
  38313. }
  38314. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  38315. // the given name in this mutation.
  38316. func (m *SettingMutation) RemovedIDs(name string) []ent.Value {
  38317. return nil
  38318. }
  38319. // ClearedEdges returns all edge names that were cleared in this mutation.
  38320. func (m *SettingMutation) ClearedEdges() []string {
  38321. edges := make([]string, 0, 0)
  38322. return edges
  38323. }
  38324. // EdgeCleared returns a boolean which indicates if the edge with the given name
  38325. // was cleared in this mutation.
  38326. func (m *SettingMutation) EdgeCleared(name string) bool {
  38327. return false
  38328. }
  38329. // ClearEdge clears the value of the edge with the given name. It returns an error
  38330. // if that edge is not defined in the schema.
  38331. func (m *SettingMutation) ClearEdge(name string) error {
  38332. return fmt.Errorf("unknown Setting unique edge %s", name)
  38333. }
  38334. // ResetEdge resets all changes to the edge with the given name in this mutation.
  38335. // It returns an error if the edge is not defined in the schema.
  38336. func (m *SettingMutation) ResetEdge(name string) error {
  38337. return fmt.Errorf("unknown Setting edge %s", name)
  38338. }
  38339. // SubscriptionPlanMutation represents an operation that mutates the SubscriptionPlan nodes in the graph.
  38340. type SubscriptionPlanMutation struct {
  38341. config
  38342. op Op
  38343. typ string
  38344. id *int64
  38345. group_id *int64
  38346. addgroup_id *int64
  38347. name *string
  38348. description *string
  38349. price *float64
  38350. addprice *float64
  38351. original_price *float64
  38352. addoriginal_price *float64
  38353. currency *string
  38354. validity_days *int
  38355. addvalidity_days *int
  38356. validity_unit *string
  38357. features *string
  38358. product_name *string
  38359. for_sale *bool
  38360. sort_order *int
  38361. addsort_order *int
  38362. created_at *time.Time
  38363. updated_at *time.Time
  38364. clearedFields map[string]struct{}
  38365. done bool
  38366. oldValue func(context.Context) (*SubscriptionPlan, error)
  38367. predicates []predicate.SubscriptionPlan
  38368. }
  38369. var _ ent.Mutation = (*SubscriptionPlanMutation)(nil)
  38370. // subscriptionplanOption allows management of the mutation configuration using functional options.
  38371. type subscriptionplanOption func(*SubscriptionPlanMutation)
  38372. // newSubscriptionPlanMutation creates new mutation for the SubscriptionPlan entity.
  38373. func newSubscriptionPlanMutation(c config, op Op, opts ...subscriptionplanOption) *SubscriptionPlanMutation {
  38374. m := &SubscriptionPlanMutation{
  38375. config: c,
  38376. op: op,
  38377. typ: TypeSubscriptionPlan,
  38378. clearedFields: make(map[string]struct{}),
  38379. }
  38380. for _, opt := range opts {
  38381. opt(m)
  38382. }
  38383. return m
  38384. }
  38385. // withSubscriptionPlanID sets the ID field of the mutation.
  38386. func withSubscriptionPlanID(id int64) subscriptionplanOption {
  38387. return func(m *SubscriptionPlanMutation) {
  38388. var (
  38389. err error
  38390. once sync.Once
  38391. value *SubscriptionPlan
  38392. )
  38393. m.oldValue = func(ctx context.Context) (*SubscriptionPlan, error) {
  38394. once.Do(func() {
  38395. if m.done {
  38396. err = errors.New("querying old values post mutation is not allowed")
  38397. } else {
  38398. value, err = m.Client().SubscriptionPlan.Get(ctx, id)
  38399. }
  38400. })
  38401. return value, err
  38402. }
  38403. m.id = &id
  38404. }
  38405. }
  38406. // withSubscriptionPlan sets the old SubscriptionPlan of the mutation.
  38407. func withSubscriptionPlan(node *SubscriptionPlan) subscriptionplanOption {
  38408. return func(m *SubscriptionPlanMutation) {
  38409. m.oldValue = func(context.Context) (*SubscriptionPlan, error) {
  38410. return node, nil
  38411. }
  38412. m.id = &node.ID
  38413. }
  38414. }
  38415. // Client returns a new `ent.Client` from the mutation. If the mutation was
  38416. // executed in a transaction (ent.Tx), a transactional client is returned.
  38417. func (m SubscriptionPlanMutation) Client() *Client {
  38418. client := &Client{config: m.config}
  38419. client.init()
  38420. return client
  38421. }
  38422. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  38423. // it returns an error otherwise.
  38424. func (m SubscriptionPlanMutation) Tx() (*Tx, error) {
  38425. if _, ok := m.driver.(*txDriver); !ok {
  38426. return nil, errors.New("ent: mutation is not running in a transaction")
  38427. }
  38428. tx := &Tx{config: m.config}
  38429. tx.init()
  38430. return tx, nil
  38431. }
  38432. // ID returns the ID value in the mutation. Note that the ID is only available
  38433. // if it was provided to the builder or after it was returned from the database.
  38434. func (m *SubscriptionPlanMutation) ID() (id int64, exists bool) {
  38435. if m.id == nil {
  38436. return
  38437. }
  38438. return *m.id, true
  38439. }
  38440. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  38441. // That means, if the mutation is applied within a transaction with an isolation level such
  38442. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  38443. // or updated by the mutation.
  38444. func (m *SubscriptionPlanMutation) IDs(ctx context.Context) ([]int64, error) {
  38445. switch {
  38446. case m.op.Is(OpUpdateOne | OpDeleteOne):
  38447. id, exists := m.ID()
  38448. if exists {
  38449. return []int64{id}, nil
  38450. }
  38451. fallthrough
  38452. case m.op.Is(OpUpdate | OpDelete):
  38453. return m.Client().SubscriptionPlan.Query().Where(m.predicates...).IDs(ctx)
  38454. default:
  38455. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  38456. }
  38457. }
  38458. // SetGroupID sets the "group_id" field.
  38459. func (m *SubscriptionPlanMutation) SetGroupID(i int64) {
  38460. m.group_id = &i
  38461. m.addgroup_id = nil
  38462. }
  38463. // GroupID returns the value of the "group_id" field in the mutation.
  38464. func (m *SubscriptionPlanMutation) GroupID() (r int64, exists bool) {
  38465. v := m.group_id
  38466. if v == nil {
  38467. return
  38468. }
  38469. return *v, true
  38470. }
  38471. // OldGroupID returns the old "group_id" field's value of the SubscriptionPlan entity.
  38472. // If the SubscriptionPlan object wasn't provided to the builder, the object is fetched from the database.
  38473. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38474. func (m *SubscriptionPlanMutation) OldGroupID(ctx context.Context) (v int64, err error) {
  38475. if !m.op.Is(OpUpdateOne) {
  38476. return v, errors.New("OldGroupID is only allowed on UpdateOne operations")
  38477. }
  38478. if m.id == nil || m.oldValue == nil {
  38479. return v, errors.New("OldGroupID requires an ID field in the mutation")
  38480. }
  38481. oldValue, err := m.oldValue(ctx)
  38482. if err != nil {
  38483. return v, fmt.Errorf("querying old value for OldGroupID: %w", err)
  38484. }
  38485. return oldValue.GroupID, nil
  38486. }
  38487. // AddGroupID adds i to the "group_id" field.
  38488. func (m *SubscriptionPlanMutation) AddGroupID(i int64) {
  38489. if m.addgroup_id != nil {
  38490. *m.addgroup_id += i
  38491. } else {
  38492. m.addgroup_id = &i
  38493. }
  38494. }
  38495. // AddedGroupID returns the value that was added to the "group_id" field in this mutation.
  38496. func (m *SubscriptionPlanMutation) AddedGroupID() (r int64, exists bool) {
  38497. v := m.addgroup_id
  38498. if v == nil {
  38499. return
  38500. }
  38501. return *v, true
  38502. }
  38503. // ResetGroupID resets all changes to the "group_id" field.
  38504. func (m *SubscriptionPlanMutation) ResetGroupID() {
  38505. m.group_id = nil
  38506. m.addgroup_id = nil
  38507. }
  38508. // SetName sets the "name" field.
  38509. func (m *SubscriptionPlanMutation) SetName(s string) {
  38510. m.name = &s
  38511. }
  38512. // Name returns the value of the "name" field in the mutation.
  38513. func (m *SubscriptionPlanMutation) Name() (r string, exists bool) {
  38514. v := m.name
  38515. if v == nil {
  38516. return
  38517. }
  38518. return *v, true
  38519. }
  38520. // OldName returns the old "name" field's value of the SubscriptionPlan entity.
  38521. // If the SubscriptionPlan object wasn't provided to the builder, the object is fetched from the database.
  38522. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38523. func (m *SubscriptionPlanMutation) OldName(ctx context.Context) (v string, err error) {
  38524. if !m.op.Is(OpUpdateOne) {
  38525. return v, errors.New("OldName is only allowed on UpdateOne operations")
  38526. }
  38527. if m.id == nil || m.oldValue == nil {
  38528. return v, errors.New("OldName requires an ID field in the mutation")
  38529. }
  38530. oldValue, err := m.oldValue(ctx)
  38531. if err != nil {
  38532. return v, fmt.Errorf("querying old value for OldName: %w", err)
  38533. }
  38534. return oldValue.Name, nil
  38535. }
  38536. // ResetName resets all changes to the "name" field.
  38537. func (m *SubscriptionPlanMutation) ResetName() {
  38538. m.name = nil
  38539. }
  38540. // SetDescription sets the "description" field.
  38541. func (m *SubscriptionPlanMutation) SetDescription(s string) {
  38542. m.description = &s
  38543. }
  38544. // Description returns the value of the "description" field in the mutation.
  38545. func (m *SubscriptionPlanMutation) Description() (r string, exists bool) {
  38546. v := m.description
  38547. if v == nil {
  38548. return
  38549. }
  38550. return *v, true
  38551. }
  38552. // OldDescription returns the old "description" field's value of the SubscriptionPlan entity.
  38553. // If the SubscriptionPlan object wasn't provided to the builder, the object is fetched from the database.
  38554. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38555. func (m *SubscriptionPlanMutation) OldDescription(ctx context.Context) (v string, err error) {
  38556. if !m.op.Is(OpUpdateOne) {
  38557. return v, errors.New("OldDescription is only allowed on UpdateOne operations")
  38558. }
  38559. if m.id == nil || m.oldValue == nil {
  38560. return v, errors.New("OldDescription requires an ID field in the mutation")
  38561. }
  38562. oldValue, err := m.oldValue(ctx)
  38563. if err != nil {
  38564. return v, fmt.Errorf("querying old value for OldDescription: %w", err)
  38565. }
  38566. return oldValue.Description, nil
  38567. }
  38568. // ResetDescription resets all changes to the "description" field.
  38569. func (m *SubscriptionPlanMutation) ResetDescription() {
  38570. m.description = nil
  38571. }
  38572. // SetPrice sets the "price" field.
  38573. func (m *SubscriptionPlanMutation) SetPrice(f float64) {
  38574. m.price = &f
  38575. m.addprice = nil
  38576. }
  38577. // Price returns the value of the "price" field in the mutation.
  38578. func (m *SubscriptionPlanMutation) Price() (r float64, exists bool) {
  38579. v := m.price
  38580. if v == nil {
  38581. return
  38582. }
  38583. return *v, true
  38584. }
  38585. // OldPrice returns the old "price" field's value of the SubscriptionPlan entity.
  38586. // If the SubscriptionPlan object wasn't provided to the builder, the object is fetched from the database.
  38587. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38588. func (m *SubscriptionPlanMutation) OldPrice(ctx context.Context) (v float64, err error) {
  38589. if !m.op.Is(OpUpdateOne) {
  38590. return v, errors.New("OldPrice is only allowed on UpdateOne operations")
  38591. }
  38592. if m.id == nil || m.oldValue == nil {
  38593. return v, errors.New("OldPrice requires an ID field in the mutation")
  38594. }
  38595. oldValue, err := m.oldValue(ctx)
  38596. if err != nil {
  38597. return v, fmt.Errorf("querying old value for OldPrice: %w", err)
  38598. }
  38599. return oldValue.Price, nil
  38600. }
  38601. // AddPrice adds f to the "price" field.
  38602. func (m *SubscriptionPlanMutation) AddPrice(f float64) {
  38603. if m.addprice != nil {
  38604. *m.addprice += f
  38605. } else {
  38606. m.addprice = &f
  38607. }
  38608. }
  38609. // AddedPrice returns the value that was added to the "price" field in this mutation.
  38610. func (m *SubscriptionPlanMutation) AddedPrice() (r float64, exists bool) {
  38611. v := m.addprice
  38612. if v == nil {
  38613. return
  38614. }
  38615. return *v, true
  38616. }
  38617. // ResetPrice resets all changes to the "price" field.
  38618. func (m *SubscriptionPlanMutation) ResetPrice() {
  38619. m.price = nil
  38620. m.addprice = nil
  38621. }
  38622. // SetOriginalPrice sets the "original_price" field.
  38623. func (m *SubscriptionPlanMutation) SetOriginalPrice(f float64) {
  38624. m.original_price = &f
  38625. m.addoriginal_price = nil
  38626. }
  38627. // OriginalPrice returns the value of the "original_price" field in the mutation.
  38628. func (m *SubscriptionPlanMutation) OriginalPrice() (r float64, exists bool) {
  38629. v := m.original_price
  38630. if v == nil {
  38631. return
  38632. }
  38633. return *v, true
  38634. }
  38635. // OldOriginalPrice returns the old "original_price" field's value of the SubscriptionPlan entity.
  38636. // If the SubscriptionPlan object wasn't provided to the builder, the object is fetched from the database.
  38637. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38638. func (m *SubscriptionPlanMutation) OldOriginalPrice(ctx context.Context) (v *float64, err error) {
  38639. if !m.op.Is(OpUpdateOne) {
  38640. return v, errors.New("OldOriginalPrice is only allowed on UpdateOne operations")
  38641. }
  38642. if m.id == nil || m.oldValue == nil {
  38643. return v, errors.New("OldOriginalPrice requires an ID field in the mutation")
  38644. }
  38645. oldValue, err := m.oldValue(ctx)
  38646. if err != nil {
  38647. return v, fmt.Errorf("querying old value for OldOriginalPrice: %w", err)
  38648. }
  38649. return oldValue.OriginalPrice, nil
  38650. }
  38651. // AddOriginalPrice adds f to the "original_price" field.
  38652. func (m *SubscriptionPlanMutation) AddOriginalPrice(f float64) {
  38653. if m.addoriginal_price != nil {
  38654. *m.addoriginal_price += f
  38655. } else {
  38656. m.addoriginal_price = &f
  38657. }
  38658. }
  38659. // AddedOriginalPrice returns the value that was added to the "original_price" field in this mutation.
  38660. func (m *SubscriptionPlanMutation) AddedOriginalPrice() (r float64, exists bool) {
  38661. v := m.addoriginal_price
  38662. if v == nil {
  38663. return
  38664. }
  38665. return *v, true
  38666. }
  38667. // ClearOriginalPrice clears the value of the "original_price" field.
  38668. func (m *SubscriptionPlanMutation) ClearOriginalPrice() {
  38669. m.original_price = nil
  38670. m.addoriginal_price = nil
  38671. m.clearedFields[subscriptionplan.FieldOriginalPrice] = struct{}{}
  38672. }
  38673. // OriginalPriceCleared returns if the "original_price" field was cleared in this mutation.
  38674. func (m *SubscriptionPlanMutation) OriginalPriceCleared() bool {
  38675. _, ok := m.clearedFields[subscriptionplan.FieldOriginalPrice]
  38676. return ok
  38677. }
  38678. // ResetOriginalPrice resets all changes to the "original_price" field.
  38679. func (m *SubscriptionPlanMutation) ResetOriginalPrice() {
  38680. m.original_price = nil
  38681. m.addoriginal_price = nil
  38682. delete(m.clearedFields, subscriptionplan.FieldOriginalPrice)
  38683. }
  38684. // SetCurrency sets the "currency" field.
  38685. func (m *SubscriptionPlanMutation) SetCurrency(s string) {
  38686. m.currency = &s
  38687. }
  38688. // Currency returns the value of the "currency" field in the mutation.
  38689. func (m *SubscriptionPlanMutation) Currency() (r string, exists bool) {
  38690. v := m.currency
  38691. if v == nil {
  38692. return
  38693. }
  38694. return *v, true
  38695. }
  38696. // OldCurrency returns the old "currency" field's value of the SubscriptionPlan entity.
  38697. // If the SubscriptionPlan object wasn't provided to the builder, the object is fetched from the database.
  38698. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38699. func (m *SubscriptionPlanMutation) OldCurrency(ctx context.Context) (v string, err error) {
  38700. if !m.op.Is(OpUpdateOne) {
  38701. return v, errors.New("OldCurrency is only allowed on UpdateOne operations")
  38702. }
  38703. if m.id == nil || m.oldValue == nil {
  38704. return v, errors.New("OldCurrency requires an ID field in the mutation")
  38705. }
  38706. oldValue, err := m.oldValue(ctx)
  38707. if err != nil {
  38708. return v, fmt.Errorf("querying old value for OldCurrency: %w", err)
  38709. }
  38710. return oldValue.Currency, nil
  38711. }
  38712. // ResetCurrency resets all changes to the "currency" field.
  38713. func (m *SubscriptionPlanMutation) ResetCurrency() {
  38714. m.currency = nil
  38715. }
  38716. // SetValidityDays sets the "validity_days" field.
  38717. func (m *SubscriptionPlanMutation) SetValidityDays(i int) {
  38718. m.validity_days = &i
  38719. m.addvalidity_days = nil
  38720. }
  38721. // ValidityDays returns the value of the "validity_days" field in the mutation.
  38722. func (m *SubscriptionPlanMutation) ValidityDays() (r int, exists bool) {
  38723. v := m.validity_days
  38724. if v == nil {
  38725. return
  38726. }
  38727. return *v, true
  38728. }
  38729. // OldValidityDays returns the old "validity_days" field's value of the SubscriptionPlan entity.
  38730. // If the SubscriptionPlan object wasn't provided to the builder, the object is fetched from the database.
  38731. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38732. func (m *SubscriptionPlanMutation) OldValidityDays(ctx context.Context) (v int, err error) {
  38733. if !m.op.Is(OpUpdateOne) {
  38734. return v, errors.New("OldValidityDays is only allowed on UpdateOne operations")
  38735. }
  38736. if m.id == nil || m.oldValue == nil {
  38737. return v, errors.New("OldValidityDays requires an ID field in the mutation")
  38738. }
  38739. oldValue, err := m.oldValue(ctx)
  38740. if err != nil {
  38741. return v, fmt.Errorf("querying old value for OldValidityDays: %w", err)
  38742. }
  38743. return oldValue.ValidityDays, nil
  38744. }
  38745. // AddValidityDays adds i to the "validity_days" field.
  38746. func (m *SubscriptionPlanMutation) AddValidityDays(i int) {
  38747. if m.addvalidity_days != nil {
  38748. *m.addvalidity_days += i
  38749. } else {
  38750. m.addvalidity_days = &i
  38751. }
  38752. }
  38753. // AddedValidityDays returns the value that was added to the "validity_days" field in this mutation.
  38754. func (m *SubscriptionPlanMutation) AddedValidityDays() (r int, exists bool) {
  38755. v := m.addvalidity_days
  38756. if v == nil {
  38757. return
  38758. }
  38759. return *v, true
  38760. }
  38761. // ResetValidityDays resets all changes to the "validity_days" field.
  38762. func (m *SubscriptionPlanMutation) ResetValidityDays() {
  38763. m.validity_days = nil
  38764. m.addvalidity_days = nil
  38765. }
  38766. // SetValidityUnit sets the "validity_unit" field.
  38767. func (m *SubscriptionPlanMutation) SetValidityUnit(s string) {
  38768. m.validity_unit = &s
  38769. }
  38770. // ValidityUnit returns the value of the "validity_unit" field in the mutation.
  38771. func (m *SubscriptionPlanMutation) ValidityUnit() (r string, exists bool) {
  38772. v := m.validity_unit
  38773. if v == nil {
  38774. return
  38775. }
  38776. return *v, true
  38777. }
  38778. // OldValidityUnit returns the old "validity_unit" field's value of the SubscriptionPlan entity.
  38779. // If the SubscriptionPlan object wasn't provided to the builder, the object is fetched from the database.
  38780. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38781. func (m *SubscriptionPlanMutation) OldValidityUnit(ctx context.Context) (v string, err error) {
  38782. if !m.op.Is(OpUpdateOne) {
  38783. return v, errors.New("OldValidityUnit is only allowed on UpdateOne operations")
  38784. }
  38785. if m.id == nil || m.oldValue == nil {
  38786. return v, errors.New("OldValidityUnit requires an ID field in the mutation")
  38787. }
  38788. oldValue, err := m.oldValue(ctx)
  38789. if err != nil {
  38790. return v, fmt.Errorf("querying old value for OldValidityUnit: %w", err)
  38791. }
  38792. return oldValue.ValidityUnit, nil
  38793. }
  38794. // ResetValidityUnit resets all changes to the "validity_unit" field.
  38795. func (m *SubscriptionPlanMutation) ResetValidityUnit() {
  38796. m.validity_unit = nil
  38797. }
  38798. // SetFeatures sets the "features" field.
  38799. func (m *SubscriptionPlanMutation) SetFeatures(s string) {
  38800. m.features = &s
  38801. }
  38802. // Features returns the value of the "features" field in the mutation.
  38803. func (m *SubscriptionPlanMutation) Features() (r string, exists bool) {
  38804. v := m.features
  38805. if v == nil {
  38806. return
  38807. }
  38808. return *v, true
  38809. }
  38810. // OldFeatures returns the old "features" field's value of the SubscriptionPlan entity.
  38811. // If the SubscriptionPlan object wasn't provided to the builder, the object is fetched from the database.
  38812. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38813. func (m *SubscriptionPlanMutation) OldFeatures(ctx context.Context) (v string, err error) {
  38814. if !m.op.Is(OpUpdateOne) {
  38815. return v, errors.New("OldFeatures is only allowed on UpdateOne operations")
  38816. }
  38817. if m.id == nil || m.oldValue == nil {
  38818. return v, errors.New("OldFeatures requires an ID field in the mutation")
  38819. }
  38820. oldValue, err := m.oldValue(ctx)
  38821. if err != nil {
  38822. return v, fmt.Errorf("querying old value for OldFeatures: %w", err)
  38823. }
  38824. return oldValue.Features, nil
  38825. }
  38826. // ResetFeatures resets all changes to the "features" field.
  38827. func (m *SubscriptionPlanMutation) ResetFeatures() {
  38828. m.features = nil
  38829. }
  38830. // SetProductName sets the "product_name" field.
  38831. func (m *SubscriptionPlanMutation) SetProductName(s string) {
  38832. m.product_name = &s
  38833. }
  38834. // ProductName returns the value of the "product_name" field in the mutation.
  38835. func (m *SubscriptionPlanMutation) ProductName() (r string, exists bool) {
  38836. v := m.product_name
  38837. if v == nil {
  38838. return
  38839. }
  38840. return *v, true
  38841. }
  38842. // OldProductName returns the old "product_name" field's value of the SubscriptionPlan entity.
  38843. // If the SubscriptionPlan object wasn't provided to the builder, the object is fetched from the database.
  38844. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38845. func (m *SubscriptionPlanMutation) OldProductName(ctx context.Context) (v string, err error) {
  38846. if !m.op.Is(OpUpdateOne) {
  38847. return v, errors.New("OldProductName is only allowed on UpdateOne operations")
  38848. }
  38849. if m.id == nil || m.oldValue == nil {
  38850. return v, errors.New("OldProductName requires an ID field in the mutation")
  38851. }
  38852. oldValue, err := m.oldValue(ctx)
  38853. if err != nil {
  38854. return v, fmt.Errorf("querying old value for OldProductName: %w", err)
  38855. }
  38856. return oldValue.ProductName, nil
  38857. }
  38858. // ResetProductName resets all changes to the "product_name" field.
  38859. func (m *SubscriptionPlanMutation) ResetProductName() {
  38860. m.product_name = nil
  38861. }
  38862. // SetForSale sets the "for_sale" field.
  38863. func (m *SubscriptionPlanMutation) SetForSale(b bool) {
  38864. m.for_sale = &b
  38865. }
  38866. // ForSale returns the value of the "for_sale" field in the mutation.
  38867. func (m *SubscriptionPlanMutation) ForSale() (r bool, exists bool) {
  38868. v := m.for_sale
  38869. if v == nil {
  38870. return
  38871. }
  38872. return *v, true
  38873. }
  38874. // OldForSale returns the old "for_sale" field's value of the SubscriptionPlan entity.
  38875. // If the SubscriptionPlan object wasn't provided to the builder, the object is fetched from the database.
  38876. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38877. func (m *SubscriptionPlanMutation) OldForSale(ctx context.Context) (v bool, err error) {
  38878. if !m.op.Is(OpUpdateOne) {
  38879. return v, errors.New("OldForSale is only allowed on UpdateOne operations")
  38880. }
  38881. if m.id == nil || m.oldValue == nil {
  38882. return v, errors.New("OldForSale requires an ID field in the mutation")
  38883. }
  38884. oldValue, err := m.oldValue(ctx)
  38885. if err != nil {
  38886. return v, fmt.Errorf("querying old value for OldForSale: %w", err)
  38887. }
  38888. return oldValue.ForSale, nil
  38889. }
  38890. // ResetForSale resets all changes to the "for_sale" field.
  38891. func (m *SubscriptionPlanMutation) ResetForSale() {
  38892. m.for_sale = nil
  38893. }
  38894. // SetSortOrder sets the "sort_order" field.
  38895. func (m *SubscriptionPlanMutation) SetSortOrder(i int) {
  38896. m.sort_order = &i
  38897. m.addsort_order = nil
  38898. }
  38899. // SortOrder returns the value of the "sort_order" field in the mutation.
  38900. func (m *SubscriptionPlanMutation) SortOrder() (r int, exists bool) {
  38901. v := m.sort_order
  38902. if v == nil {
  38903. return
  38904. }
  38905. return *v, true
  38906. }
  38907. // OldSortOrder returns the old "sort_order" field's value of the SubscriptionPlan entity.
  38908. // If the SubscriptionPlan object wasn't provided to the builder, the object is fetched from the database.
  38909. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38910. func (m *SubscriptionPlanMutation) OldSortOrder(ctx context.Context) (v int, err error) {
  38911. if !m.op.Is(OpUpdateOne) {
  38912. return v, errors.New("OldSortOrder is only allowed on UpdateOne operations")
  38913. }
  38914. if m.id == nil || m.oldValue == nil {
  38915. return v, errors.New("OldSortOrder requires an ID field in the mutation")
  38916. }
  38917. oldValue, err := m.oldValue(ctx)
  38918. if err != nil {
  38919. return v, fmt.Errorf("querying old value for OldSortOrder: %w", err)
  38920. }
  38921. return oldValue.SortOrder, nil
  38922. }
  38923. // AddSortOrder adds i to the "sort_order" field.
  38924. func (m *SubscriptionPlanMutation) AddSortOrder(i int) {
  38925. if m.addsort_order != nil {
  38926. *m.addsort_order += i
  38927. } else {
  38928. m.addsort_order = &i
  38929. }
  38930. }
  38931. // AddedSortOrder returns the value that was added to the "sort_order" field in this mutation.
  38932. func (m *SubscriptionPlanMutation) AddedSortOrder() (r int, exists bool) {
  38933. v := m.addsort_order
  38934. if v == nil {
  38935. return
  38936. }
  38937. return *v, true
  38938. }
  38939. // ResetSortOrder resets all changes to the "sort_order" field.
  38940. func (m *SubscriptionPlanMutation) ResetSortOrder() {
  38941. m.sort_order = nil
  38942. m.addsort_order = nil
  38943. }
  38944. // SetCreatedAt sets the "created_at" field.
  38945. func (m *SubscriptionPlanMutation) SetCreatedAt(t time.Time) {
  38946. m.created_at = &t
  38947. }
  38948. // CreatedAt returns the value of the "created_at" field in the mutation.
  38949. func (m *SubscriptionPlanMutation) CreatedAt() (r time.Time, exists bool) {
  38950. v := m.created_at
  38951. if v == nil {
  38952. return
  38953. }
  38954. return *v, true
  38955. }
  38956. // OldCreatedAt returns the old "created_at" field's value of the SubscriptionPlan entity.
  38957. // If the SubscriptionPlan object wasn't provided to the builder, the object is fetched from the database.
  38958. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38959. func (m *SubscriptionPlanMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  38960. if !m.op.Is(OpUpdateOne) {
  38961. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  38962. }
  38963. if m.id == nil || m.oldValue == nil {
  38964. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  38965. }
  38966. oldValue, err := m.oldValue(ctx)
  38967. if err != nil {
  38968. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  38969. }
  38970. return oldValue.CreatedAt, nil
  38971. }
  38972. // ResetCreatedAt resets all changes to the "created_at" field.
  38973. func (m *SubscriptionPlanMutation) ResetCreatedAt() {
  38974. m.created_at = nil
  38975. }
  38976. // SetUpdatedAt sets the "updated_at" field.
  38977. func (m *SubscriptionPlanMutation) SetUpdatedAt(t time.Time) {
  38978. m.updated_at = &t
  38979. }
  38980. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  38981. func (m *SubscriptionPlanMutation) UpdatedAt() (r time.Time, exists bool) {
  38982. v := m.updated_at
  38983. if v == nil {
  38984. return
  38985. }
  38986. return *v, true
  38987. }
  38988. // OldUpdatedAt returns the old "updated_at" field's value of the SubscriptionPlan entity.
  38989. // If the SubscriptionPlan object wasn't provided to the builder, the object is fetched from the database.
  38990. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38991. func (m *SubscriptionPlanMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  38992. if !m.op.Is(OpUpdateOne) {
  38993. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  38994. }
  38995. if m.id == nil || m.oldValue == nil {
  38996. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  38997. }
  38998. oldValue, err := m.oldValue(ctx)
  38999. if err != nil {
  39000. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  39001. }
  39002. return oldValue.UpdatedAt, nil
  39003. }
  39004. // ResetUpdatedAt resets all changes to the "updated_at" field.
  39005. func (m *SubscriptionPlanMutation) ResetUpdatedAt() {
  39006. m.updated_at = nil
  39007. }
  39008. // Where appends a list predicates to the SubscriptionPlanMutation builder.
  39009. func (m *SubscriptionPlanMutation) Where(ps ...predicate.SubscriptionPlan) {
  39010. m.predicates = append(m.predicates, ps...)
  39011. }
  39012. // WhereP appends storage-level predicates to the SubscriptionPlanMutation builder. Using this method,
  39013. // users can use type-assertion to append predicates that do not depend on any generated package.
  39014. func (m *SubscriptionPlanMutation) WhereP(ps ...func(*sql.Selector)) {
  39015. p := make([]predicate.SubscriptionPlan, len(ps))
  39016. for i := range ps {
  39017. p[i] = ps[i]
  39018. }
  39019. m.Where(p...)
  39020. }
  39021. // Op returns the operation name.
  39022. func (m *SubscriptionPlanMutation) Op() Op {
  39023. return m.op
  39024. }
  39025. // SetOp allows setting the mutation operation.
  39026. func (m *SubscriptionPlanMutation) SetOp(op Op) {
  39027. m.op = op
  39028. }
  39029. // Type returns the node type of this mutation (SubscriptionPlan).
  39030. func (m *SubscriptionPlanMutation) Type() string {
  39031. return m.typ
  39032. }
  39033. // Fields returns all fields that were changed during this mutation. Note that in
  39034. // order to get all numeric fields that were incremented/decremented, call
  39035. // AddedFields().
  39036. func (m *SubscriptionPlanMutation) Fields() []string {
  39037. fields := make([]string, 0, 14)
  39038. if m.group_id != nil {
  39039. fields = append(fields, subscriptionplan.FieldGroupID)
  39040. }
  39041. if m.name != nil {
  39042. fields = append(fields, subscriptionplan.FieldName)
  39043. }
  39044. if m.description != nil {
  39045. fields = append(fields, subscriptionplan.FieldDescription)
  39046. }
  39047. if m.price != nil {
  39048. fields = append(fields, subscriptionplan.FieldPrice)
  39049. }
  39050. if m.original_price != nil {
  39051. fields = append(fields, subscriptionplan.FieldOriginalPrice)
  39052. }
  39053. if m.currency != nil {
  39054. fields = append(fields, subscriptionplan.FieldCurrency)
  39055. }
  39056. if m.validity_days != nil {
  39057. fields = append(fields, subscriptionplan.FieldValidityDays)
  39058. }
  39059. if m.validity_unit != nil {
  39060. fields = append(fields, subscriptionplan.FieldValidityUnit)
  39061. }
  39062. if m.features != nil {
  39063. fields = append(fields, subscriptionplan.FieldFeatures)
  39064. }
  39065. if m.product_name != nil {
  39066. fields = append(fields, subscriptionplan.FieldProductName)
  39067. }
  39068. if m.for_sale != nil {
  39069. fields = append(fields, subscriptionplan.FieldForSale)
  39070. }
  39071. if m.sort_order != nil {
  39072. fields = append(fields, subscriptionplan.FieldSortOrder)
  39073. }
  39074. if m.created_at != nil {
  39075. fields = append(fields, subscriptionplan.FieldCreatedAt)
  39076. }
  39077. if m.updated_at != nil {
  39078. fields = append(fields, subscriptionplan.FieldUpdatedAt)
  39079. }
  39080. return fields
  39081. }
  39082. // Field returns the value of a field with the given name. The second boolean
  39083. // return value indicates that this field was not set, or was not defined in the
  39084. // schema.
  39085. func (m *SubscriptionPlanMutation) Field(name string) (ent.Value, bool) {
  39086. switch name {
  39087. case subscriptionplan.FieldGroupID:
  39088. return m.GroupID()
  39089. case subscriptionplan.FieldName:
  39090. return m.Name()
  39091. case subscriptionplan.FieldDescription:
  39092. return m.Description()
  39093. case subscriptionplan.FieldPrice:
  39094. return m.Price()
  39095. case subscriptionplan.FieldOriginalPrice:
  39096. return m.OriginalPrice()
  39097. case subscriptionplan.FieldCurrency:
  39098. return m.Currency()
  39099. case subscriptionplan.FieldValidityDays:
  39100. return m.ValidityDays()
  39101. case subscriptionplan.FieldValidityUnit:
  39102. return m.ValidityUnit()
  39103. case subscriptionplan.FieldFeatures:
  39104. return m.Features()
  39105. case subscriptionplan.FieldProductName:
  39106. return m.ProductName()
  39107. case subscriptionplan.FieldForSale:
  39108. return m.ForSale()
  39109. case subscriptionplan.FieldSortOrder:
  39110. return m.SortOrder()
  39111. case subscriptionplan.FieldCreatedAt:
  39112. return m.CreatedAt()
  39113. case subscriptionplan.FieldUpdatedAt:
  39114. return m.UpdatedAt()
  39115. }
  39116. return nil, false
  39117. }
  39118. // OldField returns the old value of the field from the database. An error is
  39119. // returned if the mutation operation is not UpdateOne, or the query to the
  39120. // database failed.
  39121. func (m *SubscriptionPlanMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  39122. switch name {
  39123. case subscriptionplan.FieldGroupID:
  39124. return m.OldGroupID(ctx)
  39125. case subscriptionplan.FieldName:
  39126. return m.OldName(ctx)
  39127. case subscriptionplan.FieldDescription:
  39128. return m.OldDescription(ctx)
  39129. case subscriptionplan.FieldPrice:
  39130. return m.OldPrice(ctx)
  39131. case subscriptionplan.FieldOriginalPrice:
  39132. return m.OldOriginalPrice(ctx)
  39133. case subscriptionplan.FieldCurrency:
  39134. return m.OldCurrency(ctx)
  39135. case subscriptionplan.FieldValidityDays:
  39136. return m.OldValidityDays(ctx)
  39137. case subscriptionplan.FieldValidityUnit:
  39138. return m.OldValidityUnit(ctx)
  39139. case subscriptionplan.FieldFeatures:
  39140. return m.OldFeatures(ctx)
  39141. case subscriptionplan.FieldProductName:
  39142. return m.OldProductName(ctx)
  39143. case subscriptionplan.FieldForSale:
  39144. return m.OldForSale(ctx)
  39145. case subscriptionplan.FieldSortOrder:
  39146. return m.OldSortOrder(ctx)
  39147. case subscriptionplan.FieldCreatedAt:
  39148. return m.OldCreatedAt(ctx)
  39149. case subscriptionplan.FieldUpdatedAt:
  39150. return m.OldUpdatedAt(ctx)
  39151. }
  39152. return nil, fmt.Errorf("unknown SubscriptionPlan field %s", name)
  39153. }
  39154. // SetField sets the value of a field with the given name. It returns an error if
  39155. // the field is not defined in the schema, or if the type mismatched the field
  39156. // type.
  39157. func (m *SubscriptionPlanMutation) SetField(name string, value ent.Value) error {
  39158. switch name {
  39159. case subscriptionplan.FieldGroupID:
  39160. v, ok := value.(int64)
  39161. if !ok {
  39162. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39163. }
  39164. m.SetGroupID(v)
  39165. return nil
  39166. case subscriptionplan.FieldName:
  39167. v, ok := value.(string)
  39168. if !ok {
  39169. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39170. }
  39171. m.SetName(v)
  39172. return nil
  39173. case subscriptionplan.FieldDescription:
  39174. v, ok := value.(string)
  39175. if !ok {
  39176. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39177. }
  39178. m.SetDescription(v)
  39179. return nil
  39180. case subscriptionplan.FieldPrice:
  39181. v, ok := value.(float64)
  39182. if !ok {
  39183. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39184. }
  39185. m.SetPrice(v)
  39186. return nil
  39187. case subscriptionplan.FieldOriginalPrice:
  39188. v, ok := value.(float64)
  39189. if !ok {
  39190. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39191. }
  39192. m.SetOriginalPrice(v)
  39193. return nil
  39194. case subscriptionplan.FieldCurrency:
  39195. v, ok := value.(string)
  39196. if !ok {
  39197. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39198. }
  39199. m.SetCurrency(v)
  39200. return nil
  39201. case subscriptionplan.FieldValidityDays:
  39202. v, ok := value.(int)
  39203. if !ok {
  39204. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39205. }
  39206. m.SetValidityDays(v)
  39207. return nil
  39208. case subscriptionplan.FieldValidityUnit:
  39209. v, ok := value.(string)
  39210. if !ok {
  39211. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39212. }
  39213. m.SetValidityUnit(v)
  39214. return nil
  39215. case subscriptionplan.FieldFeatures:
  39216. v, ok := value.(string)
  39217. if !ok {
  39218. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39219. }
  39220. m.SetFeatures(v)
  39221. return nil
  39222. case subscriptionplan.FieldProductName:
  39223. v, ok := value.(string)
  39224. if !ok {
  39225. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39226. }
  39227. m.SetProductName(v)
  39228. return nil
  39229. case subscriptionplan.FieldForSale:
  39230. v, ok := value.(bool)
  39231. if !ok {
  39232. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39233. }
  39234. m.SetForSale(v)
  39235. return nil
  39236. case subscriptionplan.FieldSortOrder:
  39237. v, ok := value.(int)
  39238. if !ok {
  39239. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39240. }
  39241. m.SetSortOrder(v)
  39242. return nil
  39243. case subscriptionplan.FieldCreatedAt:
  39244. v, ok := value.(time.Time)
  39245. if !ok {
  39246. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39247. }
  39248. m.SetCreatedAt(v)
  39249. return nil
  39250. case subscriptionplan.FieldUpdatedAt:
  39251. v, ok := value.(time.Time)
  39252. if !ok {
  39253. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39254. }
  39255. m.SetUpdatedAt(v)
  39256. return nil
  39257. }
  39258. return fmt.Errorf("unknown SubscriptionPlan field %s", name)
  39259. }
  39260. // AddedFields returns all numeric fields that were incremented/decremented during
  39261. // this mutation.
  39262. func (m *SubscriptionPlanMutation) AddedFields() []string {
  39263. var fields []string
  39264. if m.addgroup_id != nil {
  39265. fields = append(fields, subscriptionplan.FieldGroupID)
  39266. }
  39267. if m.addprice != nil {
  39268. fields = append(fields, subscriptionplan.FieldPrice)
  39269. }
  39270. if m.addoriginal_price != nil {
  39271. fields = append(fields, subscriptionplan.FieldOriginalPrice)
  39272. }
  39273. if m.addvalidity_days != nil {
  39274. fields = append(fields, subscriptionplan.FieldValidityDays)
  39275. }
  39276. if m.addsort_order != nil {
  39277. fields = append(fields, subscriptionplan.FieldSortOrder)
  39278. }
  39279. return fields
  39280. }
  39281. // AddedField returns the numeric value that was incremented/decremented on a field
  39282. // with the given name. The second boolean return value indicates that this field
  39283. // was not set, or was not defined in the schema.
  39284. func (m *SubscriptionPlanMutation) AddedField(name string) (ent.Value, bool) {
  39285. switch name {
  39286. case subscriptionplan.FieldGroupID:
  39287. return m.AddedGroupID()
  39288. case subscriptionplan.FieldPrice:
  39289. return m.AddedPrice()
  39290. case subscriptionplan.FieldOriginalPrice:
  39291. return m.AddedOriginalPrice()
  39292. case subscriptionplan.FieldValidityDays:
  39293. return m.AddedValidityDays()
  39294. case subscriptionplan.FieldSortOrder:
  39295. return m.AddedSortOrder()
  39296. }
  39297. return nil, false
  39298. }
  39299. // AddField adds the value to the field with the given name. It returns an error if
  39300. // the field is not defined in the schema, or if the type mismatched the field
  39301. // type.
  39302. func (m *SubscriptionPlanMutation) AddField(name string, value ent.Value) error {
  39303. switch name {
  39304. case subscriptionplan.FieldGroupID:
  39305. v, ok := value.(int64)
  39306. if !ok {
  39307. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39308. }
  39309. m.AddGroupID(v)
  39310. return nil
  39311. case subscriptionplan.FieldPrice:
  39312. v, ok := value.(float64)
  39313. if !ok {
  39314. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39315. }
  39316. m.AddPrice(v)
  39317. return nil
  39318. case subscriptionplan.FieldOriginalPrice:
  39319. v, ok := value.(float64)
  39320. if !ok {
  39321. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39322. }
  39323. m.AddOriginalPrice(v)
  39324. return nil
  39325. case subscriptionplan.FieldValidityDays:
  39326. v, ok := value.(int)
  39327. if !ok {
  39328. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39329. }
  39330. m.AddValidityDays(v)
  39331. return nil
  39332. case subscriptionplan.FieldSortOrder:
  39333. v, ok := value.(int)
  39334. if !ok {
  39335. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39336. }
  39337. m.AddSortOrder(v)
  39338. return nil
  39339. }
  39340. return fmt.Errorf("unknown SubscriptionPlan numeric field %s", name)
  39341. }
  39342. // ClearedFields returns all nullable fields that were cleared during this
  39343. // mutation.
  39344. func (m *SubscriptionPlanMutation) ClearedFields() []string {
  39345. var fields []string
  39346. if m.FieldCleared(subscriptionplan.FieldOriginalPrice) {
  39347. fields = append(fields, subscriptionplan.FieldOriginalPrice)
  39348. }
  39349. return fields
  39350. }
  39351. // FieldCleared returns a boolean indicating if a field with the given name was
  39352. // cleared in this mutation.
  39353. func (m *SubscriptionPlanMutation) FieldCleared(name string) bool {
  39354. _, ok := m.clearedFields[name]
  39355. return ok
  39356. }
  39357. // ClearField clears the value of the field with the given name. It returns an
  39358. // error if the field is not defined in the schema.
  39359. func (m *SubscriptionPlanMutation) ClearField(name string) error {
  39360. switch name {
  39361. case subscriptionplan.FieldOriginalPrice:
  39362. m.ClearOriginalPrice()
  39363. return nil
  39364. }
  39365. return fmt.Errorf("unknown SubscriptionPlan nullable field %s", name)
  39366. }
  39367. // ResetField resets all changes in the mutation for the field with the given name.
  39368. // It returns an error if the field is not defined in the schema.
  39369. func (m *SubscriptionPlanMutation) ResetField(name string) error {
  39370. switch name {
  39371. case subscriptionplan.FieldGroupID:
  39372. m.ResetGroupID()
  39373. return nil
  39374. case subscriptionplan.FieldName:
  39375. m.ResetName()
  39376. return nil
  39377. case subscriptionplan.FieldDescription:
  39378. m.ResetDescription()
  39379. return nil
  39380. case subscriptionplan.FieldPrice:
  39381. m.ResetPrice()
  39382. return nil
  39383. case subscriptionplan.FieldOriginalPrice:
  39384. m.ResetOriginalPrice()
  39385. return nil
  39386. case subscriptionplan.FieldCurrency:
  39387. m.ResetCurrency()
  39388. return nil
  39389. case subscriptionplan.FieldValidityDays:
  39390. m.ResetValidityDays()
  39391. return nil
  39392. case subscriptionplan.FieldValidityUnit:
  39393. m.ResetValidityUnit()
  39394. return nil
  39395. case subscriptionplan.FieldFeatures:
  39396. m.ResetFeatures()
  39397. return nil
  39398. case subscriptionplan.FieldProductName:
  39399. m.ResetProductName()
  39400. return nil
  39401. case subscriptionplan.FieldForSale:
  39402. m.ResetForSale()
  39403. return nil
  39404. case subscriptionplan.FieldSortOrder:
  39405. m.ResetSortOrder()
  39406. return nil
  39407. case subscriptionplan.FieldCreatedAt:
  39408. m.ResetCreatedAt()
  39409. return nil
  39410. case subscriptionplan.FieldUpdatedAt:
  39411. m.ResetUpdatedAt()
  39412. return nil
  39413. }
  39414. return fmt.Errorf("unknown SubscriptionPlan field %s", name)
  39415. }
  39416. // AddedEdges returns all edge names that were set/added in this mutation.
  39417. func (m *SubscriptionPlanMutation) AddedEdges() []string {
  39418. edges := make([]string, 0, 0)
  39419. return edges
  39420. }
  39421. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  39422. // name in this mutation.
  39423. func (m *SubscriptionPlanMutation) AddedIDs(name string) []ent.Value {
  39424. return nil
  39425. }
  39426. // RemovedEdges returns all edge names that were removed in this mutation.
  39427. func (m *SubscriptionPlanMutation) RemovedEdges() []string {
  39428. edges := make([]string, 0, 0)
  39429. return edges
  39430. }
  39431. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  39432. // the given name in this mutation.
  39433. func (m *SubscriptionPlanMutation) RemovedIDs(name string) []ent.Value {
  39434. return nil
  39435. }
  39436. // ClearedEdges returns all edge names that were cleared in this mutation.
  39437. func (m *SubscriptionPlanMutation) ClearedEdges() []string {
  39438. edges := make([]string, 0, 0)
  39439. return edges
  39440. }
  39441. // EdgeCleared returns a boolean which indicates if the edge with the given name
  39442. // was cleared in this mutation.
  39443. func (m *SubscriptionPlanMutation) EdgeCleared(name string) bool {
  39444. return false
  39445. }
  39446. // ClearEdge clears the value of the edge with the given name. It returns an error
  39447. // if that edge is not defined in the schema.
  39448. func (m *SubscriptionPlanMutation) ClearEdge(name string) error {
  39449. return fmt.Errorf("unknown SubscriptionPlan unique edge %s", name)
  39450. }
  39451. // ResetEdge resets all changes to the edge with the given name in this mutation.
  39452. // It returns an error if the edge is not defined in the schema.
  39453. func (m *SubscriptionPlanMutation) ResetEdge(name string) error {
  39454. return fmt.Errorf("unknown SubscriptionPlan edge %s", name)
  39455. }
  39456. // TLSFingerprintProfileMutation represents an operation that mutates the TLSFingerprintProfile nodes in the graph.
  39457. type TLSFingerprintProfileMutation struct {
  39458. config
  39459. op Op
  39460. typ string
  39461. id *int64
  39462. created_at *time.Time
  39463. updated_at *time.Time
  39464. name *string
  39465. description *string
  39466. enable_grease *bool
  39467. cipher_suites *[]uint16
  39468. appendcipher_suites []uint16
  39469. curves *[]uint16
  39470. appendcurves []uint16
  39471. point_formats *[]uint16
  39472. appendpoint_formats []uint16
  39473. signature_algorithms *[]uint16
  39474. appendsignature_algorithms []uint16
  39475. alpn_protocols *[]string
  39476. appendalpn_protocols []string
  39477. supported_versions *[]uint16
  39478. appendsupported_versions []uint16
  39479. key_share_groups *[]uint16
  39480. appendkey_share_groups []uint16
  39481. psk_modes *[]uint16
  39482. appendpsk_modes []uint16
  39483. extensions *[]uint16
  39484. appendextensions []uint16
  39485. clearedFields map[string]struct{}
  39486. done bool
  39487. oldValue func(context.Context) (*TLSFingerprintProfile, error)
  39488. predicates []predicate.TLSFingerprintProfile
  39489. }
  39490. var _ ent.Mutation = (*TLSFingerprintProfileMutation)(nil)
  39491. // tlsfingerprintprofileOption allows management of the mutation configuration using functional options.
  39492. type tlsfingerprintprofileOption func(*TLSFingerprintProfileMutation)
  39493. // newTLSFingerprintProfileMutation creates new mutation for the TLSFingerprintProfile entity.
  39494. func newTLSFingerprintProfileMutation(c config, op Op, opts ...tlsfingerprintprofileOption) *TLSFingerprintProfileMutation {
  39495. m := &TLSFingerprintProfileMutation{
  39496. config: c,
  39497. op: op,
  39498. typ: TypeTLSFingerprintProfile,
  39499. clearedFields: make(map[string]struct{}),
  39500. }
  39501. for _, opt := range opts {
  39502. opt(m)
  39503. }
  39504. return m
  39505. }
  39506. // withTLSFingerprintProfileID sets the ID field of the mutation.
  39507. func withTLSFingerprintProfileID(id int64) tlsfingerprintprofileOption {
  39508. return func(m *TLSFingerprintProfileMutation) {
  39509. var (
  39510. err error
  39511. once sync.Once
  39512. value *TLSFingerprintProfile
  39513. )
  39514. m.oldValue = func(ctx context.Context) (*TLSFingerprintProfile, error) {
  39515. once.Do(func() {
  39516. if m.done {
  39517. err = errors.New("querying old values post mutation is not allowed")
  39518. } else {
  39519. value, err = m.Client().TLSFingerprintProfile.Get(ctx, id)
  39520. }
  39521. })
  39522. return value, err
  39523. }
  39524. m.id = &id
  39525. }
  39526. }
  39527. // withTLSFingerprintProfile sets the old TLSFingerprintProfile of the mutation.
  39528. func withTLSFingerprintProfile(node *TLSFingerprintProfile) tlsfingerprintprofileOption {
  39529. return func(m *TLSFingerprintProfileMutation) {
  39530. m.oldValue = func(context.Context) (*TLSFingerprintProfile, error) {
  39531. return node, nil
  39532. }
  39533. m.id = &node.ID
  39534. }
  39535. }
  39536. // Client returns a new `ent.Client` from the mutation. If the mutation was
  39537. // executed in a transaction (ent.Tx), a transactional client is returned.
  39538. func (m TLSFingerprintProfileMutation) Client() *Client {
  39539. client := &Client{config: m.config}
  39540. client.init()
  39541. return client
  39542. }
  39543. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  39544. // it returns an error otherwise.
  39545. func (m TLSFingerprintProfileMutation) Tx() (*Tx, error) {
  39546. if _, ok := m.driver.(*txDriver); !ok {
  39547. return nil, errors.New("ent: mutation is not running in a transaction")
  39548. }
  39549. tx := &Tx{config: m.config}
  39550. tx.init()
  39551. return tx, nil
  39552. }
  39553. // ID returns the ID value in the mutation. Note that the ID is only available
  39554. // if it was provided to the builder or after it was returned from the database.
  39555. func (m *TLSFingerprintProfileMutation) ID() (id int64, exists bool) {
  39556. if m.id == nil {
  39557. return
  39558. }
  39559. return *m.id, true
  39560. }
  39561. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  39562. // That means, if the mutation is applied within a transaction with an isolation level such
  39563. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  39564. // or updated by the mutation.
  39565. func (m *TLSFingerprintProfileMutation) IDs(ctx context.Context) ([]int64, error) {
  39566. switch {
  39567. case m.op.Is(OpUpdateOne | OpDeleteOne):
  39568. id, exists := m.ID()
  39569. if exists {
  39570. return []int64{id}, nil
  39571. }
  39572. fallthrough
  39573. case m.op.Is(OpUpdate | OpDelete):
  39574. return m.Client().TLSFingerprintProfile.Query().Where(m.predicates...).IDs(ctx)
  39575. default:
  39576. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  39577. }
  39578. }
  39579. // SetCreatedAt sets the "created_at" field.
  39580. func (m *TLSFingerprintProfileMutation) SetCreatedAt(t time.Time) {
  39581. m.created_at = &t
  39582. }
  39583. // CreatedAt returns the value of the "created_at" field in the mutation.
  39584. func (m *TLSFingerprintProfileMutation) CreatedAt() (r time.Time, exists bool) {
  39585. v := m.created_at
  39586. if v == nil {
  39587. return
  39588. }
  39589. return *v, true
  39590. }
  39591. // OldCreatedAt returns the old "created_at" field's value of the TLSFingerprintProfile entity.
  39592. // If the TLSFingerprintProfile object wasn't provided to the builder, the object is fetched from the database.
  39593. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39594. func (m *TLSFingerprintProfileMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  39595. if !m.op.Is(OpUpdateOne) {
  39596. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  39597. }
  39598. if m.id == nil || m.oldValue == nil {
  39599. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  39600. }
  39601. oldValue, err := m.oldValue(ctx)
  39602. if err != nil {
  39603. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  39604. }
  39605. return oldValue.CreatedAt, nil
  39606. }
  39607. // ResetCreatedAt resets all changes to the "created_at" field.
  39608. func (m *TLSFingerprintProfileMutation) ResetCreatedAt() {
  39609. m.created_at = nil
  39610. }
  39611. // SetUpdatedAt sets the "updated_at" field.
  39612. func (m *TLSFingerprintProfileMutation) SetUpdatedAt(t time.Time) {
  39613. m.updated_at = &t
  39614. }
  39615. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  39616. func (m *TLSFingerprintProfileMutation) UpdatedAt() (r time.Time, exists bool) {
  39617. v := m.updated_at
  39618. if v == nil {
  39619. return
  39620. }
  39621. return *v, true
  39622. }
  39623. // OldUpdatedAt returns the old "updated_at" field's value of the TLSFingerprintProfile entity.
  39624. // If the TLSFingerprintProfile object wasn't provided to the builder, the object is fetched from the database.
  39625. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39626. func (m *TLSFingerprintProfileMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  39627. if !m.op.Is(OpUpdateOne) {
  39628. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  39629. }
  39630. if m.id == nil || m.oldValue == nil {
  39631. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  39632. }
  39633. oldValue, err := m.oldValue(ctx)
  39634. if err != nil {
  39635. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  39636. }
  39637. return oldValue.UpdatedAt, nil
  39638. }
  39639. // ResetUpdatedAt resets all changes to the "updated_at" field.
  39640. func (m *TLSFingerprintProfileMutation) ResetUpdatedAt() {
  39641. m.updated_at = nil
  39642. }
  39643. // SetName sets the "name" field.
  39644. func (m *TLSFingerprintProfileMutation) SetName(s string) {
  39645. m.name = &s
  39646. }
  39647. // Name returns the value of the "name" field in the mutation.
  39648. func (m *TLSFingerprintProfileMutation) Name() (r string, exists bool) {
  39649. v := m.name
  39650. if v == nil {
  39651. return
  39652. }
  39653. return *v, true
  39654. }
  39655. // OldName returns the old "name" field's value of the TLSFingerprintProfile entity.
  39656. // If the TLSFingerprintProfile object wasn't provided to the builder, the object is fetched from the database.
  39657. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39658. func (m *TLSFingerprintProfileMutation) OldName(ctx context.Context) (v string, err error) {
  39659. if !m.op.Is(OpUpdateOne) {
  39660. return v, errors.New("OldName is only allowed on UpdateOne operations")
  39661. }
  39662. if m.id == nil || m.oldValue == nil {
  39663. return v, errors.New("OldName requires an ID field in the mutation")
  39664. }
  39665. oldValue, err := m.oldValue(ctx)
  39666. if err != nil {
  39667. return v, fmt.Errorf("querying old value for OldName: %w", err)
  39668. }
  39669. return oldValue.Name, nil
  39670. }
  39671. // ResetName resets all changes to the "name" field.
  39672. func (m *TLSFingerprintProfileMutation) ResetName() {
  39673. m.name = nil
  39674. }
  39675. // SetDescription sets the "description" field.
  39676. func (m *TLSFingerprintProfileMutation) SetDescription(s string) {
  39677. m.description = &s
  39678. }
  39679. // Description returns the value of the "description" field in the mutation.
  39680. func (m *TLSFingerprintProfileMutation) Description() (r string, exists bool) {
  39681. v := m.description
  39682. if v == nil {
  39683. return
  39684. }
  39685. return *v, true
  39686. }
  39687. // OldDescription returns the old "description" field's value of the TLSFingerprintProfile entity.
  39688. // If the TLSFingerprintProfile object wasn't provided to the builder, the object is fetched from the database.
  39689. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39690. func (m *TLSFingerprintProfileMutation) OldDescription(ctx context.Context) (v *string, err error) {
  39691. if !m.op.Is(OpUpdateOne) {
  39692. return v, errors.New("OldDescription is only allowed on UpdateOne operations")
  39693. }
  39694. if m.id == nil || m.oldValue == nil {
  39695. return v, errors.New("OldDescription requires an ID field in the mutation")
  39696. }
  39697. oldValue, err := m.oldValue(ctx)
  39698. if err != nil {
  39699. return v, fmt.Errorf("querying old value for OldDescription: %w", err)
  39700. }
  39701. return oldValue.Description, nil
  39702. }
  39703. // ClearDescription clears the value of the "description" field.
  39704. func (m *TLSFingerprintProfileMutation) ClearDescription() {
  39705. m.description = nil
  39706. m.clearedFields[tlsfingerprintprofile.FieldDescription] = struct{}{}
  39707. }
  39708. // DescriptionCleared returns if the "description" field was cleared in this mutation.
  39709. func (m *TLSFingerprintProfileMutation) DescriptionCleared() bool {
  39710. _, ok := m.clearedFields[tlsfingerprintprofile.FieldDescription]
  39711. return ok
  39712. }
  39713. // ResetDescription resets all changes to the "description" field.
  39714. func (m *TLSFingerprintProfileMutation) ResetDescription() {
  39715. m.description = nil
  39716. delete(m.clearedFields, tlsfingerprintprofile.FieldDescription)
  39717. }
  39718. // SetEnableGrease sets the "enable_grease" field.
  39719. func (m *TLSFingerprintProfileMutation) SetEnableGrease(b bool) {
  39720. m.enable_grease = &b
  39721. }
  39722. // EnableGrease returns the value of the "enable_grease" field in the mutation.
  39723. func (m *TLSFingerprintProfileMutation) EnableGrease() (r bool, exists bool) {
  39724. v := m.enable_grease
  39725. if v == nil {
  39726. return
  39727. }
  39728. return *v, true
  39729. }
  39730. // OldEnableGrease returns the old "enable_grease" field's value of the TLSFingerprintProfile entity.
  39731. // If the TLSFingerprintProfile object wasn't provided to the builder, the object is fetched from the database.
  39732. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39733. func (m *TLSFingerprintProfileMutation) OldEnableGrease(ctx context.Context) (v bool, err error) {
  39734. if !m.op.Is(OpUpdateOne) {
  39735. return v, errors.New("OldEnableGrease is only allowed on UpdateOne operations")
  39736. }
  39737. if m.id == nil || m.oldValue == nil {
  39738. return v, errors.New("OldEnableGrease requires an ID field in the mutation")
  39739. }
  39740. oldValue, err := m.oldValue(ctx)
  39741. if err != nil {
  39742. return v, fmt.Errorf("querying old value for OldEnableGrease: %w", err)
  39743. }
  39744. return oldValue.EnableGrease, nil
  39745. }
  39746. // ResetEnableGrease resets all changes to the "enable_grease" field.
  39747. func (m *TLSFingerprintProfileMutation) ResetEnableGrease() {
  39748. m.enable_grease = nil
  39749. }
  39750. // SetCipherSuites sets the "cipher_suites" field.
  39751. func (m *TLSFingerprintProfileMutation) SetCipherSuites(u []uint16) {
  39752. m.cipher_suites = &u
  39753. m.appendcipher_suites = nil
  39754. }
  39755. // CipherSuites returns the value of the "cipher_suites" field in the mutation.
  39756. func (m *TLSFingerprintProfileMutation) CipherSuites() (r []uint16, exists bool) {
  39757. v := m.cipher_suites
  39758. if v == nil {
  39759. return
  39760. }
  39761. return *v, true
  39762. }
  39763. // OldCipherSuites returns the old "cipher_suites" field's value of the TLSFingerprintProfile entity.
  39764. // If the TLSFingerprintProfile object wasn't provided to the builder, the object is fetched from the database.
  39765. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39766. func (m *TLSFingerprintProfileMutation) OldCipherSuites(ctx context.Context) (v []uint16, err error) {
  39767. if !m.op.Is(OpUpdateOne) {
  39768. return v, errors.New("OldCipherSuites is only allowed on UpdateOne operations")
  39769. }
  39770. if m.id == nil || m.oldValue == nil {
  39771. return v, errors.New("OldCipherSuites requires an ID field in the mutation")
  39772. }
  39773. oldValue, err := m.oldValue(ctx)
  39774. if err != nil {
  39775. return v, fmt.Errorf("querying old value for OldCipherSuites: %w", err)
  39776. }
  39777. return oldValue.CipherSuites, nil
  39778. }
  39779. // AppendCipherSuites adds u to the "cipher_suites" field.
  39780. func (m *TLSFingerprintProfileMutation) AppendCipherSuites(u []uint16) {
  39781. m.appendcipher_suites = append(m.appendcipher_suites, u...)
  39782. }
  39783. // AppendedCipherSuites returns the list of values that were appended to the "cipher_suites" field in this mutation.
  39784. func (m *TLSFingerprintProfileMutation) AppendedCipherSuites() ([]uint16, bool) {
  39785. if len(m.appendcipher_suites) == 0 {
  39786. return nil, false
  39787. }
  39788. return m.appendcipher_suites, true
  39789. }
  39790. // ClearCipherSuites clears the value of the "cipher_suites" field.
  39791. func (m *TLSFingerprintProfileMutation) ClearCipherSuites() {
  39792. m.cipher_suites = nil
  39793. m.appendcipher_suites = nil
  39794. m.clearedFields[tlsfingerprintprofile.FieldCipherSuites] = struct{}{}
  39795. }
  39796. // CipherSuitesCleared returns if the "cipher_suites" field was cleared in this mutation.
  39797. func (m *TLSFingerprintProfileMutation) CipherSuitesCleared() bool {
  39798. _, ok := m.clearedFields[tlsfingerprintprofile.FieldCipherSuites]
  39799. return ok
  39800. }
  39801. // ResetCipherSuites resets all changes to the "cipher_suites" field.
  39802. func (m *TLSFingerprintProfileMutation) ResetCipherSuites() {
  39803. m.cipher_suites = nil
  39804. m.appendcipher_suites = nil
  39805. delete(m.clearedFields, tlsfingerprintprofile.FieldCipherSuites)
  39806. }
  39807. // SetCurves sets the "curves" field.
  39808. func (m *TLSFingerprintProfileMutation) SetCurves(u []uint16) {
  39809. m.curves = &u
  39810. m.appendcurves = nil
  39811. }
  39812. // Curves returns the value of the "curves" field in the mutation.
  39813. func (m *TLSFingerprintProfileMutation) Curves() (r []uint16, exists bool) {
  39814. v := m.curves
  39815. if v == nil {
  39816. return
  39817. }
  39818. return *v, true
  39819. }
  39820. // OldCurves returns the old "curves" field's value of the TLSFingerprintProfile entity.
  39821. // If the TLSFingerprintProfile object wasn't provided to the builder, the object is fetched from the database.
  39822. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39823. func (m *TLSFingerprintProfileMutation) OldCurves(ctx context.Context) (v []uint16, err error) {
  39824. if !m.op.Is(OpUpdateOne) {
  39825. return v, errors.New("OldCurves is only allowed on UpdateOne operations")
  39826. }
  39827. if m.id == nil || m.oldValue == nil {
  39828. return v, errors.New("OldCurves requires an ID field in the mutation")
  39829. }
  39830. oldValue, err := m.oldValue(ctx)
  39831. if err != nil {
  39832. return v, fmt.Errorf("querying old value for OldCurves: %w", err)
  39833. }
  39834. return oldValue.Curves, nil
  39835. }
  39836. // AppendCurves adds u to the "curves" field.
  39837. func (m *TLSFingerprintProfileMutation) AppendCurves(u []uint16) {
  39838. m.appendcurves = append(m.appendcurves, u...)
  39839. }
  39840. // AppendedCurves returns the list of values that were appended to the "curves" field in this mutation.
  39841. func (m *TLSFingerprintProfileMutation) AppendedCurves() ([]uint16, bool) {
  39842. if len(m.appendcurves) == 0 {
  39843. return nil, false
  39844. }
  39845. return m.appendcurves, true
  39846. }
  39847. // ClearCurves clears the value of the "curves" field.
  39848. func (m *TLSFingerprintProfileMutation) ClearCurves() {
  39849. m.curves = nil
  39850. m.appendcurves = nil
  39851. m.clearedFields[tlsfingerprintprofile.FieldCurves] = struct{}{}
  39852. }
  39853. // CurvesCleared returns if the "curves" field was cleared in this mutation.
  39854. func (m *TLSFingerprintProfileMutation) CurvesCleared() bool {
  39855. _, ok := m.clearedFields[tlsfingerprintprofile.FieldCurves]
  39856. return ok
  39857. }
  39858. // ResetCurves resets all changes to the "curves" field.
  39859. func (m *TLSFingerprintProfileMutation) ResetCurves() {
  39860. m.curves = nil
  39861. m.appendcurves = nil
  39862. delete(m.clearedFields, tlsfingerprintprofile.FieldCurves)
  39863. }
  39864. // SetPointFormats sets the "point_formats" field.
  39865. func (m *TLSFingerprintProfileMutation) SetPointFormats(u []uint16) {
  39866. m.point_formats = &u
  39867. m.appendpoint_formats = nil
  39868. }
  39869. // PointFormats returns the value of the "point_formats" field in the mutation.
  39870. func (m *TLSFingerprintProfileMutation) PointFormats() (r []uint16, exists bool) {
  39871. v := m.point_formats
  39872. if v == nil {
  39873. return
  39874. }
  39875. return *v, true
  39876. }
  39877. // OldPointFormats returns the old "point_formats" field's value of the TLSFingerprintProfile entity.
  39878. // If the TLSFingerprintProfile object wasn't provided to the builder, the object is fetched from the database.
  39879. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39880. func (m *TLSFingerprintProfileMutation) OldPointFormats(ctx context.Context) (v []uint16, err error) {
  39881. if !m.op.Is(OpUpdateOne) {
  39882. return v, errors.New("OldPointFormats is only allowed on UpdateOne operations")
  39883. }
  39884. if m.id == nil || m.oldValue == nil {
  39885. return v, errors.New("OldPointFormats requires an ID field in the mutation")
  39886. }
  39887. oldValue, err := m.oldValue(ctx)
  39888. if err != nil {
  39889. return v, fmt.Errorf("querying old value for OldPointFormats: %w", err)
  39890. }
  39891. return oldValue.PointFormats, nil
  39892. }
  39893. // AppendPointFormats adds u to the "point_formats" field.
  39894. func (m *TLSFingerprintProfileMutation) AppendPointFormats(u []uint16) {
  39895. m.appendpoint_formats = append(m.appendpoint_formats, u...)
  39896. }
  39897. // AppendedPointFormats returns the list of values that were appended to the "point_formats" field in this mutation.
  39898. func (m *TLSFingerprintProfileMutation) AppendedPointFormats() ([]uint16, bool) {
  39899. if len(m.appendpoint_formats) == 0 {
  39900. return nil, false
  39901. }
  39902. return m.appendpoint_formats, true
  39903. }
  39904. // ClearPointFormats clears the value of the "point_formats" field.
  39905. func (m *TLSFingerprintProfileMutation) ClearPointFormats() {
  39906. m.point_formats = nil
  39907. m.appendpoint_formats = nil
  39908. m.clearedFields[tlsfingerprintprofile.FieldPointFormats] = struct{}{}
  39909. }
  39910. // PointFormatsCleared returns if the "point_formats" field was cleared in this mutation.
  39911. func (m *TLSFingerprintProfileMutation) PointFormatsCleared() bool {
  39912. _, ok := m.clearedFields[tlsfingerprintprofile.FieldPointFormats]
  39913. return ok
  39914. }
  39915. // ResetPointFormats resets all changes to the "point_formats" field.
  39916. func (m *TLSFingerprintProfileMutation) ResetPointFormats() {
  39917. m.point_formats = nil
  39918. m.appendpoint_formats = nil
  39919. delete(m.clearedFields, tlsfingerprintprofile.FieldPointFormats)
  39920. }
  39921. // SetSignatureAlgorithms sets the "signature_algorithms" field.
  39922. func (m *TLSFingerprintProfileMutation) SetSignatureAlgorithms(u []uint16) {
  39923. m.signature_algorithms = &u
  39924. m.appendsignature_algorithms = nil
  39925. }
  39926. // SignatureAlgorithms returns the value of the "signature_algorithms" field in the mutation.
  39927. func (m *TLSFingerprintProfileMutation) SignatureAlgorithms() (r []uint16, exists bool) {
  39928. v := m.signature_algorithms
  39929. if v == nil {
  39930. return
  39931. }
  39932. return *v, true
  39933. }
  39934. // OldSignatureAlgorithms returns the old "signature_algorithms" field's value of the TLSFingerprintProfile entity.
  39935. // If the TLSFingerprintProfile object wasn't provided to the builder, the object is fetched from the database.
  39936. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39937. func (m *TLSFingerprintProfileMutation) OldSignatureAlgorithms(ctx context.Context) (v []uint16, err error) {
  39938. if !m.op.Is(OpUpdateOne) {
  39939. return v, errors.New("OldSignatureAlgorithms is only allowed on UpdateOne operations")
  39940. }
  39941. if m.id == nil || m.oldValue == nil {
  39942. return v, errors.New("OldSignatureAlgorithms requires an ID field in the mutation")
  39943. }
  39944. oldValue, err := m.oldValue(ctx)
  39945. if err != nil {
  39946. return v, fmt.Errorf("querying old value for OldSignatureAlgorithms: %w", err)
  39947. }
  39948. return oldValue.SignatureAlgorithms, nil
  39949. }
  39950. // AppendSignatureAlgorithms adds u to the "signature_algorithms" field.
  39951. func (m *TLSFingerprintProfileMutation) AppendSignatureAlgorithms(u []uint16) {
  39952. m.appendsignature_algorithms = append(m.appendsignature_algorithms, u...)
  39953. }
  39954. // AppendedSignatureAlgorithms returns the list of values that were appended to the "signature_algorithms" field in this mutation.
  39955. func (m *TLSFingerprintProfileMutation) AppendedSignatureAlgorithms() ([]uint16, bool) {
  39956. if len(m.appendsignature_algorithms) == 0 {
  39957. return nil, false
  39958. }
  39959. return m.appendsignature_algorithms, true
  39960. }
  39961. // ClearSignatureAlgorithms clears the value of the "signature_algorithms" field.
  39962. func (m *TLSFingerprintProfileMutation) ClearSignatureAlgorithms() {
  39963. m.signature_algorithms = nil
  39964. m.appendsignature_algorithms = nil
  39965. m.clearedFields[tlsfingerprintprofile.FieldSignatureAlgorithms] = struct{}{}
  39966. }
  39967. // SignatureAlgorithmsCleared returns if the "signature_algorithms" field was cleared in this mutation.
  39968. func (m *TLSFingerprintProfileMutation) SignatureAlgorithmsCleared() bool {
  39969. _, ok := m.clearedFields[tlsfingerprintprofile.FieldSignatureAlgorithms]
  39970. return ok
  39971. }
  39972. // ResetSignatureAlgorithms resets all changes to the "signature_algorithms" field.
  39973. func (m *TLSFingerprintProfileMutation) ResetSignatureAlgorithms() {
  39974. m.signature_algorithms = nil
  39975. m.appendsignature_algorithms = nil
  39976. delete(m.clearedFields, tlsfingerprintprofile.FieldSignatureAlgorithms)
  39977. }
  39978. // SetAlpnProtocols sets the "alpn_protocols" field.
  39979. func (m *TLSFingerprintProfileMutation) SetAlpnProtocols(s []string) {
  39980. m.alpn_protocols = &s
  39981. m.appendalpn_protocols = nil
  39982. }
  39983. // AlpnProtocols returns the value of the "alpn_protocols" field in the mutation.
  39984. func (m *TLSFingerprintProfileMutation) AlpnProtocols() (r []string, exists bool) {
  39985. v := m.alpn_protocols
  39986. if v == nil {
  39987. return
  39988. }
  39989. return *v, true
  39990. }
  39991. // OldAlpnProtocols returns the old "alpn_protocols" field's value of the TLSFingerprintProfile entity.
  39992. // If the TLSFingerprintProfile object wasn't provided to the builder, the object is fetched from the database.
  39993. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39994. func (m *TLSFingerprintProfileMutation) OldAlpnProtocols(ctx context.Context) (v []string, err error) {
  39995. if !m.op.Is(OpUpdateOne) {
  39996. return v, errors.New("OldAlpnProtocols is only allowed on UpdateOne operations")
  39997. }
  39998. if m.id == nil || m.oldValue == nil {
  39999. return v, errors.New("OldAlpnProtocols requires an ID field in the mutation")
  40000. }
  40001. oldValue, err := m.oldValue(ctx)
  40002. if err != nil {
  40003. return v, fmt.Errorf("querying old value for OldAlpnProtocols: %w", err)
  40004. }
  40005. return oldValue.AlpnProtocols, nil
  40006. }
  40007. // AppendAlpnProtocols adds s to the "alpn_protocols" field.
  40008. func (m *TLSFingerprintProfileMutation) AppendAlpnProtocols(s []string) {
  40009. m.appendalpn_protocols = append(m.appendalpn_protocols, s...)
  40010. }
  40011. // AppendedAlpnProtocols returns the list of values that were appended to the "alpn_protocols" field in this mutation.
  40012. func (m *TLSFingerprintProfileMutation) AppendedAlpnProtocols() ([]string, bool) {
  40013. if len(m.appendalpn_protocols) == 0 {
  40014. return nil, false
  40015. }
  40016. return m.appendalpn_protocols, true
  40017. }
  40018. // ClearAlpnProtocols clears the value of the "alpn_protocols" field.
  40019. func (m *TLSFingerprintProfileMutation) ClearAlpnProtocols() {
  40020. m.alpn_protocols = nil
  40021. m.appendalpn_protocols = nil
  40022. m.clearedFields[tlsfingerprintprofile.FieldAlpnProtocols] = struct{}{}
  40023. }
  40024. // AlpnProtocolsCleared returns if the "alpn_protocols" field was cleared in this mutation.
  40025. func (m *TLSFingerprintProfileMutation) AlpnProtocolsCleared() bool {
  40026. _, ok := m.clearedFields[tlsfingerprintprofile.FieldAlpnProtocols]
  40027. return ok
  40028. }
  40029. // ResetAlpnProtocols resets all changes to the "alpn_protocols" field.
  40030. func (m *TLSFingerprintProfileMutation) ResetAlpnProtocols() {
  40031. m.alpn_protocols = nil
  40032. m.appendalpn_protocols = nil
  40033. delete(m.clearedFields, tlsfingerprintprofile.FieldAlpnProtocols)
  40034. }
  40035. // SetSupportedVersions sets the "supported_versions" field.
  40036. func (m *TLSFingerprintProfileMutation) SetSupportedVersions(u []uint16) {
  40037. m.supported_versions = &u
  40038. m.appendsupported_versions = nil
  40039. }
  40040. // SupportedVersions returns the value of the "supported_versions" field in the mutation.
  40041. func (m *TLSFingerprintProfileMutation) SupportedVersions() (r []uint16, exists bool) {
  40042. v := m.supported_versions
  40043. if v == nil {
  40044. return
  40045. }
  40046. return *v, true
  40047. }
  40048. // OldSupportedVersions returns the old "supported_versions" field's value of the TLSFingerprintProfile entity.
  40049. // If the TLSFingerprintProfile object wasn't provided to the builder, the object is fetched from the database.
  40050. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40051. func (m *TLSFingerprintProfileMutation) OldSupportedVersions(ctx context.Context) (v []uint16, err error) {
  40052. if !m.op.Is(OpUpdateOne) {
  40053. return v, errors.New("OldSupportedVersions is only allowed on UpdateOne operations")
  40054. }
  40055. if m.id == nil || m.oldValue == nil {
  40056. return v, errors.New("OldSupportedVersions requires an ID field in the mutation")
  40057. }
  40058. oldValue, err := m.oldValue(ctx)
  40059. if err != nil {
  40060. return v, fmt.Errorf("querying old value for OldSupportedVersions: %w", err)
  40061. }
  40062. return oldValue.SupportedVersions, nil
  40063. }
  40064. // AppendSupportedVersions adds u to the "supported_versions" field.
  40065. func (m *TLSFingerprintProfileMutation) AppendSupportedVersions(u []uint16) {
  40066. m.appendsupported_versions = append(m.appendsupported_versions, u...)
  40067. }
  40068. // AppendedSupportedVersions returns the list of values that were appended to the "supported_versions" field in this mutation.
  40069. func (m *TLSFingerprintProfileMutation) AppendedSupportedVersions() ([]uint16, bool) {
  40070. if len(m.appendsupported_versions) == 0 {
  40071. return nil, false
  40072. }
  40073. return m.appendsupported_versions, true
  40074. }
  40075. // ClearSupportedVersions clears the value of the "supported_versions" field.
  40076. func (m *TLSFingerprintProfileMutation) ClearSupportedVersions() {
  40077. m.supported_versions = nil
  40078. m.appendsupported_versions = nil
  40079. m.clearedFields[tlsfingerprintprofile.FieldSupportedVersions] = struct{}{}
  40080. }
  40081. // SupportedVersionsCleared returns if the "supported_versions" field was cleared in this mutation.
  40082. func (m *TLSFingerprintProfileMutation) SupportedVersionsCleared() bool {
  40083. _, ok := m.clearedFields[tlsfingerprintprofile.FieldSupportedVersions]
  40084. return ok
  40085. }
  40086. // ResetSupportedVersions resets all changes to the "supported_versions" field.
  40087. func (m *TLSFingerprintProfileMutation) ResetSupportedVersions() {
  40088. m.supported_versions = nil
  40089. m.appendsupported_versions = nil
  40090. delete(m.clearedFields, tlsfingerprintprofile.FieldSupportedVersions)
  40091. }
  40092. // SetKeyShareGroups sets the "key_share_groups" field.
  40093. func (m *TLSFingerprintProfileMutation) SetKeyShareGroups(u []uint16) {
  40094. m.key_share_groups = &u
  40095. m.appendkey_share_groups = nil
  40096. }
  40097. // KeyShareGroups returns the value of the "key_share_groups" field in the mutation.
  40098. func (m *TLSFingerprintProfileMutation) KeyShareGroups() (r []uint16, exists bool) {
  40099. v := m.key_share_groups
  40100. if v == nil {
  40101. return
  40102. }
  40103. return *v, true
  40104. }
  40105. // OldKeyShareGroups returns the old "key_share_groups" field's value of the TLSFingerprintProfile entity.
  40106. // If the TLSFingerprintProfile object wasn't provided to the builder, the object is fetched from the database.
  40107. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40108. func (m *TLSFingerprintProfileMutation) OldKeyShareGroups(ctx context.Context) (v []uint16, err error) {
  40109. if !m.op.Is(OpUpdateOne) {
  40110. return v, errors.New("OldKeyShareGroups is only allowed on UpdateOne operations")
  40111. }
  40112. if m.id == nil || m.oldValue == nil {
  40113. return v, errors.New("OldKeyShareGroups requires an ID field in the mutation")
  40114. }
  40115. oldValue, err := m.oldValue(ctx)
  40116. if err != nil {
  40117. return v, fmt.Errorf("querying old value for OldKeyShareGroups: %w", err)
  40118. }
  40119. return oldValue.KeyShareGroups, nil
  40120. }
  40121. // AppendKeyShareGroups adds u to the "key_share_groups" field.
  40122. func (m *TLSFingerprintProfileMutation) AppendKeyShareGroups(u []uint16) {
  40123. m.appendkey_share_groups = append(m.appendkey_share_groups, u...)
  40124. }
  40125. // AppendedKeyShareGroups returns the list of values that were appended to the "key_share_groups" field in this mutation.
  40126. func (m *TLSFingerprintProfileMutation) AppendedKeyShareGroups() ([]uint16, bool) {
  40127. if len(m.appendkey_share_groups) == 0 {
  40128. return nil, false
  40129. }
  40130. return m.appendkey_share_groups, true
  40131. }
  40132. // ClearKeyShareGroups clears the value of the "key_share_groups" field.
  40133. func (m *TLSFingerprintProfileMutation) ClearKeyShareGroups() {
  40134. m.key_share_groups = nil
  40135. m.appendkey_share_groups = nil
  40136. m.clearedFields[tlsfingerprintprofile.FieldKeyShareGroups] = struct{}{}
  40137. }
  40138. // KeyShareGroupsCleared returns if the "key_share_groups" field was cleared in this mutation.
  40139. func (m *TLSFingerprintProfileMutation) KeyShareGroupsCleared() bool {
  40140. _, ok := m.clearedFields[tlsfingerprintprofile.FieldKeyShareGroups]
  40141. return ok
  40142. }
  40143. // ResetKeyShareGroups resets all changes to the "key_share_groups" field.
  40144. func (m *TLSFingerprintProfileMutation) ResetKeyShareGroups() {
  40145. m.key_share_groups = nil
  40146. m.appendkey_share_groups = nil
  40147. delete(m.clearedFields, tlsfingerprintprofile.FieldKeyShareGroups)
  40148. }
  40149. // SetPskModes sets the "psk_modes" field.
  40150. func (m *TLSFingerprintProfileMutation) SetPskModes(u []uint16) {
  40151. m.psk_modes = &u
  40152. m.appendpsk_modes = nil
  40153. }
  40154. // PskModes returns the value of the "psk_modes" field in the mutation.
  40155. func (m *TLSFingerprintProfileMutation) PskModes() (r []uint16, exists bool) {
  40156. v := m.psk_modes
  40157. if v == nil {
  40158. return
  40159. }
  40160. return *v, true
  40161. }
  40162. // OldPskModes returns the old "psk_modes" field's value of the TLSFingerprintProfile entity.
  40163. // If the TLSFingerprintProfile object wasn't provided to the builder, the object is fetched from the database.
  40164. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40165. func (m *TLSFingerprintProfileMutation) OldPskModes(ctx context.Context) (v []uint16, err error) {
  40166. if !m.op.Is(OpUpdateOne) {
  40167. return v, errors.New("OldPskModes is only allowed on UpdateOne operations")
  40168. }
  40169. if m.id == nil || m.oldValue == nil {
  40170. return v, errors.New("OldPskModes requires an ID field in the mutation")
  40171. }
  40172. oldValue, err := m.oldValue(ctx)
  40173. if err != nil {
  40174. return v, fmt.Errorf("querying old value for OldPskModes: %w", err)
  40175. }
  40176. return oldValue.PskModes, nil
  40177. }
  40178. // AppendPskModes adds u to the "psk_modes" field.
  40179. func (m *TLSFingerprintProfileMutation) AppendPskModes(u []uint16) {
  40180. m.appendpsk_modes = append(m.appendpsk_modes, u...)
  40181. }
  40182. // AppendedPskModes returns the list of values that were appended to the "psk_modes" field in this mutation.
  40183. func (m *TLSFingerprintProfileMutation) AppendedPskModes() ([]uint16, bool) {
  40184. if len(m.appendpsk_modes) == 0 {
  40185. return nil, false
  40186. }
  40187. return m.appendpsk_modes, true
  40188. }
  40189. // ClearPskModes clears the value of the "psk_modes" field.
  40190. func (m *TLSFingerprintProfileMutation) ClearPskModes() {
  40191. m.psk_modes = nil
  40192. m.appendpsk_modes = nil
  40193. m.clearedFields[tlsfingerprintprofile.FieldPskModes] = struct{}{}
  40194. }
  40195. // PskModesCleared returns if the "psk_modes" field was cleared in this mutation.
  40196. func (m *TLSFingerprintProfileMutation) PskModesCleared() bool {
  40197. _, ok := m.clearedFields[tlsfingerprintprofile.FieldPskModes]
  40198. return ok
  40199. }
  40200. // ResetPskModes resets all changes to the "psk_modes" field.
  40201. func (m *TLSFingerprintProfileMutation) ResetPskModes() {
  40202. m.psk_modes = nil
  40203. m.appendpsk_modes = nil
  40204. delete(m.clearedFields, tlsfingerprintprofile.FieldPskModes)
  40205. }
  40206. // SetExtensions sets the "extensions" field.
  40207. func (m *TLSFingerprintProfileMutation) SetExtensions(u []uint16) {
  40208. m.extensions = &u
  40209. m.appendextensions = nil
  40210. }
  40211. // Extensions returns the value of the "extensions" field in the mutation.
  40212. func (m *TLSFingerprintProfileMutation) Extensions() (r []uint16, exists bool) {
  40213. v := m.extensions
  40214. if v == nil {
  40215. return
  40216. }
  40217. return *v, true
  40218. }
  40219. // OldExtensions returns the old "extensions" field's value of the TLSFingerprintProfile entity.
  40220. // If the TLSFingerprintProfile object wasn't provided to the builder, the object is fetched from the database.
  40221. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40222. func (m *TLSFingerprintProfileMutation) OldExtensions(ctx context.Context) (v []uint16, err error) {
  40223. if !m.op.Is(OpUpdateOne) {
  40224. return v, errors.New("OldExtensions is only allowed on UpdateOne operations")
  40225. }
  40226. if m.id == nil || m.oldValue == nil {
  40227. return v, errors.New("OldExtensions requires an ID field in the mutation")
  40228. }
  40229. oldValue, err := m.oldValue(ctx)
  40230. if err != nil {
  40231. return v, fmt.Errorf("querying old value for OldExtensions: %w", err)
  40232. }
  40233. return oldValue.Extensions, nil
  40234. }
  40235. // AppendExtensions adds u to the "extensions" field.
  40236. func (m *TLSFingerprintProfileMutation) AppendExtensions(u []uint16) {
  40237. m.appendextensions = append(m.appendextensions, u...)
  40238. }
  40239. // AppendedExtensions returns the list of values that were appended to the "extensions" field in this mutation.
  40240. func (m *TLSFingerprintProfileMutation) AppendedExtensions() ([]uint16, bool) {
  40241. if len(m.appendextensions) == 0 {
  40242. return nil, false
  40243. }
  40244. return m.appendextensions, true
  40245. }
  40246. // ClearExtensions clears the value of the "extensions" field.
  40247. func (m *TLSFingerprintProfileMutation) ClearExtensions() {
  40248. m.extensions = nil
  40249. m.appendextensions = nil
  40250. m.clearedFields[tlsfingerprintprofile.FieldExtensions] = struct{}{}
  40251. }
  40252. // ExtensionsCleared returns if the "extensions" field was cleared in this mutation.
  40253. func (m *TLSFingerprintProfileMutation) ExtensionsCleared() bool {
  40254. _, ok := m.clearedFields[tlsfingerprintprofile.FieldExtensions]
  40255. return ok
  40256. }
  40257. // ResetExtensions resets all changes to the "extensions" field.
  40258. func (m *TLSFingerprintProfileMutation) ResetExtensions() {
  40259. m.extensions = nil
  40260. m.appendextensions = nil
  40261. delete(m.clearedFields, tlsfingerprintprofile.FieldExtensions)
  40262. }
  40263. // Where appends a list predicates to the TLSFingerprintProfileMutation builder.
  40264. func (m *TLSFingerprintProfileMutation) Where(ps ...predicate.TLSFingerprintProfile) {
  40265. m.predicates = append(m.predicates, ps...)
  40266. }
  40267. // WhereP appends storage-level predicates to the TLSFingerprintProfileMutation builder. Using this method,
  40268. // users can use type-assertion to append predicates that do not depend on any generated package.
  40269. func (m *TLSFingerprintProfileMutation) WhereP(ps ...func(*sql.Selector)) {
  40270. p := make([]predicate.TLSFingerprintProfile, len(ps))
  40271. for i := range ps {
  40272. p[i] = ps[i]
  40273. }
  40274. m.Where(p...)
  40275. }
  40276. // Op returns the operation name.
  40277. func (m *TLSFingerprintProfileMutation) Op() Op {
  40278. return m.op
  40279. }
  40280. // SetOp allows setting the mutation operation.
  40281. func (m *TLSFingerprintProfileMutation) SetOp(op Op) {
  40282. m.op = op
  40283. }
  40284. // Type returns the node type of this mutation (TLSFingerprintProfile).
  40285. func (m *TLSFingerprintProfileMutation) Type() string {
  40286. return m.typ
  40287. }
  40288. // Fields returns all fields that were changed during this mutation. Note that in
  40289. // order to get all numeric fields that were incremented/decremented, call
  40290. // AddedFields().
  40291. func (m *TLSFingerprintProfileMutation) Fields() []string {
  40292. fields := make([]string, 0, 14)
  40293. if m.created_at != nil {
  40294. fields = append(fields, tlsfingerprintprofile.FieldCreatedAt)
  40295. }
  40296. if m.updated_at != nil {
  40297. fields = append(fields, tlsfingerprintprofile.FieldUpdatedAt)
  40298. }
  40299. if m.name != nil {
  40300. fields = append(fields, tlsfingerprintprofile.FieldName)
  40301. }
  40302. if m.description != nil {
  40303. fields = append(fields, tlsfingerprintprofile.FieldDescription)
  40304. }
  40305. if m.enable_grease != nil {
  40306. fields = append(fields, tlsfingerprintprofile.FieldEnableGrease)
  40307. }
  40308. if m.cipher_suites != nil {
  40309. fields = append(fields, tlsfingerprintprofile.FieldCipherSuites)
  40310. }
  40311. if m.curves != nil {
  40312. fields = append(fields, tlsfingerprintprofile.FieldCurves)
  40313. }
  40314. if m.point_formats != nil {
  40315. fields = append(fields, tlsfingerprintprofile.FieldPointFormats)
  40316. }
  40317. if m.signature_algorithms != nil {
  40318. fields = append(fields, tlsfingerprintprofile.FieldSignatureAlgorithms)
  40319. }
  40320. if m.alpn_protocols != nil {
  40321. fields = append(fields, tlsfingerprintprofile.FieldAlpnProtocols)
  40322. }
  40323. if m.supported_versions != nil {
  40324. fields = append(fields, tlsfingerprintprofile.FieldSupportedVersions)
  40325. }
  40326. if m.key_share_groups != nil {
  40327. fields = append(fields, tlsfingerprintprofile.FieldKeyShareGroups)
  40328. }
  40329. if m.psk_modes != nil {
  40330. fields = append(fields, tlsfingerprintprofile.FieldPskModes)
  40331. }
  40332. if m.extensions != nil {
  40333. fields = append(fields, tlsfingerprintprofile.FieldExtensions)
  40334. }
  40335. return fields
  40336. }
  40337. // Field returns the value of a field with the given name. The second boolean
  40338. // return value indicates that this field was not set, or was not defined in the
  40339. // schema.
  40340. func (m *TLSFingerprintProfileMutation) Field(name string) (ent.Value, bool) {
  40341. switch name {
  40342. case tlsfingerprintprofile.FieldCreatedAt:
  40343. return m.CreatedAt()
  40344. case tlsfingerprintprofile.FieldUpdatedAt:
  40345. return m.UpdatedAt()
  40346. case tlsfingerprintprofile.FieldName:
  40347. return m.Name()
  40348. case tlsfingerprintprofile.FieldDescription:
  40349. return m.Description()
  40350. case tlsfingerprintprofile.FieldEnableGrease:
  40351. return m.EnableGrease()
  40352. case tlsfingerprintprofile.FieldCipherSuites:
  40353. return m.CipherSuites()
  40354. case tlsfingerprintprofile.FieldCurves:
  40355. return m.Curves()
  40356. case tlsfingerprintprofile.FieldPointFormats:
  40357. return m.PointFormats()
  40358. case tlsfingerprintprofile.FieldSignatureAlgorithms:
  40359. return m.SignatureAlgorithms()
  40360. case tlsfingerprintprofile.FieldAlpnProtocols:
  40361. return m.AlpnProtocols()
  40362. case tlsfingerprintprofile.FieldSupportedVersions:
  40363. return m.SupportedVersions()
  40364. case tlsfingerprintprofile.FieldKeyShareGroups:
  40365. return m.KeyShareGroups()
  40366. case tlsfingerprintprofile.FieldPskModes:
  40367. return m.PskModes()
  40368. case tlsfingerprintprofile.FieldExtensions:
  40369. return m.Extensions()
  40370. }
  40371. return nil, false
  40372. }
  40373. // OldField returns the old value of the field from the database. An error is
  40374. // returned if the mutation operation is not UpdateOne, or the query to the
  40375. // database failed.
  40376. func (m *TLSFingerprintProfileMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  40377. switch name {
  40378. case tlsfingerprintprofile.FieldCreatedAt:
  40379. return m.OldCreatedAt(ctx)
  40380. case tlsfingerprintprofile.FieldUpdatedAt:
  40381. return m.OldUpdatedAt(ctx)
  40382. case tlsfingerprintprofile.FieldName:
  40383. return m.OldName(ctx)
  40384. case tlsfingerprintprofile.FieldDescription:
  40385. return m.OldDescription(ctx)
  40386. case tlsfingerprintprofile.FieldEnableGrease:
  40387. return m.OldEnableGrease(ctx)
  40388. case tlsfingerprintprofile.FieldCipherSuites:
  40389. return m.OldCipherSuites(ctx)
  40390. case tlsfingerprintprofile.FieldCurves:
  40391. return m.OldCurves(ctx)
  40392. case tlsfingerprintprofile.FieldPointFormats:
  40393. return m.OldPointFormats(ctx)
  40394. case tlsfingerprintprofile.FieldSignatureAlgorithms:
  40395. return m.OldSignatureAlgorithms(ctx)
  40396. case tlsfingerprintprofile.FieldAlpnProtocols:
  40397. return m.OldAlpnProtocols(ctx)
  40398. case tlsfingerprintprofile.FieldSupportedVersions:
  40399. return m.OldSupportedVersions(ctx)
  40400. case tlsfingerprintprofile.FieldKeyShareGroups:
  40401. return m.OldKeyShareGroups(ctx)
  40402. case tlsfingerprintprofile.FieldPskModes:
  40403. return m.OldPskModes(ctx)
  40404. case tlsfingerprintprofile.FieldExtensions:
  40405. return m.OldExtensions(ctx)
  40406. }
  40407. return nil, fmt.Errorf("unknown TLSFingerprintProfile field %s", name)
  40408. }
  40409. // SetField sets the value of a field with the given name. It returns an error if
  40410. // the field is not defined in the schema, or if the type mismatched the field
  40411. // type.
  40412. func (m *TLSFingerprintProfileMutation) SetField(name string, value ent.Value) error {
  40413. switch name {
  40414. case tlsfingerprintprofile.FieldCreatedAt:
  40415. v, ok := value.(time.Time)
  40416. if !ok {
  40417. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40418. }
  40419. m.SetCreatedAt(v)
  40420. return nil
  40421. case tlsfingerprintprofile.FieldUpdatedAt:
  40422. v, ok := value.(time.Time)
  40423. if !ok {
  40424. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40425. }
  40426. m.SetUpdatedAt(v)
  40427. return nil
  40428. case tlsfingerprintprofile.FieldName:
  40429. v, ok := value.(string)
  40430. if !ok {
  40431. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40432. }
  40433. m.SetName(v)
  40434. return nil
  40435. case tlsfingerprintprofile.FieldDescription:
  40436. v, ok := value.(string)
  40437. if !ok {
  40438. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40439. }
  40440. m.SetDescription(v)
  40441. return nil
  40442. case tlsfingerprintprofile.FieldEnableGrease:
  40443. v, ok := value.(bool)
  40444. if !ok {
  40445. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40446. }
  40447. m.SetEnableGrease(v)
  40448. return nil
  40449. case tlsfingerprintprofile.FieldCipherSuites:
  40450. v, ok := value.([]uint16)
  40451. if !ok {
  40452. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40453. }
  40454. m.SetCipherSuites(v)
  40455. return nil
  40456. case tlsfingerprintprofile.FieldCurves:
  40457. v, ok := value.([]uint16)
  40458. if !ok {
  40459. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40460. }
  40461. m.SetCurves(v)
  40462. return nil
  40463. case tlsfingerprintprofile.FieldPointFormats:
  40464. v, ok := value.([]uint16)
  40465. if !ok {
  40466. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40467. }
  40468. m.SetPointFormats(v)
  40469. return nil
  40470. case tlsfingerprintprofile.FieldSignatureAlgorithms:
  40471. v, ok := value.([]uint16)
  40472. if !ok {
  40473. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40474. }
  40475. m.SetSignatureAlgorithms(v)
  40476. return nil
  40477. case tlsfingerprintprofile.FieldAlpnProtocols:
  40478. v, ok := value.([]string)
  40479. if !ok {
  40480. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40481. }
  40482. m.SetAlpnProtocols(v)
  40483. return nil
  40484. case tlsfingerprintprofile.FieldSupportedVersions:
  40485. v, ok := value.([]uint16)
  40486. if !ok {
  40487. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40488. }
  40489. m.SetSupportedVersions(v)
  40490. return nil
  40491. case tlsfingerprintprofile.FieldKeyShareGroups:
  40492. v, ok := value.([]uint16)
  40493. if !ok {
  40494. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40495. }
  40496. m.SetKeyShareGroups(v)
  40497. return nil
  40498. case tlsfingerprintprofile.FieldPskModes:
  40499. v, ok := value.([]uint16)
  40500. if !ok {
  40501. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40502. }
  40503. m.SetPskModes(v)
  40504. return nil
  40505. case tlsfingerprintprofile.FieldExtensions:
  40506. v, ok := value.([]uint16)
  40507. if !ok {
  40508. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40509. }
  40510. m.SetExtensions(v)
  40511. return nil
  40512. }
  40513. return fmt.Errorf("unknown TLSFingerprintProfile field %s", name)
  40514. }
  40515. // AddedFields returns all numeric fields that were incremented/decremented during
  40516. // this mutation.
  40517. func (m *TLSFingerprintProfileMutation) AddedFields() []string {
  40518. return nil
  40519. }
  40520. // AddedField returns the numeric value that was incremented/decremented on a field
  40521. // with the given name. The second boolean return value indicates that this field
  40522. // was not set, or was not defined in the schema.
  40523. func (m *TLSFingerprintProfileMutation) AddedField(name string) (ent.Value, bool) {
  40524. return nil, false
  40525. }
  40526. // AddField adds the value to the field with the given name. It returns an error if
  40527. // the field is not defined in the schema, or if the type mismatched the field
  40528. // type.
  40529. func (m *TLSFingerprintProfileMutation) AddField(name string, value ent.Value) error {
  40530. switch name {
  40531. }
  40532. return fmt.Errorf("unknown TLSFingerprintProfile numeric field %s", name)
  40533. }
  40534. // ClearedFields returns all nullable fields that were cleared during this
  40535. // mutation.
  40536. func (m *TLSFingerprintProfileMutation) ClearedFields() []string {
  40537. var fields []string
  40538. if m.FieldCleared(tlsfingerprintprofile.FieldDescription) {
  40539. fields = append(fields, tlsfingerprintprofile.FieldDescription)
  40540. }
  40541. if m.FieldCleared(tlsfingerprintprofile.FieldCipherSuites) {
  40542. fields = append(fields, tlsfingerprintprofile.FieldCipherSuites)
  40543. }
  40544. if m.FieldCleared(tlsfingerprintprofile.FieldCurves) {
  40545. fields = append(fields, tlsfingerprintprofile.FieldCurves)
  40546. }
  40547. if m.FieldCleared(tlsfingerprintprofile.FieldPointFormats) {
  40548. fields = append(fields, tlsfingerprintprofile.FieldPointFormats)
  40549. }
  40550. if m.FieldCleared(tlsfingerprintprofile.FieldSignatureAlgorithms) {
  40551. fields = append(fields, tlsfingerprintprofile.FieldSignatureAlgorithms)
  40552. }
  40553. if m.FieldCleared(tlsfingerprintprofile.FieldAlpnProtocols) {
  40554. fields = append(fields, tlsfingerprintprofile.FieldAlpnProtocols)
  40555. }
  40556. if m.FieldCleared(tlsfingerprintprofile.FieldSupportedVersions) {
  40557. fields = append(fields, tlsfingerprintprofile.FieldSupportedVersions)
  40558. }
  40559. if m.FieldCleared(tlsfingerprintprofile.FieldKeyShareGroups) {
  40560. fields = append(fields, tlsfingerprintprofile.FieldKeyShareGroups)
  40561. }
  40562. if m.FieldCleared(tlsfingerprintprofile.FieldPskModes) {
  40563. fields = append(fields, tlsfingerprintprofile.FieldPskModes)
  40564. }
  40565. if m.FieldCleared(tlsfingerprintprofile.FieldExtensions) {
  40566. fields = append(fields, tlsfingerprintprofile.FieldExtensions)
  40567. }
  40568. return fields
  40569. }
  40570. // FieldCleared returns a boolean indicating if a field with the given name was
  40571. // cleared in this mutation.
  40572. func (m *TLSFingerprintProfileMutation) FieldCleared(name string) bool {
  40573. _, ok := m.clearedFields[name]
  40574. return ok
  40575. }
  40576. // ClearField clears the value of the field with the given name. It returns an
  40577. // error if the field is not defined in the schema.
  40578. func (m *TLSFingerprintProfileMutation) ClearField(name string) error {
  40579. switch name {
  40580. case tlsfingerprintprofile.FieldDescription:
  40581. m.ClearDescription()
  40582. return nil
  40583. case tlsfingerprintprofile.FieldCipherSuites:
  40584. m.ClearCipherSuites()
  40585. return nil
  40586. case tlsfingerprintprofile.FieldCurves:
  40587. m.ClearCurves()
  40588. return nil
  40589. case tlsfingerprintprofile.FieldPointFormats:
  40590. m.ClearPointFormats()
  40591. return nil
  40592. case tlsfingerprintprofile.FieldSignatureAlgorithms:
  40593. m.ClearSignatureAlgorithms()
  40594. return nil
  40595. case tlsfingerprintprofile.FieldAlpnProtocols:
  40596. m.ClearAlpnProtocols()
  40597. return nil
  40598. case tlsfingerprintprofile.FieldSupportedVersions:
  40599. m.ClearSupportedVersions()
  40600. return nil
  40601. case tlsfingerprintprofile.FieldKeyShareGroups:
  40602. m.ClearKeyShareGroups()
  40603. return nil
  40604. case tlsfingerprintprofile.FieldPskModes:
  40605. m.ClearPskModes()
  40606. return nil
  40607. case tlsfingerprintprofile.FieldExtensions:
  40608. m.ClearExtensions()
  40609. return nil
  40610. }
  40611. return fmt.Errorf("unknown TLSFingerprintProfile nullable field %s", name)
  40612. }
  40613. // ResetField resets all changes in the mutation for the field with the given name.
  40614. // It returns an error if the field is not defined in the schema.
  40615. func (m *TLSFingerprintProfileMutation) ResetField(name string) error {
  40616. switch name {
  40617. case tlsfingerprintprofile.FieldCreatedAt:
  40618. m.ResetCreatedAt()
  40619. return nil
  40620. case tlsfingerprintprofile.FieldUpdatedAt:
  40621. m.ResetUpdatedAt()
  40622. return nil
  40623. case tlsfingerprintprofile.FieldName:
  40624. m.ResetName()
  40625. return nil
  40626. case tlsfingerprintprofile.FieldDescription:
  40627. m.ResetDescription()
  40628. return nil
  40629. case tlsfingerprintprofile.FieldEnableGrease:
  40630. m.ResetEnableGrease()
  40631. return nil
  40632. case tlsfingerprintprofile.FieldCipherSuites:
  40633. m.ResetCipherSuites()
  40634. return nil
  40635. case tlsfingerprintprofile.FieldCurves:
  40636. m.ResetCurves()
  40637. return nil
  40638. case tlsfingerprintprofile.FieldPointFormats:
  40639. m.ResetPointFormats()
  40640. return nil
  40641. case tlsfingerprintprofile.FieldSignatureAlgorithms:
  40642. m.ResetSignatureAlgorithms()
  40643. return nil
  40644. case tlsfingerprintprofile.FieldAlpnProtocols:
  40645. m.ResetAlpnProtocols()
  40646. return nil
  40647. case tlsfingerprintprofile.FieldSupportedVersions:
  40648. m.ResetSupportedVersions()
  40649. return nil
  40650. case tlsfingerprintprofile.FieldKeyShareGroups:
  40651. m.ResetKeyShareGroups()
  40652. return nil
  40653. case tlsfingerprintprofile.FieldPskModes:
  40654. m.ResetPskModes()
  40655. return nil
  40656. case tlsfingerprintprofile.FieldExtensions:
  40657. m.ResetExtensions()
  40658. return nil
  40659. }
  40660. return fmt.Errorf("unknown TLSFingerprintProfile field %s", name)
  40661. }
  40662. // AddedEdges returns all edge names that were set/added in this mutation.
  40663. func (m *TLSFingerprintProfileMutation) AddedEdges() []string {
  40664. edges := make([]string, 0, 0)
  40665. return edges
  40666. }
  40667. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  40668. // name in this mutation.
  40669. func (m *TLSFingerprintProfileMutation) AddedIDs(name string) []ent.Value {
  40670. return nil
  40671. }
  40672. // RemovedEdges returns all edge names that were removed in this mutation.
  40673. func (m *TLSFingerprintProfileMutation) RemovedEdges() []string {
  40674. edges := make([]string, 0, 0)
  40675. return edges
  40676. }
  40677. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  40678. // the given name in this mutation.
  40679. func (m *TLSFingerprintProfileMutation) RemovedIDs(name string) []ent.Value {
  40680. return nil
  40681. }
  40682. // ClearedEdges returns all edge names that were cleared in this mutation.
  40683. func (m *TLSFingerprintProfileMutation) ClearedEdges() []string {
  40684. edges := make([]string, 0, 0)
  40685. return edges
  40686. }
  40687. // EdgeCleared returns a boolean which indicates if the edge with the given name
  40688. // was cleared in this mutation.
  40689. func (m *TLSFingerprintProfileMutation) EdgeCleared(name string) bool {
  40690. return false
  40691. }
  40692. // ClearEdge clears the value of the edge with the given name. It returns an error
  40693. // if that edge is not defined in the schema.
  40694. func (m *TLSFingerprintProfileMutation) ClearEdge(name string) error {
  40695. return fmt.Errorf("unknown TLSFingerprintProfile unique edge %s", name)
  40696. }
  40697. // ResetEdge resets all changes to the edge with the given name in this mutation.
  40698. // It returns an error if the edge is not defined in the schema.
  40699. func (m *TLSFingerprintProfileMutation) ResetEdge(name string) error {
  40700. return fmt.Errorf("unknown TLSFingerprintProfile edge %s", name)
  40701. }
  40702. // UsageCleanupTaskMutation represents an operation that mutates the UsageCleanupTask nodes in the graph.
  40703. type UsageCleanupTaskMutation struct {
  40704. config
  40705. op Op
  40706. typ string
  40707. id *int64
  40708. created_at *time.Time
  40709. updated_at *time.Time
  40710. status *string
  40711. filters *jsontext.Value
  40712. appendfilters jsontext.Value
  40713. created_by *int64
  40714. addcreated_by *int64
  40715. deleted_rows *int64
  40716. adddeleted_rows *int64
  40717. error_message *string
  40718. canceled_by *int64
  40719. addcanceled_by *int64
  40720. canceled_at *time.Time
  40721. started_at *time.Time
  40722. finished_at *time.Time
  40723. clearedFields map[string]struct{}
  40724. done bool
  40725. oldValue func(context.Context) (*UsageCleanupTask, error)
  40726. predicates []predicate.UsageCleanupTask
  40727. }
  40728. var _ ent.Mutation = (*UsageCleanupTaskMutation)(nil)
  40729. // usagecleanuptaskOption allows management of the mutation configuration using functional options.
  40730. type usagecleanuptaskOption func(*UsageCleanupTaskMutation)
  40731. // newUsageCleanupTaskMutation creates new mutation for the UsageCleanupTask entity.
  40732. func newUsageCleanupTaskMutation(c config, op Op, opts ...usagecleanuptaskOption) *UsageCleanupTaskMutation {
  40733. m := &UsageCleanupTaskMutation{
  40734. config: c,
  40735. op: op,
  40736. typ: TypeUsageCleanupTask,
  40737. clearedFields: make(map[string]struct{}),
  40738. }
  40739. for _, opt := range opts {
  40740. opt(m)
  40741. }
  40742. return m
  40743. }
  40744. // withUsageCleanupTaskID sets the ID field of the mutation.
  40745. func withUsageCleanupTaskID(id int64) usagecleanuptaskOption {
  40746. return func(m *UsageCleanupTaskMutation) {
  40747. var (
  40748. err error
  40749. once sync.Once
  40750. value *UsageCleanupTask
  40751. )
  40752. m.oldValue = func(ctx context.Context) (*UsageCleanupTask, error) {
  40753. once.Do(func() {
  40754. if m.done {
  40755. err = errors.New("querying old values post mutation is not allowed")
  40756. } else {
  40757. value, err = m.Client().UsageCleanupTask.Get(ctx, id)
  40758. }
  40759. })
  40760. return value, err
  40761. }
  40762. m.id = &id
  40763. }
  40764. }
  40765. // withUsageCleanupTask sets the old UsageCleanupTask of the mutation.
  40766. func withUsageCleanupTask(node *UsageCleanupTask) usagecleanuptaskOption {
  40767. return func(m *UsageCleanupTaskMutation) {
  40768. m.oldValue = func(context.Context) (*UsageCleanupTask, error) {
  40769. return node, nil
  40770. }
  40771. m.id = &node.ID
  40772. }
  40773. }
  40774. // Client returns a new `ent.Client` from the mutation. If the mutation was
  40775. // executed in a transaction (ent.Tx), a transactional client is returned.
  40776. func (m UsageCleanupTaskMutation) Client() *Client {
  40777. client := &Client{config: m.config}
  40778. client.init()
  40779. return client
  40780. }
  40781. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  40782. // it returns an error otherwise.
  40783. func (m UsageCleanupTaskMutation) Tx() (*Tx, error) {
  40784. if _, ok := m.driver.(*txDriver); !ok {
  40785. return nil, errors.New("ent: mutation is not running in a transaction")
  40786. }
  40787. tx := &Tx{config: m.config}
  40788. tx.init()
  40789. return tx, nil
  40790. }
  40791. // ID returns the ID value in the mutation. Note that the ID is only available
  40792. // if it was provided to the builder or after it was returned from the database.
  40793. func (m *UsageCleanupTaskMutation) ID() (id int64, exists bool) {
  40794. if m.id == nil {
  40795. return
  40796. }
  40797. return *m.id, true
  40798. }
  40799. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  40800. // That means, if the mutation is applied within a transaction with an isolation level such
  40801. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  40802. // or updated by the mutation.
  40803. func (m *UsageCleanupTaskMutation) IDs(ctx context.Context) ([]int64, error) {
  40804. switch {
  40805. case m.op.Is(OpUpdateOne | OpDeleteOne):
  40806. id, exists := m.ID()
  40807. if exists {
  40808. return []int64{id}, nil
  40809. }
  40810. fallthrough
  40811. case m.op.Is(OpUpdate | OpDelete):
  40812. return m.Client().UsageCleanupTask.Query().Where(m.predicates...).IDs(ctx)
  40813. default:
  40814. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  40815. }
  40816. }
  40817. // SetCreatedAt sets the "created_at" field.
  40818. func (m *UsageCleanupTaskMutation) SetCreatedAt(t time.Time) {
  40819. m.created_at = &t
  40820. }
  40821. // CreatedAt returns the value of the "created_at" field in the mutation.
  40822. func (m *UsageCleanupTaskMutation) CreatedAt() (r time.Time, exists bool) {
  40823. v := m.created_at
  40824. if v == nil {
  40825. return
  40826. }
  40827. return *v, true
  40828. }
  40829. // OldCreatedAt returns the old "created_at" field's value of the UsageCleanupTask entity.
  40830. // If the UsageCleanupTask object wasn't provided to the builder, the object is fetched from the database.
  40831. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40832. func (m *UsageCleanupTaskMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  40833. if !m.op.Is(OpUpdateOne) {
  40834. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  40835. }
  40836. if m.id == nil || m.oldValue == nil {
  40837. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  40838. }
  40839. oldValue, err := m.oldValue(ctx)
  40840. if err != nil {
  40841. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  40842. }
  40843. return oldValue.CreatedAt, nil
  40844. }
  40845. // ResetCreatedAt resets all changes to the "created_at" field.
  40846. func (m *UsageCleanupTaskMutation) ResetCreatedAt() {
  40847. m.created_at = nil
  40848. }
  40849. // SetUpdatedAt sets the "updated_at" field.
  40850. func (m *UsageCleanupTaskMutation) SetUpdatedAt(t time.Time) {
  40851. m.updated_at = &t
  40852. }
  40853. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  40854. func (m *UsageCleanupTaskMutation) UpdatedAt() (r time.Time, exists bool) {
  40855. v := m.updated_at
  40856. if v == nil {
  40857. return
  40858. }
  40859. return *v, true
  40860. }
  40861. // OldUpdatedAt returns the old "updated_at" field's value of the UsageCleanupTask entity.
  40862. // If the UsageCleanupTask object wasn't provided to the builder, the object is fetched from the database.
  40863. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40864. func (m *UsageCleanupTaskMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  40865. if !m.op.Is(OpUpdateOne) {
  40866. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  40867. }
  40868. if m.id == nil || m.oldValue == nil {
  40869. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  40870. }
  40871. oldValue, err := m.oldValue(ctx)
  40872. if err != nil {
  40873. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  40874. }
  40875. return oldValue.UpdatedAt, nil
  40876. }
  40877. // ResetUpdatedAt resets all changes to the "updated_at" field.
  40878. func (m *UsageCleanupTaskMutation) ResetUpdatedAt() {
  40879. m.updated_at = nil
  40880. }
  40881. // SetStatus sets the "status" field.
  40882. func (m *UsageCleanupTaskMutation) SetStatus(s string) {
  40883. m.status = &s
  40884. }
  40885. // Status returns the value of the "status" field in the mutation.
  40886. func (m *UsageCleanupTaskMutation) Status() (r string, exists bool) {
  40887. v := m.status
  40888. if v == nil {
  40889. return
  40890. }
  40891. return *v, true
  40892. }
  40893. // OldStatus returns the old "status" field's value of the UsageCleanupTask entity.
  40894. // If the UsageCleanupTask object wasn't provided to the builder, the object is fetched from the database.
  40895. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40896. func (m *UsageCleanupTaskMutation) OldStatus(ctx context.Context) (v string, err error) {
  40897. if !m.op.Is(OpUpdateOne) {
  40898. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  40899. }
  40900. if m.id == nil || m.oldValue == nil {
  40901. return v, errors.New("OldStatus requires an ID field in the mutation")
  40902. }
  40903. oldValue, err := m.oldValue(ctx)
  40904. if err != nil {
  40905. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  40906. }
  40907. return oldValue.Status, nil
  40908. }
  40909. // ResetStatus resets all changes to the "status" field.
  40910. func (m *UsageCleanupTaskMutation) ResetStatus() {
  40911. m.status = nil
  40912. }
  40913. // SetFilters sets the "filters" field.
  40914. func (m *UsageCleanupTaskMutation) SetFilters(j jsontext.Value) {
  40915. m.filters = &j
  40916. m.appendfilters = nil
  40917. }
  40918. // Filters returns the value of the "filters" field in the mutation.
  40919. func (m *UsageCleanupTaskMutation) Filters() (r jsontext.Value, exists bool) {
  40920. v := m.filters
  40921. if v == nil {
  40922. return
  40923. }
  40924. return *v, true
  40925. }
  40926. // OldFilters returns the old "filters" field's value of the UsageCleanupTask entity.
  40927. // If the UsageCleanupTask object wasn't provided to the builder, the object is fetched from the database.
  40928. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40929. func (m *UsageCleanupTaskMutation) OldFilters(ctx context.Context) (v jsontext.Value, err error) {
  40930. if !m.op.Is(OpUpdateOne) {
  40931. return v, errors.New("OldFilters is only allowed on UpdateOne operations")
  40932. }
  40933. if m.id == nil || m.oldValue == nil {
  40934. return v, errors.New("OldFilters requires an ID field in the mutation")
  40935. }
  40936. oldValue, err := m.oldValue(ctx)
  40937. if err != nil {
  40938. return v, fmt.Errorf("querying old value for OldFilters: %w", err)
  40939. }
  40940. return oldValue.Filters, nil
  40941. }
  40942. // AppendFilters adds j to the "filters" field.
  40943. func (m *UsageCleanupTaskMutation) AppendFilters(j jsontext.Value) {
  40944. m.appendfilters = append(m.appendfilters, j...)
  40945. }
  40946. // AppendedFilters returns the list of values that were appended to the "filters" field in this mutation.
  40947. func (m *UsageCleanupTaskMutation) AppendedFilters() (jsontext.Value, bool) {
  40948. if len(m.appendfilters) == 0 {
  40949. return nil, false
  40950. }
  40951. return m.appendfilters, true
  40952. }
  40953. // ResetFilters resets all changes to the "filters" field.
  40954. func (m *UsageCleanupTaskMutation) ResetFilters() {
  40955. m.filters = nil
  40956. m.appendfilters = nil
  40957. }
  40958. // SetCreatedBy sets the "created_by" field.
  40959. func (m *UsageCleanupTaskMutation) SetCreatedBy(i int64) {
  40960. m.created_by = &i
  40961. m.addcreated_by = nil
  40962. }
  40963. // CreatedBy returns the value of the "created_by" field in the mutation.
  40964. func (m *UsageCleanupTaskMutation) CreatedBy() (r int64, exists bool) {
  40965. v := m.created_by
  40966. if v == nil {
  40967. return
  40968. }
  40969. return *v, true
  40970. }
  40971. // OldCreatedBy returns the old "created_by" field's value of the UsageCleanupTask entity.
  40972. // If the UsageCleanupTask object wasn't provided to the builder, the object is fetched from the database.
  40973. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40974. func (m *UsageCleanupTaskMutation) OldCreatedBy(ctx context.Context) (v int64, err error) {
  40975. if !m.op.Is(OpUpdateOne) {
  40976. return v, errors.New("OldCreatedBy is only allowed on UpdateOne operations")
  40977. }
  40978. if m.id == nil || m.oldValue == nil {
  40979. return v, errors.New("OldCreatedBy requires an ID field in the mutation")
  40980. }
  40981. oldValue, err := m.oldValue(ctx)
  40982. if err != nil {
  40983. return v, fmt.Errorf("querying old value for OldCreatedBy: %w", err)
  40984. }
  40985. return oldValue.CreatedBy, nil
  40986. }
  40987. // AddCreatedBy adds i to the "created_by" field.
  40988. func (m *UsageCleanupTaskMutation) AddCreatedBy(i int64) {
  40989. if m.addcreated_by != nil {
  40990. *m.addcreated_by += i
  40991. } else {
  40992. m.addcreated_by = &i
  40993. }
  40994. }
  40995. // AddedCreatedBy returns the value that was added to the "created_by" field in this mutation.
  40996. func (m *UsageCleanupTaskMutation) AddedCreatedBy() (r int64, exists bool) {
  40997. v := m.addcreated_by
  40998. if v == nil {
  40999. return
  41000. }
  41001. return *v, true
  41002. }
  41003. // ResetCreatedBy resets all changes to the "created_by" field.
  41004. func (m *UsageCleanupTaskMutation) ResetCreatedBy() {
  41005. m.created_by = nil
  41006. m.addcreated_by = nil
  41007. }
  41008. // SetDeletedRows sets the "deleted_rows" field.
  41009. func (m *UsageCleanupTaskMutation) SetDeletedRows(i int64) {
  41010. m.deleted_rows = &i
  41011. m.adddeleted_rows = nil
  41012. }
  41013. // DeletedRows returns the value of the "deleted_rows" field in the mutation.
  41014. func (m *UsageCleanupTaskMutation) DeletedRows() (r int64, exists bool) {
  41015. v := m.deleted_rows
  41016. if v == nil {
  41017. return
  41018. }
  41019. return *v, true
  41020. }
  41021. // OldDeletedRows returns the old "deleted_rows" field's value of the UsageCleanupTask entity.
  41022. // If the UsageCleanupTask object wasn't provided to the builder, the object is fetched from the database.
  41023. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41024. func (m *UsageCleanupTaskMutation) OldDeletedRows(ctx context.Context) (v int64, err error) {
  41025. if !m.op.Is(OpUpdateOne) {
  41026. return v, errors.New("OldDeletedRows is only allowed on UpdateOne operations")
  41027. }
  41028. if m.id == nil || m.oldValue == nil {
  41029. return v, errors.New("OldDeletedRows requires an ID field in the mutation")
  41030. }
  41031. oldValue, err := m.oldValue(ctx)
  41032. if err != nil {
  41033. return v, fmt.Errorf("querying old value for OldDeletedRows: %w", err)
  41034. }
  41035. return oldValue.DeletedRows, nil
  41036. }
  41037. // AddDeletedRows adds i to the "deleted_rows" field.
  41038. func (m *UsageCleanupTaskMutation) AddDeletedRows(i int64) {
  41039. if m.adddeleted_rows != nil {
  41040. *m.adddeleted_rows += i
  41041. } else {
  41042. m.adddeleted_rows = &i
  41043. }
  41044. }
  41045. // AddedDeletedRows returns the value that was added to the "deleted_rows" field in this mutation.
  41046. func (m *UsageCleanupTaskMutation) AddedDeletedRows() (r int64, exists bool) {
  41047. v := m.adddeleted_rows
  41048. if v == nil {
  41049. return
  41050. }
  41051. return *v, true
  41052. }
  41053. // ResetDeletedRows resets all changes to the "deleted_rows" field.
  41054. func (m *UsageCleanupTaskMutation) ResetDeletedRows() {
  41055. m.deleted_rows = nil
  41056. m.adddeleted_rows = nil
  41057. }
  41058. // SetErrorMessage sets the "error_message" field.
  41059. func (m *UsageCleanupTaskMutation) SetErrorMessage(s string) {
  41060. m.error_message = &s
  41061. }
  41062. // ErrorMessage returns the value of the "error_message" field in the mutation.
  41063. func (m *UsageCleanupTaskMutation) ErrorMessage() (r string, exists bool) {
  41064. v := m.error_message
  41065. if v == nil {
  41066. return
  41067. }
  41068. return *v, true
  41069. }
  41070. // OldErrorMessage returns the old "error_message" field's value of the UsageCleanupTask entity.
  41071. // If the UsageCleanupTask object wasn't provided to the builder, the object is fetched from the database.
  41072. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41073. func (m *UsageCleanupTaskMutation) OldErrorMessage(ctx context.Context) (v *string, err error) {
  41074. if !m.op.Is(OpUpdateOne) {
  41075. return v, errors.New("OldErrorMessage is only allowed on UpdateOne operations")
  41076. }
  41077. if m.id == nil || m.oldValue == nil {
  41078. return v, errors.New("OldErrorMessage requires an ID field in the mutation")
  41079. }
  41080. oldValue, err := m.oldValue(ctx)
  41081. if err != nil {
  41082. return v, fmt.Errorf("querying old value for OldErrorMessage: %w", err)
  41083. }
  41084. return oldValue.ErrorMessage, nil
  41085. }
  41086. // ClearErrorMessage clears the value of the "error_message" field.
  41087. func (m *UsageCleanupTaskMutation) ClearErrorMessage() {
  41088. m.error_message = nil
  41089. m.clearedFields[usagecleanuptask.FieldErrorMessage] = struct{}{}
  41090. }
  41091. // ErrorMessageCleared returns if the "error_message" field was cleared in this mutation.
  41092. func (m *UsageCleanupTaskMutation) ErrorMessageCleared() bool {
  41093. _, ok := m.clearedFields[usagecleanuptask.FieldErrorMessage]
  41094. return ok
  41095. }
  41096. // ResetErrorMessage resets all changes to the "error_message" field.
  41097. func (m *UsageCleanupTaskMutation) ResetErrorMessage() {
  41098. m.error_message = nil
  41099. delete(m.clearedFields, usagecleanuptask.FieldErrorMessage)
  41100. }
  41101. // SetCanceledBy sets the "canceled_by" field.
  41102. func (m *UsageCleanupTaskMutation) SetCanceledBy(i int64) {
  41103. m.canceled_by = &i
  41104. m.addcanceled_by = nil
  41105. }
  41106. // CanceledBy returns the value of the "canceled_by" field in the mutation.
  41107. func (m *UsageCleanupTaskMutation) CanceledBy() (r int64, exists bool) {
  41108. v := m.canceled_by
  41109. if v == nil {
  41110. return
  41111. }
  41112. return *v, true
  41113. }
  41114. // OldCanceledBy returns the old "canceled_by" field's value of the UsageCleanupTask entity.
  41115. // If the UsageCleanupTask object wasn't provided to the builder, the object is fetched from the database.
  41116. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41117. func (m *UsageCleanupTaskMutation) OldCanceledBy(ctx context.Context) (v *int64, err error) {
  41118. if !m.op.Is(OpUpdateOne) {
  41119. return v, errors.New("OldCanceledBy is only allowed on UpdateOne operations")
  41120. }
  41121. if m.id == nil || m.oldValue == nil {
  41122. return v, errors.New("OldCanceledBy requires an ID field in the mutation")
  41123. }
  41124. oldValue, err := m.oldValue(ctx)
  41125. if err != nil {
  41126. return v, fmt.Errorf("querying old value for OldCanceledBy: %w", err)
  41127. }
  41128. return oldValue.CanceledBy, nil
  41129. }
  41130. // AddCanceledBy adds i to the "canceled_by" field.
  41131. func (m *UsageCleanupTaskMutation) AddCanceledBy(i int64) {
  41132. if m.addcanceled_by != nil {
  41133. *m.addcanceled_by += i
  41134. } else {
  41135. m.addcanceled_by = &i
  41136. }
  41137. }
  41138. // AddedCanceledBy returns the value that was added to the "canceled_by" field in this mutation.
  41139. func (m *UsageCleanupTaskMutation) AddedCanceledBy() (r int64, exists bool) {
  41140. v := m.addcanceled_by
  41141. if v == nil {
  41142. return
  41143. }
  41144. return *v, true
  41145. }
  41146. // ClearCanceledBy clears the value of the "canceled_by" field.
  41147. func (m *UsageCleanupTaskMutation) ClearCanceledBy() {
  41148. m.canceled_by = nil
  41149. m.addcanceled_by = nil
  41150. m.clearedFields[usagecleanuptask.FieldCanceledBy] = struct{}{}
  41151. }
  41152. // CanceledByCleared returns if the "canceled_by" field was cleared in this mutation.
  41153. func (m *UsageCleanupTaskMutation) CanceledByCleared() bool {
  41154. _, ok := m.clearedFields[usagecleanuptask.FieldCanceledBy]
  41155. return ok
  41156. }
  41157. // ResetCanceledBy resets all changes to the "canceled_by" field.
  41158. func (m *UsageCleanupTaskMutation) ResetCanceledBy() {
  41159. m.canceled_by = nil
  41160. m.addcanceled_by = nil
  41161. delete(m.clearedFields, usagecleanuptask.FieldCanceledBy)
  41162. }
  41163. // SetCanceledAt sets the "canceled_at" field.
  41164. func (m *UsageCleanupTaskMutation) SetCanceledAt(t time.Time) {
  41165. m.canceled_at = &t
  41166. }
  41167. // CanceledAt returns the value of the "canceled_at" field in the mutation.
  41168. func (m *UsageCleanupTaskMutation) CanceledAt() (r time.Time, exists bool) {
  41169. v := m.canceled_at
  41170. if v == nil {
  41171. return
  41172. }
  41173. return *v, true
  41174. }
  41175. // OldCanceledAt returns the old "canceled_at" field's value of the UsageCleanupTask entity.
  41176. // If the UsageCleanupTask object wasn't provided to the builder, the object is fetched from the database.
  41177. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41178. func (m *UsageCleanupTaskMutation) OldCanceledAt(ctx context.Context) (v *time.Time, err error) {
  41179. if !m.op.Is(OpUpdateOne) {
  41180. return v, errors.New("OldCanceledAt is only allowed on UpdateOne operations")
  41181. }
  41182. if m.id == nil || m.oldValue == nil {
  41183. return v, errors.New("OldCanceledAt requires an ID field in the mutation")
  41184. }
  41185. oldValue, err := m.oldValue(ctx)
  41186. if err != nil {
  41187. return v, fmt.Errorf("querying old value for OldCanceledAt: %w", err)
  41188. }
  41189. return oldValue.CanceledAt, nil
  41190. }
  41191. // ClearCanceledAt clears the value of the "canceled_at" field.
  41192. func (m *UsageCleanupTaskMutation) ClearCanceledAt() {
  41193. m.canceled_at = nil
  41194. m.clearedFields[usagecleanuptask.FieldCanceledAt] = struct{}{}
  41195. }
  41196. // CanceledAtCleared returns if the "canceled_at" field was cleared in this mutation.
  41197. func (m *UsageCleanupTaskMutation) CanceledAtCleared() bool {
  41198. _, ok := m.clearedFields[usagecleanuptask.FieldCanceledAt]
  41199. return ok
  41200. }
  41201. // ResetCanceledAt resets all changes to the "canceled_at" field.
  41202. func (m *UsageCleanupTaskMutation) ResetCanceledAt() {
  41203. m.canceled_at = nil
  41204. delete(m.clearedFields, usagecleanuptask.FieldCanceledAt)
  41205. }
  41206. // SetStartedAt sets the "started_at" field.
  41207. func (m *UsageCleanupTaskMutation) SetStartedAt(t time.Time) {
  41208. m.started_at = &t
  41209. }
  41210. // StartedAt returns the value of the "started_at" field in the mutation.
  41211. func (m *UsageCleanupTaskMutation) StartedAt() (r time.Time, exists bool) {
  41212. v := m.started_at
  41213. if v == nil {
  41214. return
  41215. }
  41216. return *v, true
  41217. }
  41218. // OldStartedAt returns the old "started_at" field's value of the UsageCleanupTask entity.
  41219. // If the UsageCleanupTask object wasn't provided to the builder, the object is fetched from the database.
  41220. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41221. func (m *UsageCleanupTaskMutation) OldStartedAt(ctx context.Context) (v *time.Time, err error) {
  41222. if !m.op.Is(OpUpdateOne) {
  41223. return v, errors.New("OldStartedAt is only allowed on UpdateOne operations")
  41224. }
  41225. if m.id == nil || m.oldValue == nil {
  41226. return v, errors.New("OldStartedAt requires an ID field in the mutation")
  41227. }
  41228. oldValue, err := m.oldValue(ctx)
  41229. if err != nil {
  41230. return v, fmt.Errorf("querying old value for OldStartedAt: %w", err)
  41231. }
  41232. return oldValue.StartedAt, nil
  41233. }
  41234. // ClearStartedAt clears the value of the "started_at" field.
  41235. func (m *UsageCleanupTaskMutation) ClearStartedAt() {
  41236. m.started_at = nil
  41237. m.clearedFields[usagecleanuptask.FieldStartedAt] = struct{}{}
  41238. }
  41239. // StartedAtCleared returns if the "started_at" field was cleared in this mutation.
  41240. func (m *UsageCleanupTaskMutation) StartedAtCleared() bool {
  41241. _, ok := m.clearedFields[usagecleanuptask.FieldStartedAt]
  41242. return ok
  41243. }
  41244. // ResetStartedAt resets all changes to the "started_at" field.
  41245. func (m *UsageCleanupTaskMutation) ResetStartedAt() {
  41246. m.started_at = nil
  41247. delete(m.clearedFields, usagecleanuptask.FieldStartedAt)
  41248. }
  41249. // SetFinishedAt sets the "finished_at" field.
  41250. func (m *UsageCleanupTaskMutation) SetFinishedAt(t time.Time) {
  41251. m.finished_at = &t
  41252. }
  41253. // FinishedAt returns the value of the "finished_at" field in the mutation.
  41254. func (m *UsageCleanupTaskMutation) FinishedAt() (r time.Time, exists bool) {
  41255. v := m.finished_at
  41256. if v == nil {
  41257. return
  41258. }
  41259. return *v, true
  41260. }
  41261. // OldFinishedAt returns the old "finished_at" field's value of the UsageCleanupTask entity.
  41262. // If the UsageCleanupTask object wasn't provided to the builder, the object is fetched from the database.
  41263. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41264. func (m *UsageCleanupTaskMutation) OldFinishedAt(ctx context.Context) (v *time.Time, err error) {
  41265. if !m.op.Is(OpUpdateOne) {
  41266. return v, errors.New("OldFinishedAt is only allowed on UpdateOne operations")
  41267. }
  41268. if m.id == nil || m.oldValue == nil {
  41269. return v, errors.New("OldFinishedAt requires an ID field in the mutation")
  41270. }
  41271. oldValue, err := m.oldValue(ctx)
  41272. if err != nil {
  41273. return v, fmt.Errorf("querying old value for OldFinishedAt: %w", err)
  41274. }
  41275. return oldValue.FinishedAt, nil
  41276. }
  41277. // ClearFinishedAt clears the value of the "finished_at" field.
  41278. func (m *UsageCleanupTaskMutation) ClearFinishedAt() {
  41279. m.finished_at = nil
  41280. m.clearedFields[usagecleanuptask.FieldFinishedAt] = struct{}{}
  41281. }
  41282. // FinishedAtCleared returns if the "finished_at" field was cleared in this mutation.
  41283. func (m *UsageCleanupTaskMutation) FinishedAtCleared() bool {
  41284. _, ok := m.clearedFields[usagecleanuptask.FieldFinishedAt]
  41285. return ok
  41286. }
  41287. // ResetFinishedAt resets all changes to the "finished_at" field.
  41288. func (m *UsageCleanupTaskMutation) ResetFinishedAt() {
  41289. m.finished_at = nil
  41290. delete(m.clearedFields, usagecleanuptask.FieldFinishedAt)
  41291. }
  41292. // Where appends a list predicates to the UsageCleanupTaskMutation builder.
  41293. func (m *UsageCleanupTaskMutation) Where(ps ...predicate.UsageCleanupTask) {
  41294. m.predicates = append(m.predicates, ps...)
  41295. }
  41296. // WhereP appends storage-level predicates to the UsageCleanupTaskMutation builder. Using this method,
  41297. // users can use type-assertion to append predicates that do not depend on any generated package.
  41298. func (m *UsageCleanupTaskMutation) WhereP(ps ...func(*sql.Selector)) {
  41299. p := make([]predicate.UsageCleanupTask, len(ps))
  41300. for i := range ps {
  41301. p[i] = ps[i]
  41302. }
  41303. m.Where(p...)
  41304. }
  41305. // Op returns the operation name.
  41306. func (m *UsageCleanupTaskMutation) Op() Op {
  41307. return m.op
  41308. }
  41309. // SetOp allows setting the mutation operation.
  41310. func (m *UsageCleanupTaskMutation) SetOp(op Op) {
  41311. m.op = op
  41312. }
  41313. // Type returns the node type of this mutation (UsageCleanupTask).
  41314. func (m *UsageCleanupTaskMutation) Type() string {
  41315. return m.typ
  41316. }
  41317. // Fields returns all fields that were changed during this mutation. Note that in
  41318. // order to get all numeric fields that were incremented/decremented, call
  41319. // AddedFields().
  41320. func (m *UsageCleanupTaskMutation) Fields() []string {
  41321. fields := make([]string, 0, 11)
  41322. if m.created_at != nil {
  41323. fields = append(fields, usagecleanuptask.FieldCreatedAt)
  41324. }
  41325. if m.updated_at != nil {
  41326. fields = append(fields, usagecleanuptask.FieldUpdatedAt)
  41327. }
  41328. if m.status != nil {
  41329. fields = append(fields, usagecleanuptask.FieldStatus)
  41330. }
  41331. if m.filters != nil {
  41332. fields = append(fields, usagecleanuptask.FieldFilters)
  41333. }
  41334. if m.created_by != nil {
  41335. fields = append(fields, usagecleanuptask.FieldCreatedBy)
  41336. }
  41337. if m.deleted_rows != nil {
  41338. fields = append(fields, usagecleanuptask.FieldDeletedRows)
  41339. }
  41340. if m.error_message != nil {
  41341. fields = append(fields, usagecleanuptask.FieldErrorMessage)
  41342. }
  41343. if m.canceled_by != nil {
  41344. fields = append(fields, usagecleanuptask.FieldCanceledBy)
  41345. }
  41346. if m.canceled_at != nil {
  41347. fields = append(fields, usagecleanuptask.FieldCanceledAt)
  41348. }
  41349. if m.started_at != nil {
  41350. fields = append(fields, usagecleanuptask.FieldStartedAt)
  41351. }
  41352. if m.finished_at != nil {
  41353. fields = append(fields, usagecleanuptask.FieldFinishedAt)
  41354. }
  41355. return fields
  41356. }
  41357. // Field returns the value of a field with the given name. The second boolean
  41358. // return value indicates that this field was not set, or was not defined in the
  41359. // schema.
  41360. func (m *UsageCleanupTaskMutation) Field(name string) (ent.Value, bool) {
  41361. switch name {
  41362. case usagecleanuptask.FieldCreatedAt:
  41363. return m.CreatedAt()
  41364. case usagecleanuptask.FieldUpdatedAt:
  41365. return m.UpdatedAt()
  41366. case usagecleanuptask.FieldStatus:
  41367. return m.Status()
  41368. case usagecleanuptask.FieldFilters:
  41369. return m.Filters()
  41370. case usagecleanuptask.FieldCreatedBy:
  41371. return m.CreatedBy()
  41372. case usagecleanuptask.FieldDeletedRows:
  41373. return m.DeletedRows()
  41374. case usagecleanuptask.FieldErrorMessage:
  41375. return m.ErrorMessage()
  41376. case usagecleanuptask.FieldCanceledBy:
  41377. return m.CanceledBy()
  41378. case usagecleanuptask.FieldCanceledAt:
  41379. return m.CanceledAt()
  41380. case usagecleanuptask.FieldStartedAt:
  41381. return m.StartedAt()
  41382. case usagecleanuptask.FieldFinishedAt:
  41383. return m.FinishedAt()
  41384. }
  41385. return nil, false
  41386. }
  41387. // OldField returns the old value of the field from the database. An error is
  41388. // returned if the mutation operation is not UpdateOne, or the query to the
  41389. // database failed.
  41390. func (m *UsageCleanupTaskMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  41391. switch name {
  41392. case usagecleanuptask.FieldCreatedAt:
  41393. return m.OldCreatedAt(ctx)
  41394. case usagecleanuptask.FieldUpdatedAt:
  41395. return m.OldUpdatedAt(ctx)
  41396. case usagecleanuptask.FieldStatus:
  41397. return m.OldStatus(ctx)
  41398. case usagecleanuptask.FieldFilters:
  41399. return m.OldFilters(ctx)
  41400. case usagecleanuptask.FieldCreatedBy:
  41401. return m.OldCreatedBy(ctx)
  41402. case usagecleanuptask.FieldDeletedRows:
  41403. return m.OldDeletedRows(ctx)
  41404. case usagecleanuptask.FieldErrorMessage:
  41405. return m.OldErrorMessage(ctx)
  41406. case usagecleanuptask.FieldCanceledBy:
  41407. return m.OldCanceledBy(ctx)
  41408. case usagecleanuptask.FieldCanceledAt:
  41409. return m.OldCanceledAt(ctx)
  41410. case usagecleanuptask.FieldStartedAt:
  41411. return m.OldStartedAt(ctx)
  41412. case usagecleanuptask.FieldFinishedAt:
  41413. return m.OldFinishedAt(ctx)
  41414. }
  41415. return nil, fmt.Errorf("unknown UsageCleanupTask field %s", name)
  41416. }
  41417. // SetField sets the value of a field with the given name. It returns an error if
  41418. // the field is not defined in the schema, or if the type mismatched the field
  41419. // type.
  41420. func (m *UsageCleanupTaskMutation) SetField(name string, value ent.Value) error {
  41421. switch name {
  41422. case usagecleanuptask.FieldCreatedAt:
  41423. v, ok := value.(time.Time)
  41424. if !ok {
  41425. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41426. }
  41427. m.SetCreatedAt(v)
  41428. return nil
  41429. case usagecleanuptask.FieldUpdatedAt:
  41430. v, ok := value.(time.Time)
  41431. if !ok {
  41432. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41433. }
  41434. m.SetUpdatedAt(v)
  41435. return nil
  41436. case usagecleanuptask.FieldStatus:
  41437. v, ok := value.(string)
  41438. if !ok {
  41439. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41440. }
  41441. m.SetStatus(v)
  41442. return nil
  41443. case usagecleanuptask.FieldFilters:
  41444. v, ok := value.(jsontext.Value)
  41445. if !ok {
  41446. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41447. }
  41448. m.SetFilters(v)
  41449. return nil
  41450. case usagecleanuptask.FieldCreatedBy:
  41451. v, ok := value.(int64)
  41452. if !ok {
  41453. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41454. }
  41455. m.SetCreatedBy(v)
  41456. return nil
  41457. case usagecleanuptask.FieldDeletedRows:
  41458. v, ok := value.(int64)
  41459. if !ok {
  41460. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41461. }
  41462. m.SetDeletedRows(v)
  41463. return nil
  41464. case usagecleanuptask.FieldErrorMessage:
  41465. v, ok := value.(string)
  41466. if !ok {
  41467. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41468. }
  41469. m.SetErrorMessage(v)
  41470. return nil
  41471. case usagecleanuptask.FieldCanceledBy:
  41472. v, ok := value.(int64)
  41473. if !ok {
  41474. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41475. }
  41476. m.SetCanceledBy(v)
  41477. return nil
  41478. case usagecleanuptask.FieldCanceledAt:
  41479. v, ok := value.(time.Time)
  41480. if !ok {
  41481. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41482. }
  41483. m.SetCanceledAt(v)
  41484. return nil
  41485. case usagecleanuptask.FieldStartedAt:
  41486. v, ok := value.(time.Time)
  41487. if !ok {
  41488. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41489. }
  41490. m.SetStartedAt(v)
  41491. return nil
  41492. case usagecleanuptask.FieldFinishedAt:
  41493. v, ok := value.(time.Time)
  41494. if !ok {
  41495. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41496. }
  41497. m.SetFinishedAt(v)
  41498. return nil
  41499. }
  41500. return fmt.Errorf("unknown UsageCleanupTask field %s", name)
  41501. }
  41502. // AddedFields returns all numeric fields that were incremented/decremented during
  41503. // this mutation.
  41504. func (m *UsageCleanupTaskMutation) AddedFields() []string {
  41505. var fields []string
  41506. if m.addcreated_by != nil {
  41507. fields = append(fields, usagecleanuptask.FieldCreatedBy)
  41508. }
  41509. if m.adddeleted_rows != nil {
  41510. fields = append(fields, usagecleanuptask.FieldDeletedRows)
  41511. }
  41512. if m.addcanceled_by != nil {
  41513. fields = append(fields, usagecleanuptask.FieldCanceledBy)
  41514. }
  41515. return fields
  41516. }
  41517. // AddedField returns the numeric value that was incremented/decremented on a field
  41518. // with the given name. The second boolean return value indicates that this field
  41519. // was not set, or was not defined in the schema.
  41520. func (m *UsageCleanupTaskMutation) AddedField(name string) (ent.Value, bool) {
  41521. switch name {
  41522. case usagecleanuptask.FieldCreatedBy:
  41523. return m.AddedCreatedBy()
  41524. case usagecleanuptask.FieldDeletedRows:
  41525. return m.AddedDeletedRows()
  41526. case usagecleanuptask.FieldCanceledBy:
  41527. return m.AddedCanceledBy()
  41528. }
  41529. return nil, false
  41530. }
  41531. // AddField adds the value to the field with the given name. It returns an error if
  41532. // the field is not defined in the schema, or if the type mismatched the field
  41533. // type.
  41534. func (m *UsageCleanupTaskMutation) AddField(name string, value ent.Value) error {
  41535. switch name {
  41536. case usagecleanuptask.FieldCreatedBy:
  41537. v, ok := value.(int64)
  41538. if !ok {
  41539. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41540. }
  41541. m.AddCreatedBy(v)
  41542. return nil
  41543. case usagecleanuptask.FieldDeletedRows:
  41544. v, ok := value.(int64)
  41545. if !ok {
  41546. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41547. }
  41548. m.AddDeletedRows(v)
  41549. return nil
  41550. case usagecleanuptask.FieldCanceledBy:
  41551. v, ok := value.(int64)
  41552. if !ok {
  41553. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41554. }
  41555. m.AddCanceledBy(v)
  41556. return nil
  41557. }
  41558. return fmt.Errorf("unknown UsageCleanupTask numeric field %s", name)
  41559. }
  41560. // ClearedFields returns all nullable fields that were cleared during this
  41561. // mutation.
  41562. func (m *UsageCleanupTaskMutation) ClearedFields() []string {
  41563. var fields []string
  41564. if m.FieldCleared(usagecleanuptask.FieldErrorMessage) {
  41565. fields = append(fields, usagecleanuptask.FieldErrorMessage)
  41566. }
  41567. if m.FieldCleared(usagecleanuptask.FieldCanceledBy) {
  41568. fields = append(fields, usagecleanuptask.FieldCanceledBy)
  41569. }
  41570. if m.FieldCleared(usagecleanuptask.FieldCanceledAt) {
  41571. fields = append(fields, usagecleanuptask.FieldCanceledAt)
  41572. }
  41573. if m.FieldCleared(usagecleanuptask.FieldStartedAt) {
  41574. fields = append(fields, usagecleanuptask.FieldStartedAt)
  41575. }
  41576. if m.FieldCleared(usagecleanuptask.FieldFinishedAt) {
  41577. fields = append(fields, usagecleanuptask.FieldFinishedAt)
  41578. }
  41579. return fields
  41580. }
  41581. // FieldCleared returns a boolean indicating if a field with the given name was
  41582. // cleared in this mutation.
  41583. func (m *UsageCleanupTaskMutation) FieldCleared(name string) bool {
  41584. _, ok := m.clearedFields[name]
  41585. return ok
  41586. }
  41587. // ClearField clears the value of the field with the given name. It returns an
  41588. // error if the field is not defined in the schema.
  41589. func (m *UsageCleanupTaskMutation) ClearField(name string) error {
  41590. switch name {
  41591. case usagecleanuptask.FieldErrorMessage:
  41592. m.ClearErrorMessage()
  41593. return nil
  41594. case usagecleanuptask.FieldCanceledBy:
  41595. m.ClearCanceledBy()
  41596. return nil
  41597. case usagecleanuptask.FieldCanceledAt:
  41598. m.ClearCanceledAt()
  41599. return nil
  41600. case usagecleanuptask.FieldStartedAt:
  41601. m.ClearStartedAt()
  41602. return nil
  41603. case usagecleanuptask.FieldFinishedAt:
  41604. m.ClearFinishedAt()
  41605. return nil
  41606. }
  41607. return fmt.Errorf("unknown UsageCleanupTask nullable field %s", name)
  41608. }
  41609. // ResetField resets all changes in the mutation for the field with the given name.
  41610. // It returns an error if the field is not defined in the schema.
  41611. func (m *UsageCleanupTaskMutation) ResetField(name string) error {
  41612. switch name {
  41613. case usagecleanuptask.FieldCreatedAt:
  41614. m.ResetCreatedAt()
  41615. return nil
  41616. case usagecleanuptask.FieldUpdatedAt:
  41617. m.ResetUpdatedAt()
  41618. return nil
  41619. case usagecleanuptask.FieldStatus:
  41620. m.ResetStatus()
  41621. return nil
  41622. case usagecleanuptask.FieldFilters:
  41623. m.ResetFilters()
  41624. return nil
  41625. case usagecleanuptask.FieldCreatedBy:
  41626. m.ResetCreatedBy()
  41627. return nil
  41628. case usagecleanuptask.FieldDeletedRows:
  41629. m.ResetDeletedRows()
  41630. return nil
  41631. case usagecleanuptask.FieldErrorMessage:
  41632. m.ResetErrorMessage()
  41633. return nil
  41634. case usagecleanuptask.FieldCanceledBy:
  41635. m.ResetCanceledBy()
  41636. return nil
  41637. case usagecleanuptask.FieldCanceledAt:
  41638. m.ResetCanceledAt()
  41639. return nil
  41640. case usagecleanuptask.FieldStartedAt:
  41641. m.ResetStartedAt()
  41642. return nil
  41643. case usagecleanuptask.FieldFinishedAt:
  41644. m.ResetFinishedAt()
  41645. return nil
  41646. }
  41647. return fmt.Errorf("unknown UsageCleanupTask field %s", name)
  41648. }
  41649. // AddedEdges returns all edge names that were set/added in this mutation.
  41650. func (m *UsageCleanupTaskMutation) AddedEdges() []string {
  41651. edges := make([]string, 0, 0)
  41652. return edges
  41653. }
  41654. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  41655. // name in this mutation.
  41656. func (m *UsageCleanupTaskMutation) AddedIDs(name string) []ent.Value {
  41657. return nil
  41658. }
  41659. // RemovedEdges returns all edge names that were removed in this mutation.
  41660. func (m *UsageCleanupTaskMutation) RemovedEdges() []string {
  41661. edges := make([]string, 0, 0)
  41662. return edges
  41663. }
  41664. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  41665. // the given name in this mutation.
  41666. func (m *UsageCleanupTaskMutation) RemovedIDs(name string) []ent.Value {
  41667. return nil
  41668. }
  41669. // ClearedEdges returns all edge names that were cleared in this mutation.
  41670. func (m *UsageCleanupTaskMutation) ClearedEdges() []string {
  41671. edges := make([]string, 0, 0)
  41672. return edges
  41673. }
  41674. // EdgeCleared returns a boolean which indicates if the edge with the given name
  41675. // was cleared in this mutation.
  41676. func (m *UsageCleanupTaskMutation) EdgeCleared(name string) bool {
  41677. return false
  41678. }
  41679. // ClearEdge clears the value of the edge with the given name. It returns an error
  41680. // if that edge is not defined in the schema.
  41681. func (m *UsageCleanupTaskMutation) ClearEdge(name string) error {
  41682. return fmt.Errorf("unknown UsageCleanupTask unique edge %s", name)
  41683. }
  41684. // ResetEdge resets all changes to the edge with the given name in this mutation.
  41685. // It returns an error if the edge is not defined in the schema.
  41686. func (m *UsageCleanupTaskMutation) ResetEdge(name string) error {
  41687. return fmt.Errorf("unknown UsageCleanupTask edge %s", name)
  41688. }
  41689. // UsageLogMutation represents an operation that mutates the UsageLog nodes in the graph.
  41690. type UsageLogMutation struct {
  41691. config
  41692. op Op
  41693. typ string
  41694. id *int64
  41695. request_id *string
  41696. model *string
  41697. requested_model *string
  41698. upstream_model *string
  41699. upstream_response_model *string
  41700. upstream_model_mismatch *bool
  41701. channel_id *int64
  41702. addchannel_id *int64
  41703. model_mapping_chain *string
  41704. billing_tier *string
  41705. billing_mode *string
  41706. input_tokens *int
  41707. addinput_tokens *int
  41708. output_tokens *int
  41709. addoutput_tokens *int
  41710. cache_creation_tokens *int
  41711. addcache_creation_tokens *int
  41712. cache_read_tokens *int
  41713. addcache_read_tokens *int
  41714. cache_creation_5m_tokens *int
  41715. addcache_creation_5m_tokens *int
  41716. cache_creation_1h_tokens *int
  41717. addcache_creation_1h_tokens *int
  41718. input_cost *float64
  41719. addinput_cost *float64
  41720. output_cost *float64
  41721. addoutput_cost *float64
  41722. cache_creation_cost *float64
  41723. addcache_creation_cost *float64
  41724. cache_read_cost *float64
  41725. addcache_read_cost *float64
  41726. total_cost *float64
  41727. addtotal_cost *float64
  41728. actual_cost *float64
  41729. addactual_cost *float64
  41730. rate_multiplier *float64
  41731. addrate_multiplier *float64
  41732. long_context_billing_applied *bool
  41733. account_rate_multiplier *float64
  41734. addaccount_rate_multiplier *float64
  41735. billing_type *int8
  41736. addbilling_type *int8
  41737. stream *bool
  41738. duration_ms *int
  41739. addduration_ms *int
  41740. first_token_ms *int
  41741. addfirst_token_ms *int
  41742. user_agent *string
  41743. ip_address *string
  41744. image_count *int
  41745. addimage_count *int
  41746. image_size *string
  41747. image_input_size *string
  41748. image_output_size *string
  41749. image_size_source *string
  41750. image_size_breakdown *map[string]int
  41751. video_count *int
  41752. addvideo_count *int
  41753. video_resolution *string
  41754. video_duration_seconds *int
  41755. addvideo_duration_seconds *int
  41756. cache_ttl_overridden *bool
  41757. created_at *time.Time
  41758. clearedFields map[string]struct{}
  41759. user *int64
  41760. cleareduser bool
  41761. api_key *int64
  41762. clearedapi_key bool
  41763. account *int64
  41764. clearedaccount bool
  41765. group *int64
  41766. clearedgroup bool
  41767. subscription *int64
  41768. clearedsubscription bool
  41769. done bool
  41770. oldValue func(context.Context) (*UsageLog, error)
  41771. predicates []predicate.UsageLog
  41772. }
  41773. var _ ent.Mutation = (*UsageLogMutation)(nil)
  41774. // usagelogOption allows management of the mutation configuration using functional options.
  41775. type usagelogOption func(*UsageLogMutation)
  41776. // newUsageLogMutation creates new mutation for the UsageLog entity.
  41777. func newUsageLogMutation(c config, op Op, opts ...usagelogOption) *UsageLogMutation {
  41778. m := &UsageLogMutation{
  41779. config: c,
  41780. op: op,
  41781. typ: TypeUsageLog,
  41782. clearedFields: make(map[string]struct{}),
  41783. }
  41784. for _, opt := range opts {
  41785. opt(m)
  41786. }
  41787. return m
  41788. }
  41789. // withUsageLogID sets the ID field of the mutation.
  41790. func withUsageLogID(id int64) usagelogOption {
  41791. return func(m *UsageLogMutation) {
  41792. var (
  41793. err error
  41794. once sync.Once
  41795. value *UsageLog
  41796. )
  41797. m.oldValue = func(ctx context.Context) (*UsageLog, error) {
  41798. once.Do(func() {
  41799. if m.done {
  41800. err = errors.New("querying old values post mutation is not allowed")
  41801. } else {
  41802. value, err = m.Client().UsageLog.Get(ctx, id)
  41803. }
  41804. })
  41805. return value, err
  41806. }
  41807. m.id = &id
  41808. }
  41809. }
  41810. // withUsageLog sets the old UsageLog of the mutation.
  41811. func withUsageLog(node *UsageLog) usagelogOption {
  41812. return func(m *UsageLogMutation) {
  41813. m.oldValue = func(context.Context) (*UsageLog, error) {
  41814. return node, nil
  41815. }
  41816. m.id = &node.ID
  41817. }
  41818. }
  41819. // Client returns a new `ent.Client` from the mutation. If the mutation was
  41820. // executed in a transaction (ent.Tx), a transactional client is returned.
  41821. func (m UsageLogMutation) Client() *Client {
  41822. client := &Client{config: m.config}
  41823. client.init()
  41824. return client
  41825. }
  41826. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  41827. // it returns an error otherwise.
  41828. func (m UsageLogMutation) Tx() (*Tx, error) {
  41829. if _, ok := m.driver.(*txDriver); !ok {
  41830. return nil, errors.New("ent: mutation is not running in a transaction")
  41831. }
  41832. tx := &Tx{config: m.config}
  41833. tx.init()
  41834. return tx, nil
  41835. }
  41836. // ID returns the ID value in the mutation. Note that the ID is only available
  41837. // if it was provided to the builder or after it was returned from the database.
  41838. func (m *UsageLogMutation) ID() (id int64, exists bool) {
  41839. if m.id == nil {
  41840. return
  41841. }
  41842. return *m.id, true
  41843. }
  41844. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  41845. // That means, if the mutation is applied within a transaction with an isolation level such
  41846. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  41847. // or updated by the mutation.
  41848. func (m *UsageLogMutation) IDs(ctx context.Context) ([]int64, error) {
  41849. switch {
  41850. case m.op.Is(OpUpdateOne | OpDeleteOne):
  41851. id, exists := m.ID()
  41852. if exists {
  41853. return []int64{id}, nil
  41854. }
  41855. fallthrough
  41856. case m.op.Is(OpUpdate | OpDelete):
  41857. return m.Client().UsageLog.Query().Where(m.predicates...).IDs(ctx)
  41858. default:
  41859. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  41860. }
  41861. }
  41862. // SetUserID sets the "user_id" field.
  41863. func (m *UsageLogMutation) SetUserID(i int64) {
  41864. m.user = &i
  41865. }
  41866. // UserID returns the value of the "user_id" field in the mutation.
  41867. func (m *UsageLogMutation) UserID() (r int64, exists bool) {
  41868. v := m.user
  41869. if v == nil {
  41870. return
  41871. }
  41872. return *v, true
  41873. }
  41874. // OldUserID returns the old "user_id" field's value of the UsageLog entity.
  41875. // If the UsageLog object wasn't provided to the builder, the object is fetched from the database.
  41876. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41877. func (m *UsageLogMutation) OldUserID(ctx context.Context) (v int64, err error) {
  41878. if !m.op.Is(OpUpdateOne) {
  41879. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  41880. }
  41881. if m.id == nil || m.oldValue == nil {
  41882. return v, errors.New("OldUserID requires an ID field in the mutation")
  41883. }
  41884. oldValue, err := m.oldValue(ctx)
  41885. if err != nil {
  41886. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  41887. }
  41888. return oldValue.UserID, nil
  41889. }
  41890. // ResetUserID resets all changes to the "user_id" field.
  41891. func (m *UsageLogMutation) ResetUserID() {
  41892. m.user = nil
  41893. }
  41894. // SetAPIKeyID sets the "api_key_id" field.
  41895. func (m *UsageLogMutation) SetAPIKeyID(i int64) {
  41896. m.api_key = &i
  41897. }
  41898. // APIKeyID returns the value of the "api_key_id" field in the mutation.
  41899. func (m *UsageLogMutation) APIKeyID() (r int64, exists bool) {
  41900. v := m.api_key
  41901. if v == nil {
  41902. return
  41903. }
  41904. return *v, true
  41905. }
  41906. // OldAPIKeyID returns the old "api_key_id" field's value of the UsageLog entity.
  41907. // If the UsageLog object wasn't provided to the builder, the object is fetched from the database.
  41908. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41909. func (m *UsageLogMutation) OldAPIKeyID(ctx context.Context) (v int64, err error) {
  41910. if !m.op.Is(OpUpdateOne) {
  41911. return v, errors.New("OldAPIKeyID is only allowed on UpdateOne operations")
  41912. }
  41913. if m.id == nil || m.oldValue == nil {
  41914. return v, errors.New("OldAPIKeyID requires an ID field in the mutation")
  41915. }
  41916. oldValue, err := m.oldValue(ctx)
  41917. if err != nil {
  41918. return v, fmt.Errorf("querying old value for OldAPIKeyID: %w", err)
  41919. }
  41920. return oldValue.APIKeyID, nil
  41921. }
  41922. // ResetAPIKeyID resets all changes to the "api_key_id" field.
  41923. func (m *UsageLogMutation) ResetAPIKeyID() {
  41924. m.api_key = nil
  41925. }
  41926. // SetAccountID sets the "account_id" field.
  41927. func (m *UsageLogMutation) SetAccountID(i int64) {
  41928. m.account = &i
  41929. }
  41930. // AccountID returns the value of the "account_id" field in the mutation.
  41931. func (m *UsageLogMutation) AccountID() (r int64, exists bool) {
  41932. v := m.account
  41933. if v == nil {
  41934. return
  41935. }
  41936. return *v, true
  41937. }
  41938. // OldAccountID returns the old "account_id" field's value of the UsageLog entity.
  41939. // If the UsageLog object wasn't provided to the builder, the object is fetched from the database.
  41940. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41941. func (m *UsageLogMutation) OldAccountID(ctx context.Context) (v int64, err error) {
  41942. if !m.op.Is(OpUpdateOne) {
  41943. return v, errors.New("OldAccountID is only allowed on UpdateOne operations")
  41944. }
  41945. if m.id == nil || m.oldValue == nil {
  41946. return v, errors.New("OldAccountID requires an ID field in the mutation")
  41947. }
  41948. oldValue, err := m.oldValue(ctx)
  41949. if err != nil {
  41950. return v, fmt.Errorf("querying old value for OldAccountID: %w", err)
  41951. }
  41952. return oldValue.AccountID, nil
  41953. }
  41954. // ResetAccountID resets all changes to the "account_id" field.
  41955. func (m *UsageLogMutation) ResetAccountID() {
  41956. m.account = nil
  41957. }
  41958. // SetRequestID sets the "request_id" field.
  41959. func (m *UsageLogMutation) SetRequestID(s string) {
  41960. m.request_id = &s
  41961. }
  41962. // RequestID returns the value of the "request_id" field in the mutation.
  41963. func (m *UsageLogMutation) RequestID() (r string, exists bool) {
  41964. v := m.request_id
  41965. if v == nil {
  41966. return
  41967. }
  41968. return *v, true
  41969. }
  41970. // OldRequestID returns the old "request_id" field's value of the UsageLog entity.
  41971. // If the UsageLog object wasn't provided to the builder, the object is fetched from the database.
  41972. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41973. func (m *UsageLogMutation) OldRequestID(ctx context.Context) (v string, err error) {
  41974. if !m.op.Is(OpUpdateOne) {
  41975. return v, errors.New("OldRequestID is only allowed on UpdateOne operations")
  41976. }
  41977. if m.id == nil || m.oldValue == nil {
  41978. return v, errors.New("OldRequestID requires an ID field in the mutation")
  41979. }
  41980. oldValue, err := m.oldValue(ctx)
  41981. if err != nil {
  41982. return v, fmt.Errorf("querying old value for OldRequestID: %w", err)
  41983. }
  41984. return oldValue.RequestID, nil
  41985. }
  41986. // ResetRequestID resets all changes to the "request_id" field.
  41987. func (m *UsageLogMutation) ResetRequestID() {
  41988. m.request_id = nil
  41989. }
  41990. // SetModel sets the "model" field.
  41991. func (m *UsageLogMutation) SetModel(s string) {
  41992. m.model = &s
  41993. }
  41994. // Model returns the value of the "model" field in the mutation.
  41995. func (m *UsageLogMutation) Model() (r string, exists bool) {
  41996. v := m.model
  41997. if v == nil {
  41998. return
  41999. }
  42000. return *v, true
  42001. }
  42002. // OldModel returns the old "model" field's value of the UsageLog entity.
  42003. // If the UsageLog object wasn't provided to the builder, the object is fetched from the database.
  42004. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42005. func (m *UsageLogMutation) OldModel(ctx context.Context) (v string, err error) {
  42006. if !m.op.Is(OpUpdateOne) {
  42007. return v, errors.New("OldModel is only allowed on UpdateOne operations")
  42008. }
  42009. if m.id == nil || m.oldValue == nil {
  42010. return v, errors.New("OldModel requires an ID field in the mutation")
  42011. }
  42012. oldValue, err := m.oldValue(ctx)
  42013. if err != nil {
  42014. return v, fmt.Errorf("querying old value for OldModel: %w", err)
  42015. }
  42016. return oldValue.Model, nil
  42017. }
  42018. // ResetModel resets all changes to the "model" field.
  42019. func (m *UsageLogMutation) ResetModel() {
  42020. m.model = nil
  42021. }
  42022. // SetRequestedModel sets the "requested_model" field.
  42023. func (m *UsageLogMutation) SetRequestedModel(s string) {
  42024. m.requested_model = &s
  42025. }
  42026. // RequestedModel returns the value of the "requested_model" field in the mutation.
  42027. func (m *UsageLogMutation) RequestedModel() (r string, exists bool) {
  42028. v := m.requested_model
  42029. if v == nil {
  42030. return
  42031. }
  42032. return *v, true
  42033. }
  42034. // OldRequestedModel returns the old "requested_model" field's value of the UsageLog entity.
  42035. // If the UsageLog object wasn't provided to the builder, the object is fetched from the database.
  42036. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42037. func (m *UsageLogMutation) OldRequestedModel(ctx context.Context) (v *string, err error) {
  42038. if !m.op.Is(OpUpdateOne) {
  42039. return v, errors.New("OldRequestedModel is only allowed on UpdateOne operations")
  42040. }
  42041. if m.id == nil || m.oldValue == nil {
  42042. return v, errors.New("OldRequestedModel requires an ID field in the mutation")
  42043. }
  42044. oldValue, err := m.oldValue(ctx)
  42045. if err != nil {
  42046. return v, fmt.Errorf("querying old value for OldRequestedModel: %w", err)
  42047. }
  42048. return oldValue.RequestedModel, nil
  42049. }
  42050. // ClearRequestedModel clears the value of the "requested_model" field.
  42051. func (m *UsageLogMutation) ClearRequestedModel() {
  42052. m.requested_model = nil
  42053. m.clearedFields[usagelog.FieldRequestedModel] = struct{}{}
  42054. }
  42055. // RequestedModelCleared returns if the "requested_model" field was cleared in this mutation.
  42056. func (m *UsageLogMutation) RequestedModelCleared() bool {
  42057. _, ok := m.clearedFields[usagelog.FieldRequestedModel]
  42058. return ok
  42059. }
  42060. // ResetRequestedModel resets all changes to the "requested_model" field.
  42061. func (m *UsageLogMutation) ResetRequestedModel() {
  42062. m.requested_model = nil
  42063. delete(m.clearedFields, usagelog.FieldRequestedModel)
  42064. }
  42065. // SetUpstreamModel sets the "upstream_model" field.
  42066. func (m *UsageLogMutation) SetUpstreamModel(s string) {
  42067. m.upstream_model = &s
  42068. }
  42069. // UpstreamModel returns the value of the "upstream_model" field in the mutation.
  42070. func (m *UsageLogMutation) UpstreamModel() (r string, exists bool) {
  42071. v := m.upstream_model
  42072. if v == nil {
  42073. return
  42074. }
  42075. return *v, true
  42076. }
  42077. // OldUpstreamModel returns the old "upstream_model" field's value of the UsageLog entity.
  42078. // If the UsageLog object wasn't provided to the builder, the object is fetched from the database.
  42079. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42080. func (m *UsageLogMutation) OldUpstreamModel(ctx context.Context) (v *string, err error) {
  42081. if !m.op.Is(OpUpdateOne) {
  42082. return v, errors.New("OldUpstreamModel is only allowed on UpdateOne operations")
  42083. }
  42084. if m.id == nil || m.oldValue == nil {
  42085. return v, errors.New("OldUpstreamModel requires an ID field in the mutation")
  42086. }
  42087. oldValue, err := m.oldValue(ctx)
  42088. if err != nil {
  42089. return v, fmt.Errorf("querying old value for OldUpstreamModel: %w", err)
  42090. }
  42091. return oldValue.UpstreamModel, nil
  42092. }
  42093. // ClearUpstreamModel clears the value of the "upstream_model" field.
  42094. func (m *UsageLogMutation) ClearUpstreamModel() {
  42095. m.upstream_model = nil
  42096. m.clearedFields[usagelog.FieldUpstreamModel] = struct{}{}
  42097. }
  42098. // UpstreamModelCleared returns if the "upstream_model" field was cleared in this mutation.
  42099. func (m *UsageLogMutation) UpstreamModelCleared() bool {
  42100. _, ok := m.clearedFields[usagelog.FieldUpstreamModel]
  42101. return ok
  42102. }
  42103. // ResetUpstreamModel resets all changes to the "upstream_model" field.
  42104. func (m *UsageLogMutation) ResetUpstreamModel() {
  42105. m.upstream_model = nil
  42106. delete(m.clearedFields, usagelog.FieldUpstreamModel)
  42107. }
  42108. // SetUpstreamResponseModel sets the "upstream_response_model" field.
  42109. func (m *UsageLogMutation) SetUpstreamResponseModel(s string) {
  42110. m.upstream_response_model = &s
  42111. }
  42112. // UpstreamResponseModel returns the value of the "upstream_response_model" field in the mutation.
  42113. func (m *UsageLogMutation) UpstreamResponseModel() (r string, exists bool) {
  42114. v := m.upstream_response_model
  42115. if v == nil {
  42116. return
  42117. }
  42118. return *v, true
  42119. }
  42120. // OldUpstreamResponseModel returns the old "upstream_response_model" field's value of the UsageLog entity.
  42121. // If the UsageLog object wasn't provided to the builder, the object is fetched from the database.
  42122. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42123. func (m *UsageLogMutation) OldUpstreamResponseModel(ctx context.Context) (v *string, err error) {
  42124. if !m.op.Is(OpUpdateOne) {
  42125. return v, errors.New("OldUpstreamResponseModel is only allowed on UpdateOne operations")
  42126. }
  42127. if m.id == nil || m.oldValue == nil {
  42128. return v, errors.New("OldUpstreamResponseModel requires an ID field in the mutation")
  42129. }
  42130. oldValue, err := m.oldValue(ctx)
  42131. if err != nil {
  42132. return v, fmt.Errorf("querying old value for OldUpstreamResponseModel: %w", err)
  42133. }
  42134. return oldValue.UpstreamResponseModel, nil
  42135. }
  42136. // ClearUpstreamResponseModel clears the value of the "upstream_response_model" field.
  42137. func (m *UsageLogMutation) ClearUpstreamResponseModel() {
  42138. m.upstream_response_model = nil
  42139. m.clearedFields[usagelog.FieldUpstreamResponseModel] = struct{}{}
  42140. }
  42141. // UpstreamResponseModelCleared returns if the "upstream_response_model" field was cleared in this mutation.
  42142. func (m *UsageLogMutation) UpstreamResponseModelCleared() bool {
  42143. _, ok := m.clearedFields[usagelog.FieldUpstreamResponseModel]
  42144. return ok
  42145. }
  42146. // ResetUpstreamResponseModel resets all changes to the "upstream_response_model" field.
  42147. func (m *UsageLogMutation) ResetUpstreamResponseModel() {
  42148. m.upstream_response_model = nil
  42149. delete(m.clearedFields, usagelog.FieldUpstreamResponseModel)
  42150. }
  42151. // SetUpstreamModelMismatch sets the "upstream_model_mismatch" field.
  42152. func (m *UsageLogMutation) SetUpstreamModelMismatch(b bool) {
  42153. m.upstream_model_mismatch = &b
  42154. }
  42155. // UpstreamModelMismatch returns the value of the "upstream_model_mismatch" field in the mutation.
  42156. func (m *UsageLogMutation) UpstreamModelMismatch() (r bool, exists bool) {
  42157. v := m.upstream_model_mismatch
  42158. if v == nil {
  42159. return
  42160. }
  42161. return *v, true
  42162. }
  42163. // OldUpstreamModelMismatch returns the old "upstream_model_mismatch" field's value of the UsageLog entity.
  42164. // If the UsageLog object wasn't provided to the builder, the object is fetched from the database.
  42165. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42166. func (m *UsageLogMutation) OldUpstreamModelMismatch(ctx context.Context) (v *bool, err error) {
  42167. if !m.op.Is(OpUpdateOne) {
  42168. return v, errors.New("OldUpstreamModelMismatch is only allowed on UpdateOne operations")
  42169. }
  42170. if m.id == nil || m.oldValue == nil {
  42171. return v, errors.New("OldUpstreamModelMismatch requires an ID field in the mutation")
  42172. }
  42173. oldValue, err := m.oldValue(ctx)
  42174. if err != nil {
  42175. return v, fmt.Errorf("querying old value for OldUpstreamModelMismatch: %w", err)
  42176. }
  42177. return oldValue.UpstreamModelMismatch, nil
  42178. }
  42179. // ClearUpstreamModelMismatch clears the value of the "upstream_model_mismatch" field.
  42180. func (m *UsageLogMutation) ClearUpstreamModelMismatch() {
  42181. m.upstream_model_mismatch = nil
  42182. m.clearedFields[usagelog.FieldUpstreamModelMismatch] = struct{}{}
  42183. }
  42184. // UpstreamModelMismatchCleared returns if the "upstream_model_mismatch" field was cleared in this mutation.
  42185. func (m *UsageLogMutation) UpstreamModelMismatchCleared() bool {
  42186. _, ok := m.clearedFields[usagelog.FieldUpstreamModelMismatch]
  42187. return ok
  42188. }
  42189. // ResetUpstreamModelMismatch resets all changes to the "upstream_model_mismatch" field.
  42190. func (m *UsageLogMutation) ResetUpstreamModelMismatch() {
  42191. m.upstream_model_mismatch = nil
  42192. delete(m.clearedFields, usagelog.FieldUpstreamModelMismatch)
  42193. }
  42194. // SetChannelID sets the "channel_id" field.
  42195. func (m *UsageLogMutation) SetChannelID(i int64) {
  42196. m.channel_id = &i
  42197. m.addchannel_id = nil
  42198. }
  42199. // ChannelID returns the value of the "channel_id" field in the mutation.
  42200. func (m *UsageLogMutation) ChannelID() (r int64, exists bool) {
  42201. v := m.channel_id
  42202. if v == nil {
  42203. return
  42204. }
  42205. return *v, true
  42206. }
  42207. // OldChannelID returns the old "channel_id" field's value of the UsageLog entity.
  42208. // If the UsageLog object wasn't provided to the builder, the object is fetched from the database.
  42209. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42210. func (m *UsageLogMutation) OldChannelID(ctx context.Context) (v *int64, err error) {
  42211. if !m.op.Is(OpUpdateOne) {
  42212. return v, errors.New("OldChannelID is only allowed on UpdateOne operations")
  42213. }
  42214. if m.id == nil || m.oldValue == nil {
  42215. return v, errors.New("OldChannelID requires an ID field in the mutation")
  42216. }
  42217. oldValue, err := m.oldValue(ctx)
  42218. if err != nil {
  42219. return v, fmt.Errorf("querying old value for OldChannelID: %w", err)
  42220. }
  42221. return oldValue.ChannelID, nil
  42222. }
  42223. // AddChannelID adds i to the "channel_id" field.
  42224. func (m *UsageLogMutation) AddChannelID(i int64) {
  42225. if m.addchannel_id != nil {
  42226. *m.addchannel_id += i
  42227. } else {
  42228. m.addchannel_id = &i
  42229. }
  42230. }
  42231. // AddedChannelID returns the value that was added to the "channel_id" field in this mutation.
  42232. func (m *UsageLogMutation) AddedChannelID() (r int64, exists bool) {
  42233. v := m.addchannel_id
  42234. if v == nil {
  42235. return
  42236. }
  42237. return *v, true
  42238. }
  42239. // ClearChannelID clears the value of the "channel_id" field.
  42240. func (m *UsageLogMutation) ClearChannelID() {
  42241. m.channel_id = nil
  42242. m.addchannel_id = nil
  42243. m.clearedFields[usagelog.FieldChannelID] = struct{}{}
  42244. }
  42245. // ChannelIDCleared returns if the "channel_id" field was cleared in this mutation.
  42246. func (m *UsageLogMutation) ChannelIDCleared() bool {
  42247. _, ok := m.clearedFields[usagelog.FieldChannelID]
  42248. return ok
  42249. }
  42250. // ResetChannelID resets all changes to the "channel_id" field.
  42251. func (m *UsageLogMutation) ResetChannelID() {
  42252. m.channel_id = nil
  42253. m.addchannel_id = nil
  42254. delete(m.clearedFields, usagelog.FieldChannelID)
  42255. }
  42256. // SetModelMappingChain sets the "model_mapping_chain" field.
  42257. func (m *UsageLogMutation) SetModelMappingChain(s string) {
  42258. m.model_mapping_chain = &s
  42259. }
  42260. // ModelMappingChain returns the value of the "model_mapping_chain" field in the mutation.
  42261. func (m *UsageLogMutation) ModelMappingChain() (r string, exists bool) {
  42262. v := m.model_mapping_chain
  42263. if v == nil {
  42264. return
  42265. }
  42266. return *v, true
  42267. }
  42268. // OldModelMappingChain returns the old "model_mapping_chain" field's value of the UsageLog entity.
  42269. // If the UsageLog object wasn't provided to the builder, the object is fetched from the database.
  42270. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42271. func (m *UsageLogMutation) OldModelMappingChain(ctx context.Context) (v *string, err error) {
  42272. if !m.op.Is(OpUpdateOne) {
  42273. return v, errors.New("OldModelMappingChain is only allowed on UpdateOne operations")
  42274. }
  42275. if m.id == nil || m.oldValue == nil {
  42276. return v, errors.New("OldModelMappingChain requires an ID field in the mutation")
  42277. }
  42278. oldValue, err := m.oldValue(ctx)
  42279. if err != nil {
  42280. return v, fmt.Errorf("querying old value for OldModelMappingChain: %w", err)
  42281. }
  42282. return oldValue.ModelMappingChain, nil
  42283. }
  42284. // ClearModelMappingChain clears the value of the "model_mapping_chain" field.
  42285. func (m *UsageLogMutation) ClearModelMappingChain() {
  42286. m.model_mapping_chain = nil
  42287. m.clearedFields[usagelog.FieldModelMappingChain] = struct{}{}
  42288. }
  42289. // ModelMappingChainCleared returns if the "model_mapping_chain" field was cleared in this mutation.
  42290. func (m *UsageLogMutation) ModelMappingChainCleared() bool {
  42291. _, ok := m.clearedFields[usagelog.FieldModelMappingChain]
  42292. return ok
  42293. }
  42294. // ResetModelMappingChain resets all changes to the "model_mapping_chain" field.
  42295. func (m *UsageLogMutation) ResetModelMappingChain() {
  42296. m.model_mapping_chain = nil
  42297. delete(m.clearedFields, usagelog.FieldModelMappingChain)
  42298. }
  42299. // SetBillingTier sets the "billing_tier" field.
  42300. func (m *UsageLogMutation) SetBillingTier(s string) {
  42301. m.billing_tier = &s
  42302. }
  42303. // BillingTier returns the value of the "billing_tier" field in the mutation.
  42304. func (m *UsageLogMutation) BillingTier() (r string, exists bool) {
  42305. v := m.billing_tier
  42306. if v == nil {
  42307. return
  42308. }
  42309. return *v, true
  42310. }
  42311. // OldBillingTier returns the old "billing_tier" field's value of the UsageLog entity.
  42312. // If the UsageLog object wasn't provided to the builder, the object is fetched from the database.
  42313. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42314. func (m *UsageLogMutation) OldBillingTier(ctx context.Context) (v *string, err error) {
  42315. if !m.op.Is(OpUpdateOne) {
  42316. return v, errors.New("OldBillingTier is only allowed on UpdateOne operations")
  42317. }
  42318. if m.id == nil || m.oldValue == nil {
  42319. return v, errors.New("OldBillingTier requires an ID field in the mutation")
  42320. }
  42321. oldValue, err := m.oldValue(ctx)
  42322. if err != nil {
  42323. return v, fmt.Errorf("querying old value for OldBillingTier: %w", err)
  42324. }
  42325. return oldValue.BillingTier, nil
  42326. }
  42327. // ClearBillingTier clears the value of the "billing_tier" field.
  42328. func (m *UsageLogMutation) ClearBillingTier() {
  42329. m.billing_tier = nil
  42330. m.clearedFields[usagelog.FieldBillingTier] = struct{}{}
  42331. }
  42332. // BillingTierCleared returns if the "billing_tier" field was cleared in this mutation.
  42333. func (m *UsageLogMutation) BillingTierCleared() bool {
  42334. _, ok := m.clearedFields[usagelog.FieldBillingTier]
  42335. return ok
  42336. }
  42337. // ResetBillingTier resets all changes to the "billing_tier" field.
  42338. func (m *UsageLogMutation) ResetBillingTier() {
  42339. m.billing_tier = nil
  42340. delete(m.clearedFields, usagelog.FieldBillingTier)
  42341. }
  42342. // SetBillingMode sets the "billing_mode" field.
  42343. func (m *UsageLogMutation) SetBillingMode(s string) {
  42344. m.billing_mode = &s
  42345. }
  42346. // BillingMode returns the value of the "billing_mode" field in the mutation.
  42347. func (m *UsageLogMutation) BillingMode() (r string, exists bool) {
  42348. v := m.billing_mode
  42349. if v == nil {
  42350. return
  42351. }
  42352. return *v, true
  42353. }
  42354. // OldBillingMode returns the old "billing_mode" field's value of the UsageLog entity.
  42355. // If the UsageLog object wasn't provided to the builder, the object is fetched from the database.
  42356. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42357. func (m *UsageLogMutation) OldBillingMode(ctx context.Context) (v *string, err error) {
  42358. if !m.op.Is(OpUpdateOne) {
  42359. return v, errors.New("OldBillingMode is only allowed on UpdateOne operations")
  42360. }
  42361. if m.id == nil || m.oldValue == nil {
  42362. return v, errors.New("OldBillingMode requires an ID field in the mutation")
  42363. }
  42364. oldValue, err := m.oldValue(ctx)
  42365. if err != nil {
  42366. return v, fmt.Errorf("querying old value for OldBillingMode: %w", err)
  42367. }
  42368. return oldValue.BillingMode, nil
  42369. }
  42370. // ClearBillingMode clears the value of the "billing_mode" field.
  42371. func (m *UsageLogMutation) ClearBillingMode() {
  42372. m.billing_mode = nil
  42373. m.clearedFields[usagelog.FieldBillingMode] = struct{}{}
  42374. }
  42375. // BillingModeCleared returns if the "billing_mode" field was cleared in this mutation.
  42376. func (m *UsageLogMutation) BillingModeCleared() bool {
  42377. _, ok := m.clearedFields[usagelog.FieldBillingMode]
  42378. return ok
  42379. }
  42380. // ResetBillingMode resets all changes to the "billing_mode" field.
  42381. func (m *UsageLogMutation) ResetBillingMode() {
  42382. m.billing_mode = nil
  42383. delete(m.clearedFields, usagelog.FieldBillingMode)
  42384. }
  42385. // SetGroupID sets the "group_id" field.
  42386. func (m *UsageLogMutation) SetGroupID(i int64) {
  42387. m.group = &i
  42388. }
  42389. // GroupID returns the value of the "group_id" field in the mutation.
  42390. func (m *UsageLogMutation) GroupID() (r int64, exists bool) {
  42391. v := m.group
  42392. if v == nil {
  42393. return
  42394. }
  42395. return *v, true
  42396. }
  42397. // OldGroupID returns the old "group_id" field's value of the UsageLog entity.
  42398. // If the UsageLog object wasn't provided to the builder, the object is fetched from the database.
  42399. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42400. func (m *UsageLogMutation) OldGroupID(ctx context.Context) (v *int64, err error) {
  42401. if !m.op.Is(OpUpdateOne) {
  42402. return v, errors.New("OldGroupID is only allowed on UpdateOne operations")
  42403. }
  42404. if m.id == nil || m.oldValue == nil {
  42405. return v, errors.New("OldGroupID requires an ID field in the mutation")
  42406. }
  42407. oldValue, err := m.oldValue(ctx)
  42408. if err != nil {
  42409. return v, fmt.Errorf("querying old value for OldGroupID: %w", err)
  42410. }
  42411. return oldValue.GroupID, nil
  42412. }
  42413. // ClearGroupID clears the value of the "group_id" field.
  42414. func (m *UsageLogMutation) ClearGroupID() {
  42415. m.group = nil
  42416. m.clearedFields[usagelog.FieldGroupID] = struct{}{}
  42417. }
  42418. // GroupIDCleared returns if the "group_id" field was cleared in this mutation.
  42419. func (m *UsageLogMutation) GroupIDCleared() bool {
  42420. _, ok := m.clearedFields[usagelog.FieldGroupID]
  42421. return ok
  42422. }
  42423. // ResetGroupID resets all changes to the "group_id" field.
  42424. func (m *UsageLogMutation) ResetGroupID() {
  42425. m.group = nil
  42426. delete(m.clearedFields, usagelog.FieldGroupID)
  42427. }
  42428. // SetSubscriptionID sets the "subscription_id" field.
  42429. func (m *UsageLogMutation) SetSubscriptionID(i int64) {
  42430. m.subscription = &i
  42431. }
  42432. // SubscriptionID returns the value of the "subscription_id" field in the mutation.
  42433. func (m *UsageLogMutation) SubscriptionID() (r int64, exists bool) {
  42434. v := m.subscription
  42435. if v == nil {
  42436. return
  42437. }
  42438. return *v, true
  42439. }
  42440. // OldSubscriptionID returns the old "subscription_id" field's value of the UsageLog entity.
  42441. // If the UsageLog object wasn't provided to the builder, the object is fetched from the database.
  42442. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42443. func (m *UsageLogMutation) OldSubscriptionID(ctx context.Context) (v *int64, err error) {
  42444. if !m.op.Is(OpUpdateOne) {
  42445. return v, errors.New("OldSubscriptionID is only allowed on UpdateOne operations")
  42446. }
  42447. if m.id == nil || m.oldValue == nil {
  42448. return v, errors.New("OldSubscriptionID requires an ID field in the mutation")
  42449. }
  42450. oldValue, err := m.oldValue(ctx)
  42451. if err != nil {
  42452. return v, fmt.Errorf("querying old value for OldSubscriptionID: %w", err)
  42453. }
  42454. return oldValue.SubscriptionID, nil
  42455. }
  42456. // ClearSubscriptionID clears the value of the "subscription_id" field.
  42457. func (m *UsageLogMutation) ClearSubscriptionID() {
  42458. m.subscription = nil
  42459. m.clearedFields[usagelog.FieldSubscriptionID] = struct{}{}
  42460. }
  42461. // SubscriptionIDCleared returns if the "subscription_id" field was cleared in this mutation.
  42462. func (m *UsageLogMutation) SubscriptionIDCleared() bool {
  42463. _, ok := m.clearedFields[usagelog.FieldSubscriptionID]
  42464. return ok
  42465. }
  42466. // ResetSubscriptionID resets all changes to the "subscription_id" field.
  42467. func (m *UsageLogMutation) ResetSubscriptionID() {
  42468. m.subscription = nil
  42469. delete(m.clearedFields, usagelog.FieldSubscriptionID)
  42470. }
  42471. // SetInputTokens sets the "input_tokens" field.
  42472. func (m *UsageLogMutation) SetInputTokens(i int) {
  42473. m.input_tokens = &i
  42474. m.addinput_tokens = nil
  42475. }
  42476. // InputTokens returns the value of the "input_tokens" field in the mutation.
  42477. func (m *UsageLogMutation) InputTokens() (r int, exists bool) {
  42478. v := m.input_tokens
  42479. if v == nil {
  42480. return
  42481. }
  42482. return *v, true
  42483. }
  42484. // OldInputTokens returns the old "input_tokens" field's value of the UsageLog entity.
  42485. // If the UsageLog object wasn't provided to the builder, the object is fetched from the database.
  42486. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42487. func (m *UsageLogMutation) OldInputTokens(ctx context.Context) (v int, err error) {
  42488. if !m.op.Is(OpUpdateOne) {
  42489. return v, errors.New("OldInputTokens is only allowed on UpdateOne operations")
  42490. }
  42491. if m.id == nil || m.oldValue == nil {
  42492. return v, errors.New("OldInputTokens requires an ID field in the mutation")
  42493. }
  42494. oldValue, err := m.oldValue(ctx)
  42495. if err != nil {
  42496. return v, fmt.Errorf("querying old value for OldInputTokens: %w", err)
  42497. }
  42498. return oldValue.InputTokens, nil
  42499. }
  42500. // AddInputTokens adds i to the "input_tokens" field.
  42501. func (m *UsageLogMutation) AddInputTokens(i int) {
  42502. if m.addinput_tokens != nil {
  42503. *m.addinput_tokens += i
  42504. } else {
  42505. m.addinput_tokens = &i
  42506. }
  42507. }
  42508. // AddedInputTokens returns the value that was added to the "input_tokens" field in this mutation.
  42509. func (m *UsageLogMutation) AddedInputTokens() (r int, exists bool) {
  42510. v := m.addinput_tokens
  42511. if v == nil {
  42512. return
  42513. }
  42514. return *v, true
  42515. }
  42516. // ResetInputTokens resets all changes to the "input_tokens" field.
  42517. func (m *UsageLogMutation) ResetInputTokens() {
  42518. m.input_tokens = nil
  42519. m.addinput_tokens = nil
  42520. }
  42521. // SetOutputTokens sets the "output_tokens" field.
  42522. func (m *UsageLogMutation) SetOutputTokens(i int) {
  42523. m.output_tokens = &i
  42524. m.addoutput_tokens = nil
  42525. }
  42526. // OutputTokens returns the value of the "output_tokens" field in the mutation.
  42527. func (m *UsageLogMutation) OutputTokens() (r int, exists bool) {
  42528. v := m.output_tokens
  42529. if v == nil {
  42530. return
  42531. }
  42532. return *v, true
  42533. }
  42534. // OldOutputTokens returns the old "output_tokens" field's value of the UsageLog entity.
  42535. // If the UsageLog object wasn't provided to the builder, the object is fetched from the database.
  42536. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42537. func (m *UsageLogMutation) OldOutputTokens(ctx context.Context) (v int, err error) {
  42538. if !m.op.Is(OpUpdateOne) {
  42539. return v, errors.New("OldOutputTokens is only allowed on UpdateOne operations")
  42540. }
  42541. if m.id == nil || m.oldValue == nil {
  42542. return v, errors.New("OldOutputTokens requires an ID field in the mutation")
  42543. }
  42544. oldValue, err := m.oldValue(ctx)
  42545. if err != nil {
  42546. return v, fmt.Errorf("querying old value for OldOutputTokens: %w", err)
  42547. }
  42548. return oldValue.OutputTokens, nil
  42549. }
  42550. // AddOutputTokens adds i to the "output_tokens" field.
  42551. func (m *UsageLogMutation) AddOutputTokens(i int) {
  42552. if m.addoutput_tokens != nil {
  42553. *m.addoutput_tokens += i
  42554. } else {
  42555. m.addoutput_tokens = &i
  42556. }
  42557. }
  42558. // AddedOutputTokens returns the value that was added to the "output_tokens" field in this mutation.
  42559. func (m *UsageLogMutation) AddedOutputTokens() (r int, exists bool) {
  42560. v := m.addoutput_tokens
  42561. if v == nil {
  42562. return
  42563. }
  42564. return *v, true
  42565. }
  42566. // ResetOutputTokens resets all changes to the "output_tokens" field.
  42567. func (m *UsageLogMutation) ResetOutputTokens() {
  42568. m.output_tokens = nil
  42569. m.addoutput_tokens = nil
  42570. }
  42571. // SetCacheCreationTokens sets the "cache_creation_tokens" field.
  42572. func (m *UsageLogMutation) SetCacheCreationTokens(i int) {
  42573. m.cache_creation_tokens = &i
  42574. m.addcache_creation_tokens = nil
  42575. }
  42576. // CacheCreationTokens returns the value of the "cache_creation_tokens" field in the mutation.
  42577. func (m *UsageLogMutation) CacheCreationTokens() (r int, exists bool) {
  42578. v := m.cache_creation_tokens
  42579. if v == nil {
  42580. return
  42581. }
  42582. return *v, true
  42583. }
  42584. // OldCacheCreationTokens returns the old "cache_creation_tokens" field's value of the UsageLog entity.
  42585. // If the UsageLog object wasn't provided to the builder, the object is fetched from the database.
  42586. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42587. func (m *UsageLogMutation) OldCacheCreationTokens(ctx context.Context) (v int, err error) {
  42588. if !m.op.Is(OpUpdateOne) {
  42589. return v, errors.New("OldCacheCreationTokens is only allowed on UpdateOne operations")
  42590. }
  42591. if m.id == nil || m.oldValue == nil {
  42592. return v, errors.New("OldCacheCreationTokens requires an ID field in the mutation")
  42593. }
  42594. oldValue, err := m.oldValue(ctx)
  42595. if err != nil {
  42596. return v, fmt.Errorf("querying old value for OldCacheCreationTokens: %w", err)
  42597. }
  42598. return oldValue.CacheCreationTokens, nil
  42599. }
  42600. // AddCacheCreationTokens adds i to the "cache_creation_tokens" field.
  42601. func (m *UsageLogMutation) AddCacheCreationTokens(i int) {
  42602. if m.addcache_creation_tokens != nil {
  42603. *m.addcache_creation_tokens += i
  42604. } else {
  42605. m.addcache_creation_tokens = &i
  42606. }
  42607. }
  42608. // AddedCacheCreationTokens returns the value that was added to the "cache_creation_tokens" field in this mutation.
  42609. func (m *UsageLogMutation) AddedCacheCreationTokens() (r int, exists bool) {
  42610. v := m.addcache_creation_tokens
  42611. if v == nil {
  42612. return
  42613. }
  42614. return *v, true
  42615. }
  42616. // ResetCacheCreationTokens resets all changes to the "cache_creation_tokens" field.
  42617. func (m *UsageLogMutation) ResetCacheCreationTokens() {
  42618. m.cache_creation_tokens = nil
  42619. m.addcache_creation_tokens = nil
  42620. }
  42621. // SetCacheReadTokens sets the "cache_read_tokens" field.
  42622. func (m *UsageLogMutation) SetCacheReadTokens(i int) {
  42623. m.cache_read_tokens = &i
  42624. m.addcache_read_tokens = nil
  42625. }
  42626. // CacheReadTokens returns the value of the "cache_read_tokens" field in the mutation.
  42627. func (m *UsageLogMutation) CacheReadTokens() (r int, exists bool) {
  42628. v := m.cache_read_tokens
  42629. if v == nil {
  42630. return
  42631. }
  42632. return *v, true
  42633. }
  42634. // OldCacheReadTokens returns the old "cache_read_tokens" field's value of the UsageLog entity.
  42635. // If the UsageLog object wasn't provided to the builder, the object is fetched from the database.
  42636. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42637. func (m *UsageLogMutation) OldCacheReadTokens(ctx context.Context) (v int, err error) {
  42638. if !m.op.Is(OpUpdateOne) {
  42639. return v, errors.New("OldCacheReadTokens is only allowed on UpdateOne operations")
  42640. }
  42641. if m.id == nil || m.oldValue == nil {
  42642. return v, errors.New("OldCacheReadTokens requires an ID field in the mutation")
  42643. }
  42644. oldValue, err := m.oldValue(ctx)
  42645. if err != nil {
  42646. return v, fmt.Errorf("querying old value for OldCacheReadTokens: %w", err)
  42647. }
  42648. return oldValue.CacheReadTokens, nil
  42649. }
  42650. // AddCacheReadTokens adds i to the "cache_read_tokens" field.
  42651. func (m *UsageLogMutation) AddCacheReadTokens(i int) {
  42652. if m.addcache_read_tokens != nil {
  42653. *m.addcache_read_tokens += i
  42654. } else {
  42655. m.addcache_read_tokens = &i
  42656. }
  42657. }
  42658. // AddedCacheReadTokens returns the value that was added to the "cache_read_tokens" field in this mutation.
  42659. func (m *UsageLogMutation) AddedCacheReadTokens() (r int, exists bool) {
  42660. v := m.addcache_read_tokens
  42661. if v == nil {
  42662. return
  42663. }
  42664. return *v, true
  42665. }
  42666. // ResetCacheReadTokens resets all changes to the "cache_read_tokens" field.
  42667. func (m *UsageLogMutation) ResetCacheReadTokens() {
  42668. m.cache_read_tokens = nil
  42669. m.addcache_read_tokens = nil
  42670. }
  42671. // SetCacheCreation5mTokens sets the "cache_creation_5m_tokens" field.
  42672. func (m *UsageLogMutation) SetCacheCreation5mTokens(i int) {
  42673. m.cache_creation_5m_tokens = &i
  42674. m.addcache_creation_5m_tokens = nil
  42675. }
  42676. // CacheCreation5mTokens returns the value of the "cache_creation_5m_tokens" field in the mutation.
  42677. func (m *UsageLogMutation) CacheCreation5mTokens() (r int, exists bool) {
  42678. v := m.cache_creation_5m_tokens
  42679. if v == nil {
  42680. return
  42681. }
  42682. return *v, true
  42683. }
  42684. // OldCacheCreation5mTokens returns the old "cache_creation_5m_tokens" field's value of the UsageLog entity.
  42685. // If the UsageLog object wasn't provided to the builder, the object is fetched from the database.
  42686. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42687. func (m *UsageLogMutation) OldCacheCreation5mTokens(ctx context.Context) (v int, err error) {
  42688. if !m.op.Is(OpUpdateOne) {
  42689. return v, errors.New("OldCacheCreation5mTokens is only allowed on UpdateOne operations")
  42690. }
  42691. if m.id == nil || m.oldValue == nil {
  42692. return v, errors.New("OldCacheCreation5mTokens requires an ID field in the mutation")
  42693. }
  42694. oldValue, err := m.oldValue(ctx)
  42695. if err != nil {
  42696. return v, fmt.Errorf("querying old value for OldCacheCreation5mTokens: %w", err)
  42697. }
  42698. return oldValue.CacheCreation5mTokens, nil
  42699. }
  42700. // AddCacheCreation5mTokens adds i to the "cache_creation_5m_tokens" field.
  42701. func (m *UsageLogMutation) AddCacheCreation5mTokens(i int) {
  42702. if m.addcache_creation_5m_tokens != nil {
  42703. *m.addcache_creation_5m_tokens += i
  42704. } else {
  42705. m.addcache_creation_5m_tokens = &i
  42706. }
  42707. }
  42708. // AddedCacheCreation5mTokens returns the value that was added to the "cache_creation_5m_tokens" field in this mutation.
  42709. func (m *UsageLogMutation) AddedCacheCreation5mTokens() (r int, exists bool) {
  42710. v := m.addcache_creation_5m_tokens
  42711. if v == nil {
  42712. return
  42713. }
  42714. return *v, true
  42715. }
  42716. // ResetCacheCreation5mTokens resets all changes to the "cache_creation_5m_tokens" field.
  42717. func (m *UsageLogMutation) ResetCacheCreation5mTokens() {
  42718. m.cache_creation_5m_tokens = nil
  42719. m.addcache_creation_5m_tokens = nil
  42720. }
  42721. // SetCacheCreation1hTokens sets the "cache_creation_1h_tokens" field.
  42722. func (m *UsageLogMutation) SetCacheCreation1hTokens(i int) {
  42723. m.cache_creation_1h_tokens = &i
  42724. m.addcache_creation_1h_tokens = nil
  42725. }
  42726. // CacheCreation1hTokens returns the value of the "cache_creation_1h_tokens" field in the mutation.
  42727. func (m *UsageLogMutation) CacheCreation1hTokens() (r int, exists bool) {
  42728. v := m.cache_creation_1h_tokens
  42729. if v == nil {
  42730. return
  42731. }
  42732. return *v, true
  42733. }
  42734. // OldCacheCreation1hTokens returns the old "cache_creation_1h_tokens" field's value of the UsageLog entity.
  42735. // If the UsageLog object wasn't provided to the builder, the object is fetched from the database.
  42736. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42737. func (m *UsageLogMutation) OldCacheCreation1hTokens(ctx context.Context) (v int, err error) {
  42738. if !m.op.Is(OpUpdateOne) {
  42739. return v, errors.New("OldCacheCreation1hTokens is only allowed on UpdateOne operations")
  42740. }
  42741. if m.id == nil || m.oldValue == nil {
  42742. return v, errors.New("OldCacheCreation1hTokens requires an ID field in the mutation")
  42743. }
  42744. oldValue, err := m.oldValue(ctx)
  42745. if err != nil {
  42746. return v, fmt.Errorf("querying old value for OldCacheCreation1hTokens: %w", err)
  42747. }
  42748. return oldValue.CacheCreation1hTokens, nil
  42749. }
  42750. // AddCacheCreation1hTokens adds i to the "cache_creation_1h_tokens" field.
  42751. func (m *UsageLogMutation) AddCacheCreation1hTokens(i int) {
  42752. if m.addcache_creation_1h_tokens != nil {
  42753. *m.addcache_creation_1h_tokens += i
  42754. } else {
  42755. m.addcache_creation_1h_tokens = &i
  42756. }
  42757. }
  42758. // AddedCacheCreation1hTokens returns the value that was added to the "cache_creation_1h_tokens" field in this mutation.
  42759. func (m *UsageLogMutation) AddedCacheCreation1hTokens() (r int, exists bool) {
  42760. v := m.addcache_creation_1h_tokens
  42761. if v == nil {
  42762. return
  42763. }
  42764. return *v, true
  42765. }
  42766. // ResetCacheCreation1hTokens resets all changes to the "cache_creation_1h_tokens" field.
  42767. func (m *UsageLogMutation) ResetCacheCreation1hTokens() {
  42768. m.cache_creation_1h_tokens = nil
  42769. m.addcache_creation_1h_tokens = nil
  42770. }
  42771. // SetInputCost sets the "input_cost" field.
  42772. func (m *UsageLogMutation) SetInputCost(f float64) {
  42773. m.input_cost = &f
  42774. m.addinput_cost = nil
  42775. }
  42776. // InputCost returns the value of the "input_cost" field in the mutation.
  42777. func (m *UsageLogMutation) InputCost() (r float64, exists bool) {
  42778. v := m.input_cost
  42779. if v == nil {
  42780. return
  42781. }
  42782. return *v, true
  42783. }
  42784. // OldInputCost returns the old "input_cost" field's value of the UsageLog entity.
  42785. // If the UsageLog object wasn't provided to the builder, the object is fetched from the database.
  42786. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42787. func (m *UsageLogMutation) OldInputCost(ctx context.Context) (v float64, err error) {
  42788. if !m.op.Is(OpUpdateOne) {
  42789. return v, errors.New("OldInputCost is only allowed on UpdateOne operations")
  42790. }
  42791. if m.id == nil || m.oldValue == nil {
  42792. return v, errors.New("OldInputCost requires an ID field in the mutation")
  42793. }
  42794. oldValue, err := m.oldValue(ctx)
  42795. if err != nil {
  42796. return v, fmt.Errorf("querying old value for OldInputCost: %w", err)
  42797. }
  42798. return oldValue.InputCost, nil
  42799. }
  42800. // AddInputCost adds f to the "input_cost" field.
  42801. func (m *UsageLogMutation) AddInputCost(f float64) {
  42802. if m.addinput_cost != nil {
  42803. *m.addinput_cost += f
  42804. } else {
  42805. m.addinput_cost = &f
  42806. }
  42807. }
  42808. // AddedInputCost returns the value that was added to the "input_cost" field in this mutation.
  42809. func (m *UsageLogMutation) AddedInputCost() (r float64, exists bool) {
  42810. v := m.addinput_cost
  42811. if v == nil {
  42812. return
  42813. }
  42814. return *v, true
  42815. }
  42816. // ResetInputCost resets all changes to the "input_cost" field.
  42817. func (m *UsageLogMutation) ResetInputCost() {
  42818. m.input_cost = nil
  42819. m.addinput_cost = nil
  42820. }
  42821. // SetOutputCost sets the "output_cost" field.
  42822. func (m *UsageLogMutation) SetOutputCost(f float64) {
  42823. m.output_cost = &f
  42824. m.addoutput_cost = nil
  42825. }
  42826. // OutputCost returns the value of the "output_cost" field in the mutation.
  42827. func (m *UsageLogMutation) OutputCost() (r float64, exists bool) {
  42828. v := m.output_cost
  42829. if v == nil {
  42830. return
  42831. }
  42832. return *v, true
  42833. }
  42834. // OldOutputCost returns the old "output_cost" field's value of the UsageLog entity.
  42835. // If the UsageLog object wasn't provided to the builder, the object is fetched from the database.
  42836. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42837. func (m *UsageLogMutation) OldOutputCost(ctx context.Context) (v float64, err error) {
  42838. if !m.op.Is(OpUpdateOne) {
  42839. return v, errors.New("OldOutputCost is only allowed on UpdateOne operations")
  42840. }
  42841. if m.id == nil || m.oldValue == nil {
  42842. return v, errors.New("OldOutputCost requires an ID field in the mutation")
  42843. }
  42844. oldValue, err := m.oldValue(ctx)
  42845. if err != nil {
  42846. return v, fmt.Errorf("querying old value for OldOutputCost: %w", err)
  42847. }
  42848. return oldValue.OutputCost, nil
  42849. }
  42850. // AddOutputCost adds f to the "output_cost" field.
  42851. func (m *UsageLogMutation) AddOutputCost(f float64) {
  42852. if m.addoutput_cost != nil {
  42853. *m.addoutput_cost += f
  42854. } else {
  42855. m.addoutput_cost = &f
  42856. }
  42857. }
  42858. // AddedOutputCost returns the value that was added to the "output_cost" field in this mutation.
  42859. func (m *UsageLogMutation) AddedOutputCost() (r float64, exists bool) {
  42860. v := m.addoutput_cost
  42861. if v == nil {
  42862. return
  42863. }
  42864. return *v, true
  42865. }
  42866. // ResetOutputCost resets all changes to the "output_cost" field.
  42867. func (m *UsageLogMutation) ResetOutputCost() {
  42868. m.output_cost = nil
  42869. m.addoutput_cost = nil
  42870. }
  42871. // SetCacheCreationCost sets the "cache_creation_cost" field.
  42872. func (m *UsageLogMutation) SetCacheCreationCost(f float64) {
  42873. m.cache_creation_cost = &f
  42874. m.addcache_creation_cost = nil
  42875. }
  42876. // CacheCreationCost returns the value of the "cache_creation_cost" field in the mutation.
  42877. func (m *UsageLogMutation) CacheCreationCost() (r float64, exists bool) {
  42878. v := m.cache_creation_cost
  42879. if v == nil {
  42880. return
  42881. }
  42882. return *v, true
  42883. }
  42884. // OldCacheCreationCost returns the old "cache_creation_cost" field's value of the UsageLog entity.
  42885. // If the UsageLog object wasn't provided to the builder, the object is fetched from the database.
  42886. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42887. func (m *UsageLogMutation) OldCacheCreationCost(ctx context.Context) (v float64, err error) {
  42888. if !m.op.Is(OpUpdateOne) {
  42889. return v, errors.New("OldCacheCreationCost is only allowed on UpdateOne operations")
  42890. }
  42891. if m.id == nil || m.oldValue == nil {
  42892. return v, errors.New("OldCacheCreationCost requires an ID field in the mutation")
  42893. }
  42894. oldValue, err := m.oldValue(ctx)
  42895. if err != nil {
  42896. return v, fmt.Errorf("querying old value for OldCacheCreationCost: %w", err)
  42897. }
  42898. return oldValue.CacheCreationCost, nil
  42899. }
  42900. // AddCacheCreationCost adds f to the "cache_creation_cost" field.
  42901. func (m *UsageLogMutation) AddCacheCreationCost(f float64) {
  42902. if m.addcache_creation_cost != nil {
  42903. *m.addcache_creation_cost += f
  42904. } else {
  42905. m.addcache_creation_cost = &f
  42906. }
  42907. }
  42908. // AddedCacheCreationCost returns the value that was added to the "cache_creation_cost" field in this mutation.
  42909. func (m *UsageLogMutation) AddedCacheCreationCost() (r float64, exists bool) {
  42910. v := m.addcache_creation_cost
  42911. if v == nil {
  42912. return
  42913. }
  42914. return *v, true
  42915. }
  42916. // ResetCacheCreationCost resets all changes to the "cache_creation_cost" field.
  42917. func (m *UsageLogMutation) ResetCacheCreationCost() {
  42918. m.cache_creation_cost = nil
  42919. m.addcache_creation_cost = nil
  42920. }
  42921. // SetCacheReadCost sets the "cache_read_cost" field.
  42922. func (m *UsageLogMutation) SetCacheReadCost(f float64) {
  42923. m.cache_read_cost = &f
  42924. m.addcache_read_cost = nil
  42925. }
  42926. // CacheReadCost returns the value of the "cache_read_cost" field in the mutation.
  42927. func (m *UsageLogMutation) CacheReadCost() (r float64, exists bool) {
  42928. v := m.cache_read_cost
  42929. if v == nil {
  42930. return
  42931. }
  42932. return *v, true
  42933. }
  42934. // OldCacheReadCost returns the old "cache_read_cost" field's value of the UsageLog entity.
  42935. // If the UsageLog object wasn't provided to the builder, the object is fetched from the database.
  42936. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42937. func (m *UsageLogMutation) OldCacheReadCost(ctx context.Context) (v float64, err error) {
  42938. if !m.op.Is(OpUpdateOne) {
  42939. return v, errors.New("OldCacheReadCost is only allowed on UpdateOne operations")
  42940. }
  42941. if m.id == nil || m.oldValue == nil {
  42942. return v, errors.New("OldCacheReadCost requires an ID field in the mutation")
  42943. }
  42944. oldValue, err := m.oldValue(ctx)
  42945. if err != nil {
  42946. return v, fmt.Errorf("querying old value for OldCacheReadCost: %w", err)
  42947. }
  42948. return oldValue.CacheReadCost, nil
  42949. }
  42950. // AddCacheReadCost adds f to the "cache_read_cost" field.
  42951. func (m *UsageLogMutation) AddCacheReadCost(f float64) {
  42952. if m.addcache_read_cost != nil {
  42953. *m.addcache_read_cost += f
  42954. } else {
  42955. m.addcache_read_cost = &f
  42956. }
  42957. }
  42958. // AddedCacheReadCost returns the value that was added to the "cache_read_cost" field in this mutation.
  42959. func (m *UsageLogMutation) AddedCacheReadCost() (r float64, exists bool) {
  42960. v := m.addcache_read_cost
  42961. if v == nil {
  42962. return
  42963. }
  42964. return *v, true
  42965. }
  42966. // ResetCacheReadCost resets all changes to the "cache_read_cost" field.
  42967. func (m *UsageLogMutation) ResetCacheReadCost() {
  42968. m.cache_read_cost = nil
  42969. m.addcache_read_cost = nil
  42970. }
  42971. // SetTotalCost sets the "total_cost" field.
  42972. func (m *UsageLogMutation) SetTotalCost(f float64) {
  42973. m.total_cost = &f
  42974. m.addtotal_cost = nil
  42975. }
  42976. // TotalCost returns the value of the "total_cost" field in the mutation.
  42977. func (m *UsageLogMutation) TotalCost() (r float64, exists bool) {
  42978. v := m.total_cost
  42979. if v == nil {
  42980. return
  42981. }
  42982. return *v, true
  42983. }
  42984. // OldTotalCost returns the old "total_cost" field's value of the UsageLog entity.
  42985. // If the UsageLog object wasn't provided to the builder, the object is fetched from the database.
  42986. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42987. func (m *UsageLogMutation) OldTotalCost(ctx context.Context) (v float64, err error) {
  42988. if !m.op.Is(OpUpdateOne) {
  42989. return v, errors.New("OldTotalCost is only allowed on UpdateOne operations")
  42990. }
  42991. if m.id == nil || m.oldValue == nil {
  42992. return v, errors.New("OldTotalCost requires an ID field in the mutation")
  42993. }
  42994. oldValue, err := m.oldValue(ctx)
  42995. if err != nil {
  42996. return v, fmt.Errorf("querying old value for OldTotalCost: %w", err)
  42997. }
  42998. return oldValue.TotalCost, nil
  42999. }
  43000. // AddTotalCost adds f to the "total_cost" field.
  43001. func (m *UsageLogMutation) AddTotalCost(f float64) {
  43002. if m.addtotal_cost != nil {
  43003. *m.addtotal_cost += f
  43004. } else {
  43005. m.addtotal_cost = &f
  43006. }
  43007. }
  43008. // AddedTotalCost returns the value that was added to the "total_cost" field in this mutation.
  43009. func (m *UsageLogMutation) AddedTotalCost() (r float64, exists bool) {
  43010. v := m.addtotal_cost
  43011. if v == nil {
  43012. return
  43013. }
  43014. return *v, true
  43015. }
  43016. // ResetTotalCost resets all changes to the "total_cost" field.
  43017. func (m *UsageLogMutation) ResetTotalCost() {
  43018. m.total_cost = nil
  43019. m.addtotal_cost = nil
  43020. }
  43021. // SetActualCost sets the "actual_cost" field.
  43022. func (m *UsageLogMutation) SetActualCost(f float64) {
  43023. m.actual_cost = &f
  43024. m.addactual_cost = nil
  43025. }
  43026. // ActualCost returns the value of the "actual_cost" field in the mutation.
  43027. func (m *UsageLogMutation) ActualCost() (r float64, exists bool) {
  43028. v := m.actual_cost
  43029. if v == nil {
  43030. return
  43031. }
  43032. return *v, true
  43033. }
  43034. // OldActualCost returns the old "actual_cost" field's value of the UsageLog entity.
  43035. // If the UsageLog object wasn't provided to the builder, the object is fetched from the database.
  43036. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43037. func (m *UsageLogMutation) OldActualCost(ctx context.Context) (v float64, err error) {
  43038. if !m.op.Is(OpUpdateOne) {
  43039. return v, errors.New("OldActualCost is only allowed on UpdateOne operations")
  43040. }
  43041. if m.id == nil || m.oldValue == nil {
  43042. return v, errors.New("OldActualCost requires an ID field in the mutation")
  43043. }
  43044. oldValue, err := m.oldValue(ctx)
  43045. if err != nil {
  43046. return v, fmt.Errorf("querying old value for OldActualCost: %w", err)
  43047. }
  43048. return oldValue.ActualCost, nil
  43049. }
  43050. // AddActualCost adds f to the "actual_cost" field.
  43051. func (m *UsageLogMutation) AddActualCost(f float64) {
  43052. if m.addactual_cost != nil {
  43053. *m.addactual_cost += f
  43054. } else {
  43055. m.addactual_cost = &f
  43056. }
  43057. }
  43058. // AddedActualCost returns the value that was added to the "actual_cost" field in this mutation.
  43059. func (m *UsageLogMutation) AddedActualCost() (r float64, exists bool) {
  43060. v := m.addactual_cost
  43061. if v == nil {
  43062. return
  43063. }
  43064. return *v, true
  43065. }
  43066. // ResetActualCost resets all changes to the "actual_cost" field.
  43067. func (m *UsageLogMutation) ResetActualCost() {
  43068. m.actual_cost = nil
  43069. m.addactual_cost = nil
  43070. }
  43071. // SetRateMultiplier sets the "rate_multiplier" field.
  43072. func (m *UsageLogMutation) SetRateMultiplier(f float64) {
  43073. m.rate_multiplier = &f
  43074. m.addrate_multiplier = nil
  43075. }
  43076. // RateMultiplier returns the value of the "rate_multiplier" field in the mutation.
  43077. func (m *UsageLogMutation) RateMultiplier() (r float64, exists bool) {
  43078. v := m.rate_multiplier
  43079. if v == nil {
  43080. return
  43081. }
  43082. return *v, true
  43083. }
  43084. // OldRateMultiplier returns the old "rate_multiplier" field's value of the UsageLog entity.
  43085. // If the UsageLog object wasn't provided to the builder, the object is fetched from the database.
  43086. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43087. func (m *UsageLogMutation) OldRateMultiplier(ctx context.Context) (v float64, err error) {
  43088. if !m.op.Is(OpUpdateOne) {
  43089. return v, errors.New("OldRateMultiplier is only allowed on UpdateOne operations")
  43090. }
  43091. if m.id == nil || m.oldValue == nil {
  43092. return v, errors.New("OldRateMultiplier requires an ID field in the mutation")
  43093. }
  43094. oldValue, err := m.oldValue(ctx)
  43095. if err != nil {
  43096. return v, fmt.Errorf("querying old value for OldRateMultiplier: %w", err)
  43097. }
  43098. return oldValue.RateMultiplier, nil
  43099. }
  43100. // AddRateMultiplier adds f to the "rate_multiplier" field.
  43101. func (m *UsageLogMutation) AddRateMultiplier(f float64) {
  43102. if m.addrate_multiplier != nil {
  43103. *m.addrate_multiplier += f
  43104. } else {
  43105. m.addrate_multiplier = &f
  43106. }
  43107. }
  43108. // AddedRateMultiplier returns the value that was added to the "rate_multiplier" field in this mutation.
  43109. func (m *UsageLogMutation) AddedRateMultiplier() (r float64, exists bool) {
  43110. v := m.addrate_multiplier
  43111. if v == nil {
  43112. return
  43113. }
  43114. return *v, true
  43115. }
  43116. // ResetRateMultiplier resets all changes to the "rate_multiplier" field.
  43117. func (m *UsageLogMutation) ResetRateMultiplier() {
  43118. m.rate_multiplier = nil
  43119. m.addrate_multiplier = nil
  43120. }
  43121. // SetLongContextBillingApplied sets the "long_context_billing_applied" field.
  43122. func (m *UsageLogMutation) SetLongContextBillingApplied(b bool) {
  43123. m.long_context_billing_applied = &b
  43124. }
  43125. // LongContextBillingApplied returns the value of the "long_context_billing_applied" field in the mutation.
  43126. func (m *UsageLogMutation) LongContextBillingApplied() (r bool, exists bool) {
  43127. v := m.long_context_billing_applied
  43128. if v == nil {
  43129. return
  43130. }
  43131. return *v, true
  43132. }
  43133. // OldLongContextBillingApplied returns the old "long_context_billing_applied" field's value of the UsageLog entity.
  43134. // If the UsageLog object wasn't provided to the builder, the object is fetched from the database.
  43135. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43136. func (m *UsageLogMutation) OldLongContextBillingApplied(ctx context.Context) (v bool, err error) {
  43137. if !m.op.Is(OpUpdateOne) {
  43138. return v, errors.New("OldLongContextBillingApplied is only allowed on UpdateOne operations")
  43139. }
  43140. if m.id == nil || m.oldValue == nil {
  43141. return v, errors.New("OldLongContextBillingApplied requires an ID field in the mutation")
  43142. }
  43143. oldValue, err := m.oldValue(ctx)
  43144. if err != nil {
  43145. return v, fmt.Errorf("querying old value for OldLongContextBillingApplied: %w", err)
  43146. }
  43147. return oldValue.LongContextBillingApplied, nil
  43148. }
  43149. // ResetLongContextBillingApplied resets all changes to the "long_context_billing_applied" field.
  43150. func (m *UsageLogMutation) ResetLongContextBillingApplied() {
  43151. m.long_context_billing_applied = nil
  43152. }
  43153. // SetAccountRateMultiplier sets the "account_rate_multiplier" field.
  43154. func (m *UsageLogMutation) SetAccountRateMultiplier(f float64) {
  43155. m.account_rate_multiplier = &f
  43156. m.addaccount_rate_multiplier = nil
  43157. }
  43158. // AccountRateMultiplier returns the value of the "account_rate_multiplier" field in the mutation.
  43159. func (m *UsageLogMutation) AccountRateMultiplier() (r float64, exists bool) {
  43160. v := m.account_rate_multiplier
  43161. if v == nil {
  43162. return
  43163. }
  43164. return *v, true
  43165. }
  43166. // OldAccountRateMultiplier returns the old "account_rate_multiplier" field's value of the UsageLog entity.
  43167. // If the UsageLog object wasn't provided to the builder, the object is fetched from the database.
  43168. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43169. func (m *UsageLogMutation) OldAccountRateMultiplier(ctx context.Context) (v *float64, err error) {
  43170. if !m.op.Is(OpUpdateOne) {
  43171. return v, errors.New("OldAccountRateMultiplier is only allowed on UpdateOne operations")
  43172. }
  43173. if m.id == nil || m.oldValue == nil {
  43174. return v, errors.New("OldAccountRateMultiplier requires an ID field in the mutation")
  43175. }
  43176. oldValue, err := m.oldValue(ctx)
  43177. if err != nil {
  43178. return v, fmt.Errorf("querying old value for OldAccountRateMultiplier: %w", err)
  43179. }
  43180. return oldValue.AccountRateMultiplier, nil
  43181. }
  43182. // AddAccountRateMultiplier adds f to the "account_rate_multiplier" field.
  43183. func (m *UsageLogMutation) AddAccountRateMultiplier(f float64) {
  43184. if m.addaccount_rate_multiplier != nil {
  43185. *m.addaccount_rate_multiplier += f
  43186. } else {
  43187. m.addaccount_rate_multiplier = &f
  43188. }
  43189. }
  43190. // AddedAccountRateMultiplier returns the value that was added to the "account_rate_multiplier" field in this mutation.
  43191. func (m *UsageLogMutation) AddedAccountRateMultiplier() (r float64, exists bool) {
  43192. v := m.addaccount_rate_multiplier
  43193. if v == nil {
  43194. return
  43195. }
  43196. return *v, true
  43197. }
  43198. // ClearAccountRateMultiplier clears the value of the "account_rate_multiplier" field.
  43199. func (m *UsageLogMutation) ClearAccountRateMultiplier() {
  43200. m.account_rate_multiplier = nil
  43201. m.addaccount_rate_multiplier = nil
  43202. m.clearedFields[usagelog.FieldAccountRateMultiplier] = struct{}{}
  43203. }
  43204. // AccountRateMultiplierCleared returns if the "account_rate_multiplier" field was cleared in this mutation.
  43205. func (m *UsageLogMutation) AccountRateMultiplierCleared() bool {
  43206. _, ok := m.clearedFields[usagelog.FieldAccountRateMultiplier]
  43207. return ok
  43208. }
  43209. // ResetAccountRateMultiplier resets all changes to the "account_rate_multiplier" field.
  43210. func (m *UsageLogMutation) ResetAccountRateMultiplier() {
  43211. m.account_rate_multiplier = nil
  43212. m.addaccount_rate_multiplier = nil
  43213. delete(m.clearedFields, usagelog.FieldAccountRateMultiplier)
  43214. }
  43215. // SetBillingType sets the "billing_type" field.
  43216. func (m *UsageLogMutation) SetBillingType(i int8) {
  43217. m.billing_type = &i
  43218. m.addbilling_type = nil
  43219. }
  43220. // BillingType returns the value of the "billing_type" field in the mutation.
  43221. func (m *UsageLogMutation) BillingType() (r int8, exists bool) {
  43222. v := m.billing_type
  43223. if v == nil {
  43224. return
  43225. }
  43226. return *v, true
  43227. }
  43228. // OldBillingType returns the old "billing_type" field's value of the UsageLog entity.
  43229. // If the UsageLog object wasn't provided to the builder, the object is fetched from the database.
  43230. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43231. func (m *UsageLogMutation) OldBillingType(ctx context.Context) (v int8, err error) {
  43232. if !m.op.Is(OpUpdateOne) {
  43233. return v, errors.New("OldBillingType is only allowed on UpdateOne operations")
  43234. }
  43235. if m.id == nil || m.oldValue == nil {
  43236. return v, errors.New("OldBillingType requires an ID field in the mutation")
  43237. }
  43238. oldValue, err := m.oldValue(ctx)
  43239. if err != nil {
  43240. return v, fmt.Errorf("querying old value for OldBillingType: %w", err)
  43241. }
  43242. return oldValue.BillingType, nil
  43243. }
  43244. // AddBillingType adds i to the "billing_type" field.
  43245. func (m *UsageLogMutation) AddBillingType(i int8) {
  43246. if m.addbilling_type != nil {
  43247. *m.addbilling_type += i
  43248. } else {
  43249. m.addbilling_type = &i
  43250. }
  43251. }
  43252. // AddedBillingType returns the value that was added to the "billing_type" field in this mutation.
  43253. func (m *UsageLogMutation) AddedBillingType() (r int8, exists bool) {
  43254. v := m.addbilling_type
  43255. if v == nil {
  43256. return
  43257. }
  43258. return *v, true
  43259. }
  43260. // ResetBillingType resets all changes to the "billing_type" field.
  43261. func (m *UsageLogMutation) ResetBillingType() {
  43262. m.billing_type = nil
  43263. m.addbilling_type = nil
  43264. }
  43265. // SetStream sets the "stream" field.
  43266. func (m *UsageLogMutation) SetStream(b bool) {
  43267. m.stream = &b
  43268. }
  43269. // Stream returns the value of the "stream" field in the mutation.
  43270. func (m *UsageLogMutation) Stream() (r bool, exists bool) {
  43271. v := m.stream
  43272. if v == nil {
  43273. return
  43274. }
  43275. return *v, true
  43276. }
  43277. // OldStream returns the old "stream" field's value of the UsageLog entity.
  43278. // If the UsageLog object wasn't provided to the builder, the object is fetched from the database.
  43279. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43280. func (m *UsageLogMutation) OldStream(ctx context.Context) (v bool, err error) {
  43281. if !m.op.Is(OpUpdateOne) {
  43282. return v, errors.New("OldStream is only allowed on UpdateOne operations")
  43283. }
  43284. if m.id == nil || m.oldValue == nil {
  43285. return v, errors.New("OldStream requires an ID field in the mutation")
  43286. }
  43287. oldValue, err := m.oldValue(ctx)
  43288. if err != nil {
  43289. return v, fmt.Errorf("querying old value for OldStream: %w", err)
  43290. }
  43291. return oldValue.Stream, nil
  43292. }
  43293. // ResetStream resets all changes to the "stream" field.
  43294. func (m *UsageLogMutation) ResetStream() {
  43295. m.stream = nil
  43296. }
  43297. // SetDurationMs sets the "duration_ms" field.
  43298. func (m *UsageLogMutation) SetDurationMs(i int) {
  43299. m.duration_ms = &i
  43300. m.addduration_ms = nil
  43301. }
  43302. // DurationMs returns the value of the "duration_ms" field in the mutation.
  43303. func (m *UsageLogMutation) DurationMs() (r int, exists bool) {
  43304. v := m.duration_ms
  43305. if v == nil {
  43306. return
  43307. }
  43308. return *v, true
  43309. }
  43310. // OldDurationMs returns the old "duration_ms" field's value of the UsageLog entity.
  43311. // If the UsageLog object wasn't provided to the builder, the object is fetched from the database.
  43312. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43313. func (m *UsageLogMutation) OldDurationMs(ctx context.Context) (v *int, err error) {
  43314. if !m.op.Is(OpUpdateOne) {
  43315. return v, errors.New("OldDurationMs is only allowed on UpdateOne operations")
  43316. }
  43317. if m.id == nil || m.oldValue == nil {
  43318. return v, errors.New("OldDurationMs requires an ID field in the mutation")
  43319. }
  43320. oldValue, err := m.oldValue(ctx)
  43321. if err != nil {
  43322. return v, fmt.Errorf("querying old value for OldDurationMs: %w", err)
  43323. }
  43324. return oldValue.DurationMs, nil
  43325. }
  43326. // AddDurationMs adds i to the "duration_ms" field.
  43327. func (m *UsageLogMutation) AddDurationMs(i int) {
  43328. if m.addduration_ms != nil {
  43329. *m.addduration_ms += i
  43330. } else {
  43331. m.addduration_ms = &i
  43332. }
  43333. }
  43334. // AddedDurationMs returns the value that was added to the "duration_ms" field in this mutation.
  43335. func (m *UsageLogMutation) AddedDurationMs() (r int, exists bool) {
  43336. v := m.addduration_ms
  43337. if v == nil {
  43338. return
  43339. }
  43340. return *v, true
  43341. }
  43342. // ClearDurationMs clears the value of the "duration_ms" field.
  43343. func (m *UsageLogMutation) ClearDurationMs() {
  43344. m.duration_ms = nil
  43345. m.addduration_ms = nil
  43346. m.clearedFields[usagelog.FieldDurationMs] = struct{}{}
  43347. }
  43348. // DurationMsCleared returns if the "duration_ms" field was cleared in this mutation.
  43349. func (m *UsageLogMutation) DurationMsCleared() bool {
  43350. _, ok := m.clearedFields[usagelog.FieldDurationMs]
  43351. return ok
  43352. }
  43353. // ResetDurationMs resets all changes to the "duration_ms" field.
  43354. func (m *UsageLogMutation) ResetDurationMs() {
  43355. m.duration_ms = nil
  43356. m.addduration_ms = nil
  43357. delete(m.clearedFields, usagelog.FieldDurationMs)
  43358. }
  43359. // SetFirstTokenMs sets the "first_token_ms" field.
  43360. func (m *UsageLogMutation) SetFirstTokenMs(i int) {
  43361. m.first_token_ms = &i
  43362. m.addfirst_token_ms = nil
  43363. }
  43364. // FirstTokenMs returns the value of the "first_token_ms" field in the mutation.
  43365. func (m *UsageLogMutation) FirstTokenMs() (r int, exists bool) {
  43366. v := m.first_token_ms
  43367. if v == nil {
  43368. return
  43369. }
  43370. return *v, true
  43371. }
  43372. // OldFirstTokenMs returns the old "first_token_ms" field's value of the UsageLog entity.
  43373. // If the UsageLog object wasn't provided to the builder, the object is fetched from the database.
  43374. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43375. func (m *UsageLogMutation) OldFirstTokenMs(ctx context.Context) (v *int, err error) {
  43376. if !m.op.Is(OpUpdateOne) {
  43377. return v, errors.New("OldFirstTokenMs is only allowed on UpdateOne operations")
  43378. }
  43379. if m.id == nil || m.oldValue == nil {
  43380. return v, errors.New("OldFirstTokenMs requires an ID field in the mutation")
  43381. }
  43382. oldValue, err := m.oldValue(ctx)
  43383. if err != nil {
  43384. return v, fmt.Errorf("querying old value for OldFirstTokenMs: %w", err)
  43385. }
  43386. return oldValue.FirstTokenMs, nil
  43387. }
  43388. // AddFirstTokenMs adds i to the "first_token_ms" field.
  43389. func (m *UsageLogMutation) AddFirstTokenMs(i int) {
  43390. if m.addfirst_token_ms != nil {
  43391. *m.addfirst_token_ms += i
  43392. } else {
  43393. m.addfirst_token_ms = &i
  43394. }
  43395. }
  43396. // AddedFirstTokenMs returns the value that was added to the "first_token_ms" field in this mutation.
  43397. func (m *UsageLogMutation) AddedFirstTokenMs() (r int, exists bool) {
  43398. v := m.addfirst_token_ms
  43399. if v == nil {
  43400. return
  43401. }
  43402. return *v, true
  43403. }
  43404. // ClearFirstTokenMs clears the value of the "first_token_ms" field.
  43405. func (m *UsageLogMutation) ClearFirstTokenMs() {
  43406. m.first_token_ms = nil
  43407. m.addfirst_token_ms = nil
  43408. m.clearedFields[usagelog.FieldFirstTokenMs] = struct{}{}
  43409. }
  43410. // FirstTokenMsCleared returns if the "first_token_ms" field was cleared in this mutation.
  43411. func (m *UsageLogMutation) FirstTokenMsCleared() bool {
  43412. _, ok := m.clearedFields[usagelog.FieldFirstTokenMs]
  43413. return ok
  43414. }
  43415. // ResetFirstTokenMs resets all changes to the "first_token_ms" field.
  43416. func (m *UsageLogMutation) ResetFirstTokenMs() {
  43417. m.first_token_ms = nil
  43418. m.addfirst_token_ms = nil
  43419. delete(m.clearedFields, usagelog.FieldFirstTokenMs)
  43420. }
  43421. // SetUserAgent sets the "user_agent" field.
  43422. func (m *UsageLogMutation) SetUserAgent(s string) {
  43423. m.user_agent = &s
  43424. }
  43425. // UserAgent returns the value of the "user_agent" field in the mutation.
  43426. func (m *UsageLogMutation) UserAgent() (r string, exists bool) {
  43427. v := m.user_agent
  43428. if v == nil {
  43429. return
  43430. }
  43431. return *v, true
  43432. }
  43433. // OldUserAgent returns the old "user_agent" field's value of the UsageLog entity.
  43434. // If the UsageLog object wasn't provided to the builder, the object is fetched from the database.
  43435. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43436. func (m *UsageLogMutation) OldUserAgent(ctx context.Context) (v *string, err error) {
  43437. if !m.op.Is(OpUpdateOne) {
  43438. return v, errors.New("OldUserAgent is only allowed on UpdateOne operations")
  43439. }
  43440. if m.id == nil || m.oldValue == nil {
  43441. return v, errors.New("OldUserAgent requires an ID field in the mutation")
  43442. }
  43443. oldValue, err := m.oldValue(ctx)
  43444. if err != nil {
  43445. return v, fmt.Errorf("querying old value for OldUserAgent: %w", err)
  43446. }
  43447. return oldValue.UserAgent, nil
  43448. }
  43449. // ClearUserAgent clears the value of the "user_agent" field.
  43450. func (m *UsageLogMutation) ClearUserAgent() {
  43451. m.user_agent = nil
  43452. m.clearedFields[usagelog.FieldUserAgent] = struct{}{}
  43453. }
  43454. // UserAgentCleared returns if the "user_agent" field was cleared in this mutation.
  43455. func (m *UsageLogMutation) UserAgentCleared() bool {
  43456. _, ok := m.clearedFields[usagelog.FieldUserAgent]
  43457. return ok
  43458. }
  43459. // ResetUserAgent resets all changes to the "user_agent" field.
  43460. func (m *UsageLogMutation) ResetUserAgent() {
  43461. m.user_agent = nil
  43462. delete(m.clearedFields, usagelog.FieldUserAgent)
  43463. }
  43464. // SetIPAddress sets the "ip_address" field.
  43465. func (m *UsageLogMutation) SetIPAddress(s string) {
  43466. m.ip_address = &s
  43467. }
  43468. // IPAddress returns the value of the "ip_address" field in the mutation.
  43469. func (m *UsageLogMutation) IPAddress() (r string, exists bool) {
  43470. v := m.ip_address
  43471. if v == nil {
  43472. return
  43473. }
  43474. return *v, true
  43475. }
  43476. // OldIPAddress returns the old "ip_address" field's value of the UsageLog entity.
  43477. // If the UsageLog object wasn't provided to the builder, the object is fetched from the database.
  43478. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43479. func (m *UsageLogMutation) OldIPAddress(ctx context.Context) (v *string, err error) {
  43480. if !m.op.Is(OpUpdateOne) {
  43481. return v, errors.New("OldIPAddress is only allowed on UpdateOne operations")
  43482. }
  43483. if m.id == nil || m.oldValue == nil {
  43484. return v, errors.New("OldIPAddress requires an ID field in the mutation")
  43485. }
  43486. oldValue, err := m.oldValue(ctx)
  43487. if err != nil {
  43488. return v, fmt.Errorf("querying old value for OldIPAddress: %w", err)
  43489. }
  43490. return oldValue.IPAddress, nil
  43491. }
  43492. // ClearIPAddress clears the value of the "ip_address" field.
  43493. func (m *UsageLogMutation) ClearIPAddress() {
  43494. m.ip_address = nil
  43495. m.clearedFields[usagelog.FieldIPAddress] = struct{}{}
  43496. }
  43497. // IPAddressCleared returns if the "ip_address" field was cleared in this mutation.
  43498. func (m *UsageLogMutation) IPAddressCleared() bool {
  43499. _, ok := m.clearedFields[usagelog.FieldIPAddress]
  43500. return ok
  43501. }
  43502. // ResetIPAddress resets all changes to the "ip_address" field.
  43503. func (m *UsageLogMutation) ResetIPAddress() {
  43504. m.ip_address = nil
  43505. delete(m.clearedFields, usagelog.FieldIPAddress)
  43506. }
  43507. // SetImageCount sets the "image_count" field.
  43508. func (m *UsageLogMutation) SetImageCount(i int) {
  43509. m.image_count = &i
  43510. m.addimage_count = nil
  43511. }
  43512. // ImageCount returns the value of the "image_count" field in the mutation.
  43513. func (m *UsageLogMutation) ImageCount() (r int, exists bool) {
  43514. v := m.image_count
  43515. if v == nil {
  43516. return
  43517. }
  43518. return *v, true
  43519. }
  43520. // OldImageCount returns the old "image_count" field's value of the UsageLog entity.
  43521. // If the UsageLog object wasn't provided to the builder, the object is fetched from the database.
  43522. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43523. func (m *UsageLogMutation) OldImageCount(ctx context.Context) (v int, err error) {
  43524. if !m.op.Is(OpUpdateOne) {
  43525. return v, errors.New("OldImageCount is only allowed on UpdateOne operations")
  43526. }
  43527. if m.id == nil || m.oldValue == nil {
  43528. return v, errors.New("OldImageCount requires an ID field in the mutation")
  43529. }
  43530. oldValue, err := m.oldValue(ctx)
  43531. if err != nil {
  43532. return v, fmt.Errorf("querying old value for OldImageCount: %w", err)
  43533. }
  43534. return oldValue.ImageCount, nil
  43535. }
  43536. // AddImageCount adds i to the "image_count" field.
  43537. func (m *UsageLogMutation) AddImageCount(i int) {
  43538. if m.addimage_count != nil {
  43539. *m.addimage_count += i
  43540. } else {
  43541. m.addimage_count = &i
  43542. }
  43543. }
  43544. // AddedImageCount returns the value that was added to the "image_count" field in this mutation.
  43545. func (m *UsageLogMutation) AddedImageCount() (r int, exists bool) {
  43546. v := m.addimage_count
  43547. if v == nil {
  43548. return
  43549. }
  43550. return *v, true
  43551. }
  43552. // ResetImageCount resets all changes to the "image_count" field.
  43553. func (m *UsageLogMutation) ResetImageCount() {
  43554. m.image_count = nil
  43555. m.addimage_count = nil
  43556. }
  43557. // SetImageSize sets the "image_size" field.
  43558. func (m *UsageLogMutation) SetImageSize(s string) {
  43559. m.image_size = &s
  43560. }
  43561. // ImageSize returns the value of the "image_size" field in the mutation.
  43562. func (m *UsageLogMutation) ImageSize() (r string, exists bool) {
  43563. v := m.image_size
  43564. if v == nil {
  43565. return
  43566. }
  43567. return *v, true
  43568. }
  43569. // OldImageSize returns the old "image_size" field's value of the UsageLog entity.
  43570. // If the UsageLog object wasn't provided to the builder, the object is fetched from the database.
  43571. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43572. func (m *UsageLogMutation) OldImageSize(ctx context.Context) (v *string, err error) {
  43573. if !m.op.Is(OpUpdateOne) {
  43574. return v, errors.New("OldImageSize is only allowed on UpdateOne operations")
  43575. }
  43576. if m.id == nil || m.oldValue == nil {
  43577. return v, errors.New("OldImageSize requires an ID field in the mutation")
  43578. }
  43579. oldValue, err := m.oldValue(ctx)
  43580. if err != nil {
  43581. return v, fmt.Errorf("querying old value for OldImageSize: %w", err)
  43582. }
  43583. return oldValue.ImageSize, nil
  43584. }
  43585. // ClearImageSize clears the value of the "image_size" field.
  43586. func (m *UsageLogMutation) ClearImageSize() {
  43587. m.image_size = nil
  43588. m.clearedFields[usagelog.FieldImageSize] = struct{}{}
  43589. }
  43590. // ImageSizeCleared returns if the "image_size" field was cleared in this mutation.
  43591. func (m *UsageLogMutation) ImageSizeCleared() bool {
  43592. _, ok := m.clearedFields[usagelog.FieldImageSize]
  43593. return ok
  43594. }
  43595. // ResetImageSize resets all changes to the "image_size" field.
  43596. func (m *UsageLogMutation) ResetImageSize() {
  43597. m.image_size = nil
  43598. delete(m.clearedFields, usagelog.FieldImageSize)
  43599. }
  43600. // SetImageInputSize sets the "image_input_size" field.
  43601. func (m *UsageLogMutation) SetImageInputSize(s string) {
  43602. m.image_input_size = &s
  43603. }
  43604. // ImageInputSize returns the value of the "image_input_size" field in the mutation.
  43605. func (m *UsageLogMutation) ImageInputSize() (r string, exists bool) {
  43606. v := m.image_input_size
  43607. if v == nil {
  43608. return
  43609. }
  43610. return *v, true
  43611. }
  43612. // OldImageInputSize returns the old "image_input_size" field's value of the UsageLog entity.
  43613. // If the UsageLog object wasn't provided to the builder, the object is fetched from the database.
  43614. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43615. func (m *UsageLogMutation) OldImageInputSize(ctx context.Context) (v *string, err error) {
  43616. if !m.op.Is(OpUpdateOne) {
  43617. return v, errors.New("OldImageInputSize is only allowed on UpdateOne operations")
  43618. }
  43619. if m.id == nil || m.oldValue == nil {
  43620. return v, errors.New("OldImageInputSize requires an ID field in the mutation")
  43621. }
  43622. oldValue, err := m.oldValue(ctx)
  43623. if err != nil {
  43624. return v, fmt.Errorf("querying old value for OldImageInputSize: %w", err)
  43625. }
  43626. return oldValue.ImageInputSize, nil
  43627. }
  43628. // ClearImageInputSize clears the value of the "image_input_size" field.
  43629. func (m *UsageLogMutation) ClearImageInputSize() {
  43630. m.image_input_size = nil
  43631. m.clearedFields[usagelog.FieldImageInputSize] = struct{}{}
  43632. }
  43633. // ImageInputSizeCleared returns if the "image_input_size" field was cleared in this mutation.
  43634. func (m *UsageLogMutation) ImageInputSizeCleared() bool {
  43635. _, ok := m.clearedFields[usagelog.FieldImageInputSize]
  43636. return ok
  43637. }
  43638. // ResetImageInputSize resets all changes to the "image_input_size" field.
  43639. func (m *UsageLogMutation) ResetImageInputSize() {
  43640. m.image_input_size = nil
  43641. delete(m.clearedFields, usagelog.FieldImageInputSize)
  43642. }
  43643. // SetImageOutputSize sets the "image_output_size" field.
  43644. func (m *UsageLogMutation) SetImageOutputSize(s string) {
  43645. m.image_output_size = &s
  43646. }
  43647. // ImageOutputSize returns the value of the "image_output_size" field in the mutation.
  43648. func (m *UsageLogMutation) ImageOutputSize() (r string, exists bool) {
  43649. v := m.image_output_size
  43650. if v == nil {
  43651. return
  43652. }
  43653. return *v, true
  43654. }
  43655. // OldImageOutputSize returns the old "image_output_size" field's value of the UsageLog entity.
  43656. // If the UsageLog object wasn't provided to the builder, the object is fetched from the database.
  43657. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43658. func (m *UsageLogMutation) OldImageOutputSize(ctx context.Context) (v *string, err error) {
  43659. if !m.op.Is(OpUpdateOne) {
  43660. return v, errors.New("OldImageOutputSize is only allowed on UpdateOne operations")
  43661. }
  43662. if m.id == nil || m.oldValue == nil {
  43663. return v, errors.New("OldImageOutputSize requires an ID field in the mutation")
  43664. }
  43665. oldValue, err := m.oldValue(ctx)
  43666. if err != nil {
  43667. return v, fmt.Errorf("querying old value for OldImageOutputSize: %w", err)
  43668. }
  43669. return oldValue.ImageOutputSize, nil
  43670. }
  43671. // ClearImageOutputSize clears the value of the "image_output_size" field.
  43672. func (m *UsageLogMutation) ClearImageOutputSize() {
  43673. m.image_output_size = nil
  43674. m.clearedFields[usagelog.FieldImageOutputSize] = struct{}{}
  43675. }
  43676. // ImageOutputSizeCleared returns if the "image_output_size" field was cleared in this mutation.
  43677. func (m *UsageLogMutation) ImageOutputSizeCleared() bool {
  43678. _, ok := m.clearedFields[usagelog.FieldImageOutputSize]
  43679. return ok
  43680. }
  43681. // ResetImageOutputSize resets all changes to the "image_output_size" field.
  43682. func (m *UsageLogMutation) ResetImageOutputSize() {
  43683. m.image_output_size = nil
  43684. delete(m.clearedFields, usagelog.FieldImageOutputSize)
  43685. }
  43686. // SetImageSizeSource sets the "image_size_source" field.
  43687. func (m *UsageLogMutation) SetImageSizeSource(s string) {
  43688. m.image_size_source = &s
  43689. }
  43690. // ImageSizeSource returns the value of the "image_size_source" field in the mutation.
  43691. func (m *UsageLogMutation) ImageSizeSource() (r string, exists bool) {
  43692. v := m.image_size_source
  43693. if v == nil {
  43694. return
  43695. }
  43696. return *v, true
  43697. }
  43698. // OldImageSizeSource returns the old "image_size_source" field's value of the UsageLog entity.
  43699. // If the UsageLog object wasn't provided to the builder, the object is fetched from the database.
  43700. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43701. func (m *UsageLogMutation) OldImageSizeSource(ctx context.Context) (v *string, err error) {
  43702. if !m.op.Is(OpUpdateOne) {
  43703. return v, errors.New("OldImageSizeSource is only allowed on UpdateOne operations")
  43704. }
  43705. if m.id == nil || m.oldValue == nil {
  43706. return v, errors.New("OldImageSizeSource requires an ID field in the mutation")
  43707. }
  43708. oldValue, err := m.oldValue(ctx)
  43709. if err != nil {
  43710. return v, fmt.Errorf("querying old value for OldImageSizeSource: %w", err)
  43711. }
  43712. return oldValue.ImageSizeSource, nil
  43713. }
  43714. // ClearImageSizeSource clears the value of the "image_size_source" field.
  43715. func (m *UsageLogMutation) ClearImageSizeSource() {
  43716. m.image_size_source = nil
  43717. m.clearedFields[usagelog.FieldImageSizeSource] = struct{}{}
  43718. }
  43719. // ImageSizeSourceCleared returns if the "image_size_source" field was cleared in this mutation.
  43720. func (m *UsageLogMutation) ImageSizeSourceCleared() bool {
  43721. _, ok := m.clearedFields[usagelog.FieldImageSizeSource]
  43722. return ok
  43723. }
  43724. // ResetImageSizeSource resets all changes to the "image_size_source" field.
  43725. func (m *UsageLogMutation) ResetImageSizeSource() {
  43726. m.image_size_source = nil
  43727. delete(m.clearedFields, usagelog.FieldImageSizeSource)
  43728. }
  43729. // SetImageSizeBreakdown sets the "image_size_breakdown" field.
  43730. func (m *UsageLogMutation) SetImageSizeBreakdown(value map[string]int) {
  43731. m.image_size_breakdown = &value
  43732. }
  43733. // ImageSizeBreakdown returns the value of the "image_size_breakdown" field in the mutation.
  43734. func (m *UsageLogMutation) ImageSizeBreakdown() (r map[string]int, exists bool) {
  43735. v := m.image_size_breakdown
  43736. if v == nil {
  43737. return
  43738. }
  43739. return *v, true
  43740. }
  43741. // OldImageSizeBreakdown returns the old "image_size_breakdown" field's value of the UsageLog entity.
  43742. // If the UsageLog object wasn't provided to the builder, the object is fetched from the database.
  43743. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43744. func (m *UsageLogMutation) OldImageSizeBreakdown(ctx context.Context) (v map[string]int, err error) {
  43745. if !m.op.Is(OpUpdateOne) {
  43746. return v, errors.New("OldImageSizeBreakdown is only allowed on UpdateOne operations")
  43747. }
  43748. if m.id == nil || m.oldValue == nil {
  43749. return v, errors.New("OldImageSizeBreakdown requires an ID field in the mutation")
  43750. }
  43751. oldValue, err := m.oldValue(ctx)
  43752. if err != nil {
  43753. return v, fmt.Errorf("querying old value for OldImageSizeBreakdown: %w", err)
  43754. }
  43755. return oldValue.ImageSizeBreakdown, nil
  43756. }
  43757. // ClearImageSizeBreakdown clears the value of the "image_size_breakdown" field.
  43758. func (m *UsageLogMutation) ClearImageSizeBreakdown() {
  43759. m.image_size_breakdown = nil
  43760. m.clearedFields[usagelog.FieldImageSizeBreakdown] = struct{}{}
  43761. }
  43762. // ImageSizeBreakdownCleared returns if the "image_size_breakdown" field was cleared in this mutation.
  43763. func (m *UsageLogMutation) ImageSizeBreakdownCleared() bool {
  43764. _, ok := m.clearedFields[usagelog.FieldImageSizeBreakdown]
  43765. return ok
  43766. }
  43767. // ResetImageSizeBreakdown resets all changes to the "image_size_breakdown" field.
  43768. func (m *UsageLogMutation) ResetImageSizeBreakdown() {
  43769. m.image_size_breakdown = nil
  43770. delete(m.clearedFields, usagelog.FieldImageSizeBreakdown)
  43771. }
  43772. // SetVideoCount sets the "video_count" field.
  43773. func (m *UsageLogMutation) SetVideoCount(i int) {
  43774. m.video_count = &i
  43775. m.addvideo_count = nil
  43776. }
  43777. // VideoCount returns the value of the "video_count" field in the mutation.
  43778. func (m *UsageLogMutation) VideoCount() (r int, exists bool) {
  43779. v := m.video_count
  43780. if v == nil {
  43781. return
  43782. }
  43783. return *v, true
  43784. }
  43785. // OldVideoCount returns the old "video_count" field's value of the UsageLog entity.
  43786. // If the UsageLog object wasn't provided to the builder, the object is fetched from the database.
  43787. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43788. func (m *UsageLogMutation) OldVideoCount(ctx context.Context) (v int, err error) {
  43789. if !m.op.Is(OpUpdateOne) {
  43790. return v, errors.New("OldVideoCount is only allowed on UpdateOne operations")
  43791. }
  43792. if m.id == nil || m.oldValue == nil {
  43793. return v, errors.New("OldVideoCount requires an ID field in the mutation")
  43794. }
  43795. oldValue, err := m.oldValue(ctx)
  43796. if err != nil {
  43797. return v, fmt.Errorf("querying old value for OldVideoCount: %w", err)
  43798. }
  43799. return oldValue.VideoCount, nil
  43800. }
  43801. // AddVideoCount adds i to the "video_count" field.
  43802. func (m *UsageLogMutation) AddVideoCount(i int) {
  43803. if m.addvideo_count != nil {
  43804. *m.addvideo_count += i
  43805. } else {
  43806. m.addvideo_count = &i
  43807. }
  43808. }
  43809. // AddedVideoCount returns the value that was added to the "video_count" field in this mutation.
  43810. func (m *UsageLogMutation) AddedVideoCount() (r int, exists bool) {
  43811. v := m.addvideo_count
  43812. if v == nil {
  43813. return
  43814. }
  43815. return *v, true
  43816. }
  43817. // ResetVideoCount resets all changes to the "video_count" field.
  43818. func (m *UsageLogMutation) ResetVideoCount() {
  43819. m.video_count = nil
  43820. m.addvideo_count = nil
  43821. }
  43822. // SetVideoResolution sets the "video_resolution" field.
  43823. func (m *UsageLogMutation) SetVideoResolution(s string) {
  43824. m.video_resolution = &s
  43825. }
  43826. // VideoResolution returns the value of the "video_resolution" field in the mutation.
  43827. func (m *UsageLogMutation) VideoResolution() (r string, exists bool) {
  43828. v := m.video_resolution
  43829. if v == nil {
  43830. return
  43831. }
  43832. return *v, true
  43833. }
  43834. // OldVideoResolution returns the old "video_resolution" field's value of the UsageLog entity.
  43835. // If the UsageLog object wasn't provided to the builder, the object is fetched from the database.
  43836. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43837. func (m *UsageLogMutation) OldVideoResolution(ctx context.Context) (v *string, err error) {
  43838. if !m.op.Is(OpUpdateOne) {
  43839. return v, errors.New("OldVideoResolution is only allowed on UpdateOne operations")
  43840. }
  43841. if m.id == nil || m.oldValue == nil {
  43842. return v, errors.New("OldVideoResolution requires an ID field in the mutation")
  43843. }
  43844. oldValue, err := m.oldValue(ctx)
  43845. if err != nil {
  43846. return v, fmt.Errorf("querying old value for OldVideoResolution: %w", err)
  43847. }
  43848. return oldValue.VideoResolution, nil
  43849. }
  43850. // ClearVideoResolution clears the value of the "video_resolution" field.
  43851. func (m *UsageLogMutation) ClearVideoResolution() {
  43852. m.video_resolution = nil
  43853. m.clearedFields[usagelog.FieldVideoResolution] = struct{}{}
  43854. }
  43855. // VideoResolutionCleared returns if the "video_resolution" field was cleared in this mutation.
  43856. func (m *UsageLogMutation) VideoResolutionCleared() bool {
  43857. _, ok := m.clearedFields[usagelog.FieldVideoResolution]
  43858. return ok
  43859. }
  43860. // ResetVideoResolution resets all changes to the "video_resolution" field.
  43861. func (m *UsageLogMutation) ResetVideoResolution() {
  43862. m.video_resolution = nil
  43863. delete(m.clearedFields, usagelog.FieldVideoResolution)
  43864. }
  43865. // SetVideoDurationSeconds sets the "video_duration_seconds" field.
  43866. func (m *UsageLogMutation) SetVideoDurationSeconds(i int) {
  43867. m.video_duration_seconds = &i
  43868. m.addvideo_duration_seconds = nil
  43869. }
  43870. // VideoDurationSeconds returns the value of the "video_duration_seconds" field in the mutation.
  43871. func (m *UsageLogMutation) VideoDurationSeconds() (r int, exists bool) {
  43872. v := m.video_duration_seconds
  43873. if v == nil {
  43874. return
  43875. }
  43876. return *v, true
  43877. }
  43878. // OldVideoDurationSeconds returns the old "video_duration_seconds" field's value of the UsageLog entity.
  43879. // If the UsageLog object wasn't provided to the builder, the object is fetched from the database.
  43880. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43881. func (m *UsageLogMutation) OldVideoDurationSeconds(ctx context.Context) (v *int, err error) {
  43882. if !m.op.Is(OpUpdateOne) {
  43883. return v, errors.New("OldVideoDurationSeconds is only allowed on UpdateOne operations")
  43884. }
  43885. if m.id == nil || m.oldValue == nil {
  43886. return v, errors.New("OldVideoDurationSeconds requires an ID field in the mutation")
  43887. }
  43888. oldValue, err := m.oldValue(ctx)
  43889. if err != nil {
  43890. return v, fmt.Errorf("querying old value for OldVideoDurationSeconds: %w", err)
  43891. }
  43892. return oldValue.VideoDurationSeconds, nil
  43893. }
  43894. // AddVideoDurationSeconds adds i to the "video_duration_seconds" field.
  43895. func (m *UsageLogMutation) AddVideoDurationSeconds(i int) {
  43896. if m.addvideo_duration_seconds != nil {
  43897. *m.addvideo_duration_seconds += i
  43898. } else {
  43899. m.addvideo_duration_seconds = &i
  43900. }
  43901. }
  43902. // AddedVideoDurationSeconds returns the value that was added to the "video_duration_seconds" field in this mutation.
  43903. func (m *UsageLogMutation) AddedVideoDurationSeconds() (r int, exists bool) {
  43904. v := m.addvideo_duration_seconds
  43905. if v == nil {
  43906. return
  43907. }
  43908. return *v, true
  43909. }
  43910. // ClearVideoDurationSeconds clears the value of the "video_duration_seconds" field.
  43911. func (m *UsageLogMutation) ClearVideoDurationSeconds() {
  43912. m.video_duration_seconds = nil
  43913. m.addvideo_duration_seconds = nil
  43914. m.clearedFields[usagelog.FieldVideoDurationSeconds] = struct{}{}
  43915. }
  43916. // VideoDurationSecondsCleared returns if the "video_duration_seconds" field was cleared in this mutation.
  43917. func (m *UsageLogMutation) VideoDurationSecondsCleared() bool {
  43918. _, ok := m.clearedFields[usagelog.FieldVideoDurationSeconds]
  43919. return ok
  43920. }
  43921. // ResetVideoDurationSeconds resets all changes to the "video_duration_seconds" field.
  43922. func (m *UsageLogMutation) ResetVideoDurationSeconds() {
  43923. m.video_duration_seconds = nil
  43924. m.addvideo_duration_seconds = nil
  43925. delete(m.clearedFields, usagelog.FieldVideoDurationSeconds)
  43926. }
  43927. // SetCacheTTLOverridden sets the "cache_ttl_overridden" field.
  43928. func (m *UsageLogMutation) SetCacheTTLOverridden(b bool) {
  43929. m.cache_ttl_overridden = &b
  43930. }
  43931. // CacheTTLOverridden returns the value of the "cache_ttl_overridden" field in the mutation.
  43932. func (m *UsageLogMutation) CacheTTLOverridden() (r bool, exists bool) {
  43933. v := m.cache_ttl_overridden
  43934. if v == nil {
  43935. return
  43936. }
  43937. return *v, true
  43938. }
  43939. // OldCacheTTLOverridden returns the old "cache_ttl_overridden" field's value of the UsageLog entity.
  43940. // If the UsageLog object wasn't provided to the builder, the object is fetched from the database.
  43941. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43942. func (m *UsageLogMutation) OldCacheTTLOverridden(ctx context.Context) (v bool, err error) {
  43943. if !m.op.Is(OpUpdateOne) {
  43944. return v, errors.New("OldCacheTTLOverridden is only allowed on UpdateOne operations")
  43945. }
  43946. if m.id == nil || m.oldValue == nil {
  43947. return v, errors.New("OldCacheTTLOverridden requires an ID field in the mutation")
  43948. }
  43949. oldValue, err := m.oldValue(ctx)
  43950. if err != nil {
  43951. return v, fmt.Errorf("querying old value for OldCacheTTLOverridden: %w", err)
  43952. }
  43953. return oldValue.CacheTTLOverridden, nil
  43954. }
  43955. // ResetCacheTTLOverridden resets all changes to the "cache_ttl_overridden" field.
  43956. func (m *UsageLogMutation) ResetCacheTTLOverridden() {
  43957. m.cache_ttl_overridden = nil
  43958. }
  43959. // SetCreatedAt sets the "created_at" field.
  43960. func (m *UsageLogMutation) SetCreatedAt(t time.Time) {
  43961. m.created_at = &t
  43962. }
  43963. // CreatedAt returns the value of the "created_at" field in the mutation.
  43964. func (m *UsageLogMutation) CreatedAt() (r time.Time, exists bool) {
  43965. v := m.created_at
  43966. if v == nil {
  43967. return
  43968. }
  43969. return *v, true
  43970. }
  43971. // OldCreatedAt returns the old "created_at" field's value of the UsageLog entity.
  43972. // If the UsageLog object wasn't provided to the builder, the object is fetched from the database.
  43973. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43974. func (m *UsageLogMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  43975. if !m.op.Is(OpUpdateOne) {
  43976. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  43977. }
  43978. if m.id == nil || m.oldValue == nil {
  43979. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  43980. }
  43981. oldValue, err := m.oldValue(ctx)
  43982. if err != nil {
  43983. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  43984. }
  43985. return oldValue.CreatedAt, nil
  43986. }
  43987. // ResetCreatedAt resets all changes to the "created_at" field.
  43988. func (m *UsageLogMutation) ResetCreatedAt() {
  43989. m.created_at = nil
  43990. }
  43991. // ClearUser clears the "user" edge to the User entity.
  43992. func (m *UsageLogMutation) ClearUser() {
  43993. m.cleareduser = true
  43994. m.clearedFields[usagelog.FieldUserID] = struct{}{}
  43995. }
  43996. // UserCleared reports if the "user" edge to the User entity was cleared.
  43997. func (m *UsageLogMutation) UserCleared() bool {
  43998. return m.cleareduser
  43999. }
  44000. // UserIDs returns the "user" edge IDs in the mutation.
  44001. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  44002. // UserID instead. It exists only for internal usage by the builders.
  44003. func (m *UsageLogMutation) UserIDs() (ids []int64) {
  44004. if id := m.user; id != nil {
  44005. ids = append(ids, *id)
  44006. }
  44007. return
  44008. }
  44009. // ResetUser resets all changes to the "user" edge.
  44010. func (m *UsageLogMutation) ResetUser() {
  44011. m.user = nil
  44012. m.cleareduser = false
  44013. }
  44014. // ClearAPIKey clears the "api_key" edge to the APIKey entity.
  44015. func (m *UsageLogMutation) ClearAPIKey() {
  44016. m.clearedapi_key = true
  44017. m.clearedFields[usagelog.FieldAPIKeyID] = struct{}{}
  44018. }
  44019. // APIKeyCleared reports if the "api_key" edge to the APIKey entity was cleared.
  44020. func (m *UsageLogMutation) APIKeyCleared() bool {
  44021. return m.clearedapi_key
  44022. }
  44023. // APIKeyIDs returns the "api_key" edge IDs in the mutation.
  44024. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  44025. // APIKeyID instead. It exists only for internal usage by the builders.
  44026. func (m *UsageLogMutation) APIKeyIDs() (ids []int64) {
  44027. if id := m.api_key; id != nil {
  44028. ids = append(ids, *id)
  44029. }
  44030. return
  44031. }
  44032. // ResetAPIKey resets all changes to the "api_key" edge.
  44033. func (m *UsageLogMutation) ResetAPIKey() {
  44034. m.api_key = nil
  44035. m.clearedapi_key = false
  44036. }
  44037. // ClearAccount clears the "account" edge to the Account entity.
  44038. func (m *UsageLogMutation) ClearAccount() {
  44039. m.clearedaccount = true
  44040. m.clearedFields[usagelog.FieldAccountID] = struct{}{}
  44041. }
  44042. // AccountCleared reports if the "account" edge to the Account entity was cleared.
  44043. func (m *UsageLogMutation) AccountCleared() bool {
  44044. return m.clearedaccount
  44045. }
  44046. // AccountIDs returns the "account" edge IDs in the mutation.
  44047. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  44048. // AccountID instead. It exists only for internal usage by the builders.
  44049. func (m *UsageLogMutation) AccountIDs() (ids []int64) {
  44050. if id := m.account; id != nil {
  44051. ids = append(ids, *id)
  44052. }
  44053. return
  44054. }
  44055. // ResetAccount resets all changes to the "account" edge.
  44056. func (m *UsageLogMutation) ResetAccount() {
  44057. m.account = nil
  44058. m.clearedaccount = false
  44059. }
  44060. // ClearGroup clears the "group" edge to the Group entity.
  44061. func (m *UsageLogMutation) ClearGroup() {
  44062. m.clearedgroup = true
  44063. m.clearedFields[usagelog.FieldGroupID] = struct{}{}
  44064. }
  44065. // GroupCleared reports if the "group" edge to the Group entity was cleared.
  44066. func (m *UsageLogMutation) GroupCleared() bool {
  44067. return m.GroupIDCleared() || m.clearedgroup
  44068. }
  44069. // GroupIDs returns the "group" edge IDs in the mutation.
  44070. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  44071. // GroupID instead. It exists only for internal usage by the builders.
  44072. func (m *UsageLogMutation) GroupIDs() (ids []int64) {
  44073. if id := m.group; id != nil {
  44074. ids = append(ids, *id)
  44075. }
  44076. return
  44077. }
  44078. // ResetGroup resets all changes to the "group" edge.
  44079. func (m *UsageLogMutation) ResetGroup() {
  44080. m.group = nil
  44081. m.clearedgroup = false
  44082. }
  44083. // ClearSubscription clears the "subscription" edge to the UserSubscription entity.
  44084. func (m *UsageLogMutation) ClearSubscription() {
  44085. m.clearedsubscription = true
  44086. m.clearedFields[usagelog.FieldSubscriptionID] = struct{}{}
  44087. }
  44088. // SubscriptionCleared reports if the "subscription" edge to the UserSubscription entity was cleared.
  44089. func (m *UsageLogMutation) SubscriptionCleared() bool {
  44090. return m.SubscriptionIDCleared() || m.clearedsubscription
  44091. }
  44092. // SubscriptionIDs returns the "subscription" edge IDs in the mutation.
  44093. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  44094. // SubscriptionID instead. It exists only for internal usage by the builders.
  44095. func (m *UsageLogMutation) SubscriptionIDs() (ids []int64) {
  44096. if id := m.subscription; id != nil {
  44097. ids = append(ids, *id)
  44098. }
  44099. return
  44100. }
  44101. // ResetSubscription resets all changes to the "subscription" edge.
  44102. func (m *UsageLogMutation) ResetSubscription() {
  44103. m.subscription = nil
  44104. m.clearedsubscription = false
  44105. }
  44106. // Where appends a list predicates to the UsageLogMutation builder.
  44107. func (m *UsageLogMutation) Where(ps ...predicate.UsageLog) {
  44108. m.predicates = append(m.predicates, ps...)
  44109. }
  44110. // WhereP appends storage-level predicates to the UsageLogMutation builder. Using this method,
  44111. // users can use type-assertion to append predicates that do not depend on any generated package.
  44112. func (m *UsageLogMutation) WhereP(ps ...func(*sql.Selector)) {
  44113. p := make([]predicate.UsageLog, len(ps))
  44114. for i := range ps {
  44115. p[i] = ps[i]
  44116. }
  44117. m.Where(p...)
  44118. }
  44119. // Op returns the operation name.
  44120. func (m *UsageLogMutation) Op() Op {
  44121. return m.op
  44122. }
  44123. // SetOp allows setting the mutation operation.
  44124. func (m *UsageLogMutation) SetOp(op Op) {
  44125. m.op = op
  44126. }
  44127. // Type returns the node type of this mutation (UsageLog).
  44128. func (m *UsageLogMutation) Type() string {
  44129. return m.typ
  44130. }
  44131. // Fields returns all fields that were changed during this mutation. Note that in
  44132. // order to get all numeric fields that were incremented/decremented, call
  44133. // AddedFields().
  44134. func (m *UsageLogMutation) Fields() []string {
  44135. fields := make([]string, 0, 47)
  44136. if m.user != nil {
  44137. fields = append(fields, usagelog.FieldUserID)
  44138. }
  44139. if m.api_key != nil {
  44140. fields = append(fields, usagelog.FieldAPIKeyID)
  44141. }
  44142. if m.account != nil {
  44143. fields = append(fields, usagelog.FieldAccountID)
  44144. }
  44145. if m.request_id != nil {
  44146. fields = append(fields, usagelog.FieldRequestID)
  44147. }
  44148. if m.model != nil {
  44149. fields = append(fields, usagelog.FieldModel)
  44150. }
  44151. if m.requested_model != nil {
  44152. fields = append(fields, usagelog.FieldRequestedModel)
  44153. }
  44154. if m.upstream_model != nil {
  44155. fields = append(fields, usagelog.FieldUpstreamModel)
  44156. }
  44157. if m.upstream_response_model != nil {
  44158. fields = append(fields, usagelog.FieldUpstreamResponseModel)
  44159. }
  44160. if m.upstream_model_mismatch != nil {
  44161. fields = append(fields, usagelog.FieldUpstreamModelMismatch)
  44162. }
  44163. if m.channel_id != nil {
  44164. fields = append(fields, usagelog.FieldChannelID)
  44165. }
  44166. if m.model_mapping_chain != nil {
  44167. fields = append(fields, usagelog.FieldModelMappingChain)
  44168. }
  44169. if m.billing_tier != nil {
  44170. fields = append(fields, usagelog.FieldBillingTier)
  44171. }
  44172. if m.billing_mode != nil {
  44173. fields = append(fields, usagelog.FieldBillingMode)
  44174. }
  44175. if m.group != nil {
  44176. fields = append(fields, usagelog.FieldGroupID)
  44177. }
  44178. if m.subscription != nil {
  44179. fields = append(fields, usagelog.FieldSubscriptionID)
  44180. }
  44181. if m.input_tokens != nil {
  44182. fields = append(fields, usagelog.FieldInputTokens)
  44183. }
  44184. if m.output_tokens != nil {
  44185. fields = append(fields, usagelog.FieldOutputTokens)
  44186. }
  44187. if m.cache_creation_tokens != nil {
  44188. fields = append(fields, usagelog.FieldCacheCreationTokens)
  44189. }
  44190. if m.cache_read_tokens != nil {
  44191. fields = append(fields, usagelog.FieldCacheReadTokens)
  44192. }
  44193. if m.cache_creation_5m_tokens != nil {
  44194. fields = append(fields, usagelog.FieldCacheCreation5mTokens)
  44195. }
  44196. if m.cache_creation_1h_tokens != nil {
  44197. fields = append(fields, usagelog.FieldCacheCreation1hTokens)
  44198. }
  44199. if m.input_cost != nil {
  44200. fields = append(fields, usagelog.FieldInputCost)
  44201. }
  44202. if m.output_cost != nil {
  44203. fields = append(fields, usagelog.FieldOutputCost)
  44204. }
  44205. if m.cache_creation_cost != nil {
  44206. fields = append(fields, usagelog.FieldCacheCreationCost)
  44207. }
  44208. if m.cache_read_cost != nil {
  44209. fields = append(fields, usagelog.FieldCacheReadCost)
  44210. }
  44211. if m.total_cost != nil {
  44212. fields = append(fields, usagelog.FieldTotalCost)
  44213. }
  44214. if m.actual_cost != nil {
  44215. fields = append(fields, usagelog.FieldActualCost)
  44216. }
  44217. if m.rate_multiplier != nil {
  44218. fields = append(fields, usagelog.FieldRateMultiplier)
  44219. }
  44220. if m.long_context_billing_applied != nil {
  44221. fields = append(fields, usagelog.FieldLongContextBillingApplied)
  44222. }
  44223. if m.account_rate_multiplier != nil {
  44224. fields = append(fields, usagelog.FieldAccountRateMultiplier)
  44225. }
  44226. if m.billing_type != nil {
  44227. fields = append(fields, usagelog.FieldBillingType)
  44228. }
  44229. if m.stream != nil {
  44230. fields = append(fields, usagelog.FieldStream)
  44231. }
  44232. if m.duration_ms != nil {
  44233. fields = append(fields, usagelog.FieldDurationMs)
  44234. }
  44235. if m.first_token_ms != nil {
  44236. fields = append(fields, usagelog.FieldFirstTokenMs)
  44237. }
  44238. if m.user_agent != nil {
  44239. fields = append(fields, usagelog.FieldUserAgent)
  44240. }
  44241. if m.ip_address != nil {
  44242. fields = append(fields, usagelog.FieldIPAddress)
  44243. }
  44244. if m.image_count != nil {
  44245. fields = append(fields, usagelog.FieldImageCount)
  44246. }
  44247. if m.image_size != nil {
  44248. fields = append(fields, usagelog.FieldImageSize)
  44249. }
  44250. if m.image_input_size != nil {
  44251. fields = append(fields, usagelog.FieldImageInputSize)
  44252. }
  44253. if m.image_output_size != nil {
  44254. fields = append(fields, usagelog.FieldImageOutputSize)
  44255. }
  44256. if m.image_size_source != nil {
  44257. fields = append(fields, usagelog.FieldImageSizeSource)
  44258. }
  44259. if m.image_size_breakdown != nil {
  44260. fields = append(fields, usagelog.FieldImageSizeBreakdown)
  44261. }
  44262. if m.video_count != nil {
  44263. fields = append(fields, usagelog.FieldVideoCount)
  44264. }
  44265. if m.video_resolution != nil {
  44266. fields = append(fields, usagelog.FieldVideoResolution)
  44267. }
  44268. if m.video_duration_seconds != nil {
  44269. fields = append(fields, usagelog.FieldVideoDurationSeconds)
  44270. }
  44271. if m.cache_ttl_overridden != nil {
  44272. fields = append(fields, usagelog.FieldCacheTTLOverridden)
  44273. }
  44274. if m.created_at != nil {
  44275. fields = append(fields, usagelog.FieldCreatedAt)
  44276. }
  44277. return fields
  44278. }
  44279. // Field returns the value of a field with the given name. The second boolean
  44280. // return value indicates that this field was not set, or was not defined in the
  44281. // schema.
  44282. func (m *UsageLogMutation) Field(name string) (ent.Value, bool) {
  44283. switch name {
  44284. case usagelog.FieldUserID:
  44285. return m.UserID()
  44286. case usagelog.FieldAPIKeyID:
  44287. return m.APIKeyID()
  44288. case usagelog.FieldAccountID:
  44289. return m.AccountID()
  44290. case usagelog.FieldRequestID:
  44291. return m.RequestID()
  44292. case usagelog.FieldModel:
  44293. return m.Model()
  44294. case usagelog.FieldRequestedModel:
  44295. return m.RequestedModel()
  44296. case usagelog.FieldUpstreamModel:
  44297. return m.UpstreamModel()
  44298. case usagelog.FieldUpstreamResponseModel:
  44299. return m.UpstreamResponseModel()
  44300. case usagelog.FieldUpstreamModelMismatch:
  44301. return m.UpstreamModelMismatch()
  44302. case usagelog.FieldChannelID:
  44303. return m.ChannelID()
  44304. case usagelog.FieldModelMappingChain:
  44305. return m.ModelMappingChain()
  44306. case usagelog.FieldBillingTier:
  44307. return m.BillingTier()
  44308. case usagelog.FieldBillingMode:
  44309. return m.BillingMode()
  44310. case usagelog.FieldGroupID:
  44311. return m.GroupID()
  44312. case usagelog.FieldSubscriptionID:
  44313. return m.SubscriptionID()
  44314. case usagelog.FieldInputTokens:
  44315. return m.InputTokens()
  44316. case usagelog.FieldOutputTokens:
  44317. return m.OutputTokens()
  44318. case usagelog.FieldCacheCreationTokens:
  44319. return m.CacheCreationTokens()
  44320. case usagelog.FieldCacheReadTokens:
  44321. return m.CacheReadTokens()
  44322. case usagelog.FieldCacheCreation5mTokens:
  44323. return m.CacheCreation5mTokens()
  44324. case usagelog.FieldCacheCreation1hTokens:
  44325. return m.CacheCreation1hTokens()
  44326. case usagelog.FieldInputCost:
  44327. return m.InputCost()
  44328. case usagelog.FieldOutputCost:
  44329. return m.OutputCost()
  44330. case usagelog.FieldCacheCreationCost:
  44331. return m.CacheCreationCost()
  44332. case usagelog.FieldCacheReadCost:
  44333. return m.CacheReadCost()
  44334. case usagelog.FieldTotalCost:
  44335. return m.TotalCost()
  44336. case usagelog.FieldActualCost:
  44337. return m.ActualCost()
  44338. case usagelog.FieldRateMultiplier:
  44339. return m.RateMultiplier()
  44340. case usagelog.FieldLongContextBillingApplied:
  44341. return m.LongContextBillingApplied()
  44342. case usagelog.FieldAccountRateMultiplier:
  44343. return m.AccountRateMultiplier()
  44344. case usagelog.FieldBillingType:
  44345. return m.BillingType()
  44346. case usagelog.FieldStream:
  44347. return m.Stream()
  44348. case usagelog.FieldDurationMs:
  44349. return m.DurationMs()
  44350. case usagelog.FieldFirstTokenMs:
  44351. return m.FirstTokenMs()
  44352. case usagelog.FieldUserAgent:
  44353. return m.UserAgent()
  44354. case usagelog.FieldIPAddress:
  44355. return m.IPAddress()
  44356. case usagelog.FieldImageCount:
  44357. return m.ImageCount()
  44358. case usagelog.FieldImageSize:
  44359. return m.ImageSize()
  44360. case usagelog.FieldImageInputSize:
  44361. return m.ImageInputSize()
  44362. case usagelog.FieldImageOutputSize:
  44363. return m.ImageOutputSize()
  44364. case usagelog.FieldImageSizeSource:
  44365. return m.ImageSizeSource()
  44366. case usagelog.FieldImageSizeBreakdown:
  44367. return m.ImageSizeBreakdown()
  44368. case usagelog.FieldVideoCount:
  44369. return m.VideoCount()
  44370. case usagelog.FieldVideoResolution:
  44371. return m.VideoResolution()
  44372. case usagelog.FieldVideoDurationSeconds:
  44373. return m.VideoDurationSeconds()
  44374. case usagelog.FieldCacheTTLOverridden:
  44375. return m.CacheTTLOverridden()
  44376. case usagelog.FieldCreatedAt:
  44377. return m.CreatedAt()
  44378. }
  44379. return nil, false
  44380. }
  44381. // OldField returns the old value of the field from the database. An error is
  44382. // returned if the mutation operation is not UpdateOne, or the query to the
  44383. // database failed.
  44384. func (m *UsageLogMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  44385. switch name {
  44386. case usagelog.FieldUserID:
  44387. return m.OldUserID(ctx)
  44388. case usagelog.FieldAPIKeyID:
  44389. return m.OldAPIKeyID(ctx)
  44390. case usagelog.FieldAccountID:
  44391. return m.OldAccountID(ctx)
  44392. case usagelog.FieldRequestID:
  44393. return m.OldRequestID(ctx)
  44394. case usagelog.FieldModel:
  44395. return m.OldModel(ctx)
  44396. case usagelog.FieldRequestedModel:
  44397. return m.OldRequestedModel(ctx)
  44398. case usagelog.FieldUpstreamModel:
  44399. return m.OldUpstreamModel(ctx)
  44400. case usagelog.FieldUpstreamResponseModel:
  44401. return m.OldUpstreamResponseModel(ctx)
  44402. case usagelog.FieldUpstreamModelMismatch:
  44403. return m.OldUpstreamModelMismatch(ctx)
  44404. case usagelog.FieldChannelID:
  44405. return m.OldChannelID(ctx)
  44406. case usagelog.FieldModelMappingChain:
  44407. return m.OldModelMappingChain(ctx)
  44408. case usagelog.FieldBillingTier:
  44409. return m.OldBillingTier(ctx)
  44410. case usagelog.FieldBillingMode:
  44411. return m.OldBillingMode(ctx)
  44412. case usagelog.FieldGroupID:
  44413. return m.OldGroupID(ctx)
  44414. case usagelog.FieldSubscriptionID:
  44415. return m.OldSubscriptionID(ctx)
  44416. case usagelog.FieldInputTokens:
  44417. return m.OldInputTokens(ctx)
  44418. case usagelog.FieldOutputTokens:
  44419. return m.OldOutputTokens(ctx)
  44420. case usagelog.FieldCacheCreationTokens:
  44421. return m.OldCacheCreationTokens(ctx)
  44422. case usagelog.FieldCacheReadTokens:
  44423. return m.OldCacheReadTokens(ctx)
  44424. case usagelog.FieldCacheCreation5mTokens:
  44425. return m.OldCacheCreation5mTokens(ctx)
  44426. case usagelog.FieldCacheCreation1hTokens:
  44427. return m.OldCacheCreation1hTokens(ctx)
  44428. case usagelog.FieldInputCost:
  44429. return m.OldInputCost(ctx)
  44430. case usagelog.FieldOutputCost:
  44431. return m.OldOutputCost(ctx)
  44432. case usagelog.FieldCacheCreationCost:
  44433. return m.OldCacheCreationCost(ctx)
  44434. case usagelog.FieldCacheReadCost:
  44435. return m.OldCacheReadCost(ctx)
  44436. case usagelog.FieldTotalCost:
  44437. return m.OldTotalCost(ctx)
  44438. case usagelog.FieldActualCost:
  44439. return m.OldActualCost(ctx)
  44440. case usagelog.FieldRateMultiplier:
  44441. return m.OldRateMultiplier(ctx)
  44442. case usagelog.FieldLongContextBillingApplied:
  44443. return m.OldLongContextBillingApplied(ctx)
  44444. case usagelog.FieldAccountRateMultiplier:
  44445. return m.OldAccountRateMultiplier(ctx)
  44446. case usagelog.FieldBillingType:
  44447. return m.OldBillingType(ctx)
  44448. case usagelog.FieldStream:
  44449. return m.OldStream(ctx)
  44450. case usagelog.FieldDurationMs:
  44451. return m.OldDurationMs(ctx)
  44452. case usagelog.FieldFirstTokenMs:
  44453. return m.OldFirstTokenMs(ctx)
  44454. case usagelog.FieldUserAgent:
  44455. return m.OldUserAgent(ctx)
  44456. case usagelog.FieldIPAddress:
  44457. return m.OldIPAddress(ctx)
  44458. case usagelog.FieldImageCount:
  44459. return m.OldImageCount(ctx)
  44460. case usagelog.FieldImageSize:
  44461. return m.OldImageSize(ctx)
  44462. case usagelog.FieldImageInputSize:
  44463. return m.OldImageInputSize(ctx)
  44464. case usagelog.FieldImageOutputSize:
  44465. return m.OldImageOutputSize(ctx)
  44466. case usagelog.FieldImageSizeSource:
  44467. return m.OldImageSizeSource(ctx)
  44468. case usagelog.FieldImageSizeBreakdown:
  44469. return m.OldImageSizeBreakdown(ctx)
  44470. case usagelog.FieldVideoCount:
  44471. return m.OldVideoCount(ctx)
  44472. case usagelog.FieldVideoResolution:
  44473. return m.OldVideoResolution(ctx)
  44474. case usagelog.FieldVideoDurationSeconds:
  44475. return m.OldVideoDurationSeconds(ctx)
  44476. case usagelog.FieldCacheTTLOverridden:
  44477. return m.OldCacheTTLOverridden(ctx)
  44478. case usagelog.FieldCreatedAt:
  44479. return m.OldCreatedAt(ctx)
  44480. }
  44481. return nil, fmt.Errorf("unknown UsageLog field %s", name)
  44482. }
  44483. // SetField sets the value of a field with the given name. It returns an error if
  44484. // the field is not defined in the schema, or if the type mismatched the field
  44485. // type.
  44486. func (m *UsageLogMutation) SetField(name string, value ent.Value) error {
  44487. switch name {
  44488. case usagelog.FieldUserID:
  44489. v, ok := value.(int64)
  44490. if !ok {
  44491. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44492. }
  44493. m.SetUserID(v)
  44494. return nil
  44495. case usagelog.FieldAPIKeyID:
  44496. v, ok := value.(int64)
  44497. if !ok {
  44498. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44499. }
  44500. m.SetAPIKeyID(v)
  44501. return nil
  44502. case usagelog.FieldAccountID:
  44503. v, ok := value.(int64)
  44504. if !ok {
  44505. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44506. }
  44507. m.SetAccountID(v)
  44508. return nil
  44509. case usagelog.FieldRequestID:
  44510. v, ok := value.(string)
  44511. if !ok {
  44512. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44513. }
  44514. m.SetRequestID(v)
  44515. return nil
  44516. case usagelog.FieldModel:
  44517. v, ok := value.(string)
  44518. if !ok {
  44519. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44520. }
  44521. m.SetModel(v)
  44522. return nil
  44523. case usagelog.FieldRequestedModel:
  44524. v, ok := value.(string)
  44525. if !ok {
  44526. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44527. }
  44528. m.SetRequestedModel(v)
  44529. return nil
  44530. case usagelog.FieldUpstreamModel:
  44531. v, ok := value.(string)
  44532. if !ok {
  44533. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44534. }
  44535. m.SetUpstreamModel(v)
  44536. return nil
  44537. case usagelog.FieldUpstreamResponseModel:
  44538. v, ok := value.(string)
  44539. if !ok {
  44540. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44541. }
  44542. m.SetUpstreamResponseModel(v)
  44543. return nil
  44544. case usagelog.FieldUpstreamModelMismatch:
  44545. v, ok := value.(bool)
  44546. if !ok {
  44547. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44548. }
  44549. m.SetUpstreamModelMismatch(v)
  44550. return nil
  44551. case usagelog.FieldChannelID:
  44552. v, ok := value.(int64)
  44553. if !ok {
  44554. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44555. }
  44556. m.SetChannelID(v)
  44557. return nil
  44558. case usagelog.FieldModelMappingChain:
  44559. v, ok := value.(string)
  44560. if !ok {
  44561. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44562. }
  44563. m.SetModelMappingChain(v)
  44564. return nil
  44565. case usagelog.FieldBillingTier:
  44566. v, ok := value.(string)
  44567. if !ok {
  44568. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44569. }
  44570. m.SetBillingTier(v)
  44571. return nil
  44572. case usagelog.FieldBillingMode:
  44573. v, ok := value.(string)
  44574. if !ok {
  44575. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44576. }
  44577. m.SetBillingMode(v)
  44578. return nil
  44579. case usagelog.FieldGroupID:
  44580. v, ok := value.(int64)
  44581. if !ok {
  44582. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44583. }
  44584. m.SetGroupID(v)
  44585. return nil
  44586. case usagelog.FieldSubscriptionID:
  44587. v, ok := value.(int64)
  44588. if !ok {
  44589. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44590. }
  44591. m.SetSubscriptionID(v)
  44592. return nil
  44593. case usagelog.FieldInputTokens:
  44594. v, ok := value.(int)
  44595. if !ok {
  44596. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44597. }
  44598. m.SetInputTokens(v)
  44599. return nil
  44600. case usagelog.FieldOutputTokens:
  44601. v, ok := value.(int)
  44602. if !ok {
  44603. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44604. }
  44605. m.SetOutputTokens(v)
  44606. return nil
  44607. case usagelog.FieldCacheCreationTokens:
  44608. v, ok := value.(int)
  44609. if !ok {
  44610. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44611. }
  44612. m.SetCacheCreationTokens(v)
  44613. return nil
  44614. case usagelog.FieldCacheReadTokens:
  44615. v, ok := value.(int)
  44616. if !ok {
  44617. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44618. }
  44619. m.SetCacheReadTokens(v)
  44620. return nil
  44621. case usagelog.FieldCacheCreation5mTokens:
  44622. v, ok := value.(int)
  44623. if !ok {
  44624. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44625. }
  44626. m.SetCacheCreation5mTokens(v)
  44627. return nil
  44628. case usagelog.FieldCacheCreation1hTokens:
  44629. v, ok := value.(int)
  44630. if !ok {
  44631. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44632. }
  44633. m.SetCacheCreation1hTokens(v)
  44634. return nil
  44635. case usagelog.FieldInputCost:
  44636. v, ok := value.(float64)
  44637. if !ok {
  44638. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44639. }
  44640. m.SetInputCost(v)
  44641. return nil
  44642. case usagelog.FieldOutputCost:
  44643. v, ok := value.(float64)
  44644. if !ok {
  44645. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44646. }
  44647. m.SetOutputCost(v)
  44648. return nil
  44649. case usagelog.FieldCacheCreationCost:
  44650. v, ok := value.(float64)
  44651. if !ok {
  44652. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44653. }
  44654. m.SetCacheCreationCost(v)
  44655. return nil
  44656. case usagelog.FieldCacheReadCost:
  44657. v, ok := value.(float64)
  44658. if !ok {
  44659. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44660. }
  44661. m.SetCacheReadCost(v)
  44662. return nil
  44663. case usagelog.FieldTotalCost:
  44664. v, ok := value.(float64)
  44665. if !ok {
  44666. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44667. }
  44668. m.SetTotalCost(v)
  44669. return nil
  44670. case usagelog.FieldActualCost:
  44671. v, ok := value.(float64)
  44672. if !ok {
  44673. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44674. }
  44675. m.SetActualCost(v)
  44676. return nil
  44677. case usagelog.FieldRateMultiplier:
  44678. v, ok := value.(float64)
  44679. if !ok {
  44680. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44681. }
  44682. m.SetRateMultiplier(v)
  44683. return nil
  44684. case usagelog.FieldLongContextBillingApplied:
  44685. v, ok := value.(bool)
  44686. if !ok {
  44687. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44688. }
  44689. m.SetLongContextBillingApplied(v)
  44690. return nil
  44691. case usagelog.FieldAccountRateMultiplier:
  44692. v, ok := value.(float64)
  44693. if !ok {
  44694. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44695. }
  44696. m.SetAccountRateMultiplier(v)
  44697. return nil
  44698. case usagelog.FieldBillingType:
  44699. v, ok := value.(int8)
  44700. if !ok {
  44701. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44702. }
  44703. m.SetBillingType(v)
  44704. return nil
  44705. case usagelog.FieldStream:
  44706. v, ok := value.(bool)
  44707. if !ok {
  44708. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44709. }
  44710. m.SetStream(v)
  44711. return nil
  44712. case usagelog.FieldDurationMs:
  44713. v, ok := value.(int)
  44714. if !ok {
  44715. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44716. }
  44717. m.SetDurationMs(v)
  44718. return nil
  44719. case usagelog.FieldFirstTokenMs:
  44720. v, ok := value.(int)
  44721. if !ok {
  44722. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44723. }
  44724. m.SetFirstTokenMs(v)
  44725. return nil
  44726. case usagelog.FieldUserAgent:
  44727. v, ok := value.(string)
  44728. if !ok {
  44729. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44730. }
  44731. m.SetUserAgent(v)
  44732. return nil
  44733. case usagelog.FieldIPAddress:
  44734. v, ok := value.(string)
  44735. if !ok {
  44736. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44737. }
  44738. m.SetIPAddress(v)
  44739. return nil
  44740. case usagelog.FieldImageCount:
  44741. v, ok := value.(int)
  44742. if !ok {
  44743. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44744. }
  44745. m.SetImageCount(v)
  44746. return nil
  44747. case usagelog.FieldImageSize:
  44748. v, ok := value.(string)
  44749. if !ok {
  44750. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44751. }
  44752. m.SetImageSize(v)
  44753. return nil
  44754. case usagelog.FieldImageInputSize:
  44755. v, ok := value.(string)
  44756. if !ok {
  44757. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44758. }
  44759. m.SetImageInputSize(v)
  44760. return nil
  44761. case usagelog.FieldImageOutputSize:
  44762. v, ok := value.(string)
  44763. if !ok {
  44764. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44765. }
  44766. m.SetImageOutputSize(v)
  44767. return nil
  44768. case usagelog.FieldImageSizeSource:
  44769. v, ok := value.(string)
  44770. if !ok {
  44771. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44772. }
  44773. m.SetImageSizeSource(v)
  44774. return nil
  44775. case usagelog.FieldImageSizeBreakdown:
  44776. v, ok := value.(map[string]int)
  44777. if !ok {
  44778. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44779. }
  44780. m.SetImageSizeBreakdown(v)
  44781. return nil
  44782. case usagelog.FieldVideoCount:
  44783. v, ok := value.(int)
  44784. if !ok {
  44785. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44786. }
  44787. m.SetVideoCount(v)
  44788. return nil
  44789. case usagelog.FieldVideoResolution:
  44790. v, ok := value.(string)
  44791. if !ok {
  44792. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44793. }
  44794. m.SetVideoResolution(v)
  44795. return nil
  44796. case usagelog.FieldVideoDurationSeconds:
  44797. v, ok := value.(int)
  44798. if !ok {
  44799. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44800. }
  44801. m.SetVideoDurationSeconds(v)
  44802. return nil
  44803. case usagelog.FieldCacheTTLOverridden:
  44804. v, ok := value.(bool)
  44805. if !ok {
  44806. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44807. }
  44808. m.SetCacheTTLOverridden(v)
  44809. return nil
  44810. case usagelog.FieldCreatedAt:
  44811. v, ok := value.(time.Time)
  44812. if !ok {
  44813. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44814. }
  44815. m.SetCreatedAt(v)
  44816. return nil
  44817. }
  44818. return fmt.Errorf("unknown UsageLog field %s", name)
  44819. }
  44820. // AddedFields returns all numeric fields that were incremented/decremented during
  44821. // this mutation.
  44822. func (m *UsageLogMutation) AddedFields() []string {
  44823. var fields []string
  44824. if m.addchannel_id != nil {
  44825. fields = append(fields, usagelog.FieldChannelID)
  44826. }
  44827. if m.addinput_tokens != nil {
  44828. fields = append(fields, usagelog.FieldInputTokens)
  44829. }
  44830. if m.addoutput_tokens != nil {
  44831. fields = append(fields, usagelog.FieldOutputTokens)
  44832. }
  44833. if m.addcache_creation_tokens != nil {
  44834. fields = append(fields, usagelog.FieldCacheCreationTokens)
  44835. }
  44836. if m.addcache_read_tokens != nil {
  44837. fields = append(fields, usagelog.FieldCacheReadTokens)
  44838. }
  44839. if m.addcache_creation_5m_tokens != nil {
  44840. fields = append(fields, usagelog.FieldCacheCreation5mTokens)
  44841. }
  44842. if m.addcache_creation_1h_tokens != nil {
  44843. fields = append(fields, usagelog.FieldCacheCreation1hTokens)
  44844. }
  44845. if m.addinput_cost != nil {
  44846. fields = append(fields, usagelog.FieldInputCost)
  44847. }
  44848. if m.addoutput_cost != nil {
  44849. fields = append(fields, usagelog.FieldOutputCost)
  44850. }
  44851. if m.addcache_creation_cost != nil {
  44852. fields = append(fields, usagelog.FieldCacheCreationCost)
  44853. }
  44854. if m.addcache_read_cost != nil {
  44855. fields = append(fields, usagelog.FieldCacheReadCost)
  44856. }
  44857. if m.addtotal_cost != nil {
  44858. fields = append(fields, usagelog.FieldTotalCost)
  44859. }
  44860. if m.addactual_cost != nil {
  44861. fields = append(fields, usagelog.FieldActualCost)
  44862. }
  44863. if m.addrate_multiplier != nil {
  44864. fields = append(fields, usagelog.FieldRateMultiplier)
  44865. }
  44866. if m.addaccount_rate_multiplier != nil {
  44867. fields = append(fields, usagelog.FieldAccountRateMultiplier)
  44868. }
  44869. if m.addbilling_type != nil {
  44870. fields = append(fields, usagelog.FieldBillingType)
  44871. }
  44872. if m.addduration_ms != nil {
  44873. fields = append(fields, usagelog.FieldDurationMs)
  44874. }
  44875. if m.addfirst_token_ms != nil {
  44876. fields = append(fields, usagelog.FieldFirstTokenMs)
  44877. }
  44878. if m.addimage_count != nil {
  44879. fields = append(fields, usagelog.FieldImageCount)
  44880. }
  44881. if m.addvideo_count != nil {
  44882. fields = append(fields, usagelog.FieldVideoCount)
  44883. }
  44884. if m.addvideo_duration_seconds != nil {
  44885. fields = append(fields, usagelog.FieldVideoDurationSeconds)
  44886. }
  44887. return fields
  44888. }
  44889. // AddedField returns the numeric value that was incremented/decremented on a field
  44890. // with the given name. The second boolean return value indicates that this field
  44891. // was not set, or was not defined in the schema.
  44892. func (m *UsageLogMutation) AddedField(name string) (ent.Value, bool) {
  44893. switch name {
  44894. case usagelog.FieldChannelID:
  44895. return m.AddedChannelID()
  44896. case usagelog.FieldInputTokens:
  44897. return m.AddedInputTokens()
  44898. case usagelog.FieldOutputTokens:
  44899. return m.AddedOutputTokens()
  44900. case usagelog.FieldCacheCreationTokens:
  44901. return m.AddedCacheCreationTokens()
  44902. case usagelog.FieldCacheReadTokens:
  44903. return m.AddedCacheReadTokens()
  44904. case usagelog.FieldCacheCreation5mTokens:
  44905. return m.AddedCacheCreation5mTokens()
  44906. case usagelog.FieldCacheCreation1hTokens:
  44907. return m.AddedCacheCreation1hTokens()
  44908. case usagelog.FieldInputCost:
  44909. return m.AddedInputCost()
  44910. case usagelog.FieldOutputCost:
  44911. return m.AddedOutputCost()
  44912. case usagelog.FieldCacheCreationCost:
  44913. return m.AddedCacheCreationCost()
  44914. case usagelog.FieldCacheReadCost:
  44915. return m.AddedCacheReadCost()
  44916. case usagelog.FieldTotalCost:
  44917. return m.AddedTotalCost()
  44918. case usagelog.FieldActualCost:
  44919. return m.AddedActualCost()
  44920. case usagelog.FieldRateMultiplier:
  44921. return m.AddedRateMultiplier()
  44922. case usagelog.FieldAccountRateMultiplier:
  44923. return m.AddedAccountRateMultiplier()
  44924. case usagelog.FieldBillingType:
  44925. return m.AddedBillingType()
  44926. case usagelog.FieldDurationMs:
  44927. return m.AddedDurationMs()
  44928. case usagelog.FieldFirstTokenMs:
  44929. return m.AddedFirstTokenMs()
  44930. case usagelog.FieldImageCount:
  44931. return m.AddedImageCount()
  44932. case usagelog.FieldVideoCount:
  44933. return m.AddedVideoCount()
  44934. case usagelog.FieldVideoDurationSeconds:
  44935. return m.AddedVideoDurationSeconds()
  44936. }
  44937. return nil, false
  44938. }
  44939. // AddField adds the value to the field with the given name. It returns an error if
  44940. // the field is not defined in the schema, or if the type mismatched the field
  44941. // type.
  44942. func (m *UsageLogMutation) AddField(name string, value ent.Value) error {
  44943. switch name {
  44944. case usagelog.FieldChannelID:
  44945. v, ok := value.(int64)
  44946. if !ok {
  44947. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44948. }
  44949. m.AddChannelID(v)
  44950. return nil
  44951. case usagelog.FieldInputTokens:
  44952. v, ok := value.(int)
  44953. if !ok {
  44954. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44955. }
  44956. m.AddInputTokens(v)
  44957. return nil
  44958. case usagelog.FieldOutputTokens:
  44959. v, ok := value.(int)
  44960. if !ok {
  44961. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44962. }
  44963. m.AddOutputTokens(v)
  44964. return nil
  44965. case usagelog.FieldCacheCreationTokens:
  44966. v, ok := value.(int)
  44967. if !ok {
  44968. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44969. }
  44970. m.AddCacheCreationTokens(v)
  44971. return nil
  44972. case usagelog.FieldCacheReadTokens:
  44973. v, ok := value.(int)
  44974. if !ok {
  44975. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44976. }
  44977. m.AddCacheReadTokens(v)
  44978. return nil
  44979. case usagelog.FieldCacheCreation5mTokens:
  44980. v, ok := value.(int)
  44981. if !ok {
  44982. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44983. }
  44984. m.AddCacheCreation5mTokens(v)
  44985. return nil
  44986. case usagelog.FieldCacheCreation1hTokens:
  44987. v, ok := value.(int)
  44988. if !ok {
  44989. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44990. }
  44991. m.AddCacheCreation1hTokens(v)
  44992. return nil
  44993. case usagelog.FieldInputCost:
  44994. v, ok := value.(float64)
  44995. if !ok {
  44996. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44997. }
  44998. m.AddInputCost(v)
  44999. return nil
  45000. case usagelog.FieldOutputCost:
  45001. v, ok := value.(float64)
  45002. if !ok {
  45003. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45004. }
  45005. m.AddOutputCost(v)
  45006. return nil
  45007. case usagelog.FieldCacheCreationCost:
  45008. v, ok := value.(float64)
  45009. if !ok {
  45010. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45011. }
  45012. m.AddCacheCreationCost(v)
  45013. return nil
  45014. case usagelog.FieldCacheReadCost:
  45015. v, ok := value.(float64)
  45016. if !ok {
  45017. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45018. }
  45019. m.AddCacheReadCost(v)
  45020. return nil
  45021. case usagelog.FieldTotalCost:
  45022. v, ok := value.(float64)
  45023. if !ok {
  45024. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45025. }
  45026. m.AddTotalCost(v)
  45027. return nil
  45028. case usagelog.FieldActualCost:
  45029. v, ok := value.(float64)
  45030. if !ok {
  45031. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45032. }
  45033. m.AddActualCost(v)
  45034. return nil
  45035. case usagelog.FieldRateMultiplier:
  45036. v, ok := value.(float64)
  45037. if !ok {
  45038. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45039. }
  45040. m.AddRateMultiplier(v)
  45041. return nil
  45042. case usagelog.FieldAccountRateMultiplier:
  45043. v, ok := value.(float64)
  45044. if !ok {
  45045. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45046. }
  45047. m.AddAccountRateMultiplier(v)
  45048. return nil
  45049. case usagelog.FieldBillingType:
  45050. v, ok := value.(int8)
  45051. if !ok {
  45052. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45053. }
  45054. m.AddBillingType(v)
  45055. return nil
  45056. case usagelog.FieldDurationMs:
  45057. v, ok := value.(int)
  45058. if !ok {
  45059. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45060. }
  45061. m.AddDurationMs(v)
  45062. return nil
  45063. case usagelog.FieldFirstTokenMs:
  45064. v, ok := value.(int)
  45065. if !ok {
  45066. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45067. }
  45068. m.AddFirstTokenMs(v)
  45069. return nil
  45070. case usagelog.FieldImageCount:
  45071. v, ok := value.(int)
  45072. if !ok {
  45073. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45074. }
  45075. m.AddImageCount(v)
  45076. return nil
  45077. case usagelog.FieldVideoCount:
  45078. v, ok := value.(int)
  45079. if !ok {
  45080. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45081. }
  45082. m.AddVideoCount(v)
  45083. return nil
  45084. case usagelog.FieldVideoDurationSeconds:
  45085. v, ok := value.(int)
  45086. if !ok {
  45087. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45088. }
  45089. m.AddVideoDurationSeconds(v)
  45090. return nil
  45091. }
  45092. return fmt.Errorf("unknown UsageLog numeric field %s", name)
  45093. }
  45094. // ClearedFields returns all nullable fields that were cleared during this
  45095. // mutation.
  45096. func (m *UsageLogMutation) ClearedFields() []string {
  45097. var fields []string
  45098. if m.FieldCleared(usagelog.FieldRequestedModel) {
  45099. fields = append(fields, usagelog.FieldRequestedModel)
  45100. }
  45101. if m.FieldCleared(usagelog.FieldUpstreamModel) {
  45102. fields = append(fields, usagelog.FieldUpstreamModel)
  45103. }
  45104. if m.FieldCleared(usagelog.FieldUpstreamResponseModel) {
  45105. fields = append(fields, usagelog.FieldUpstreamResponseModel)
  45106. }
  45107. if m.FieldCleared(usagelog.FieldUpstreamModelMismatch) {
  45108. fields = append(fields, usagelog.FieldUpstreamModelMismatch)
  45109. }
  45110. if m.FieldCleared(usagelog.FieldChannelID) {
  45111. fields = append(fields, usagelog.FieldChannelID)
  45112. }
  45113. if m.FieldCleared(usagelog.FieldModelMappingChain) {
  45114. fields = append(fields, usagelog.FieldModelMappingChain)
  45115. }
  45116. if m.FieldCleared(usagelog.FieldBillingTier) {
  45117. fields = append(fields, usagelog.FieldBillingTier)
  45118. }
  45119. if m.FieldCleared(usagelog.FieldBillingMode) {
  45120. fields = append(fields, usagelog.FieldBillingMode)
  45121. }
  45122. if m.FieldCleared(usagelog.FieldGroupID) {
  45123. fields = append(fields, usagelog.FieldGroupID)
  45124. }
  45125. if m.FieldCleared(usagelog.FieldSubscriptionID) {
  45126. fields = append(fields, usagelog.FieldSubscriptionID)
  45127. }
  45128. if m.FieldCleared(usagelog.FieldAccountRateMultiplier) {
  45129. fields = append(fields, usagelog.FieldAccountRateMultiplier)
  45130. }
  45131. if m.FieldCleared(usagelog.FieldDurationMs) {
  45132. fields = append(fields, usagelog.FieldDurationMs)
  45133. }
  45134. if m.FieldCleared(usagelog.FieldFirstTokenMs) {
  45135. fields = append(fields, usagelog.FieldFirstTokenMs)
  45136. }
  45137. if m.FieldCleared(usagelog.FieldUserAgent) {
  45138. fields = append(fields, usagelog.FieldUserAgent)
  45139. }
  45140. if m.FieldCleared(usagelog.FieldIPAddress) {
  45141. fields = append(fields, usagelog.FieldIPAddress)
  45142. }
  45143. if m.FieldCleared(usagelog.FieldImageSize) {
  45144. fields = append(fields, usagelog.FieldImageSize)
  45145. }
  45146. if m.FieldCleared(usagelog.FieldImageInputSize) {
  45147. fields = append(fields, usagelog.FieldImageInputSize)
  45148. }
  45149. if m.FieldCleared(usagelog.FieldImageOutputSize) {
  45150. fields = append(fields, usagelog.FieldImageOutputSize)
  45151. }
  45152. if m.FieldCleared(usagelog.FieldImageSizeSource) {
  45153. fields = append(fields, usagelog.FieldImageSizeSource)
  45154. }
  45155. if m.FieldCleared(usagelog.FieldImageSizeBreakdown) {
  45156. fields = append(fields, usagelog.FieldImageSizeBreakdown)
  45157. }
  45158. if m.FieldCleared(usagelog.FieldVideoResolution) {
  45159. fields = append(fields, usagelog.FieldVideoResolution)
  45160. }
  45161. if m.FieldCleared(usagelog.FieldVideoDurationSeconds) {
  45162. fields = append(fields, usagelog.FieldVideoDurationSeconds)
  45163. }
  45164. return fields
  45165. }
  45166. // FieldCleared returns a boolean indicating if a field with the given name was
  45167. // cleared in this mutation.
  45168. func (m *UsageLogMutation) FieldCleared(name string) bool {
  45169. _, ok := m.clearedFields[name]
  45170. return ok
  45171. }
  45172. // ClearField clears the value of the field with the given name. It returns an
  45173. // error if the field is not defined in the schema.
  45174. func (m *UsageLogMutation) ClearField(name string) error {
  45175. switch name {
  45176. case usagelog.FieldRequestedModel:
  45177. m.ClearRequestedModel()
  45178. return nil
  45179. case usagelog.FieldUpstreamModel:
  45180. m.ClearUpstreamModel()
  45181. return nil
  45182. case usagelog.FieldUpstreamResponseModel:
  45183. m.ClearUpstreamResponseModel()
  45184. return nil
  45185. case usagelog.FieldUpstreamModelMismatch:
  45186. m.ClearUpstreamModelMismatch()
  45187. return nil
  45188. case usagelog.FieldChannelID:
  45189. m.ClearChannelID()
  45190. return nil
  45191. case usagelog.FieldModelMappingChain:
  45192. m.ClearModelMappingChain()
  45193. return nil
  45194. case usagelog.FieldBillingTier:
  45195. m.ClearBillingTier()
  45196. return nil
  45197. case usagelog.FieldBillingMode:
  45198. m.ClearBillingMode()
  45199. return nil
  45200. case usagelog.FieldGroupID:
  45201. m.ClearGroupID()
  45202. return nil
  45203. case usagelog.FieldSubscriptionID:
  45204. m.ClearSubscriptionID()
  45205. return nil
  45206. case usagelog.FieldAccountRateMultiplier:
  45207. m.ClearAccountRateMultiplier()
  45208. return nil
  45209. case usagelog.FieldDurationMs:
  45210. m.ClearDurationMs()
  45211. return nil
  45212. case usagelog.FieldFirstTokenMs:
  45213. m.ClearFirstTokenMs()
  45214. return nil
  45215. case usagelog.FieldUserAgent:
  45216. m.ClearUserAgent()
  45217. return nil
  45218. case usagelog.FieldIPAddress:
  45219. m.ClearIPAddress()
  45220. return nil
  45221. case usagelog.FieldImageSize:
  45222. m.ClearImageSize()
  45223. return nil
  45224. case usagelog.FieldImageInputSize:
  45225. m.ClearImageInputSize()
  45226. return nil
  45227. case usagelog.FieldImageOutputSize:
  45228. m.ClearImageOutputSize()
  45229. return nil
  45230. case usagelog.FieldImageSizeSource:
  45231. m.ClearImageSizeSource()
  45232. return nil
  45233. case usagelog.FieldImageSizeBreakdown:
  45234. m.ClearImageSizeBreakdown()
  45235. return nil
  45236. case usagelog.FieldVideoResolution:
  45237. m.ClearVideoResolution()
  45238. return nil
  45239. case usagelog.FieldVideoDurationSeconds:
  45240. m.ClearVideoDurationSeconds()
  45241. return nil
  45242. }
  45243. return fmt.Errorf("unknown UsageLog nullable field %s", name)
  45244. }
  45245. // ResetField resets all changes in the mutation for the field with the given name.
  45246. // It returns an error if the field is not defined in the schema.
  45247. func (m *UsageLogMutation) ResetField(name string) error {
  45248. switch name {
  45249. case usagelog.FieldUserID:
  45250. m.ResetUserID()
  45251. return nil
  45252. case usagelog.FieldAPIKeyID:
  45253. m.ResetAPIKeyID()
  45254. return nil
  45255. case usagelog.FieldAccountID:
  45256. m.ResetAccountID()
  45257. return nil
  45258. case usagelog.FieldRequestID:
  45259. m.ResetRequestID()
  45260. return nil
  45261. case usagelog.FieldModel:
  45262. m.ResetModel()
  45263. return nil
  45264. case usagelog.FieldRequestedModel:
  45265. m.ResetRequestedModel()
  45266. return nil
  45267. case usagelog.FieldUpstreamModel:
  45268. m.ResetUpstreamModel()
  45269. return nil
  45270. case usagelog.FieldUpstreamResponseModel:
  45271. m.ResetUpstreamResponseModel()
  45272. return nil
  45273. case usagelog.FieldUpstreamModelMismatch:
  45274. m.ResetUpstreamModelMismatch()
  45275. return nil
  45276. case usagelog.FieldChannelID:
  45277. m.ResetChannelID()
  45278. return nil
  45279. case usagelog.FieldModelMappingChain:
  45280. m.ResetModelMappingChain()
  45281. return nil
  45282. case usagelog.FieldBillingTier:
  45283. m.ResetBillingTier()
  45284. return nil
  45285. case usagelog.FieldBillingMode:
  45286. m.ResetBillingMode()
  45287. return nil
  45288. case usagelog.FieldGroupID:
  45289. m.ResetGroupID()
  45290. return nil
  45291. case usagelog.FieldSubscriptionID:
  45292. m.ResetSubscriptionID()
  45293. return nil
  45294. case usagelog.FieldInputTokens:
  45295. m.ResetInputTokens()
  45296. return nil
  45297. case usagelog.FieldOutputTokens:
  45298. m.ResetOutputTokens()
  45299. return nil
  45300. case usagelog.FieldCacheCreationTokens:
  45301. m.ResetCacheCreationTokens()
  45302. return nil
  45303. case usagelog.FieldCacheReadTokens:
  45304. m.ResetCacheReadTokens()
  45305. return nil
  45306. case usagelog.FieldCacheCreation5mTokens:
  45307. m.ResetCacheCreation5mTokens()
  45308. return nil
  45309. case usagelog.FieldCacheCreation1hTokens:
  45310. m.ResetCacheCreation1hTokens()
  45311. return nil
  45312. case usagelog.FieldInputCost:
  45313. m.ResetInputCost()
  45314. return nil
  45315. case usagelog.FieldOutputCost:
  45316. m.ResetOutputCost()
  45317. return nil
  45318. case usagelog.FieldCacheCreationCost:
  45319. m.ResetCacheCreationCost()
  45320. return nil
  45321. case usagelog.FieldCacheReadCost:
  45322. m.ResetCacheReadCost()
  45323. return nil
  45324. case usagelog.FieldTotalCost:
  45325. m.ResetTotalCost()
  45326. return nil
  45327. case usagelog.FieldActualCost:
  45328. m.ResetActualCost()
  45329. return nil
  45330. case usagelog.FieldRateMultiplier:
  45331. m.ResetRateMultiplier()
  45332. return nil
  45333. case usagelog.FieldLongContextBillingApplied:
  45334. m.ResetLongContextBillingApplied()
  45335. return nil
  45336. case usagelog.FieldAccountRateMultiplier:
  45337. m.ResetAccountRateMultiplier()
  45338. return nil
  45339. case usagelog.FieldBillingType:
  45340. m.ResetBillingType()
  45341. return nil
  45342. case usagelog.FieldStream:
  45343. m.ResetStream()
  45344. return nil
  45345. case usagelog.FieldDurationMs:
  45346. m.ResetDurationMs()
  45347. return nil
  45348. case usagelog.FieldFirstTokenMs:
  45349. m.ResetFirstTokenMs()
  45350. return nil
  45351. case usagelog.FieldUserAgent:
  45352. m.ResetUserAgent()
  45353. return nil
  45354. case usagelog.FieldIPAddress:
  45355. m.ResetIPAddress()
  45356. return nil
  45357. case usagelog.FieldImageCount:
  45358. m.ResetImageCount()
  45359. return nil
  45360. case usagelog.FieldImageSize:
  45361. m.ResetImageSize()
  45362. return nil
  45363. case usagelog.FieldImageInputSize:
  45364. m.ResetImageInputSize()
  45365. return nil
  45366. case usagelog.FieldImageOutputSize:
  45367. m.ResetImageOutputSize()
  45368. return nil
  45369. case usagelog.FieldImageSizeSource:
  45370. m.ResetImageSizeSource()
  45371. return nil
  45372. case usagelog.FieldImageSizeBreakdown:
  45373. m.ResetImageSizeBreakdown()
  45374. return nil
  45375. case usagelog.FieldVideoCount:
  45376. m.ResetVideoCount()
  45377. return nil
  45378. case usagelog.FieldVideoResolution:
  45379. m.ResetVideoResolution()
  45380. return nil
  45381. case usagelog.FieldVideoDurationSeconds:
  45382. m.ResetVideoDurationSeconds()
  45383. return nil
  45384. case usagelog.FieldCacheTTLOverridden:
  45385. m.ResetCacheTTLOverridden()
  45386. return nil
  45387. case usagelog.FieldCreatedAt:
  45388. m.ResetCreatedAt()
  45389. return nil
  45390. }
  45391. return fmt.Errorf("unknown UsageLog field %s", name)
  45392. }
  45393. // AddedEdges returns all edge names that were set/added in this mutation.
  45394. func (m *UsageLogMutation) AddedEdges() []string {
  45395. edges := make([]string, 0, 5)
  45396. if m.user != nil {
  45397. edges = append(edges, usagelog.EdgeUser)
  45398. }
  45399. if m.api_key != nil {
  45400. edges = append(edges, usagelog.EdgeAPIKey)
  45401. }
  45402. if m.account != nil {
  45403. edges = append(edges, usagelog.EdgeAccount)
  45404. }
  45405. if m.group != nil {
  45406. edges = append(edges, usagelog.EdgeGroup)
  45407. }
  45408. if m.subscription != nil {
  45409. edges = append(edges, usagelog.EdgeSubscription)
  45410. }
  45411. return edges
  45412. }
  45413. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  45414. // name in this mutation.
  45415. func (m *UsageLogMutation) AddedIDs(name string) []ent.Value {
  45416. switch name {
  45417. case usagelog.EdgeUser:
  45418. if id := m.user; id != nil {
  45419. return []ent.Value{*id}
  45420. }
  45421. case usagelog.EdgeAPIKey:
  45422. if id := m.api_key; id != nil {
  45423. return []ent.Value{*id}
  45424. }
  45425. case usagelog.EdgeAccount:
  45426. if id := m.account; id != nil {
  45427. return []ent.Value{*id}
  45428. }
  45429. case usagelog.EdgeGroup:
  45430. if id := m.group; id != nil {
  45431. return []ent.Value{*id}
  45432. }
  45433. case usagelog.EdgeSubscription:
  45434. if id := m.subscription; id != nil {
  45435. return []ent.Value{*id}
  45436. }
  45437. }
  45438. return nil
  45439. }
  45440. // RemovedEdges returns all edge names that were removed in this mutation.
  45441. func (m *UsageLogMutation) RemovedEdges() []string {
  45442. edges := make([]string, 0, 5)
  45443. return edges
  45444. }
  45445. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  45446. // the given name in this mutation.
  45447. func (m *UsageLogMutation) RemovedIDs(name string) []ent.Value {
  45448. return nil
  45449. }
  45450. // ClearedEdges returns all edge names that were cleared in this mutation.
  45451. func (m *UsageLogMutation) ClearedEdges() []string {
  45452. edges := make([]string, 0, 5)
  45453. if m.cleareduser {
  45454. edges = append(edges, usagelog.EdgeUser)
  45455. }
  45456. if m.clearedapi_key {
  45457. edges = append(edges, usagelog.EdgeAPIKey)
  45458. }
  45459. if m.clearedaccount {
  45460. edges = append(edges, usagelog.EdgeAccount)
  45461. }
  45462. if m.clearedgroup {
  45463. edges = append(edges, usagelog.EdgeGroup)
  45464. }
  45465. if m.clearedsubscription {
  45466. edges = append(edges, usagelog.EdgeSubscription)
  45467. }
  45468. return edges
  45469. }
  45470. // EdgeCleared returns a boolean which indicates if the edge with the given name
  45471. // was cleared in this mutation.
  45472. func (m *UsageLogMutation) EdgeCleared(name string) bool {
  45473. switch name {
  45474. case usagelog.EdgeUser:
  45475. return m.cleareduser
  45476. case usagelog.EdgeAPIKey:
  45477. return m.clearedapi_key
  45478. case usagelog.EdgeAccount:
  45479. return m.clearedaccount
  45480. case usagelog.EdgeGroup:
  45481. return m.clearedgroup
  45482. case usagelog.EdgeSubscription:
  45483. return m.clearedsubscription
  45484. }
  45485. return false
  45486. }
  45487. // ClearEdge clears the value of the edge with the given name. It returns an error
  45488. // if that edge is not defined in the schema.
  45489. func (m *UsageLogMutation) ClearEdge(name string) error {
  45490. switch name {
  45491. case usagelog.EdgeUser:
  45492. m.ClearUser()
  45493. return nil
  45494. case usagelog.EdgeAPIKey:
  45495. m.ClearAPIKey()
  45496. return nil
  45497. case usagelog.EdgeAccount:
  45498. m.ClearAccount()
  45499. return nil
  45500. case usagelog.EdgeGroup:
  45501. m.ClearGroup()
  45502. return nil
  45503. case usagelog.EdgeSubscription:
  45504. m.ClearSubscription()
  45505. return nil
  45506. }
  45507. return fmt.Errorf("unknown UsageLog unique edge %s", name)
  45508. }
  45509. // ResetEdge resets all changes to the edge with the given name in this mutation.
  45510. // It returns an error if the edge is not defined in the schema.
  45511. func (m *UsageLogMutation) ResetEdge(name string) error {
  45512. switch name {
  45513. case usagelog.EdgeUser:
  45514. m.ResetUser()
  45515. return nil
  45516. case usagelog.EdgeAPIKey:
  45517. m.ResetAPIKey()
  45518. return nil
  45519. case usagelog.EdgeAccount:
  45520. m.ResetAccount()
  45521. return nil
  45522. case usagelog.EdgeGroup:
  45523. m.ResetGroup()
  45524. return nil
  45525. case usagelog.EdgeSubscription:
  45526. m.ResetSubscription()
  45527. return nil
  45528. }
  45529. return fmt.Errorf("unknown UsageLog edge %s", name)
  45530. }
  45531. // UserMutation represents an operation that mutates the User nodes in the graph.
  45532. type UserMutation struct {
  45533. config
  45534. op Op
  45535. typ string
  45536. id *int64
  45537. created_at *time.Time
  45538. updated_at *time.Time
  45539. deleted_at *time.Time
  45540. email *string
  45541. password_hash *string
  45542. role *string
  45543. balance *float64
  45544. addbalance *float64
  45545. frozen_balance *float64
  45546. addfrozen_balance *float64
  45547. concurrency *int
  45548. addconcurrency *int
  45549. status *string
  45550. username *string
  45551. notes *string
  45552. totp_secret_encrypted *string
  45553. totp_enabled *bool
  45554. totp_enabled_at *time.Time
  45555. signup_source *string
  45556. last_login_at *time.Time
  45557. last_active_at *time.Time
  45558. restrict_public_groups *bool
  45559. balance_notify_enabled *bool
  45560. balance_notify_threshold_type *string
  45561. balance_notify_threshold *float64
  45562. addbalance_notify_threshold *float64
  45563. balance_notify_extra_emails *string
  45564. total_recharged *float64
  45565. addtotal_recharged *float64
  45566. rpm_limit *int
  45567. addrpm_limit *int
  45568. clearedFields map[string]struct{}
  45569. api_keys map[int64]struct{}
  45570. removedapi_keys map[int64]struct{}
  45571. clearedapi_keys bool
  45572. redeem_codes map[int64]struct{}
  45573. removedredeem_codes map[int64]struct{}
  45574. clearedredeem_codes bool
  45575. subscriptions map[int64]struct{}
  45576. removedsubscriptions map[int64]struct{}
  45577. clearedsubscriptions bool
  45578. assigned_subscriptions map[int64]struct{}
  45579. removedassigned_subscriptions map[int64]struct{}
  45580. clearedassigned_subscriptions bool
  45581. announcement_reads map[int64]struct{}
  45582. removedannouncement_reads map[int64]struct{}
  45583. clearedannouncement_reads bool
  45584. allowed_groups map[int64]struct{}
  45585. removedallowed_groups map[int64]struct{}
  45586. clearedallowed_groups bool
  45587. usage_logs map[int64]struct{}
  45588. removedusage_logs map[int64]struct{}
  45589. clearedusage_logs bool
  45590. attribute_values map[int64]struct{}
  45591. removedattribute_values map[int64]struct{}
  45592. clearedattribute_values bool
  45593. promo_code_usages map[int64]struct{}
  45594. removedpromo_code_usages map[int64]struct{}
  45595. clearedpromo_code_usages bool
  45596. payment_orders map[int64]struct{}
  45597. removedpayment_orders map[int64]struct{}
  45598. clearedpayment_orders bool
  45599. auth_identities map[int64]struct{}
  45600. removedauth_identities map[int64]struct{}
  45601. clearedauth_identities bool
  45602. pending_auth_sessions map[int64]struct{}
  45603. removedpending_auth_sessions map[int64]struct{}
  45604. clearedpending_auth_sessions bool
  45605. platform_quotas map[int64]struct{}
  45606. removedplatform_quotas map[int64]struct{}
  45607. clearedplatform_quotas bool
  45608. done bool
  45609. oldValue func(context.Context) (*User, error)
  45610. predicates []predicate.User
  45611. }
  45612. var _ ent.Mutation = (*UserMutation)(nil)
  45613. // userOption allows management of the mutation configuration using functional options.
  45614. type userOption func(*UserMutation)
  45615. // newUserMutation creates new mutation for the User entity.
  45616. func newUserMutation(c config, op Op, opts ...userOption) *UserMutation {
  45617. m := &UserMutation{
  45618. config: c,
  45619. op: op,
  45620. typ: TypeUser,
  45621. clearedFields: make(map[string]struct{}),
  45622. }
  45623. for _, opt := range opts {
  45624. opt(m)
  45625. }
  45626. return m
  45627. }
  45628. // withUserID sets the ID field of the mutation.
  45629. func withUserID(id int64) userOption {
  45630. return func(m *UserMutation) {
  45631. var (
  45632. err error
  45633. once sync.Once
  45634. value *User
  45635. )
  45636. m.oldValue = func(ctx context.Context) (*User, error) {
  45637. once.Do(func() {
  45638. if m.done {
  45639. err = errors.New("querying old values post mutation is not allowed")
  45640. } else {
  45641. value, err = m.Client().User.Get(ctx, id)
  45642. }
  45643. })
  45644. return value, err
  45645. }
  45646. m.id = &id
  45647. }
  45648. }
  45649. // withUser sets the old User of the mutation.
  45650. func withUser(node *User) userOption {
  45651. return func(m *UserMutation) {
  45652. m.oldValue = func(context.Context) (*User, error) {
  45653. return node, nil
  45654. }
  45655. m.id = &node.ID
  45656. }
  45657. }
  45658. // Client returns a new `ent.Client` from the mutation. If the mutation was
  45659. // executed in a transaction (ent.Tx), a transactional client is returned.
  45660. func (m UserMutation) Client() *Client {
  45661. client := &Client{config: m.config}
  45662. client.init()
  45663. return client
  45664. }
  45665. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  45666. // it returns an error otherwise.
  45667. func (m UserMutation) Tx() (*Tx, error) {
  45668. if _, ok := m.driver.(*txDriver); !ok {
  45669. return nil, errors.New("ent: mutation is not running in a transaction")
  45670. }
  45671. tx := &Tx{config: m.config}
  45672. tx.init()
  45673. return tx, nil
  45674. }
  45675. // ID returns the ID value in the mutation. Note that the ID is only available
  45676. // if it was provided to the builder or after it was returned from the database.
  45677. func (m *UserMutation) ID() (id int64, exists bool) {
  45678. if m.id == nil {
  45679. return
  45680. }
  45681. return *m.id, true
  45682. }
  45683. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  45684. // That means, if the mutation is applied within a transaction with an isolation level such
  45685. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  45686. // or updated by the mutation.
  45687. func (m *UserMutation) IDs(ctx context.Context) ([]int64, error) {
  45688. switch {
  45689. case m.op.Is(OpUpdateOne | OpDeleteOne):
  45690. id, exists := m.ID()
  45691. if exists {
  45692. return []int64{id}, nil
  45693. }
  45694. fallthrough
  45695. case m.op.Is(OpUpdate | OpDelete):
  45696. return m.Client().User.Query().Where(m.predicates...).IDs(ctx)
  45697. default:
  45698. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  45699. }
  45700. }
  45701. // SetCreatedAt sets the "created_at" field.
  45702. func (m *UserMutation) SetCreatedAt(t time.Time) {
  45703. m.created_at = &t
  45704. }
  45705. // CreatedAt returns the value of the "created_at" field in the mutation.
  45706. func (m *UserMutation) CreatedAt() (r time.Time, exists bool) {
  45707. v := m.created_at
  45708. if v == nil {
  45709. return
  45710. }
  45711. return *v, true
  45712. }
  45713. // OldCreatedAt returns the old "created_at" field's value of the User entity.
  45714. // If the User object wasn't provided to the builder, the object is fetched from the database.
  45715. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45716. func (m *UserMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  45717. if !m.op.Is(OpUpdateOne) {
  45718. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  45719. }
  45720. if m.id == nil || m.oldValue == nil {
  45721. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  45722. }
  45723. oldValue, err := m.oldValue(ctx)
  45724. if err != nil {
  45725. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  45726. }
  45727. return oldValue.CreatedAt, nil
  45728. }
  45729. // ResetCreatedAt resets all changes to the "created_at" field.
  45730. func (m *UserMutation) ResetCreatedAt() {
  45731. m.created_at = nil
  45732. }
  45733. // SetUpdatedAt sets the "updated_at" field.
  45734. func (m *UserMutation) SetUpdatedAt(t time.Time) {
  45735. m.updated_at = &t
  45736. }
  45737. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  45738. func (m *UserMutation) UpdatedAt() (r time.Time, exists bool) {
  45739. v := m.updated_at
  45740. if v == nil {
  45741. return
  45742. }
  45743. return *v, true
  45744. }
  45745. // OldUpdatedAt returns the old "updated_at" field's value of the User entity.
  45746. // If the User object wasn't provided to the builder, the object is fetched from the database.
  45747. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45748. func (m *UserMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  45749. if !m.op.Is(OpUpdateOne) {
  45750. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  45751. }
  45752. if m.id == nil || m.oldValue == nil {
  45753. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  45754. }
  45755. oldValue, err := m.oldValue(ctx)
  45756. if err != nil {
  45757. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  45758. }
  45759. return oldValue.UpdatedAt, nil
  45760. }
  45761. // ResetUpdatedAt resets all changes to the "updated_at" field.
  45762. func (m *UserMutation) ResetUpdatedAt() {
  45763. m.updated_at = nil
  45764. }
  45765. // SetDeletedAt sets the "deleted_at" field.
  45766. func (m *UserMutation) SetDeletedAt(t time.Time) {
  45767. m.deleted_at = &t
  45768. }
  45769. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  45770. func (m *UserMutation) DeletedAt() (r time.Time, exists bool) {
  45771. v := m.deleted_at
  45772. if v == nil {
  45773. return
  45774. }
  45775. return *v, true
  45776. }
  45777. // OldDeletedAt returns the old "deleted_at" field's value of the User entity.
  45778. // If the User object wasn't provided to the builder, the object is fetched from the database.
  45779. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45780. func (m *UserMutation) OldDeletedAt(ctx context.Context) (v *time.Time, err error) {
  45781. if !m.op.Is(OpUpdateOne) {
  45782. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  45783. }
  45784. if m.id == nil || m.oldValue == nil {
  45785. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  45786. }
  45787. oldValue, err := m.oldValue(ctx)
  45788. if err != nil {
  45789. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  45790. }
  45791. return oldValue.DeletedAt, nil
  45792. }
  45793. // ClearDeletedAt clears the value of the "deleted_at" field.
  45794. func (m *UserMutation) ClearDeletedAt() {
  45795. m.deleted_at = nil
  45796. m.clearedFields[user.FieldDeletedAt] = struct{}{}
  45797. }
  45798. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  45799. func (m *UserMutation) DeletedAtCleared() bool {
  45800. _, ok := m.clearedFields[user.FieldDeletedAt]
  45801. return ok
  45802. }
  45803. // ResetDeletedAt resets all changes to the "deleted_at" field.
  45804. func (m *UserMutation) ResetDeletedAt() {
  45805. m.deleted_at = nil
  45806. delete(m.clearedFields, user.FieldDeletedAt)
  45807. }
  45808. // SetEmail sets the "email" field.
  45809. func (m *UserMutation) SetEmail(s string) {
  45810. m.email = &s
  45811. }
  45812. // Email returns the value of the "email" field in the mutation.
  45813. func (m *UserMutation) Email() (r string, exists bool) {
  45814. v := m.email
  45815. if v == nil {
  45816. return
  45817. }
  45818. return *v, true
  45819. }
  45820. // OldEmail returns the old "email" field's value of the User entity.
  45821. // If the User object wasn't provided to the builder, the object is fetched from the database.
  45822. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45823. func (m *UserMutation) OldEmail(ctx context.Context) (v string, err error) {
  45824. if !m.op.Is(OpUpdateOne) {
  45825. return v, errors.New("OldEmail is only allowed on UpdateOne operations")
  45826. }
  45827. if m.id == nil || m.oldValue == nil {
  45828. return v, errors.New("OldEmail requires an ID field in the mutation")
  45829. }
  45830. oldValue, err := m.oldValue(ctx)
  45831. if err != nil {
  45832. return v, fmt.Errorf("querying old value for OldEmail: %w", err)
  45833. }
  45834. return oldValue.Email, nil
  45835. }
  45836. // ResetEmail resets all changes to the "email" field.
  45837. func (m *UserMutation) ResetEmail() {
  45838. m.email = nil
  45839. }
  45840. // SetPasswordHash sets the "password_hash" field.
  45841. func (m *UserMutation) SetPasswordHash(s string) {
  45842. m.password_hash = &s
  45843. }
  45844. // PasswordHash returns the value of the "password_hash" field in the mutation.
  45845. func (m *UserMutation) PasswordHash() (r string, exists bool) {
  45846. v := m.password_hash
  45847. if v == nil {
  45848. return
  45849. }
  45850. return *v, true
  45851. }
  45852. // OldPasswordHash returns the old "password_hash" field's value of the User entity.
  45853. // If the User object wasn't provided to the builder, the object is fetched from the database.
  45854. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45855. func (m *UserMutation) OldPasswordHash(ctx context.Context) (v string, err error) {
  45856. if !m.op.Is(OpUpdateOne) {
  45857. return v, errors.New("OldPasswordHash is only allowed on UpdateOne operations")
  45858. }
  45859. if m.id == nil || m.oldValue == nil {
  45860. return v, errors.New("OldPasswordHash requires an ID field in the mutation")
  45861. }
  45862. oldValue, err := m.oldValue(ctx)
  45863. if err != nil {
  45864. return v, fmt.Errorf("querying old value for OldPasswordHash: %w", err)
  45865. }
  45866. return oldValue.PasswordHash, nil
  45867. }
  45868. // ResetPasswordHash resets all changes to the "password_hash" field.
  45869. func (m *UserMutation) ResetPasswordHash() {
  45870. m.password_hash = nil
  45871. }
  45872. // SetRole sets the "role" field.
  45873. func (m *UserMutation) SetRole(s string) {
  45874. m.role = &s
  45875. }
  45876. // Role returns the value of the "role" field in the mutation.
  45877. func (m *UserMutation) Role() (r string, exists bool) {
  45878. v := m.role
  45879. if v == nil {
  45880. return
  45881. }
  45882. return *v, true
  45883. }
  45884. // OldRole returns the old "role" field's value of the User entity.
  45885. // If the User object wasn't provided to the builder, the object is fetched from the database.
  45886. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45887. func (m *UserMutation) OldRole(ctx context.Context) (v string, err error) {
  45888. if !m.op.Is(OpUpdateOne) {
  45889. return v, errors.New("OldRole is only allowed on UpdateOne operations")
  45890. }
  45891. if m.id == nil || m.oldValue == nil {
  45892. return v, errors.New("OldRole requires an ID field in the mutation")
  45893. }
  45894. oldValue, err := m.oldValue(ctx)
  45895. if err != nil {
  45896. return v, fmt.Errorf("querying old value for OldRole: %w", err)
  45897. }
  45898. return oldValue.Role, nil
  45899. }
  45900. // ResetRole resets all changes to the "role" field.
  45901. func (m *UserMutation) ResetRole() {
  45902. m.role = nil
  45903. }
  45904. // SetBalance sets the "balance" field.
  45905. func (m *UserMutation) SetBalance(f float64) {
  45906. m.balance = &f
  45907. m.addbalance = nil
  45908. }
  45909. // Balance returns the value of the "balance" field in the mutation.
  45910. func (m *UserMutation) Balance() (r float64, exists bool) {
  45911. v := m.balance
  45912. if v == nil {
  45913. return
  45914. }
  45915. return *v, true
  45916. }
  45917. // OldBalance returns the old "balance" field's value of the User entity.
  45918. // If the User object wasn't provided to the builder, the object is fetched from the database.
  45919. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45920. func (m *UserMutation) OldBalance(ctx context.Context) (v float64, err error) {
  45921. if !m.op.Is(OpUpdateOne) {
  45922. return v, errors.New("OldBalance is only allowed on UpdateOne operations")
  45923. }
  45924. if m.id == nil || m.oldValue == nil {
  45925. return v, errors.New("OldBalance requires an ID field in the mutation")
  45926. }
  45927. oldValue, err := m.oldValue(ctx)
  45928. if err != nil {
  45929. return v, fmt.Errorf("querying old value for OldBalance: %w", err)
  45930. }
  45931. return oldValue.Balance, nil
  45932. }
  45933. // AddBalance adds f to the "balance" field.
  45934. func (m *UserMutation) AddBalance(f float64) {
  45935. if m.addbalance != nil {
  45936. *m.addbalance += f
  45937. } else {
  45938. m.addbalance = &f
  45939. }
  45940. }
  45941. // AddedBalance returns the value that was added to the "balance" field in this mutation.
  45942. func (m *UserMutation) AddedBalance() (r float64, exists bool) {
  45943. v := m.addbalance
  45944. if v == nil {
  45945. return
  45946. }
  45947. return *v, true
  45948. }
  45949. // ResetBalance resets all changes to the "balance" field.
  45950. func (m *UserMutation) ResetBalance() {
  45951. m.balance = nil
  45952. m.addbalance = nil
  45953. }
  45954. // SetFrozenBalance sets the "frozen_balance" field.
  45955. func (m *UserMutation) SetFrozenBalance(f float64) {
  45956. m.frozen_balance = &f
  45957. m.addfrozen_balance = nil
  45958. }
  45959. // FrozenBalance returns the value of the "frozen_balance" field in the mutation.
  45960. func (m *UserMutation) FrozenBalance() (r float64, exists bool) {
  45961. v := m.frozen_balance
  45962. if v == nil {
  45963. return
  45964. }
  45965. return *v, true
  45966. }
  45967. // OldFrozenBalance returns the old "frozen_balance" field's value of the User entity.
  45968. // If the User object wasn't provided to the builder, the object is fetched from the database.
  45969. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45970. func (m *UserMutation) OldFrozenBalance(ctx context.Context) (v float64, err error) {
  45971. if !m.op.Is(OpUpdateOne) {
  45972. return v, errors.New("OldFrozenBalance is only allowed on UpdateOne operations")
  45973. }
  45974. if m.id == nil || m.oldValue == nil {
  45975. return v, errors.New("OldFrozenBalance requires an ID field in the mutation")
  45976. }
  45977. oldValue, err := m.oldValue(ctx)
  45978. if err != nil {
  45979. return v, fmt.Errorf("querying old value for OldFrozenBalance: %w", err)
  45980. }
  45981. return oldValue.FrozenBalance, nil
  45982. }
  45983. // AddFrozenBalance adds f to the "frozen_balance" field.
  45984. func (m *UserMutation) AddFrozenBalance(f float64) {
  45985. if m.addfrozen_balance != nil {
  45986. *m.addfrozen_balance += f
  45987. } else {
  45988. m.addfrozen_balance = &f
  45989. }
  45990. }
  45991. // AddedFrozenBalance returns the value that was added to the "frozen_balance" field in this mutation.
  45992. func (m *UserMutation) AddedFrozenBalance() (r float64, exists bool) {
  45993. v := m.addfrozen_balance
  45994. if v == nil {
  45995. return
  45996. }
  45997. return *v, true
  45998. }
  45999. // ResetFrozenBalance resets all changes to the "frozen_balance" field.
  46000. func (m *UserMutation) ResetFrozenBalance() {
  46001. m.frozen_balance = nil
  46002. m.addfrozen_balance = nil
  46003. }
  46004. // SetConcurrency sets the "concurrency" field.
  46005. func (m *UserMutation) SetConcurrency(i int) {
  46006. m.concurrency = &i
  46007. m.addconcurrency = nil
  46008. }
  46009. // Concurrency returns the value of the "concurrency" field in the mutation.
  46010. func (m *UserMutation) Concurrency() (r int, exists bool) {
  46011. v := m.concurrency
  46012. if v == nil {
  46013. return
  46014. }
  46015. return *v, true
  46016. }
  46017. // OldConcurrency returns the old "concurrency" field's value of the User entity.
  46018. // If the User object wasn't provided to the builder, the object is fetched from the database.
  46019. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46020. func (m *UserMutation) OldConcurrency(ctx context.Context) (v int, err error) {
  46021. if !m.op.Is(OpUpdateOne) {
  46022. return v, errors.New("OldConcurrency is only allowed on UpdateOne operations")
  46023. }
  46024. if m.id == nil || m.oldValue == nil {
  46025. return v, errors.New("OldConcurrency requires an ID field in the mutation")
  46026. }
  46027. oldValue, err := m.oldValue(ctx)
  46028. if err != nil {
  46029. return v, fmt.Errorf("querying old value for OldConcurrency: %w", err)
  46030. }
  46031. return oldValue.Concurrency, nil
  46032. }
  46033. // AddConcurrency adds i to the "concurrency" field.
  46034. func (m *UserMutation) AddConcurrency(i int) {
  46035. if m.addconcurrency != nil {
  46036. *m.addconcurrency += i
  46037. } else {
  46038. m.addconcurrency = &i
  46039. }
  46040. }
  46041. // AddedConcurrency returns the value that was added to the "concurrency" field in this mutation.
  46042. func (m *UserMutation) AddedConcurrency() (r int, exists bool) {
  46043. v := m.addconcurrency
  46044. if v == nil {
  46045. return
  46046. }
  46047. return *v, true
  46048. }
  46049. // ResetConcurrency resets all changes to the "concurrency" field.
  46050. func (m *UserMutation) ResetConcurrency() {
  46051. m.concurrency = nil
  46052. m.addconcurrency = nil
  46053. }
  46054. // SetStatus sets the "status" field.
  46055. func (m *UserMutation) SetStatus(s string) {
  46056. m.status = &s
  46057. }
  46058. // Status returns the value of the "status" field in the mutation.
  46059. func (m *UserMutation) Status() (r string, exists bool) {
  46060. v := m.status
  46061. if v == nil {
  46062. return
  46063. }
  46064. return *v, true
  46065. }
  46066. // OldStatus returns the old "status" field's value of the User entity.
  46067. // If the User object wasn't provided to the builder, the object is fetched from the database.
  46068. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46069. func (m *UserMutation) OldStatus(ctx context.Context) (v string, err error) {
  46070. if !m.op.Is(OpUpdateOne) {
  46071. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  46072. }
  46073. if m.id == nil || m.oldValue == nil {
  46074. return v, errors.New("OldStatus requires an ID field in the mutation")
  46075. }
  46076. oldValue, err := m.oldValue(ctx)
  46077. if err != nil {
  46078. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  46079. }
  46080. return oldValue.Status, nil
  46081. }
  46082. // ResetStatus resets all changes to the "status" field.
  46083. func (m *UserMutation) ResetStatus() {
  46084. m.status = nil
  46085. }
  46086. // SetUsername sets the "username" field.
  46087. func (m *UserMutation) SetUsername(s string) {
  46088. m.username = &s
  46089. }
  46090. // Username returns the value of the "username" field in the mutation.
  46091. func (m *UserMutation) Username() (r string, exists bool) {
  46092. v := m.username
  46093. if v == nil {
  46094. return
  46095. }
  46096. return *v, true
  46097. }
  46098. // OldUsername returns the old "username" field's value of the User entity.
  46099. // If the User object wasn't provided to the builder, the object is fetched from the database.
  46100. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46101. func (m *UserMutation) OldUsername(ctx context.Context) (v string, err error) {
  46102. if !m.op.Is(OpUpdateOne) {
  46103. return v, errors.New("OldUsername is only allowed on UpdateOne operations")
  46104. }
  46105. if m.id == nil || m.oldValue == nil {
  46106. return v, errors.New("OldUsername requires an ID field in the mutation")
  46107. }
  46108. oldValue, err := m.oldValue(ctx)
  46109. if err != nil {
  46110. return v, fmt.Errorf("querying old value for OldUsername: %w", err)
  46111. }
  46112. return oldValue.Username, nil
  46113. }
  46114. // ResetUsername resets all changes to the "username" field.
  46115. func (m *UserMutation) ResetUsername() {
  46116. m.username = nil
  46117. }
  46118. // SetNotes sets the "notes" field.
  46119. func (m *UserMutation) SetNotes(s string) {
  46120. m.notes = &s
  46121. }
  46122. // Notes returns the value of the "notes" field in the mutation.
  46123. func (m *UserMutation) Notes() (r string, exists bool) {
  46124. v := m.notes
  46125. if v == nil {
  46126. return
  46127. }
  46128. return *v, true
  46129. }
  46130. // OldNotes returns the old "notes" field's value of the User entity.
  46131. // If the User object wasn't provided to the builder, the object is fetched from the database.
  46132. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46133. func (m *UserMutation) OldNotes(ctx context.Context) (v string, err error) {
  46134. if !m.op.Is(OpUpdateOne) {
  46135. return v, errors.New("OldNotes is only allowed on UpdateOne operations")
  46136. }
  46137. if m.id == nil || m.oldValue == nil {
  46138. return v, errors.New("OldNotes requires an ID field in the mutation")
  46139. }
  46140. oldValue, err := m.oldValue(ctx)
  46141. if err != nil {
  46142. return v, fmt.Errorf("querying old value for OldNotes: %w", err)
  46143. }
  46144. return oldValue.Notes, nil
  46145. }
  46146. // ResetNotes resets all changes to the "notes" field.
  46147. func (m *UserMutation) ResetNotes() {
  46148. m.notes = nil
  46149. }
  46150. // SetTotpSecretEncrypted sets the "totp_secret_encrypted" field.
  46151. func (m *UserMutation) SetTotpSecretEncrypted(s string) {
  46152. m.totp_secret_encrypted = &s
  46153. }
  46154. // TotpSecretEncrypted returns the value of the "totp_secret_encrypted" field in the mutation.
  46155. func (m *UserMutation) TotpSecretEncrypted() (r string, exists bool) {
  46156. v := m.totp_secret_encrypted
  46157. if v == nil {
  46158. return
  46159. }
  46160. return *v, true
  46161. }
  46162. // OldTotpSecretEncrypted returns the old "totp_secret_encrypted" field's value of the User entity.
  46163. // If the User object wasn't provided to the builder, the object is fetched from the database.
  46164. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46165. func (m *UserMutation) OldTotpSecretEncrypted(ctx context.Context) (v *string, err error) {
  46166. if !m.op.Is(OpUpdateOne) {
  46167. return v, errors.New("OldTotpSecretEncrypted is only allowed on UpdateOne operations")
  46168. }
  46169. if m.id == nil || m.oldValue == nil {
  46170. return v, errors.New("OldTotpSecretEncrypted requires an ID field in the mutation")
  46171. }
  46172. oldValue, err := m.oldValue(ctx)
  46173. if err != nil {
  46174. return v, fmt.Errorf("querying old value for OldTotpSecretEncrypted: %w", err)
  46175. }
  46176. return oldValue.TotpSecretEncrypted, nil
  46177. }
  46178. // ClearTotpSecretEncrypted clears the value of the "totp_secret_encrypted" field.
  46179. func (m *UserMutation) ClearTotpSecretEncrypted() {
  46180. m.totp_secret_encrypted = nil
  46181. m.clearedFields[user.FieldTotpSecretEncrypted] = struct{}{}
  46182. }
  46183. // TotpSecretEncryptedCleared returns if the "totp_secret_encrypted" field was cleared in this mutation.
  46184. func (m *UserMutation) TotpSecretEncryptedCleared() bool {
  46185. _, ok := m.clearedFields[user.FieldTotpSecretEncrypted]
  46186. return ok
  46187. }
  46188. // ResetTotpSecretEncrypted resets all changes to the "totp_secret_encrypted" field.
  46189. func (m *UserMutation) ResetTotpSecretEncrypted() {
  46190. m.totp_secret_encrypted = nil
  46191. delete(m.clearedFields, user.FieldTotpSecretEncrypted)
  46192. }
  46193. // SetTotpEnabled sets the "totp_enabled" field.
  46194. func (m *UserMutation) SetTotpEnabled(b bool) {
  46195. m.totp_enabled = &b
  46196. }
  46197. // TotpEnabled returns the value of the "totp_enabled" field in the mutation.
  46198. func (m *UserMutation) TotpEnabled() (r bool, exists bool) {
  46199. v := m.totp_enabled
  46200. if v == nil {
  46201. return
  46202. }
  46203. return *v, true
  46204. }
  46205. // OldTotpEnabled returns the old "totp_enabled" field's value of the User entity.
  46206. // If the User object wasn't provided to the builder, the object is fetched from the database.
  46207. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46208. func (m *UserMutation) OldTotpEnabled(ctx context.Context) (v bool, err error) {
  46209. if !m.op.Is(OpUpdateOne) {
  46210. return v, errors.New("OldTotpEnabled is only allowed on UpdateOne operations")
  46211. }
  46212. if m.id == nil || m.oldValue == nil {
  46213. return v, errors.New("OldTotpEnabled requires an ID field in the mutation")
  46214. }
  46215. oldValue, err := m.oldValue(ctx)
  46216. if err != nil {
  46217. return v, fmt.Errorf("querying old value for OldTotpEnabled: %w", err)
  46218. }
  46219. return oldValue.TotpEnabled, nil
  46220. }
  46221. // ResetTotpEnabled resets all changes to the "totp_enabled" field.
  46222. func (m *UserMutation) ResetTotpEnabled() {
  46223. m.totp_enabled = nil
  46224. }
  46225. // SetTotpEnabledAt sets the "totp_enabled_at" field.
  46226. func (m *UserMutation) SetTotpEnabledAt(t time.Time) {
  46227. m.totp_enabled_at = &t
  46228. }
  46229. // TotpEnabledAt returns the value of the "totp_enabled_at" field in the mutation.
  46230. func (m *UserMutation) TotpEnabledAt() (r time.Time, exists bool) {
  46231. v := m.totp_enabled_at
  46232. if v == nil {
  46233. return
  46234. }
  46235. return *v, true
  46236. }
  46237. // OldTotpEnabledAt returns the old "totp_enabled_at" field's value of the User entity.
  46238. // If the User object wasn't provided to the builder, the object is fetched from the database.
  46239. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46240. func (m *UserMutation) OldTotpEnabledAt(ctx context.Context) (v *time.Time, err error) {
  46241. if !m.op.Is(OpUpdateOne) {
  46242. return v, errors.New("OldTotpEnabledAt is only allowed on UpdateOne operations")
  46243. }
  46244. if m.id == nil || m.oldValue == nil {
  46245. return v, errors.New("OldTotpEnabledAt requires an ID field in the mutation")
  46246. }
  46247. oldValue, err := m.oldValue(ctx)
  46248. if err != nil {
  46249. return v, fmt.Errorf("querying old value for OldTotpEnabledAt: %w", err)
  46250. }
  46251. return oldValue.TotpEnabledAt, nil
  46252. }
  46253. // ClearTotpEnabledAt clears the value of the "totp_enabled_at" field.
  46254. func (m *UserMutation) ClearTotpEnabledAt() {
  46255. m.totp_enabled_at = nil
  46256. m.clearedFields[user.FieldTotpEnabledAt] = struct{}{}
  46257. }
  46258. // TotpEnabledAtCleared returns if the "totp_enabled_at" field was cleared in this mutation.
  46259. func (m *UserMutation) TotpEnabledAtCleared() bool {
  46260. _, ok := m.clearedFields[user.FieldTotpEnabledAt]
  46261. return ok
  46262. }
  46263. // ResetTotpEnabledAt resets all changes to the "totp_enabled_at" field.
  46264. func (m *UserMutation) ResetTotpEnabledAt() {
  46265. m.totp_enabled_at = nil
  46266. delete(m.clearedFields, user.FieldTotpEnabledAt)
  46267. }
  46268. // SetSignupSource sets the "signup_source" field.
  46269. func (m *UserMutation) SetSignupSource(s string) {
  46270. m.signup_source = &s
  46271. }
  46272. // SignupSource returns the value of the "signup_source" field in the mutation.
  46273. func (m *UserMutation) SignupSource() (r string, exists bool) {
  46274. v := m.signup_source
  46275. if v == nil {
  46276. return
  46277. }
  46278. return *v, true
  46279. }
  46280. // OldSignupSource returns the old "signup_source" field's value of the User entity.
  46281. // If the User object wasn't provided to the builder, the object is fetched from the database.
  46282. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46283. func (m *UserMutation) OldSignupSource(ctx context.Context) (v string, err error) {
  46284. if !m.op.Is(OpUpdateOne) {
  46285. return v, errors.New("OldSignupSource is only allowed on UpdateOne operations")
  46286. }
  46287. if m.id == nil || m.oldValue == nil {
  46288. return v, errors.New("OldSignupSource requires an ID field in the mutation")
  46289. }
  46290. oldValue, err := m.oldValue(ctx)
  46291. if err != nil {
  46292. return v, fmt.Errorf("querying old value for OldSignupSource: %w", err)
  46293. }
  46294. return oldValue.SignupSource, nil
  46295. }
  46296. // ResetSignupSource resets all changes to the "signup_source" field.
  46297. func (m *UserMutation) ResetSignupSource() {
  46298. m.signup_source = nil
  46299. }
  46300. // SetLastLoginAt sets the "last_login_at" field.
  46301. func (m *UserMutation) SetLastLoginAt(t time.Time) {
  46302. m.last_login_at = &t
  46303. }
  46304. // LastLoginAt returns the value of the "last_login_at" field in the mutation.
  46305. func (m *UserMutation) LastLoginAt() (r time.Time, exists bool) {
  46306. v := m.last_login_at
  46307. if v == nil {
  46308. return
  46309. }
  46310. return *v, true
  46311. }
  46312. // OldLastLoginAt returns the old "last_login_at" field's value of the User entity.
  46313. // If the User object wasn't provided to the builder, the object is fetched from the database.
  46314. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46315. func (m *UserMutation) OldLastLoginAt(ctx context.Context) (v *time.Time, err error) {
  46316. if !m.op.Is(OpUpdateOne) {
  46317. return v, errors.New("OldLastLoginAt is only allowed on UpdateOne operations")
  46318. }
  46319. if m.id == nil || m.oldValue == nil {
  46320. return v, errors.New("OldLastLoginAt requires an ID field in the mutation")
  46321. }
  46322. oldValue, err := m.oldValue(ctx)
  46323. if err != nil {
  46324. return v, fmt.Errorf("querying old value for OldLastLoginAt: %w", err)
  46325. }
  46326. return oldValue.LastLoginAt, nil
  46327. }
  46328. // ClearLastLoginAt clears the value of the "last_login_at" field.
  46329. func (m *UserMutation) ClearLastLoginAt() {
  46330. m.last_login_at = nil
  46331. m.clearedFields[user.FieldLastLoginAt] = struct{}{}
  46332. }
  46333. // LastLoginAtCleared returns if the "last_login_at" field was cleared in this mutation.
  46334. func (m *UserMutation) LastLoginAtCleared() bool {
  46335. _, ok := m.clearedFields[user.FieldLastLoginAt]
  46336. return ok
  46337. }
  46338. // ResetLastLoginAt resets all changes to the "last_login_at" field.
  46339. func (m *UserMutation) ResetLastLoginAt() {
  46340. m.last_login_at = nil
  46341. delete(m.clearedFields, user.FieldLastLoginAt)
  46342. }
  46343. // SetLastActiveAt sets the "last_active_at" field.
  46344. func (m *UserMutation) SetLastActiveAt(t time.Time) {
  46345. m.last_active_at = &t
  46346. }
  46347. // LastActiveAt returns the value of the "last_active_at" field in the mutation.
  46348. func (m *UserMutation) LastActiveAt() (r time.Time, exists bool) {
  46349. v := m.last_active_at
  46350. if v == nil {
  46351. return
  46352. }
  46353. return *v, true
  46354. }
  46355. // OldLastActiveAt returns the old "last_active_at" field's value of the User entity.
  46356. // If the User object wasn't provided to the builder, the object is fetched from the database.
  46357. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46358. func (m *UserMutation) OldLastActiveAt(ctx context.Context) (v *time.Time, err error) {
  46359. if !m.op.Is(OpUpdateOne) {
  46360. return v, errors.New("OldLastActiveAt is only allowed on UpdateOne operations")
  46361. }
  46362. if m.id == nil || m.oldValue == nil {
  46363. return v, errors.New("OldLastActiveAt requires an ID field in the mutation")
  46364. }
  46365. oldValue, err := m.oldValue(ctx)
  46366. if err != nil {
  46367. return v, fmt.Errorf("querying old value for OldLastActiveAt: %w", err)
  46368. }
  46369. return oldValue.LastActiveAt, nil
  46370. }
  46371. // ClearLastActiveAt clears the value of the "last_active_at" field.
  46372. func (m *UserMutation) ClearLastActiveAt() {
  46373. m.last_active_at = nil
  46374. m.clearedFields[user.FieldLastActiveAt] = struct{}{}
  46375. }
  46376. // LastActiveAtCleared returns if the "last_active_at" field was cleared in this mutation.
  46377. func (m *UserMutation) LastActiveAtCleared() bool {
  46378. _, ok := m.clearedFields[user.FieldLastActiveAt]
  46379. return ok
  46380. }
  46381. // ResetLastActiveAt resets all changes to the "last_active_at" field.
  46382. func (m *UserMutation) ResetLastActiveAt() {
  46383. m.last_active_at = nil
  46384. delete(m.clearedFields, user.FieldLastActiveAt)
  46385. }
  46386. // SetRestrictPublicGroups sets the "restrict_public_groups" field.
  46387. func (m *UserMutation) SetRestrictPublicGroups(b bool) {
  46388. m.restrict_public_groups = &b
  46389. }
  46390. // RestrictPublicGroups returns the value of the "restrict_public_groups" field in the mutation.
  46391. func (m *UserMutation) RestrictPublicGroups() (r bool, exists bool) {
  46392. v := m.restrict_public_groups
  46393. if v == nil {
  46394. return
  46395. }
  46396. return *v, true
  46397. }
  46398. // OldRestrictPublicGroups returns the old "restrict_public_groups" field's value of the User entity.
  46399. // If the User object wasn't provided to the builder, the object is fetched from the database.
  46400. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46401. func (m *UserMutation) OldRestrictPublicGroups(ctx context.Context) (v bool, err error) {
  46402. if !m.op.Is(OpUpdateOne) {
  46403. return v, errors.New("OldRestrictPublicGroups is only allowed on UpdateOne operations")
  46404. }
  46405. if m.id == nil || m.oldValue == nil {
  46406. return v, errors.New("OldRestrictPublicGroups requires an ID field in the mutation")
  46407. }
  46408. oldValue, err := m.oldValue(ctx)
  46409. if err != nil {
  46410. return v, fmt.Errorf("querying old value for OldRestrictPublicGroups: %w", err)
  46411. }
  46412. return oldValue.RestrictPublicGroups, nil
  46413. }
  46414. // ResetRestrictPublicGroups resets all changes to the "restrict_public_groups" field.
  46415. func (m *UserMutation) ResetRestrictPublicGroups() {
  46416. m.restrict_public_groups = nil
  46417. }
  46418. // SetBalanceNotifyEnabled sets the "balance_notify_enabled" field.
  46419. func (m *UserMutation) SetBalanceNotifyEnabled(b bool) {
  46420. m.balance_notify_enabled = &b
  46421. }
  46422. // BalanceNotifyEnabled returns the value of the "balance_notify_enabled" field in the mutation.
  46423. func (m *UserMutation) BalanceNotifyEnabled() (r bool, exists bool) {
  46424. v := m.balance_notify_enabled
  46425. if v == nil {
  46426. return
  46427. }
  46428. return *v, true
  46429. }
  46430. // OldBalanceNotifyEnabled returns the old "balance_notify_enabled" field's value of the User entity.
  46431. // If the User object wasn't provided to the builder, the object is fetched from the database.
  46432. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46433. func (m *UserMutation) OldBalanceNotifyEnabled(ctx context.Context) (v bool, err error) {
  46434. if !m.op.Is(OpUpdateOne) {
  46435. return v, errors.New("OldBalanceNotifyEnabled is only allowed on UpdateOne operations")
  46436. }
  46437. if m.id == nil || m.oldValue == nil {
  46438. return v, errors.New("OldBalanceNotifyEnabled requires an ID field in the mutation")
  46439. }
  46440. oldValue, err := m.oldValue(ctx)
  46441. if err != nil {
  46442. return v, fmt.Errorf("querying old value for OldBalanceNotifyEnabled: %w", err)
  46443. }
  46444. return oldValue.BalanceNotifyEnabled, nil
  46445. }
  46446. // ResetBalanceNotifyEnabled resets all changes to the "balance_notify_enabled" field.
  46447. func (m *UserMutation) ResetBalanceNotifyEnabled() {
  46448. m.balance_notify_enabled = nil
  46449. }
  46450. // SetBalanceNotifyThresholdType sets the "balance_notify_threshold_type" field.
  46451. func (m *UserMutation) SetBalanceNotifyThresholdType(s string) {
  46452. m.balance_notify_threshold_type = &s
  46453. }
  46454. // BalanceNotifyThresholdType returns the value of the "balance_notify_threshold_type" field in the mutation.
  46455. func (m *UserMutation) BalanceNotifyThresholdType() (r string, exists bool) {
  46456. v := m.balance_notify_threshold_type
  46457. if v == nil {
  46458. return
  46459. }
  46460. return *v, true
  46461. }
  46462. // OldBalanceNotifyThresholdType returns the old "balance_notify_threshold_type" field's value of the User entity.
  46463. // If the User object wasn't provided to the builder, the object is fetched from the database.
  46464. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46465. func (m *UserMutation) OldBalanceNotifyThresholdType(ctx context.Context) (v string, err error) {
  46466. if !m.op.Is(OpUpdateOne) {
  46467. return v, errors.New("OldBalanceNotifyThresholdType is only allowed on UpdateOne operations")
  46468. }
  46469. if m.id == nil || m.oldValue == nil {
  46470. return v, errors.New("OldBalanceNotifyThresholdType requires an ID field in the mutation")
  46471. }
  46472. oldValue, err := m.oldValue(ctx)
  46473. if err != nil {
  46474. return v, fmt.Errorf("querying old value for OldBalanceNotifyThresholdType: %w", err)
  46475. }
  46476. return oldValue.BalanceNotifyThresholdType, nil
  46477. }
  46478. // ResetBalanceNotifyThresholdType resets all changes to the "balance_notify_threshold_type" field.
  46479. func (m *UserMutation) ResetBalanceNotifyThresholdType() {
  46480. m.balance_notify_threshold_type = nil
  46481. }
  46482. // SetBalanceNotifyThreshold sets the "balance_notify_threshold" field.
  46483. func (m *UserMutation) SetBalanceNotifyThreshold(f float64) {
  46484. m.balance_notify_threshold = &f
  46485. m.addbalance_notify_threshold = nil
  46486. }
  46487. // BalanceNotifyThreshold returns the value of the "balance_notify_threshold" field in the mutation.
  46488. func (m *UserMutation) BalanceNotifyThreshold() (r float64, exists bool) {
  46489. v := m.balance_notify_threshold
  46490. if v == nil {
  46491. return
  46492. }
  46493. return *v, true
  46494. }
  46495. // OldBalanceNotifyThreshold returns the old "balance_notify_threshold" field's value of the User entity.
  46496. // If the User object wasn't provided to the builder, the object is fetched from the database.
  46497. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46498. func (m *UserMutation) OldBalanceNotifyThreshold(ctx context.Context) (v *float64, err error) {
  46499. if !m.op.Is(OpUpdateOne) {
  46500. return v, errors.New("OldBalanceNotifyThreshold is only allowed on UpdateOne operations")
  46501. }
  46502. if m.id == nil || m.oldValue == nil {
  46503. return v, errors.New("OldBalanceNotifyThreshold requires an ID field in the mutation")
  46504. }
  46505. oldValue, err := m.oldValue(ctx)
  46506. if err != nil {
  46507. return v, fmt.Errorf("querying old value for OldBalanceNotifyThreshold: %w", err)
  46508. }
  46509. return oldValue.BalanceNotifyThreshold, nil
  46510. }
  46511. // AddBalanceNotifyThreshold adds f to the "balance_notify_threshold" field.
  46512. func (m *UserMutation) AddBalanceNotifyThreshold(f float64) {
  46513. if m.addbalance_notify_threshold != nil {
  46514. *m.addbalance_notify_threshold += f
  46515. } else {
  46516. m.addbalance_notify_threshold = &f
  46517. }
  46518. }
  46519. // AddedBalanceNotifyThreshold returns the value that was added to the "balance_notify_threshold" field in this mutation.
  46520. func (m *UserMutation) AddedBalanceNotifyThreshold() (r float64, exists bool) {
  46521. v := m.addbalance_notify_threshold
  46522. if v == nil {
  46523. return
  46524. }
  46525. return *v, true
  46526. }
  46527. // ClearBalanceNotifyThreshold clears the value of the "balance_notify_threshold" field.
  46528. func (m *UserMutation) ClearBalanceNotifyThreshold() {
  46529. m.balance_notify_threshold = nil
  46530. m.addbalance_notify_threshold = nil
  46531. m.clearedFields[user.FieldBalanceNotifyThreshold] = struct{}{}
  46532. }
  46533. // BalanceNotifyThresholdCleared returns if the "balance_notify_threshold" field was cleared in this mutation.
  46534. func (m *UserMutation) BalanceNotifyThresholdCleared() bool {
  46535. _, ok := m.clearedFields[user.FieldBalanceNotifyThreshold]
  46536. return ok
  46537. }
  46538. // ResetBalanceNotifyThreshold resets all changes to the "balance_notify_threshold" field.
  46539. func (m *UserMutation) ResetBalanceNotifyThreshold() {
  46540. m.balance_notify_threshold = nil
  46541. m.addbalance_notify_threshold = nil
  46542. delete(m.clearedFields, user.FieldBalanceNotifyThreshold)
  46543. }
  46544. // SetBalanceNotifyExtraEmails sets the "balance_notify_extra_emails" field.
  46545. func (m *UserMutation) SetBalanceNotifyExtraEmails(s string) {
  46546. m.balance_notify_extra_emails = &s
  46547. }
  46548. // BalanceNotifyExtraEmails returns the value of the "balance_notify_extra_emails" field in the mutation.
  46549. func (m *UserMutation) BalanceNotifyExtraEmails() (r string, exists bool) {
  46550. v := m.balance_notify_extra_emails
  46551. if v == nil {
  46552. return
  46553. }
  46554. return *v, true
  46555. }
  46556. // OldBalanceNotifyExtraEmails returns the old "balance_notify_extra_emails" field's value of the User entity.
  46557. // If the User object wasn't provided to the builder, the object is fetched from the database.
  46558. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46559. func (m *UserMutation) OldBalanceNotifyExtraEmails(ctx context.Context) (v string, err error) {
  46560. if !m.op.Is(OpUpdateOne) {
  46561. return v, errors.New("OldBalanceNotifyExtraEmails is only allowed on UpdateOne operations")
  46562. }
  46563. if m.id == nil || m.oldValue == nil {
  46564. return v, errors.New("OldBalanceNotifyExtraEmails requires an ID field in the mutation")
  46565. }
  46566. oldValue, err := m.oldValue(ctx)
  46567. if err != nil {
  46568. return v, fmt.Errorf("querying old value for OldBalanceNotifyExtraEmails: %w", err)
  46569. }
  46570. return oldValue.BalanceNotifyExtraEmails, nil
  46571. }
  46572. // ResetBalanceNotifyExtraEmails resets all changes to the "balance_notify_extra_emails" field.
  46573. func (m *UserMutation) ResetBalanceNotifyExtraEmails() {
  46574. m.balance_notify_extra_emails = nil
  46575. }
  46576. // SetTotalRecharged sets the "total_recharged" field.
  46577. func (m *UserMutation) SetTotalRecharged(f float64) {
  46578. m.total_recharged = &f
  46579. m.addtotal_recharged = nil
  46580. }
  46581. // TotalRecharged returns the value of the "total_recharged" field in the mutation.
  46582. func (m *UserMutation) TotalRecharged() (r float64, exists bool) {
  46583. v := m.total_recharged
  46584. if v == nil {
  46585. return
  46586. }
  46587. return *v, true
  46588. }
  46589. // OldTotalRecharged returns the old "total_recharged" field's value of the User entity.
  46590. // If the User object wasn't provided to the builder, the object is fetched from the database.
  46591. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46592. func (m *UserMutation) OldTotalRecharged(ctx context.Context) (v float64, err error) {
  46593. if !m.op.Is(OpUpdateOne) {
  46594. return v, errors.New("OldTotalRecharged is only allowed on UpdateOne operations")
  46595. }
  46596. if m.id == nil || m.oldValue == nil {
  46597. return v, errors.New("OldTotalRecharged requires an ID field in the mutation")
  46598. }
  46599. oldValue, err := m.oldValue(ctx)
  46600. if err != nil {
  46601. return v, fmt.Errorf("querying old value for OldTotalRecharged: %w", err)
  46602. }
  46603. return oldValue.TotalRecharged, nil
  46604. }
  46605. // AddTotalRecharged adds f to the "total_recharged" field.
  46606. func (m *UserMutation) AddTotalRecharged(f float64) {
  46607. if m.addtotal_recharged != nil {
  46608. *m.addtotal_recharged += f
  46609. } else {
  46610. m.addtotal_recharged = &f
  46611. }
  46612. }
  46613. // AddedTotalRecharged returns the value that was added to the "total_recharged" field in this mutation.
  46614. func (m *UserMutation) AddedTotalRecharged() (r float64, exists bool) {
  46615. v := m.addtotal_recharged
  46616. if v == nil {
  46617. return
  46618. }
  46619. return *v, true
  46620. }
  46621. // ResetTotalRecharged resets all changes to the "total_recharged" field.
  46622. func (m *UserMutation) ResetTotalRecharged() {
  46623. m.total_recharged = nil
  46624. m.addtotal_recharged = nil
  46625. }
  46626. // SetRpmLimit sets the "rpm_limit" field.
  46627. func (m *UserMutation) SetRpmLimit(i int) {
  46628. m.rpm_limit = &i
  46629. m.addrpm_limit = nil
  46630. }
  46631. // RpmLimit returns the value of the "rpm_limit" field in the mutation.
  46632. func (m *UserMutation) RpmLimit() (r int, exists bool) {
  46633. v := m.rpm_limit
  46634. if v == nil {
  46635. return
  46636. }
  46637. return *v, true
  46638. }
  46639. // OldRpmLimit returns the old "rpm_limit" field's value of the User entity.
  46640. // If the User object wasn't provided to the builder, the object is fetched from the database.
  46641. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46642. func (m *UserMutation) OldRpmLimit(ctx context.Context) (v int, err error) {
  46643. if !m.op.Is(OpUpdateOne) {
  46644. return v, errors.New("OldRpmLimit is only allowed on UpdateOne operations")
  46645. }
  46646. if m.id == nil || m.oldValue == nil {
  46647. return v, errors.New("OldRpmLimit requires an ID field in the mutation")
  46648. }
  46649. oldValue, err := m.oldValue(ctx)
  46650. if err != nil {
  46651. return v, fmt.Errorf("querying old value for OldRpmLimit: %w", err)
  46652. }
  46653. return oldValue.RpmLimit, nil
  46654. }
  46655. // AddRpmLimit adds i to the "rpm_limit" field.
  46656. func (m *UserMutation) AddRpmLimit(i int) {
  46657. if m.addrpm_limit != nil {
  46658. *m.addrpm_limit += i
  46659. } else {
  46660. m.addrpm_limit = &i
  46661. }
  46662. }
  46663. // AddedRpmLimit returns the value that was added to the "rpm_limit" field in this mutation.
  46664. func (m *UserMutation) AddedRpmLimit() (r int, exists bool) {
  46665. v := m.addrpm_limit
  46666. if v == nil {
  46667. return
  46668. }
  46669. return *v, true
  46670. }
  46671. // ResetRpmLimit resets all changes to the "rpm_limit" field.
  46672. func (m *UserMutation) ResetRpmLimit() {
  46673. m.rpm_limit = nil
  46674. m.addrpm_limit = nil
  46675. }
  46676. // AddAPIKeyIDs adds the "api_keys" edge to the APIKey entity by ids.
  46677. func (m *UserMutation) AddAPIKeyIDs(ids ...int64) {
  46678. if m.api_keys == nil {
  46679. m.api_keys = make(map[int64]struct{})
  46680. }
  46681. for i := range ids {
  46682. m.api_keys[ids[i]] = struct{}{}
  46683. }
  46684. }
  46685. // ClearAPIKeys clears the "api_keys" edge to the APIKey entity.
  46686. func (m *UserMutation) ClearAPIKeys() {
  46687. m.clearedapi_keys = true
  46688. }
  46689. // APIKeysCleared reports if the "api_keys" edge to the APIKey entity was cleared.
  46690. func (m *UserMutation) APIKeysCleared() bool {
  46691. return m.clearedapi_keys
  46692. }
  46693. // RemoveAPIKeyIDs removes the "api_keys" edge to the APIKey entity by IDs.
  46694. func (m *UserMutation) RemoveAPIKeyIDs(ids ...int64) {
  46695. if m.removedapi_keys == nil {
  46696. m.removedapi_keys = make(map[int64]struct{})
  46697. }
  46698. for i := range ids {
  46699. delete(m.api_keys, ids[i])
  46700. m.removedapi_keys[ids[i]] = struct{}{}
  46701. }
  46702. }
  46703. // RemovedAPIKeys returns the removed IDs of the "api_keys" edge to the APIKey entity.
  46704. func (m *UserMutation) RemovedAPIKeysIDs() (ids []int64) {
  46705. for id := range m.removedapi_keys {
  46706. ids = append(ids, id)
  46707. }
  46708. return
  46709. }
  46710. // APIKeysIDs returns the "api_keys" edge IDs in the mutation.
  46711. func (m *UserMutation) APIKeysIDs() (ids []int64) {
  46712. for id := range m.api_keys {
  46713. ids = append(ids, id)
  46714. }
  46715. return
  46716. }
  46717. // ResetAPIKeys resets all changes to the "api_keys" edge.
  46718. func (m *UserMutation) ResetAPIKeys() {
  46719. m.api_keys = nil
  46720. m.clearedapi_keys = false
  46721. m.removedapi_keys = nil
  46722. }
  46723. // AddRedeemCodeIDs adds the "redeem_codes" edge to the RedeemCode entity by ids.
  46724. func (m *UserMutation) AddRedeemCodeIDs(ids ...int64) {
  46725. if m.redeem_codes == nil {
  46726. m.redeem_codes = make(map[int64]struct{})
  46727. }
  46728. for i := range ids {
  46729. m.redeem_codes[ids[i]] = struct{}{}
  46730. }
  46731. }
  46732. // ClearRedeemCodes clears the "redeem_codes" edge to the RedeemCode entity.
  46733. func (m *UserMutation) ClearRedeemCodes() {
  46734. m.clearedredeem_codes = true
  46735. }
  46736. // RedeemCodesCleared reports if the "redeem_codes" edge to the RedeemCode entity was cleared.
  46737. func (m *UserMutation) RedeemCodesCleared() bool {
  46738. return m.clearedredeem_codes
  46739. }
  46740. // RemoveRedeemCodeIDs removes the "redeem_codes" edge to the RedeemCode entity by IDs.
  46741. func (m *UserMutation) RemoveRedeemCodeIDs(ids ...int64) {
  46742. if m.removedredeem_codes == nil {
  46743. m.removedredeem_codes = make(map[int64]struct{})
  46744. }
  46745. for i := range ids {
  46746. delete(m.redeem_codes, ids[i])
  46747. m.removedredeem_codes[ids[i]] = struct{}{}
  46748. }
  46749. }
  46750. // RemovedRedeemCodes returns the removed IDs of the "redeem_codes" edge to the RedeemCode entity.
  46751. func (m *UserMutation) RemovedRedeemCodesIDs() (ids []int64) {
  46752. for id := range m.removedredeem_codes {
  46753. ids = append(ids, id)
  46754. }
  46755. return
  46756. }
  46757. // RedeemCodesIDs returns the "redeem_codes" edge IDs in the mutation.
  46758. func (m *UserMutation) RedeemCodesIDs() (ids []int64) {
  46759. for id := range m.redeem_codes {
  46760. ids = append(ids, id)
  46761. }
  46762. return
  46763. }
  46764. // ResetRedeemCodes resets all changes to the "redeem_codes" edge.
  46765. func (m *UserMutation) ResetRedeemCodes() {
  46766. m.redeem_codes = nil
  46767. m.clearedredeem_codes = false
  46768. m.removedredeem_codes = nil
  46769. }
  46770. // AddSubscriptionIDs adds the "subscriptions" edge to the UserSubscription entity by ids.
  46771. func (m *UserMutation) AddSubscriptionIDs(ids ...int64) {
  46772. if m.subscriptions == nil {
  46773. m.subscriptions = make(map[int64]struct{})
  46774. }
  46775. for i := range ids {
  46776. m.subscriptions[ids[i]] = struct{}{}
  46777. }
  46778. }
  46779. // ClearSubscriptions clears the "subscriptions" edge to the UserSubscription entity.
  46780. func (m *UserMutation) ClearSubscriptions() {
  46781. m.clearedsubscriptions = true
  46782. }
  46783. // SubscriptionsCleared reports if the "subscriptions" edge to the UserSubscription entity was cleared.
  46784. func (m *UserMutation) SubscriptionsCleared() bool {
  46785. return m.clearedsubscriptions
  46786. }
  46787. // RemoveSubscriptionIDs removes the "subscriptions" edge to the UserSubscription entity by IDs.
  46788. func (m *UserMutation) RemoveSubscriptionIDs(ids ...int64) {
  46789. if m.removedsubscriptions == nil {
  46790. m.removedsubscriptions = make(map[int64]struct{})
  46791. }
  46792. for i := range ids {
  46793. delete(m.subscriptions, ids[i])
  46794. m.removedsubscriptions[ids[i]] = struct{}{}
  46795. }
  46796. }
  46797. // RemovedSubscriptions returns the removed IDs of the "subscriptions" edge to the UserSubscription entity.
  46798. func (m *UserMutation) RemovedSubscriptionsIDs() (ids []int64) {
  46799. for id := range m.removedsubscriptions {
  46800. ids = append(ids, id)
  46801. }
  46802. return
  46803. }
  46804. // SubscriptionsIDs returns the "subscriptions" edge IDs in the mutation.
  46805. func (m *UserMutation) SubscriptionsIDs() (ids []int64) {
  46806. for id := range m.subscriptions {
  46807. ids = append(ids, id)
  46808. }
  46809. return
  46810. }
  46811. // ResetSubscriptions resets all changes to the "subscriptions" edge.
  46812. func (m *UserMutation) ResetSubscriptions() {
  46813. m.subscriptions = nil
  46814. m.clearedsubscriptions = false
  46815. m.removedsubscriptions = nil
  46816. }
  46817. // AddAssignedSubscriptionIDs adds the "assigned_subscriptions" edge to the UserSubscription entity by ids.
  46818. func (m *UserMutation) AddAssignedSubscriptionIDs(ids ...int64) {
  46819. if m.assigned_subscriptions == nil {
  46820. m.assigned_subscriptions = make(map[int64]struct{})
  46821. }
  46822. for i := range ids {
  46823. m.assigned_subscriptions[ids[i]] = struct{}{}
  46824. }
  46825. }
  46826. // ClearAssignedSubscriptions clears the "assigned_subscriptions" edge to the UserSubscription entity.
  46827. func (m *UserMutation) ClearAssignedSubscriptions() {
  46828. m.clearedassigned_subscriptions = true
  46829. }
  46830. // AssignedSubscriptionsCleared reports if the "assigned_subscriptions" edge to the UserSubscription entity was cleared.
  46831. func (m *UserMutation) AssignedSubscriptionsCleared() bool {
  46832. return m.clearedassigned_subscriptions
  46833. }
  46834. // RemoveAssignedSubscriptionIDs removes the "assigned_subscriptions" edge to the UserSubscription entity by IDs.
  46835. func (m *UserMutation) RemoveAssignedSubscriptionIDs(ids ...int64) {
  46836. if m.removedassigned_subscriptions == nil {
  46837. m.removedassigned_subscriptions = make(map[int64]struct{})
  46838. }
  46839. for i := range ids {
  46840. delete(m.assigned_subscriptions, ids[i])
  46841. m.removedassigned_subscriptions[ids[i]] = struct{}{}
  46842. }
  46843. }
  46844. // RemovedAssignedSubscriptions returns the removed IDs of the "assigned_subscriptions" edge to the UserSubscription entity.
  46845. func (m *UserMutation) RemovedAssignedSubscriptionsIDs() (ids []int64) {
  46846. for id := range m.removedassigned_subscriptions {
  46847. ids = append(ids, id)
  46848. }
  46849. return
  46850. }
  46851. // AssignedSubscriptionsIDs returns the "assigned_subscriptions" edge IDs in the mutation.
  46852. func (m *UserMutation) AssignedSubscriptionsIDs() (ids []int64) {
  46853. for id := range m.assigned_subscriptions {
  46854. ids = append(ids, id)
  46855. }
  46856. return
  46857. }
  46858. // ResetAssignedSubscriptions resets all changes to the "assigned_subscriptions" edge.
  46859. func (m *UserMutation) ResetAssignedSubscriptions() {
  46860. m.assigned_subscriptions = nil
  46861. m.clearedassigned_subscriptions = false
  46862. m.removedassigned_subscriptions = nil
  46863. }
  46864. // AddAnnouncementReadIDs adds the "announcement_reads" edge to the AnnouncementRead entity by ids.
  46865. func (m *UserMutation) AddAnnouncementReadIDs(ids ...int64) {
  46866. if m.announcement_reads == nil {
  46867. m.announcement_reads = make(map[int64]struct{})
  46868. }
  46869. for i := range ids {
  46870. m.announcement_reads[ids[i]] = struct{}{}
  46871. }
  46872. }
  46873. // ClearAnnouncementReads clears the "announcement_reads" edge to the AnnouncementRead entity.
  46874. func (m *UserMutation) ClearAnnouncementReads() {
  46875. m.clearedannouncement_reads = true
  46876. }
  46877. // AnnouncementReadsCleared reports if the "announcement_reads" edge to the AnnouncementRead entity was cleared.
  46878. func (m *UserMutation) AnnouncementReadsCleared() bool {
  46879. return m.clearedannouncement_reads
  46880. }
  46881. // RemoveAnnouncementReadIDs removes the "announcement_reads" edge to the AnnouncementRead entity by IDs.
  46882. func (m *UserMutation) RemoveAnnouncementReadIDs(ids ...int64) {
  46883. if m.removedannouncement_reads == nil {
  46884. m.removedannouncement_reads = make(map[int64]struct{})
  46885. }
  46886. for i := range ids {
  46887. delete(m.announcement_reads, ids[i])
  46888. m.removedannouncement_reads[ids[i]] = struct{}{}
  46889. }
  46890. }
  46891. // RemovedAnnouncementReads returns the removed IDs of the "announcement_reads" edge to the AnnouncementRead entity.
  46892. func (m *UserMutation) RemovedAnnouncementReadsIDs() (ids []int64) {
  46893. for id := range m.removedannouncement_reads {
  46894. ids = append(ids, id)
  46895. }
  46896. return
  46897. }
  46898. // AnnouncementReadsIDs returns the "announcement_reads" edge IDs in the mutation.
  46899. func (m *UserMutation) AnnouncementReadsIDs() (ids []int64) {
  46900. for id := range m.announcement_reads {
  46901. ids = append(ids, id)
  46902. }
  46903. return
  46904. }
  46905. // ResetAnnouncementReads resets all changes to the "announcement_reads" edge.
  46906. func (m *UserMutation) ResetAnnouncementReads() {
  46907. m.announcement_reads = nil
  46908. m.clearedannouncement_reads = false
  46909. m.removedannouncement_reads = nil
  46910. }
  46911. // AddAllowedGroupIDs adds the "allowed_groups" edge to the Group entity by ids.
  46912. func (m *UserMutation) AddAllowedGroupIDs(ids ...int64) {
  46913. if m.allowed_groups == nil {
  46914. m.allowed_groups = make(map[int64]struct{})
  46915. }
  46916. for i := range ids {
  46917. m.allowed_groups[ids[i]] = struct{}{}
  46918. }
  46919. }
  46920. // ClearAllowedGroups clears the "allowed_groups" edge to the Group entity.
  46921. func (m *UserMutation) ClearAllowedGroups() {
  46922. m.clearedallowed_groups = true
  46923. }
  46924. // AllowedGroupsCleared reports if the "allowed_groups" edge to the Group entity was cleared.
  46925. func (m *UserMutation) AllowedGroupsCleared() bool {
  46926. return m.clearedallowed_groups
  46927. }
  46928. // RemoveAllowedGroupIDs removes the "allowed_groups" edge to the Group entity by IDs.
  46929. func (m *UserMutation) RemoveAllowedGroupIDs(ids ...int64) {
  46930. if m.removedallowed_groups == nil {
  46931. m.removedallowed_groups = make(map[int64]struct{})
  46932. }
  46933. for i := range ids {
  46934. delete(m.allowed_groups, ids[i])
  46935. m.removedallowed_groups[ids[i]] = struct{}{}
  46936. }
  46937. }
  46938. // RemovedAllowedGroups returns the removed IDs of the "allowed_groups" edge to the Group entity.
  46939. func (m *UserMutation) RemovedAllowedGroupsIDs() (ids []int64) {
  46940. for id := range m.removedallowed_groups {
  46941. ids = append(ids, id)
  46942. }
  46943. return
  46944. }
  46945. // AllowedGroupsIDs returns the "allowed_groups" edge IDs in the mutation.
  46946. func (m *UserMutation) AllowedGroupsIDs() (ids []int64) {
  46947. for id := range m.allowed_groups {
  46948. ids = append(ids, id)
  46949. }
  46950. return
  46951. }
  46952. // ResetAllowedGroups resets all changes to the "allowed_groups" edge.
  46953. func (m *UserMutation) ResetAllowedGroups() {
  46954. m.allowed_groups = nil
  46955. m.clearedallowed_groups = false
  46956. m.removedallowed_groups = nil
  46957. }
  46958. // AddUsageLogIDs adds the "usage_logs" edge to the UsageLog entity by ids.
  46959. func (m *UserMutation) AddUsageLogIDs(ids ...int64) {
  46960. if m.usage_logs == nil {
  46961. m.usage_logs = make(map[int64]struct{})
  46962. }
  46963. for i := range ids {
  46964. m.usage_logs[ids[i]] = struct{}{}
  46965. }
  46966. }
  46967. // ClearUsageLogs clears the "usage_logs" edge to the UsageLog entity.
  46968. func (m *UserMutation) ClearUsageLogs() {
  46969. m.clearedusage_logs = true
  46970. }
  46971. // UsageLogsCleared reports if the "usage_logs" edge to the UsageLog entity was cleared.
  46972. func (m *UserMutation) UsageLogsCleared() bool {
  46973. return m.clearedusage_logs
  46974. }
  46975. // RemoveUsageLogIDs removes the "usage_logs" edge to the UsageLog entity by IDs.
  46976. func (m *UserMutation) RemoveUsageLogIDs(ids ...int64) {
  46977. if m.removedusage_logs == nil {
  46978. m.removedusage_logs = make(map[int64]struct{})
  46979. }
  46980. for i := range ids {
  46981. delete(m.usage_logs, ids[i])
  46982. m.removedusage_logs[ids[i]] = struct{}{}
  46983. }
  46984. }
  46985. // RemovedUsageLogs returns the removed IDs of the "usage_logs" edge to the UsageLog entity.
  46986. func (m *UserMutation) RemovedUsageLogsIDs() (ids []int64) {
  46987. for id := range m.removedusage_logs {
  46988. ids = append(ids, id)
  46989. }
  46990. return
  46991. }
  46992. // UsageLogsIDs returns the "usage_logs" edge IDs in the mutation.
  46993. func (m *UserMutation) UsageLogsIDs() (ids []int64) {
  46994. for id := range m.usage_logs {
  46995. ids = append(ids, id)
  46996. }
  46997. return
  46998. }
  46999. // ResetUsageLogs resets all changes to the "usage_logs" edge.
  47000. func (m *UserMutation) ResetUsageLogs() {
  47001. m.usage_logs = nil
  47002. m.clearedusage_logs = false
  47003. m.removedusage_logs = nil
  47004. }
  47005. // AddAttributeValueIDs adds the "attribute_values" edge to the UserAttributeValue entity by ids.
  47006. func (m *UserMutation) AddAttributeValueIDs(ids ...int64) {
  47007. if m.attribute_values == nil {
  47008. m.attribute_values = make(map[int64]struct{})
  47009. }
  47010. for i := range ids {
  47011. m.attribute_values[ids[i]] = struct{}{}
  47012. }
  47013. }
  47014. // ClearAttributeValues clears the "attribute_values" edge to the UserAttributeValue entity.
  47015. func (m *UserMutation) ClearAttributeValues() {
  47016. m.clearedattribute_values = true
  47017. }
  47018. // AttributeValuesCleared reports if the "attribute_values" edge to the UserAttributeValue entity was cleared.
  47019. func (m *UserMutation) AttributeValuesCleared() bool {
  47020. return m.clearedattribute_values
  47021. }
  47022. // RemoveAttributeValueIDs removes the "attribute_values" edge to the UserAttributeValue entity by IDs.
  47023. func (m *UserMutation) RemoveAttributeValueIDs(ids ...int64) {
  47024. if m.removedattribute_values == nil {
  47025. m.removedattribute_values = make(map[int64]struct{})
  47026. }
  47027. for i := range ids {
  47028. delete(m.attribute_values, ids[i])
  47029. m.removedattribute_values[ids[i]] = struct{}{}
  47030. }
  47031. }
  47032. // RemovedAttributeValues returns the removed IDs of the "attribute_values" edge to the UserAttributeValue entity.
  47033. func (m *UserMutation) RemovedAttributeValuesIDs() (ids []int64) {
  47034. for id := range m.removedattribute_values {
  47035. ids = append(ids, id)
  47036. }
  47037. return
  47038. }
  47039. // AttributeValuesIDs returns the "attribute_values" edge IDs in the mutation.
  47040. func (m *UserMutation) AttributeValuesIDs() (ids []int64) {
  47041. for id := range m.attribute_values {
  47042. ids = append(ids, id)
  47043. }
  47044. return
  47045. }
  47046. // ResetAttributeValues resets all changes to the "attribute_values" edge.
  47047. func (m *UserMutation) ResetAttributeValues() {
  47048. m.attribute_values = nil
  47049. m.clearedattribute_values = false
  47050. m.removedattribute_values = nil
  47051. }
  47052. // AddPromoCodeUsageIDs adds the "promo_code_usages" edge to the PromoCodeUsage entity by ids.
  47053. func (m *UserMutation) AddPromoCodeUsageIDs(ids ...int64) {
  47054. if m.promo_code_usages == nil {
  47055. m.promo_code_usages = make(map[int64]struct{})
  47056. }
  47057. for i := range ids {
  47058. m.promo_code_usages[ids[i]] = struct{}{}
  47059. }
  47060. }
  47061. // ClearPromoCodeUsages clears the "promo_code_usages" edge to the PromoCodeUsage entity.
  47062. func (m *UserMutation) ClearPromoCodeUsages() {
  47063. m.clearedpromo_code_usages = true
  47064. }
  47065. // PromoCodeUsagesCleared reports if the "promo_code_usages" edge to the PromoCodeUsage entity was cleared.
  47066. func (m *UserMutation) PromoCodeUsagesCleared() bool {
  47067. return m.clearedpromo_code_usages
  47068. }
  47069. // RemovePromoCodeUsageIDs removes the "promo_code_usages" edge to the PromoCodeUsage entity by IDs.
  47070. func (m *UserMutation) RemovePromoCodeUsageIDs(ids ...int64) {
  47071. if m.removedpromo_code_usages == nil {
  47072. m.removedpromo_code_usages = make(map[int64]struct{})
  47073. }
  47074. for i := range ids {
  47075. delete(m.promo_code_usages, ids[i])
  47076. m.removedpromo_code_usages[ids[i]] = struct{}{}
  47077. }
  47078. }
  47079. // RemovedPromoCodeUsages returns the removed IDs of the "promo_code_usages" edge to the PromoCodeUsage entity.
  47080. func (m *UserMutation) RemovedPromoCodeUsagesIDs() (ids []int64) {
  47081. for id := range m.removedpromo_code_usages {
  47082. ids = append(ids, id)
  47083. }
  47084. return
  47085. }
  47086. // PromoCodeUsagesIDs returns the "promo_code_usages" edge IDs in the mutation.
  47087. func (m *UserMutation) PromoCodeUsagesIDs() (ids []int64) {
  47088. for id := range m.promo_code_usages {
  47089. ids = append(ids, id)
  47090. }
  47091. return
  47092. }
  47093. // ResetPromoCodeUsages resets all changes to the "promo_code_usages" edge.
  47094. func (m *UserMutation) ResetPromoCodeUsages() {
  47095. m.promo_code_usages = nil
  47096. m.clearedpromo_code_usages = false
  47097. m.removedpromo_code_usages = nil
  47098. }
  47099. // AddPaymentOrderIDs adds the "payment_orders" edge to the PaymentOrder entity by ids.
  47100. func (m *UserMutation) AddPaymentOrderIDs(ids ...int64) {
  47101. if m.payment_orders == nil {
  47102. m.payment_orders = make(map[int64]struct{})
  47103. }
  47104. for i := range ids {
  47105. m.payment_orders[ids[i]] = struct{}{}
  47106. }
  47107. }
  47108. // ClearPaymentOrders clears the "payment_orders" edge to the PaymentOrder entity.
  47109. func (m *UserMutation) ClearPaymentOrders() {
  47110. m.clearedpayment_orders = true
  47111. }
  47112. // PaymentOrdersCleared reports if the "payment_orders" edge to the PaymentOrder entity was cleared.
  47113. func (m *UserMutation) PaymentOrdersCleared() bool {
  47114. return m.clearedpayment_orders
  47115. }
  47116. // RemovePaymentOrderIDs removes the "payment_orders" edge to the PaymentOrder entity by IDs.
  47117. func (m *UserMutation) RemovePaymentOrderIDs(ids ...int64) {
  47118. if m.removedpayment_orders == nil {
  47119. m.removedpayment_orders = make(map[int64]struct{})
  47120. }
  47121. for i := range ids {
  47122. delete(m.payment_orders, ids[i])
  47123. m.removedpayment_orders[ids[i]] = struct{}{}
  47124. }
  47125. }
  47126. // RemovedPaymentOrders returns the removed IDs of the "payment_orders" edge to the PaymentOrder entity.
  47127. func (m *UserMutation) RemovedPaymentOrdersIDs() (ids []int64) {
  47128. for id := range m.removedpayment_orders {
  47129. ids = append(ids, id)
  47130. }
  47131. return
  47132. }
  47133. // PaymentOrdersIDs returns the "payment_orders" edge IDs in the mutation.
  47134. func (m *UserMutation) PaymentOrdersIDs() (ids []int64) {
  47135. for id := range m.payment_orders {
  47136. ids = append(ids, id)
  47137. }
  47138. return
  47139. }
  47140. // ResetPaymentOrders resets all changes to the "payment_orders" edge.
  47141. func (m *UserMutation) ResetPaymentOrders() {
  47142. m.payment_orders = nil
  47143. m.clearedpayment_orders = false
  47144. m.removedpayment_orders = nil
  47145. }
  47146. // AddAuthIdentityIDs adds the "auth_identities" edge to the AuthIdentity entity by ids.
  47147. func (m *UserMutation) AddAuthIdentityIDs(ids ...int64) {
  47148. if m.auth_identities == nil {
  47149. m.auth_identities = make(map[int64]struct{})
  47150. }
  47151. for i := range ids {
  47152. m.auth_identities[ids[i]] = struct{}{}
  47153. }
  47154. }
  47155. // ClearAuthIdentities clears the "auth_identities" edge to the AuthIdentity entity.
  47156. func (m *UserMutation) ClearAuthIdentities() {
  47157. m.clearedauth_identities = true
  47158. }
  47159. // AuthIdentitiesCleared reports if the "auth_identities" edge to the AuthIdentity entity was cleared.
  47160. func (m *UserMutation) AuthIdentitiesCleared() bool {
  47161. return m.clearedauth_identities
  47162. }
  47163. // RemoveAuthIdentityIDs removes the "auth_identities" edge to the AuthIdentity entity by IDs.
  47164. func (m *UserMutation) RemoveAuthIdentityIDs(ids ...int64) {
  47165. if m.removedauth_identities == nil {
  47166. m.removedauth_identities = make(map[int64]struct{})
  47167. }
  47168. for i := range ids {
  47169. delete(m.auth_identities, ids[i])
  47170. m.removedauth_identities[ids[i]] = struct{}{}
  47171. }
  47172. }
  47173. // RemovedAuthIdentities returns the removed IDs of the "auth_identities" edge to the AuthIdentity entity.
  47174. func (m *UserMutation) RemovedAuthIdentitiesIDs() (ids []int64) {
  47175. for id := range m.removedauth_identities {
  47176. ids = append(ids, id)
  47177. }
  47178. return
  47179. }
  47180. // AuthIdentitiesIDs returns the "auth_identities" edge IDs in the mutation.
  47181. func (m *UserMutation) AuthIdentitiesIDs() (ids []int64) {
  47182. for id := range m.auth_identities {
  47183. ids = append(ids, id)
  47184. }
  47185. return
  47186. }
  47187. // ResetAuthIdentities resets all changes to the "auth_identities" edge.
  47188. func (m *UserMutation) ResetAuthIdentities() {
  47189. m.auth_identities = nil
  47190. m.clearedauth_identities = false
  47191. m.removedauth_identities = nil
  47192. }
  47193. // AddPendingAuthSessionIDs adds the "pending_auth_sessions" edge to the PendingAuthSession entity by ids.
  47194. func (m *UserMutation) AddPendingAuthSessionIDs(ids ...int64) {
  47195. if m.pending_auth_sessions == nil {
  47196. m.pending_auth_sessions = make(map[int64]struct{})
  47197. }
  47198. for i := range ids {
  47199. m.pending_auth_sessions[ids[i]] = struct{}{}
  47200. }
  47201. }
  47202. // ClearPendingAuthSessions clears the "pending_auth_sessions" edge to the PendingAuthSession entity.
  47203. func (m *UserMutation) ClearPendingAuthSessions() {
  47204. m.clearedpending_auth_sessions = true
  47205. }
  47206. // PendingAuthSessionsCleared reports if the "pending_auth_sessions" edge to the PendingAuthSession entity was cleared.
  47207. func (m *UserMutation) PendingAuthSessionsCleared() bool {
  47208. return m.clearedpending_auth_sessions
  47209. }
  47210. // RemovePendingAuthSessionIDs removes the "pending_auth_sessions" edge to the PendingAuthSession entity by IDs.
  47211. func (m *UserMutation) RemovePendingAuthSessionIDs(ids ...int64) {
  47212. if m.removedpending_auth_sessions == nil {
  47213. m.removedpending_auth_sessions = make(map[int64]struct{})
  47214. }
  47215. for i := range ids {
  47216. delete(m.pending_auth_sessions, ids[i])
  47217. m.removedpending_auth_sessions[ids[i]] = struct{}{}
  47218. }
  47219. }
  47220. // RemovedPendingAuthSessions returns the removed IDs of the "pending_auth_sessions" edge to the PendingAuthSession entity.
  47221. func (m *UserMutation) RemovedPendingAuthSessionsIDs() (ids []int64) {
  47222. for id := range m.removedpending_auth_sessions {
  47223. ids = append(ids, id)
  47224. }
  47225. return
  47226. }
  47227. // PendingAuthSessionsIDs returns the "pending_auth_sessions" edge IDs in the mutation.
  47228. func (m *UserMutation) PendingAuthSessionsIDs() (ids []int64) {
  47229. for id := range m.pending_auth_sessions {
  47230. ids = append(ids, id)
  47231. }
  47232. return
  47233. }
  47234. // ResetPendingAuthSessions resets all changes to the "pending_auth_sessions" edge.
  47235. func (m *UserMutation) ResetPendingAuthSessions() {
  47236. m.pending_auth_sessions = nil
  47237. m.clearedpending_auth_sessions = false
  47238. m.removedpending_auth_sessions = nil
  47239. }
  47240. // AddPlatformQuotaIDs adds the "platform_quotas" edge to the UserPlatformQuota entity by ids.
  47241. func (m *UserMutation) AddPlatformQuotaIDs(ids ...int64) {
  47242. if m.platform_quotas == nil {
  47243. m.platform_quotas = make(map[int64]struct{})
  47244. }
  47245. for i := range ids {
  47246. m.platform_quotas[ids[i]] = struct{}{}
  47247. }
  47248. }
  47249. // ClearPlatformQuotas clears the "platform_quotas" edge to the UserPlatformQuota entity.
  47250. func (m *UserMutation) ClearPlatformQuotas() {
  47251. m.clearedplatform_quotas = true
  47252. }
  47253. // PlatformQuotasCleared reports if the "platform_quotas" edge to the UserPlatformQuota entity was cleared.
  47254. func (m *UserMutation) PlatformQuotasCleared() bool {
  47255. return m.clearedplatform_quotas
  47256. }
  47257. // RemovePlatformQuotaIDs removes the "platform_quotas" edge to the UserPlatformQuota entity by IDs.
  47258. func (m *UserMutation) RemovePlatformQuotaIDs(ids ...int64) {
  47259. if m.removedplatform_quotas == nil {
  47260. m.removedplatform_quotas = make(map[int64]struct{})
  47261. }
  47262. for i := range ids {
  47263. delete(m.platform_quotas, ids[i])
  47264. m.removedplatform_quotas[ids[i]] = struct{}{}
  47265. }
  47266. }
  47267. // RemovedPlatformQuotas returns the removed IDs of the "platform_quotas" edge to the UserPlatformQuota entity.
  47268. func (m *UserMutation) RemovedPlatformQuotasIDs() (ids []int64) {
  47269. for id := range m.removedplatform_quotas {
  47270. ids = append(ids, id)
  47271. }
  47272. return
  47273. }
  47274. // PlatformQuotasIDs returns the "platform_quotas" edge IDs in the mutation.
  47275. func (m *UserMutation) PlatformQuotasIDs() (ids []int64) {
  47276. for id := range m.platform_quotas {
  47277. ids = append(ids, id)
  47278. }
  47279. return
  47280. }
  47281. // ResetPlatformQuotas resets all changes to the "platform_quotas" edge.
  47282. func (m *UserMutation) ResetPlatformQuotas() {
  47283. m.platform_quotas = nil
  47284. m.clearedplatform_quotas = false
  47285. m.removedplatform_quotas = nil
  47286. }
  47287. // Where appends a list predicates to the UserMutation builder.
  47288. func (m *UserMutation) Where(ps ...predicate.User) {
  47289. m.predicates = append(m.predicates, ps...)
  47290. }
  47291. // WhereP appends storage-level predicates to the UserMutation builder. Using this method,
  47292. // users can use type-assertion to append predicates that do not depend on any generated package.
  47293. func (m *UserMutation) WhereP(ps ...func(*sql.Selector)) {
  47294. p := make([]predicate.User, len(ps))
  47295. for i := range ps {
  47296. p[i] = ps[i]
  47297. }
  47298. m.Where(p...)
  47299. }
  47300. // Op returns the operation name.
  47301. func (m *UserMutation) Op() Op {
  47302. return m.op
  47303. }
  47304. // SetOp allows setting the mutation operation.
  47305. func (m *UserMutation) SetOp(op Op) {
  47306. m.op = op
  47307. }
  47308. // Type returns the node type of this mutation (User).
  47309. func (m *UserMutation) Type() string {
  47310. return m.typ
  47311. }
  47312. // Fields returns all fields that were changed during this mutation. Note that in
  47313. // order to get all numeric fields that were incremented/decremented, call
  47314. // AddedFields().
  47315. func (m *UserMutation) Fields() []string {
  47316. fields := make([]string, 0, 25)
  47317. if m.created_at != nil {
  47318. fields = append(fields, user.FieldCreatedAt)
  47319. }
  47320. if m.updated_at != nil {
  47321. fields = append(fields, user.FieldUpdatedAt)
  47322. }
  47323. if m.deleted_at != nil {
  47324. fields = append(fields, user.FieldDeletedAt)
  47325. }
  47326. if m.email != nil {
  47327. fields = append(fields, user.FieldEmail)
  47328. }
  47329. if m.password_hash != nil {
  47330. fields = append(fields, user.FieldPasswordHash)
  47331. }
  47332. if m.role != nil {
  47333. fields = append(fields, user.FieldRole)
  47334. }
  47335. if m.balance != nil {
  47336. fields = append(fields, user.FieldBalance)
  47337. }
  47338. if m.frozen_balance != nil {
  47339. fields = append(fields, user.FieldFrozenBalance)
  47340. }
  47341. if m.concurrency != nil {
  47342. fields = append(fields, user.FieldConcurrency)
  47343. }
  47344. if m.status != nil {
  47345. fields = append(fields, user.FieldStatus)
  47346. }
  47347. if m.username != nil {
  47348. fields = append(fields, user.FieldUsername)
  47349. }
  47350. if m.notes != nil {
  47351. fields = append(fields, user.FieldNotes)
  47352. }
  47353. if m.totp_secret_encrypted != nil {
  47354. fields = append(fields, user.FieldTotpSecretEncrypted)
  47355. }
  47356. if m.totp_enabled != nil {
  47357. fields = append(fields, user.FieldTotpEnabled)
  47358. }
  47359. if m.totp_enabled_at != nil {
  47360. fields = append(fields, user.FieldTotpEnabledAt)
  47361. }
  47362. if m.signup_source != nil {
  47363. fields = append(fields, user.FieldSignupSource)
  47364. }
  47365. if m.last_login_at != nil {
  47366. fields = append(fields, user.FieldLastLoginAt)
  47367. }
  47368. if m.last_active_at != nil {
  47369. fields = append(fields, user.FieldLastActiveAt)
  47370. }
  47371. if m.restrict_public_groups != nil {
  47372. fields = append(fields, user.FieldRestrictPublicGroups)
  47373. }
  47374. if m.balance_notify_enabled != nil {
  47375. fields = append(fields, user.FieldBalanceNotifyEnabled)
  47376. }
  47377. if m.balance_notify_threshold_type != nil {
  47378. fields = append(fields, user.FieldBalanceNotifyThresholdType)
  47379. }
  47380. if m.balance_notify_threshold != nil {
  47381. fields = append(fields, user.FieldBalanceNotifyThreshold)
  47382. }
  47383. if m.balance_notify_extra_emails != nil {
  47384. fields = append(fields, user.FieldBalanceNotifyExtraEmails)
  47385. }
  47386. if m.total_recharged != nil {
  47387. fields = append(fields, user.FieldTotalRecharged)
  47388. }
  47389. if m.rpm_limit != nil {
  47390. fields = append(fields, user.FieldRpmLimit)
  47391. }
  47392. return fields
  47393. }
  47394. // Field returns the value of a field with the given name. The second boolean
  47395. // return value indicates that this field was not set, or was not defined in the
  47396. // schema.
  47397. func (m *UserMutation) Field(name string) (ent.Value, bool) {
  47398. switch name {
  47399. case user.FieldCreatedAt:
  47400. return m.CreatedAt()
  47401. case user.FieldUpdatedAt:
  47402. return m.UpdatedAt()
  47403. case user.FieldDeletedAt:
  47404. return m.DeletedAt()
  47405. case user.FieldEmail:
  47406. return m.Email()
  47407. case user.FieldPasswordHash:
  47408. return m.PasswordHash()
  47409. case user.FieldRole:
  47410. return m.Role()
  47411. case user.FieldBalance:
  47412. return m.Balance()
  47413. case user.FieldFrozenBalance:
  47414. return m.FrozenBalance()
  47415. case user.FieldConcurrency:
  47416. return m.Concurrency()
  47417. case user.FieldStatus:
  47418. return m.Status()
  47419. case user.FieldUsername:
  47420. return m.Username()
  47421. case user.FieldNotes:
  47422. return m.Notes()
  47423. case user.FieldTotpSecretEncrypted:
  47424. return m.TotpSecretEncrypted()
  47425. case user.FieldTotpEnabled:
  47426. return m.TotpEnabled()
  47427. case user.FieldTotpEnabledAt:
  47428. return m.TotpEnabledAt()
  47429. case user.FieldSignupSource:
  47430. return m.SignupSource()
  47431. case user.FieldLastLoginAt:
  47432. return m.LastLoginAt()
  47433. case user.FieldLastActiveAt:
  47434. return m.LastActiveAt()
  47435. case user.FieldRestrictPublicGroups:
  47436. return m.RestrictPublicGroups()
  47437. case user.FieldBalanceNotifyEnabled:
  47438. return m.BalanceNotifyEnabled()
  47439. case user.FieldBalanceNotifyThresholdType:
  47440. return m.BalanceNotifyThresholdType()
  47441. case user.FieldBalanceNotifyThreshold:
  47442. return m.BalanceNotifyThreshold()
  47443. case user.FieldBalanceNotifyExtraEmails:
  47444. return m.BalanceNotifyExtraEmails()
  47445. case user.FieldTotalRecharged:
  47446. return m.TotalRecharged()
  47447. case user.FieldRpmLimit:
  47448. return m.RpmLimit()
  47449. }
  47450. return nil, false
  47451. }
  47452. // OldField returns the old value of the field from the database. An error is
  47453. // returned if the mutation operation is not UpdateOne, or the query to the
  47454. // database failed.
  47455. func (m *UserMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  47456. switch name {
  47457. case user.FieldCreatedAt:
  47458. return m.OldCreatedAt(ctx)
  47459. case user.FieldUpdatedAt:
  47460. return m.OldUpdatedAt(ctx)
  47461. case user.FieldDeletedAt:
  47462. return m.OldDeletedAt(ctx)
  47463. case user.FieldEmail:
  47464. return m.OldEmail(ctx)
  47465. case user.FieldPasswordHash:
  47466. return m.OldPasswordHash(ctx)
  47467. case user.FieldRole:
  47468. return m.OldRole(ctx)
  47469. case user.FieldBalance:
  47470. return m.OldBalance(ctx)
  47471. case user.FieldFrozenBalance:
  47472. return m.OldFrozenBalance(ctx)
  47473. case user.FieldConcurrency:
  47474. return m.OldConcurrency(ctx)
  47475. case user.FieldStatus:
  47476. return m.OldStatus(ctx)
  47477. case user.FieldUsername:
  47478. return m.OldUsername(ctx)
  47479. case user.FieldNotes:
  47480. return m.OldNotes(ctx)
  47481. case user.FieldTotpSecretEncrypted:
  47482. return m.OldTotpSecretEncrypted(ctx)
  47483. case user.FieldTotpEnabled:
  47484. return m.OldTotpEnabled(ctx)
  47485. case user.FieldTotpEnabledAt:
  47486. return m.OldTotpEnabledAt(ctx)
  47487. case user.FieldSignupSource:
  47488. return m.OldSignupSource(ctx)
  47489. case user.FieldLastLoginAt:
  47490. return m.OldLastLoginAt(ctx)
  47491. case user.FieldLastActiveAt:
  47492. return m.OldLastActiveAt(ctx)
  47493. case user.FieldRestrictPublicGroups:
  47494. return m.OldRestrictPublicGroups(ctx)
  47495. case user.FieldBalanceNotifyEnabled:
  47496. return m.OldBalanceNotifyEnabled(ctx)
  47497. case user.FieldBalanceNotifyThresholdType:
  47498. return m.OldBalanceNotifyThresholdType(ctx)
  47499. case user.FieldBalanceNotifyThreshold:
  47500. return m.OldBalanceNotifyThreshold(ctx)
  47501. case user.FieldBalanceNotifyExtraEmails:
  47502. return m.OldBalanceNotifyExtraEmails(ctx)
  47503. case user.FieldTotalRecharged:
  47504. return m.OldTotalRecharged(ctx)
  47505. case user.FieldRpmLimit:
  47506. return m.OldRpmLimit(ctx)
  47507. }
  47508. return nil, fmt.Errorf("unknown User field %s", name)
  47509. }
  47510. // SetField sets the value of a field with the given name. It returns an error if
  47511. // the field is not defined in the schema, or if the type mismatched the field
  47512. // type.
  47513. func (m *UserMutation) SetField(name string, value ent.Value) error {
  47514. switch name {
  47515. case user.FieldCreatedAt:
  47516. v, ok := value.(time.Time)
  47517. if !ok {
  47518. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47519. }
  47520. m.SetCreatedAt(v)
  47521. return nil
  47522. case user.FieldUpdatedAt:
  47523. v, ok := value.(time.Time)
  47524. if !ok {
  47525. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47526. }
  47527. m.SetUpdatedAt(v)
  47528. return nil
  47529. case user.FieldDeletedAt:
  47530. v, ok := value.(time.Time)
  47531. if !ok {
  47532. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47533. }
  47534. m.SetDeletedAt(v)
  47535. return nil
  47536. case user.FieldEmail:
  47537. v, ok := value.(string)
  47538. if !ok {
  47539. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47540. }
  47541. m.SetEmail(v)
  47542. return nil
  47543. case user.FieldPasswordHash:
  47544. v, ok := value.(string)
  47545. if !ok {
  47546. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47547. }
  47548. m.SetPasswordHash(v)
  47549. return nil
  47550. case user.FieldRole:
  47551. v, ok := value.(string)
  47552. if !ok {
  47553. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47554. }
  47555. m.SetRole(v)
  47556. return nil
  47557. case user.FieldBalance:
  47558. v, ok := value.(float64)
  47559. if !ok {
  47560. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47561. }
  47562. m.SetBalance(v)
  47563. return nil
  47564. case user.FieldFrozenBalance:
  47565. v, ok := value.(float64)
  47566. if !ok {
  47567. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47568. }
  47569. m.SetFrozenBalance(v)
  47570. return nil
  47571. case user.FieldConcurrency:
  47572. v, ok := value.(int)
  47573. if !ok {
  47574. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47575. }
  47576. m.SetConcurrency(v)
  47577. return nil
  47578. case user.FieldStatus:
  47579. v, ok := value.(string)
  47580. if !ok {
  47581. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47582. }
  47583. m.SetStatus(v)
  47584. return nil
  47585. case user.FieldUsername:
  47586. v, ok := value.(string)
  47587. if !ok {
  47588. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47589. }
  47590. m.SetUsername(v)
  47591. return nil
  47592. case user.FieldNotes:
  47593. v, ok := value.(string)
  47594. if !ok {
  47595. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47596. }
  47597. m.SetNotes(v)
  47598. return nil
  47599. case user.FieldTotpSecretEncrypted:
  47600. v, ok := value.(string)
  47601. if !ok {
  47602. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47603. }
  47604. m.SetTotpSecretEncrypted(v)
  47605. return nil
  47606. case user.FieldTotpEnabled:
  47607. v, ok := value.(bool)
  47608. if !ok {
  47609. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47610. }
  47611. m.SetTotpEnabled(v)
  47612. return nil
  47613. case user.FieldTotpEnabledAt:
  47614. v, ok := value.(time.Time)
  47615. if !ok {
  47616. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47617. }
  47618. m.SetTotpEnabledAt(v)
  47619. return nil
  47620. case user.FieldSignupSource:
  47621. v, ok := value.(string)
  47622. if !ok {
  47623. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47624. }
  47625. m.SetSignupSource(v)
  47626. return nil
  47627. case user.FieldLastLoginAt:
  47628. v, ok := value.(time.Time)
  47629. if !ok {
  47630. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47631. }
  47632. m.SetLastLoginAt(v)
  47633. return nil
  47634. case user.FieldLastActiveAt:
  47635. v, ok := value.(time.Time)
  47636. if !ok {
  47637. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47638. }
  47639. m.SetLastActiveAt(v)
  47640. return nil
  47641. case user.FieldRestrictPublicGroups:
  47642. v, ok := value.(bool)
  47643. if !ok {
  47644. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47645. }
  47646. m.SetRestrictPublicGroups(v)
  47647. return nil
  47648. case user.FieldBalanceNotifyEnabled:
  47649. v, ok := value.(bool)
  47650. if !ok {
  47651. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47652. }
  47653. m.SetBalanceNotifyEnabled(v)
  47654. return nil
  47655. case user.FieldBalanceNotifyThresholdType:
  47656. v, ok := value.(string)
  47657. if !ok {
  47658. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47659. }
  47660. m.SetBalanceNotifyThresholdType(v)
  47661. return nil
  47662. case user.FieldBalanceNotifyThreshold:
  47663. v, ok := value.(float64)
  47664. if !ok {
  47665. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47666. }
  47667. m.SetBalanceNotifyThreshold(v)
  47668. return nil
  47669. case user.FieldBalanceNotifyExtraEmails:
  47670. v, ok := value.(string)
  47671. if !ok {
  47672. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47673. }
  47674. m.SetBalanceNotifyExtraEmails(v)
  47675. return nil
  47676. case user.FieldTotalRecharged:
  47677. v, ok := value.(float64)
  47678. if !ok {
  47679. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47680. }
  47681. m.SetTotalRecharged(v)
  47682. return nil
  47683. case user.FieldRpmLimit:
  47684. v, ok := value.(int)
  47685. if !ok {
  47686. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47687. }
  47688. m.SetRpmLimit(v)
  47689. return nil
  47690. }
  47691. return fmt.Errorf("unknown User field %s", name)
  47692. }
  47693. // AddedFields returns all numeric fields that were incremented/decremented during
  47694. // this mutation.
  47695. func (m *UserMutation) AddedFields() []string {
  47696. var fields []string
  47697. if m.addbalance != nil {
  47698. fields = append(fields, user.FieldBalance)
  47699. }
  47700. if m.addfrozen_balance != nil {
  47701. fields = append(fields, user.FieldFrozenBalance)
  47702. }
  47703. if m.addconcurrency != nil {
  47704. fields = append(fields, user.FieldConcurrency)
  47705. }
  47706. if m.addbalance_notify_threshold != nil {
  47707. fields = append(fields, user.FieldBalanceNotifyThreshold)
  47708. }
  47709. if m.addtotal_recharged != nil {
  47710. fields = append(fields, user.FieldTotalRecharged)
  47711. }
  47712. if m.addrpm_limit != nil {
  47713. fields = append(fields, user.FieldRpmLimit)
  47714. }
  47715. return fields
  47716. }
  47717. // AddedField returns the numeric value that was incremented/decremented on a field
  47718. // with the given name. The second boolean return value indicates that this field
  47719. // was not set, or was not defined in the schema.
  47720. func (m *UserMutation) AddedField(name string) (ent.Value, bool) {
  47721. switch name {
  47722. case user.FieldBalance:
  47723. return m.AddedBalance()
  47724. case user.FieldFrozenBalance:
  47725. return m.AddedFrozenBalance()
  47726. case user.FieldConcurrency:
  47727. return m.AddedConcurrency()
  47728. case user.FieldBalanceNotifyThreshold:
  47729. return m.AddedBalanceNotifyThreshold()
  47730. case user.FieldTotalRecharged:
  47731. return m.AddedTotalRecharged()
  47732. case user.FieldRpmLimit:
  47733. return m.AddedRpmLimit()
  47734. }
  47735. return nil, false
  47736. }
  47737. // AddField adds the value to the field with the given name. It returns an error if
  47738. // the field is not defined in the schema, or if the type mismatched the field
  47739. // type.
  47740. func (m *UserMutation) AddField(name string, value ent.Value) error {
  47741. switch name {
  47742. case user.FieldBalance:
  47743. v, ok := value.(float64)
  47744. if !ok {
  47745. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47746. }
  47747. m.AddBalance(v)
  47748. return nil
  47749. case user.FieldFrozenBalance:
  47750. v, ok := value.(float64)
  47751. if !ok {
  47752. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47753. }
  47754. m.AddFrozenBalance(v)
  47755. return nil
  47756. case user.FieldConcurrency:
  47757. v, ok := value.(int)
  47758. if !ok {
  47759. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47760. }
  47761. m.AddConcurrency(v)
  47762. return nil
  47763. case user.FieldBalanceNotifyThreshold:
  47764. v, ok := value.(float64)
  47765. if !ok {
  47766. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47767. }
  47768. m.AddBalanceNotifyThreshold(v)
  47769. return nil
  47770. case user.FieldTotalRecharged:
  47771. v, ok := value.(float64)
  47772. if !ok {
  47773. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47774. }
  47775. m.AddTotalRecharged(v)
  47776. return nil
  47777. case user.FieldRpmLimit:
  47778. v, ok := value.(int)
  47779. if !ok {
  47780. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47781. }
  47782. m.AddRpmLimit(v)
  47783. return nil
  47784. }
  47785. return fmt.Errorf("unknown User numeric field %s", name)
  47786. }
  47787. // ClearedFields returns all nullable fields that were cleared during this
  47788. // mutation.
  47789. func (m *UserMutation) ClearedFields() []string {
  47790. var fields []string
  47791. if m.FieldCleared(user.FieldDeletedAt) {
  47792. fields = append(fields, user.FieldDeletedAt)
  47793. }
  47794. if m.FieldCleared(user.FieldTotpSecretEncrypted) {
  47795. fields = append(fields, user.FieldTotpSecretEncrypted)
  47796. }
  47797. if m.FieldCleared(user.FieldTotpEnabledAt) {
  47798. fields = append(fields, user.FieldTotpEnabledAt)
  47799. }
  47800. if m.FieldCleared(user.FieldLastLoginAt) {
  47801. fields = append(fields, user.FieldLastLoginAt)
  47802. }
  47803. if m.FieldCleared(user.FieldLastActiveAt) {
  47804. fields = append(fields, user.FieldLastActiveAt)
  47805. }
  47806. if m.FieldCleared(user.FieldBalanceNotifyThreshold) {
  47807. fields = append(fields, user.FieldBalanceNotifyThreshold)
  47808. }
  47809. return fields
  47810. }
  47811. // FieldCleared returns a boolean indicating if a field with the given name was
  47812. // cleared in this mutation.
  47813. func (m *UserMutation) FieldCleared(name string) bool {
  47814. _, ok := m.clearedFields[name]
  47815. return ok
  47816. }
  47817. // ClearField clears the value of the field with the given name. It returns an
  47818. // error if the field is not defined in the schema.
  47819. func (m *UserMutation) ClearField(name string) error {
  47820. switch name {
  47821. case user.FieldDeletedAt:
  47822. m.ClearDeletedAt()
  47823. return nil
  47824. case user.FieldTotpSecretEncrypted:
  47825. m.ClearTotpSecretEncrypted()
  47826. return nil
  47827. case user.FieldTotpEnabledAt:
  47828. m.ClearTotpEnabledAt()
  47829. return nil
  47830. case user.FieldLastLoginAt:
  47831. m.ClearLastLoginAt()
  47832. return nil
  47833. case user.FieldLastActiveAt:
  47834. m.ClearLastActiveAt()
  47835. return nil
  47836. case user.FieldBalanceNotifyThreshold:
  47837. m.ClearBalanceNotifyThreshold()
  47838. return nil
  47839. }
  47840. return fmt.Errorf("unknown User nullable field %s", name)
  47841. }
  47842. // ResetField resets all changes in the mutation for the field with the given name.
  47843. // It returns an error if the field is not defined in the schema.
  47844. func (m *UserMutation) ResetField(name string) error {
  47845. switch name {
  47846. case user.FieldCreatedAt:
  47847. m.ResetCreatedAt()
  47848. return nil
  47849. case user.FieldUpdatedAt:
  47850. m.ResetUpdatedAt()
  47851. return nil
  47852. case user.FieldDeletedAt:
  47853. m.ResetDeletedAt()
  47854. return nil
  47855. case user.FieldEmail:
  47856. m.ResetEmail()
  47857. return nil
  47858. case user.FieldPasswordHash:
  47859. m.ResetPasswordHash()
  47860. return nil
  47861. case user.FieldRole:
  47862. m.ResetRole()
  47863. return nil
  47864. case user.FieldBalance:
  47865. m.ResetBalance()
  47866. return nil
  47867. case user.FieldFrozenBalance:
  47868. m.ResetFrozenBalance()
  47869. return nil
  47870. case user.FieldConcurrency:
  47871. m.ResetConcurrency()
  47872. return nil
  47873. case user.FieldStatus:
  47874. m.ResetStatus()
  47875. return nil
  47876. case user.FieldUsername:
  47877. m.ResetUsername()
  47878. return nil
  47879. case user.FieldNotes:
  47880. m.ResetNotes()
  47881. return nil
  47882. case user.FieldTotpSecretEncrypted:
  47883. m.ResetTotpSecretEncrypted()
  47884. return nil
  47885. case user.FieldTotpEnabled:
  47886. m.ResetTotpEnabled()
  47887. return nil
  47888. case user.FieldTotpEnabledAt:
  47889. m.ResetTotpEnabledAt()
  47890. return nil
  47891. case user.FieldSignupSource:
  47892. m.ResetSignupSource()
  47893. return nil
  47894. case user.FieldLastLoginAt:
  47895. m.ResetLastLoginAt()
  47896. return nil
  47897. case user.FieldLastActiveAt:
  47898. m.ResetLastActiveAt()
  47899. return nil
  47900. case user.FieldRestrictPublicGroups:
  47901. m.ResetRestrictPublicGroups()
  47902. return nil
  47903. case user.FieldBalanceNotifyEnabled:
  47904. m.ResetBalanceNotifyEnabled()
  47905. return nil
  47906. case user.FieldBalanceNotifyThresholdType:
  47907. m.ResetBalanceNotifyThresholdType()
  47908. return nil
  47909. case user.FieldBalanceNotifyThreshold:
  47910. m.ResetBalanceNotifyThreshold()
  47911. return nil
  47912. case user.FieldBalanceNotifyExtraEmails:
  47913. m.ResetBalanceNotifyExtraEmails()
  47914. return nil
  47915. case user.FieldTotalRecharged:
  47916. m.ResetTotalRecharged()
  47917. return nil
  47918. case user.FieldRpmLimit:
  47919. m.ResetRpmLimit()
  47920. return nil
  47921. }
  47922. return fmt.Errorf("unknown User field %s", name)
  47923. }
  47924. // AddedEdges returns all edge names that were set/added in this mutation.
  47925. func (m *UserMutation) AddedEdges() []string {
  47926. edges := make([]string, 0, 13)
  47927. if m.api_keys != nil {
  47928. edges = append(edges, user.EdgeAPIKeys)
  47929. }
  47930. if m.redeem_codes != nil {
  47931. edges = append(edges, user.EdgeRedeemCodes)
  47932. }
  47933. if m.subscriptions != nil {
  47934. edges = append(edges, user.EdgeSubscriptions)
  47935. }
  47936. if m.assigned_subscriptions != nil {
  47937. edges = append(edges, user.EdgeAssignedSubscriptions)
  47938. }
  47939. if m.announcement_reads != nil {
  47940. edges = append(edges, user.EdgeAnnouncementReads)
  47941. }
  47942. if m.allowed_groups != nil {
  47943. edges = append(edges, user.EdgeAllowedGroups)
  47944. }
  47945. if m.usage_logs != nil {
  47946. edges = append(edges, user.EdgeUsageLogs)
  47947. }
  47948. if m.attribute_values != nil {
  47949. edges = append(edges, user.EdgeAttributeValues)
  47950. }
  47951. if m.promo_code_usages != nil {
  47952. edges = append(edges, user.EdgePromoCodeUsages)
  47953. }
  47954. if m.payment_orders != nil {
  47955. edges = append(edges, user.EdgePaymentOrders)
  47956. }
  47957. if m.auth_identities != nil {
  47958. edges = append(edges, user.EdgeAuthIdentities)
  47959. }
  47960. if m.pending_auth_sessions != nil {
  47961. edges = append(edges, user.EdgePendingAuthSessions)
  47962. }
  47963. if m.platform_quotas != nil {
  47964. edges = append(edges, user.EdgePlatformQuotas)
  47965. }
  47966. return edges
  47967. }
  47968. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  47969. // name in this mutation.
  47970. func (m *UserMutation) AddedIDs(name string) []ent.Value {
  47971. switch name {
  47972. case user.EdgeAPIKeys:
  47973. ids := make([]ent.Value, 0, len(m.api_keys))
  47974. for id := range m.api_keys {
  47975. ids = append(ids, id)
  47976. }
  47977. return ids
  47978. case user.EdgeRedeemCodes:
  47979. ids := make([]ent.Value, 0, len(m.redeem_codes))
  47980. for id := range m.redeem_codes {
  47981. ids = append(ids, id)
  47982. }
  47983. return ids
  47984. case user.EdgeSubscriptions:
  47985. ids := make([]ent.Value, 0, len(m.subscriptions))
  47986. for id := range m.subscriptions {
  47987. ids = append(ids, id)
  47988. }
  47989. return ids
  47990. case user.EdgeAssignedSubscriptions:
  47991. ids := make([]ent.Value, 0, len(m.assigned_subscriptions))
  47992. for id := range m.assigned_subscriptions {
  47993. ids = append(ids, id)
  47994. }
  47995. return ids
  47996. case user.EdgeAnnouncementReads:
  47997. ids := make([]ent.Value, 0, len(m.announcement_reads))
  47998. for id := range m.announcement_reads {
  47999. ids = append(ids, id)
  48000. }
  48001. return ids
  48002. case user.EdgeAllowedGroups:
  48003. ids := make([]ent.Value, 0, len(m.allowed_groups))
  48004. for id := range m.allowed_groups {
  48005. ids = append(ids, id)
  48006. }
  48007. return ids
  48008. case user.EdgeUsageLogs:
  48009. ids := make([]ent.Value, 0, len(m.usage_logs))
  48010. for id := range m.usage_logs {
  48011. ids = append(ids, id)
  48012. }
  48013. return ids
  48014. case user.EdgeAttributeValues:
  48015. ids := make([]ent.Value, 0, len(m.attribute_values))
  48016. for id := range m.attribute_values {
  48017. ids = append(ids, id)
  48018. }
  48019. return ids
  48020. case user.EdgePromoCodeUsages:
  48021. ids := make([]ent.Value, 0, len(m.promo_code_usages))
  48022. for id := range m.promo_code_usages {
  48023. ids = append(ids, id)
  48024. }
  48025. return ids
  48026. case user.EdgePaymentOrders:
  48027. ids := make([]ent.Value, 0, len(m.payment_orders))
  48028. for id := range m.payment_orders {
  48029. ids = append(ids, id)
  48030. }
  48031. return ids
  48032. case user.EdgeAuthIdentities:
  48033. ids := make([]ent.Value, 0, len(m.auth_identities))
  48034. for id := range m.auth_identities {
  48035. ids = append(ids, id)
  48036. }
  48037. return ids
  48038. case user.EdgePendingAuthSessions:
  48039. ids := make([]ent.Value, 0, len(m.pending_auth_sessions))
  48040. for id := range m.pending_auth_sessions {
  48041. ids = append(ids, id)
  48042. }
  48043. return ids
  48044. case user.EdgePlatformQuotas:
  48045. ids := make([]ent.Value, 0, len(m.platform_quotas))
  48046. for id := range m.platform_quotas {
  48047. ids = append(ids, id)
  48048. }
  48049. return ids
  48050. }
  48051. return nil
  48052. }
  48053. // RemovedEdges returns all edge names that were removed in this mutation.
  48054. func (m *UserMutation) RemovedEdges() []string {
  48055. edges := make([]string, 0, 13)
  48056. if m.removedapi_keys != nil {
  48057. edges = append(edges, user.EdgeAPIKeys)
  48058. }
  48059. if m.removedredeem_codes != nil {
  48060. edges = append(edges, user.EdgeRedeemCodes)
  48061. }
  48062. if m.removedsubscriptions != nil {
  48063. edges = append(edges, user.EdgeSubscriptions)
  48064. }
  48065. if m.removedassigned_subscriptions != nil {
  48066. edges = append(edges, user.EdgeAssignedSubscriptions)
  48067. }
  48068. if m.removedannouncement_reads != nil {
  48069. edges = append(edges, user.EdgeAnnouncementReads)
  48070. }
  48071. if m.removedallowed_groups != nil {
  48072. edges = append(edges, user.EdgeAllowedGroups)
  48073. }
  48074. if m.removedusage_logs != nil {
  48075. edges = append(edges, user.EdgeUsageLogs)
  48076. }
  48077. if m.removedattribute_values != nil {
  48078. edges = append(edges, user.EdgeAttributeValues)
  48079. }
  48080. if m.removedpromo_code_usages != nil {
  48081. edges = append(edges, user.EdgePromoCodeUsages)
  48082. }
  48083. if m.removedpayment_orders != nil {
  48084. edges = append(edges, user.EdgePaymentOrders)
  48085. }
  48086. if m.removedauth_identities != nil {
  48087. edges = append(edges, user.EdgeAuthIdentities)
  48088. }
  48089. if m.removedpending_auth_sessions != nil {
  48090. edges = append(edges, user.EdgePendingAuthSessions)
  48091. }
  48092. if m.removedplatform_quotas != nil {
  48093. edges = append(edges, user.EdgePlatformQuotas)
  48094. }
  48095. return edges
  48096. }
  48097. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  48098. // the given name in this mutation.
  48099. func (m *UserMutation) RemovedIDs(name string) []ent.Value {
  48100. switch name {
  48101. case user.EdgeAPIKeys:
  48102. ids := make([]ent.Value, 0, len(m.removedapi_keys))
  48103. for id := range m.removedapi_keys {
  48104. ids = append(ids, id)
  48105. }
  48106. return ids
  48107. case user.EdgeRedeemCodes:
  48108. ids := make([]ent.Value, 0, len(m.removedredeem_codes))
  48109. for id := range m.removedredeem_codes {
  48110. ids = append(ids, id)
  48111. }
  48112. return ids
  48113. case user.EdgeSubscriptions:
  48114. ids := make([]ent.Value, 0, len(m.removedsubscriptions))
  48115. for id := range m.removedsubscriptions {
  48116. ids = append(ids, id)
  48117. }
  48118. return ids
  48119. case user.EdgeAssignedSubscriptions:
  48120. ids := make([]ent.Value, 0, len(m.removedassigned_subscriptions))
  48121. for id := range m.removedassigned_subscriptions {
  48122. ids = append(ids, id)
  48123. }
  48124. return ids
  48125. case user.EdgeAnnouncementReads:
  48126. ids := make([]ent.Value, 0, len(m.removedannouncement_reads))
  48127. for id := range m.removedannouncement_reads {
  48128. ids = append(ids, id)
  48129. }
  48130. return ids
  48131. case user.EdgeAllowedGroups:
  48132. ids := make([]ent.Value, 0, len(m.removedallowed_groups))
  48133. for id := range m.removedallowed_groups {
  48134. ids = append(ids, id)
  48135. }
  48136. return ids
  48137. case user.EdgeUsageLogs:
  48138. ids := make([]ent.Value, 0, len(m.removedusage_logs))
  48139. for id := range m.removedusage_logs {
  48140. ids = append(ids, id)
  48141. }
  48142. return ids
  48143. case user.EdgeAttributeValues:
  48144. ids := make([]ent.Value, 0, len(m.removedattribute_values))
  48145. for id := range m.removedattribute_values {
  48146. ids = append(ids, id)
  48147. }
  48148. return ids
  48149. case user.EdgePromoCodeUsages:
  48150. ids := make([]ent.Value, 0, len(m.removedpromo_code_usages))
  48151. for id := range m.removedpromo_code_usages {
  48152. ids = append(ids, id)
  48153. }
  48154. return ids
  48155. case user.EdgePaymentOrders:
  48156. ids := make([]ent.Value, 0, len(m.removedpayment_orders))
  48157. for id := range m.removedpayment_orders {
  48158. ids = append(ids, id)
  48159. }
  48160. return ids
  48161. case user.EdgeAuthIdentities:
  48162. ids := make([]ent.Value, 0, len(m.removedauth_identities))
  48163. for id := range m.removedauth_identities {
  48164. ids = append(ids, id)
  48165. }
  48166. return ids
  48167. case user.EdgePendingAuthSessions:
  48168. ids := make([]ent.Value, 0, len(m.removedpending_auth_sessions))
  48169. for id := range m.removedpending_auth_sessions {
  48170. ids = append(ids, id)
  48171. }
  48172. return ids
  48173. case user.EdgePlatformQuotas:
  48174. ids := make([]ent.Value, 0, len(m.removedplatform_quotas))
  48175. for id := range m.removedplatform_quotas {
  48176. ids = append(ids, id)
  48177. }
  48178. return ids
  48179. }
  48180. return nil
  48181. }
  48182. // ClearedEdges returns all edge names that were cleared in this mutation.
  48183. func (m *UserMutation) ClearedEdges() []string {
  48184. edges := make([]string, 0, 13)
  48185. if m.clearedapi_keys {
  48186. edges = append(edges, user.EdgeAPIKeys)
  48187. }
  48188. if m.clearedredeem_codes {
  48189. edges = append(edges, user.EdgeRedeemCodes)
  48190. }
  48191. if m.clearedsubscriptions {
  48192. edges = append(edges, user.EdgeSubscriptions)
  48193. }
  48194. if m.clearedassigned_subscriptions {
  48195. edges = append(edges, user.EdgeAssignedSubscriptions)
  48196. }
  48197. if m.clearedannouncement_reads {
  48198. edges = append(edges, user.EdgeAnnouncementReads)
  48199. }
  48200. if m.clearedallowed_groups {
  48201. edges = append(edges, user.EdgeAllowedGroups)
  48202. }
  48203. if m.clearedusage_logs {
  48204. edges = append(edges, user.EdgeUsageLogs)
  48205. }
  48206. if m.clearedattribute_values {
  48207. edges = append(edges, user.EdgeAttributeValues)
  48208. }
  48209. if m.clearedpromo_code_usages {
  48210. edges = append(edges, user.EdgePromoCodeUsages)
  48211. }
  48212. if m.clearedpayment_orders {
  48213. edges = append(edges, user.EdgePaymentOrders)
  48214. }
  48215. if m.clearedauth_identities {
  48216. edges = append(edges, user.EdgeAuthIdentities)
  48217. }
  48218. if m.clearedpending_auth_sessions {
  48219. edges = append(edges, user.EdgePendingAuthSessions)
  48220. }
  48221. if m.clearedplatform_quotas {
  48222. edges = append(edges, user.EdgePlatformQuotas)
  48223. }
  48224. return edges
  48225. }
  48226. // EdgeCleared returns a boolean which indicates if the edge with the given name
  48227. // was cleared in this mutation.
  48228. func (m *UserMutation) EdgeCleared(name string) bool {
  48229. switch name {
  48230. case user.EdgeAPIKeys:
  48231. return m.clearedapi_keys
  48232. case user.EdgeRedeemCodes:
  48233. return m.clearedredeem_codes
  48234. case user.EdgeSubscriptions:
  48235. return m.clearedsubscriptions
  48236. case user.EdgeAssignedSubscriptions:
  48237. return m.clearedassigned_subscriptions
  48238. case user.EdgeAnnouncementReads:
  48239. return m.clearedannouncement_reads
  48240. case user.EdgeAllowedGroups:
  48241. return m.clearedallowed_groups
  48242. case user.EdgeUsageLogs:
  48243. return m.clearedusage_logs
  48244. case user.EdgeAttributeValues:
  48245. return m.clearedattribute_values
  48246. case user.EdgePromoCodeUsages:
  48247. return m.clearedpromo_code_usages
  48248. case user.EdgePaymentOrders:
  48249. return m.clearedpayment_orders
  48250. case user.EdgeAuthIdentities:
  48251. return m.clearedauth_identities
  48252. case user.EdgePendingAuthSessions:
  48253. return m.clearedpending_auth_sessions
  48254. case user.EdgePlatformQuotas:
  48255. return m.clearedplatform_quotas
  48256. }
  48257. return false
  48258. }
  48259. // ClearEdge clears the value of the edge with the given name. It returns an error
  48260. // if that edge is not defined in the schema.
  48261. func (m *UserMutation) ClearEdge(name string) error {
  48262. switch name {
  48263. }
  48264. return fmt.Errorf("unknown User unique edge %s", name)
  48265. }
  48266. // ResetEdge resets all changes to the edge with the given name in this mutation.
  48267. // It returns an error if the edge is not defined in the schema.
  48268. func (m *UserMutation) ResetEdge(name string) error {
  48269. switch name {
  48270. case user.EdgeAPIKeys:
  48271. m.ResetAPIKeys()
  48272. return nil
  48273. case user.EdgeRedeemCodes:
  48274. m.ResetRedeemCodes()
  48275. return nil
  48276. case user.EdgeSubscriptions:
  48277. m.ResetSubscriptions()
  48278. return nil
  48279. case user.EdgeAssignedSubscriptions:
  48280. m.ResetAssignedSubscriptions()
  48281. return nil
  48282. case user.EdgeAnnouncementReads:
  48283. m.ResetAnnouncementReads()
  48284. return nil
  48285. case user.EdgeAllowedGroups:
  48286. m.ResetAllowedGroups()
  48287. return nil
  48288. case user.EdgeUsageLogs:
  48289. m.ResetUsageLogs()
  48290. return nil
  48291. case user.EdgeAttributeValues:
  48292. m.ResetAttributeValues()
  48293. return nil
  48294. case user.EdgePromoCodeUsages:
  48295. m.ResetPromoCodeUsages()
  48296. return nil
  48297. case user.EdgePaymentOrders:
  48298. m.ResetPaymentOrders()
  48299. return nil
  48300. case user.EdgeAuthIdentities:
  48301. m.ResetAuthIdentities()
  48302. return nil
  48303. case user.EdgePendingAuthSessions:
  48304. m.ResetPendingAuthSessions()
  48305. return nil
  48306. case user.EdgePlatformQuotas:
  48307. m.ResetPlatformQuotas()
  48308. return nil
  48309. }
  48310. return fmt.Errorf("unknown User edge %s", name)
  48311. }
  48312. // UserAllowedGroupMutation represents an operation that mutates the UserAllowedGroup nodes in the graph.
  48313. type UserAllowedGroupMutation struct {
  48314. config
  48315. op Op
  48316. typ string
  48317. created_at *time.Time
  48318. clearedFields map[string]struct{}
  48319. user *int64
  48320. cleareduser bool
  48321. group *int64
  48322. clearedgroup bool
  48323. done bool
  48324. oldValue func(context.Context) (*UserAllowedGroup, error)
  48325. predicates []predicate.UserAllowedGroup
  48326. }
  48327. var _ ent.Mutation = (*UserAllowedGroupMutation)(nil)
  48328. // userallowedgroupOption allows management of the mutation configuration using functional options.
  48329. type userallowedgroupOption func(*UserAllowedGroupMutation)
  48330. // newUserAllowedGroupMutation creates new mutation for the UserAllowedGroup entity.
  48331. func newUserAllowedGroupMutation(c config, op Op, opts ...userallowedgroupOption) *UserAllowedGroupMutation {
  48332. m := &UserAllowedGroupMutation{
  48333. config: c,
  48334. op: op,
  48335. typ: TypeUserAllowedGroup,
  48336. clearedFields: make(map[string]struct{}),
  48337. }
  48338. for _, opt := range opts {
  48339. opt(m)
  48340. }
  48341. return m
  48342. }
  48343. // Client returns a new `ent.Client` from the mutation. If the mutation was
  48344. // executed in a transaction (ent.Tx), a transactional client is returned.
  48345. func (m UserAllowedGroupMutation) Client() *Client {
  48346. client := &Client{config: m.config}
  48347. client.init()
  48348. return client
  48349. }
  48350. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  48351. // it returns an error otherwise.
  48352. func (m UserAllowedGroupMutation) Tx() (*Tx, error) {
  48353. if _, ok := m.driver.(*txDriver); !ok {
  48354. return nil, errors.New("ent: mutation is not running in a transaction")
  48355. }
  48356. tx := &Tx{config: m.config}
  48357. tx.init()
  48358. return tx, nil
  48359. }
  48360. // SetUserID sets the "user_id" field.
  48361. func (m *UserAllowedGroupMutation) SetUserID(i int64) {
  48362. m.user = &i
  48363. }
  48364. // UserID returns the value of the "user_id" field in the mutation.
  48365. func (m *UserAllowedGroupMutation) UserID() (r int64, exists bool) {
  48366. v := m.user
  48367. if v == nil {
  48368. return
  48369. }
  48370. return *v, true
  48371. }
  48372. // ResetUserID resets all changes to the "user_id" field.
  48373. func (m *UserAllowedGroupMutation) ResetUserID() {
  48374. m.user = nil
  48375. }
  48376. // SetGroupID sets the "group_id" field.
  48377. func (m *UserAllowedGroupMutation) SetGroupID(i int64) {
  48378. m.group = &i
  48379. }
  48380. // GroupID returns the value of the "group_id" field in the mutation.
  48381. func (m *UserAllowedGroupMutation) GroupID() (r int64, exists bool) {
  48382. v := m.group
  48383. if v == nil {
  48384. return
  48385. }
  48386. return *v, true
  48387. }
  48388. // ResetGroupID resets all changes to the "group_id" field.
  48389. func (m *UserAllowedGroupMutation) ResetGroupID() {
  48390. m.group = nil
  48391. }
  48392. // SetCreatedAt sets the "created_at" field.
  48393. func (m *UserAllowedGroupMutation) SetCreatedAt(t time.Time) {
  48394. m.created_at = &t
  48395. }
  48396. // CreatedAt returns the value of the "created_at" field in the mutation.
  48397. func (m *UserAllowedGroupMutation) CreatedAt() (r time.Time, exists bool) {
  48398. v := m.created_at
  48399. if v == nil {
  48400. return
  48401. }
  48402. return *v, true
  48403. }
  48404. // ResetCreatedAt resets all changes to the "created_at" field.
  48405. func (m *UserAllowedGroupMutation) ResetCreatedAt() {
  48406. m.created_at = nil
  48407. }
  48408. // ClearUser clears the "user" edge to the User entity.
  48409. func (m *UserAllowedGroupMutation) ClearUser() {
  48410. m.cleareduser = true
  48411. m.clearedFields[userallowedgroup.FieldUserID] = struct{}{}
  48412. }
  48413. // UserCleared reports if the "user" edge to the User entity was cleared.
  48414. func (m *UserAllowedGroupMutation) UserCleared() bool {
  48415. return m.cleareduser
  48416. }
  48417. // UserIDs returns the "user" edge IDs in the mutation.
  48418. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  48419. // UserID instead. It exists only for internal usage by the builders.
  48420. func (m *UserAllowedGroupMutation) UserIDs() (ids []int64) {
  48421. if id := m.user; id != nil {
  48422. ids = append(ids, *id)
  48423. }
  48424. return
  48425. }
  48426. // ResetUser resets all changes to the "user" edge.
  48427. func (m *UserAllowedGroupMutation) ResetUser() {
  48428. m.user = nil
  48429. m.cleareduser = false
  48430. }
  48431. // ClearGroup clears the "group" edge to the Group entity.
  48432. func (m *UserAllowedGroupMutation) ClearGroup() {
  48433. m.clearedgroup = true
  48434. m.clearedFields[userallowedgroup.FieldGroupID] = struct{}{}
  48435. }
  48436. // GroupCleared reports if the "group" edge to the Group entity was cleared.
  48437. func (m *UserAllowedGroupMutation) GroupCleared() bool {
  48438. return m.clearedgroup
  48439. }
  48440. // GroupIDs returns the "group" edge IDs in the mutation.
  48441. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  48442. // GroupID instead. It exists only for internal usage by the builders.
  48443. func (m *UserAllowedGroupMutation) GroupIDs() (ids []int64) {
  48444. if id := m.group; id != nil {
  48445. ids = append(ids, *id)
  48446. }
  48447. return
  48448. }
  48449. // ResetGroup resets all changes to the "group" edge.
  48450. func (m *UserAllowedGroupMutation) ResetGroup() {
  48451. m.group = nil
  48452. m.clearedgroup = false
  48453. }
  48454. // Where appends a list predicates to the UserAllowedGroupMutation builder.
  48455. func (m *UserAllowedGroupMutation) Where(ps ...predicate.UserAllowedGroup) {
  48456. m.predicates = append(m.predicates, ps...)
  48457. }
  48458. // WhereP appends storage-level predicates to the UserAllowedGroupMutation builder. Using this method,
  48459. // users can use type-assertion to append predicates that do not depend on any generated package.
  48460. func (m *UserAllowedGroupMutation) WhereP(ps ...func(*sql.Selector)) {
  48461. p := make([]predicate.UserAllowedGroup, len(ps))
  48462. for i := range ps {
  48463. p[i] = ps[i]
  48464. }
  48465. m.Where(p...)
  48466. }
  48467. // Op returns the operation name.
  48468. func (m *UserAllowedGroupMutation) Op() Op {
  48469. return m.op
  48470. }
  48471. // SetOp allows setting the mutation operation.
  48472. func (m *UserAllowedGroupMutation) SetOp(op Op) {
  48473. m.op = op
  48474. }
  48475. // Type returns the node type of this mutation (UserAllowedGroup).
  48476. func (m *UserAllowedGroupMutation) Type() string {
  48477. return m.typ
  48478. }
  48479. // Fields returns all fields that were changed during this mutation. Note that in
  48480. // order to get all numeric fields that were incremented/decremented, call
  48481. // AddedFields().
  48482. func (m *UserAllowedGroupMutation) Fields() []string {
  48483. fields := make([]string, 0, 3)
  48484. if m.user != nil {
  48485. fields = append(fields, userallowedgroup.FieldUserID)
  48486. }
  48487. if m.group != nil {
  48488. fields = append(fields, userallowedgroup.FieldGroupID)
  48489. }
  48490. if m.created_at != nil {
  48491. fields = append(fields, userallowedgroup.FieldCreatedAt)
  48492. }
  48493. return fields
  48494. }
  48495. // Field returns the value of a field with the given name. The second boolean
  48496. // return value indicates that this field was not set, or was not defined in the
  48497. // schema.
  48498. func (m *UserAllowedGroupMutation) Field(name string) (ent.Value, bool) {
  48499. switch name {
  48500. case userallowedgroup.FieldUserID:
  48501. return m.UserID()
  48502. case userallowedgroup.FieldGroupID:
  48503. return m.GroupID()
  48504. case userallowedgroup.FieldCreatedAt:
  48505. return m.CreatedAt()
  48506. }
  48507. return nil, false
  48508. }
  48509. // OldField returns the old value of the field from the database. An error is
  48510. // returned if the mutation operation is not UpdateOne, or the query to the
  48511. // database failed.
  48512. func (m *UserAllowedGroupMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  48513. return nil, errors.New("edge schema UserAllowedGroup does not support getting old values")
  48514. }
  48515. // SetField sets the value of a field with the given name. It returns an error if
  48516. // the field is not defined in the schema, or if the type mismatched the field
  48517. // type.
  48518. func (m *UserAllowedGroupMutation) SetField(name string, value ent.Value) error {
  48519. switch name {
  48520. case userallowedgroup.FieldUserID:
  48521. v, ok := value.(int64)
  48522. if !ok {
  48523. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48524. }
  48525. m.SetUserID(v)
  48526. return nil
  48527. case userallowedgroup.FieldGroupID:
  48528. v, ok := value.(int64)
  48529. if !ok {
  48530. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48531. }
  48532. m.SetGroupID(v)
  48533. return nil
  48534. case userallowedgroup.FieldCreatedAt:
  48535. v, ok := value.(time.Time)
  48536. if !ok {
  48537. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48538. }
  48539. m.SetCreatedAt(v)
  48540. return nil
  48541. }
  48542. return fmt.Errorf("unknown UserAllowedGroup field %s", name)
  48543. }
  48544. // AddedFields returns all numeric fields that were incremented/decremented during
  48545. // this mutation.
  48546. func (m *UserAllowedGroupMutation) AddedFields() []string {
  48547. var fields []string
  48548. return fields
  48549. }
  48550. // AddedField returns the numeric value that was incremented/decremented on a field
  48551. // with the given name. The second boolean return value indicates that this field
  48552. // was not set, or was not defined in the schema.
  48553. func (m *UserAllowedGroupMutation) AddedField(name string) (ent.Value, bool) {
  48554. switch name {
  48555. }
  48556. return nil, false
  48557. }
  48558. // AddField adds the value to the field with the given name. It returns an error if
  48559. // the field is not defined in the schema, or if the type mismatched the field
  48560. // type.
  48561. func (m *UserAllowedGroupMutation) AddField(name string, value ent.Value) error {
  48562. switch name {
  48563. }
  48564. return fmt.Errorf("unknown UserAllowedGroup numeric field %s", name)
  48565. }
  48566. // ClearedFields returns all nullable fields that were cleared during this
  48567. // mutation.
  48568. func (m *UserAllowedGroupMutation) ClearedFields() []string {
  48569. return nil
  48570. }
  48571. // FieldCleared returns a boolean indicating if a field with the given name was
  48572. // cleared in this mutation.
  48573. func (m *UserAllowedGroupMutation) FieldCleared(name string) bool {
  48574. _, ok := m.clearedFields[name]
  48575. return ok
  48576. }
  48577. // ClearField clears the value of the field with the given name. It returns an
  48578. // error if the field is not defined in the schema.
  48579. func (m *UserAllowedGroupMutation) ClearField(name string) error {
  48580. return fmt.Errorf("unknown UserAllowedGroup nullable field %s", name)
  48581. }
  48582. // ResetField resets all changes in the mutation for the field with the given name.
  48583. // It returns an error if the field is not defined in the schema.
  48584. func (m *UserAllowedGroupMutation) ResetField(name string) error {
  48585. switch name {
  48586. case userallowedgroup.FieldUserID:
  48587. m.ResetUserID()
  48588. return nil
  48589. case userallowedgroup.FieldGroupID:
  48590. m.ResetGroupID()
  48591. return nil
  48592. case userallowedgroup.FieldCreatedAt:
  48593. m.ResetCreatedAt()
  48594. return nil
  48595. }
  48596. return fmt.Errorf("unknown UserAllowedGroup field %s", name)
  48597. }
  48598. // AddedEdges returns all edge names that were set/added in this mutation.
  48599. func (m *UserAllowedGroupMutation) AddedEdges() []string {
  48600. edges := make([]string, 0, 2)
  48601. if m.user != nil {
  48602. edges = append(edges, userallowedgroup.EdgeUser)
  48603. }
  48604. if m.group != nil {
  48605. edges = append(edges, userallowedgroup.EdgeGroup)
  48606. }
  48607. return edges
  48608. }
  48609. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  48610. // name in this mutation.
  48611. func (m *UserAllowedGroupMutation) AddedIDs(name string) []ent.Value {
  48612. switch name {
  48613. case userallowedgroup.EdgeUser:
  48614. if id := m.user; id != nil {
  48615. return []ent.Value{*id}
  48616. }
  48617. case userallowedgroup.EdgeGroup:
  48618. if id := m.group; id != nil {
  48619. return []ent.Value{*id}
  48620. }
  48621. }
  48622. return nil
  48623. }
  48624. // RemovedEdges returns all edge names that were removed in this mutation.
  48625. func (m *UserAllowedGroupMutation) RemovedEdges() []string {
  48626. edges := make([]string, 0, 2)
  48627. return edges
  48628. }
  48629. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  48630. // the given name in this mutation.
  48631. func (m *UserAllowedGroupMutation) RemovedIDs(name string) []ent.Value {
  48632. return nil
  48633. }
  48634. // ClearedEdges returns all edge names that were cleared in this mutation.
  48635. func (m *UserAllowedGroupMutation) ClearedEdges() []string {
  48636. edges := make([]string, 0, 2)
  48637. if m.cleareduser {
  48638. edges = append(edges, userallowedgroup.EdgeUser)
  48639. }
  48640. if m.clearedgroup {
  48641. edges = append(edges, userallowedgroup.EdgeGroup)
  48642. }
  48643. return edges
  48644. }
  48645. // EdgeCleared returns a boolean which indicates if the edge with the given name
  48646. // was cleared in this mutation.
  48647. func (m *UserAllowedGroupMutation) EdgeCleared(name string) bool {
  48648. switch name {
  48649. case userallowedgroup.EdgeUser:
  48650. return m.cleareduser
  48651. case userallowedgroup.EdgeGroup:
  48652. return m.clearedgroup
  48653. }
  48654. return false
  48655. }
  48656. // ClearEdge clears the value of the edge with the given name. It returns an error
  48657. // if that edge is not defined in the schema.
  48658. func (m *UserAllowedGroupMutation) ClearEdge(name string) error {
  48659. switch name {
  48660. case userallowedgroup.EdgeUser:
  48661. m.ClearUser()
  48662. return nil
  48663. case userallowedgroup.EdgeGroup:
  48664. m.ClearGroup()
  48665. return nil
  48666. }
  48667. return fmt.Errorf("unknown UserAllowedGroup unique edge %s", name)
  48668. }
  48669. // ResetEdge resets all changes to the edge with the given name in this mutation.
  48670. // It returns an error if the edge is not defined in the schema.
  48671. func (m *UserAllowedGroupMutation) ResetEdge(name string) error {
  48672. switch name {
  48673. case userallowedgroup.EdgeUser:
  48674. m.ResetUser()
  48675. return nil
  48676. case userallowedgroup.EdgeGroup:
  48677. m.ResetGroup()
  48678. return nil
  48679. }
  48680. return fmt.Errorf("unknown UserAllowedGroup edge %s", name)
  48681. }
  48682. // UserAttributeDefinitionMutation represents an operation that mutates the UserAttributeDefinition nodes in the graph.
  48683. type UserAttributeDefinitionMutation struct {
  48684. config
  48685. op Op
  48686. typ string
  48687. id *int64
  48688. created_at *time.Time
  48689. updated_at *time.Time
  48690. deleted_at *time.Time
  48691. key *string
  48692. name *string
  48693. description *string
  48694. _type *string
  48695. options *[]map[string]interface{}
  48696. appendoptions []map[string]interface{}
  48697. required *bool
  48698. validation *map[string]interface{}
  48699. placeholder *string
  48700. display_order *int
  48701. adddisplay_order *int
  48702. enabled *bool
  48703. clearedFields map[string]struct{}
  48704. values map[int64]struct{}
  48705. removedvalues map[int64]struct{}
  48706. clearedvalues bool
  48707. done bool
  48708. oldValue func(context.Context) (*UserAttributeDefinition, error)
  48709. predicates []predicate.UserAttributeDefinition
  48710. }
  48711. var _ ent.Mutation = (*UserAttributeDefinitionMutation)(nil)
  48712. // userattributedefinitionOption allows management of the mutation configuration using functional options.
  48713. type userattributedefinitionOption func(*UserAttributeDefinitionMutation)
  48714. // newUserAttributeDefinitionMutation creates new mutation for the UserAttributeDefinition entity.
  48715. func newUserAttributeDefinitionMutation(c config, op Op, opts ...userattributedefinitionOption) *UserAttributeDefinitionMutation {
  48716. m := &UserAttributeDefinitionMutation{
  48717. config: c,
  48718. op: op,
  48719. typ: TypeUserAttributeDefinition,
  48720. clearedFields: make(map[string]struct{}),
  48721. }
  48722. for _, opt := range opts {
  48723. opt(m)
  48724. }
  48725. return m
  48726. }
  48727. // withUserAttributeDefinitionID sets the ID field of the mutation.
  48728. func withUserAttributeDefinitionID(id int64) userattributedefinitionOption {
  48729. return func(m *UserAttributeDefinitionMutation) {
  48730. var (
  48731. err error
  48732. once sync.Once
  48733. value *UserAttributeDefinition
  48734. )
  48735. m.oldValue = func(ctx context.Context) (*UserAttributeDefinition, error) {
  48736. once.Do(func() {
  48737. if m.done {
  48738. err = errors.New("querying old values post mutation is not allowed")
  48739. } else {
  48740. value, err = m.Client().UserAttributeDefinition.Get(ctx, id)
  48741. }
  48742. })
  48743. return value, err
  48744. }
  48745. m.id = &id
  48746. }
  48747. }
  48748. // withUserAttributeDefinition sets the old UserAttributeDefinition of the mutation.
  48749. func withUserAttributeDefinition(node *UserAttributeDefinition) userattributedefinitionOption {
  48750. return func(m *UserAttributeDefinitionMutation) {
  48751. m.oldValue = func(context.Context) (*UserAttributeDefinition, error) {
  48752. return node, nil
  48753. }
  48754. m.id = &node.ID
  48755. }
  48756. }
  48757. // Client returns a new `ent.Client` from the mutation. If the mutation was
  48758. // executed in a transaction (ent.Tx), a transactional client is returned.
  48759. func (m UserAttributeDefinitionMutation) Client() *Client {
  48760. client := &Client{config: m.config}
  48761. client.init()
  48762. return client
  48763. }
  48764. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  48765. // it returns an error otherwise.
  48766. func (m UserAttributeDefinitionMutation) Tx() (*Tx, error) {
  48767. if _, ok := m.driver.(*txDriver); !ok {
  48768. return nil, errors.New("ent: mutation is not running in a transaction")
  48769. }
  48770. tx := &Tx{config: m.config}
  48771. tx.init()
  48772. return tx, nil
  48773. }
  48774. // ID returns the ID value in the mutation. Note that the ID is only available
  48775. // if it was provided to the builder or after it was returned from the database.
  48776. func (m *UserAttributeDefinitionMutation) ID() (id int64, exists bool) {
  48777. if m.id == nil {
  48778. return
  48779. }
  48780. return *m.id, true
  48781. }
  48782. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  48783. // That means, if the mutation is applied within a transaction with an isolation level such
  48784. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  48785. // or updated by the mutation.
  48786. func (m *UserAttributeDefinitionMutation) IDs(ctx context.Context) ([]int64, error) {
  48787. switch {
  48788. case m.op.Is(OpUpdateOne | OpDeleteOne):
  48789. id, exists := m.ID()
  48790. if exists {
  48791. return []int64{id}, nil
  48792. }
  48793. fallthrough
  48794. case m.op.Is(OpUpdate | OpDelete):
  48795. return m.Client().UserAttributeDefinition.Query().Where(m.predicates...).IDs(ctx)
  48796. default:
  48797. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  48798. }
  48799. }
  48800. // SetCreatedAt sets the "created_at" field.
  48801. func (m *UserAttributeDefinitionMutation) SetCreatedAt(t time.Time) {
  48802. m.created_at = &t
  48803. }
  48804. // CreatedAt returns the value of the "created_at" field in the mutation.
  48805. func (m *UserAttributeDefinitionMutation) CreatedAt() (r time.Time, exists bool) {
  48806. v := m.created_at
  48807. if v == nil {
  48808. return
  48809. }
  48810. return *v, true
  48811. }
  48812. // OldCreatedAt returns the old "created_at" field's value of the UserAttributeDefinition entity.
  48813. // If the UserAttributeDefinition object wasn't provided to the builder, the object is fetched from the database.
  48814. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48815. func (m *UserAttributeDefinitionMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  48816. if !m.op.Is(OpUpdateOne) {
  48817. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  48818. }
  48819. if m.id == nil || m.oldValue == nil {
  48820. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  48821. }
  48822. oldValue, err := m.oldValue(ctx)
  48823. if err != nil {
  48824. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  48825. }
  48826. return oldValue.CreatedAt, nil
  48827. }
  48828. // ResetCreatedAt resets all changes to the "created_at" field.
  48829. func (m *UserAttributeDefinitionMutation) ResetCreatedAt() {
  48830. m.created_at = nil
  48831. }
  48832. // SetUpdatedAt sets the "updated_at" field.
  48833. func (m *UserAttributeDefinitionMutation) SetUpdatedAt(t time.Time) {
  48834. m.updated_at = &t
  48835. }
  48836. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  48837. func (m *UserAttributeDefinitionMutation) UpdatedAt() (r time.Time, exists bool) {
  48838. v := m.updated_at
  48839. if v == nil {
  48840. return
  48841. }
  48842. return *v, true
  48843. }
  48844. // OldUpdatedAt returns the old "updated_at" field's value of the UserAttributeDefinition entity.
  48845. // If the UserAttributeDefinition object wasn't provided to the builder, the object is fetched from the database.
  48846. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48847. func (m *UserAttributeDefinitionMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  48848. if !m.op.Is(OpUpdateOne) {
  48849. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  48850. }
  48851. if m.id == nil || m.oldValue == nil {
  48852. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  48853. }
  48854. oldValue, err := m.oldValue(ctx)
  48855. if err != nil {
  48856. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  48857. }
  48858. return oldValue.UpdatedAt, nil
  48859. }
  48860. // ResetUpdatedAt resets all changes to the "updated_at" field.
  48861. func (m *UserAttributeDefinitionMutation) ResetUpdatedAt() {
  48862. m.updated_at = nil
  48863. }
  48864. // SetDeletedAt sets the "deleted_at" field.
  48865. func (m *UserAttributeDefinitionMutation) SetDeletedAt(t time.Time) {
  48866. m.deleted_at = &t
  48867. }
  48868. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  48869. func (m *UserAttributeDefinitionMutation) DeletedAt() (r time.Time, exists bool) {
  48870. v := m.deleted_at
  48871. if v == nil {
  48872. return
  48873. }
  48874. return *v, true
  48875. }
  48876. // OldDeletedAt returns the old "deleted_at" field's value of the UserAttributeDefinition entity.
  48877. // If the UserAttributeDefinition object wasn't provided to the builder, the object is fetched from the database.
  48878. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48879. func (m *UserAttributeDefinitionMutation) OldDeletedAt(ctx context.Context) (v *time.Time, err error) {
  48880. if !m.op.Is(OpUpdateOne) {
  48881. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  48882. }
  48883. if m.id == nil || m.oldValue == nil {
  48884. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  48885. }
  48886. oldValue, err := m.oldValue(ctx)
  48887. if err != nil {
  48888. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  48889. }
  48890. return oldValue.DeletedAt, nil
  48891. }
  48892. // ClearDeletedAt clears the value of the "deleted_at" field.
  48893. func (m *UserAttributeDefinitionMutation) ClearDeletedAt() {
  48894. m.deleted_at = nil
  48895. m.clearedFields[userattributedefinition.FieldDeletedAt] = struct{}{}
  48896. }
  48897. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  48898. func (m *UserAttributeDefinitionMutation) DeletedAtCleared() bool {
  48899. _, ok := m.clearedFields[userattributedefinition.FieldDeletedAt]
  48900. return ok
  48901. }
  48902. // ResetDeletedAt resets all changes to the "deleted_at" field.
  48903. func (m *UserAttributeDefinitionMutation) ResetDeletedAt() {
  48904. m.deleted_at = nil
  48905. delete(m.clearedFields, userattributedefinition.FieldDeletedAt)
  48906. }
  48907. // SetKey sets the "key" field.
  48908. func (m *UserAttributeDefinitionMutation) SetKey(s string) {
  48909. m.key = &s
  48910. }
  48911. // Key returns the value of the "key" field in the mutation.
  48912. func (m *UserAttributeDefinitionMutation) Key() (r string, exists bool) {
  48913. v := m.key
  48914. if v == nil {
  48915. return
  48916. }
  48917. return *v, true
  48918. }
  48919. // OldKey returns the old "key" field's value of the UserAttributeDefinition entity.
  48920. // If the UserAttributeDefinition object wasn't provided to the builder, the object is fetched from the database.
  48921. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48922. func (m *UserAttributeDefinitionMutation) OldKey(ctx context.Context) (v string, err error) {
  48923. if !m.op.Is(OpUpdateOne) {
  48924. return v, errors.New("OldKey is only allowed on UpdateOne operations")
  48925. }
  48926. if m.id == nil || m.oldValue == nil {
  48927. return v, errors.New("OldKey requires an ID field in the mutation")
  48928. }
  48929. oldValue, err := m.oldValue(ctx)
  48930. if err != nil {
  48931. return v, fmt.Errorf("querying old value for OldKey: %w", err)
  48932. }
  48933. return oldValue.Key, nil
  48934. }
  48935. // ResetKey resets all changes to the "key" field.
  48936. func (m *UserAttributeDefinitionMutation) ResetKey() {
  48937. m.key = nil
  48938. }
  48939. // SetName sets the "name" field.
  48940. func (m *UserAttributeDefinitionMutation) SetName(s string) {
  48941. m.name = &s
  48942. }
  48943. // Name returns the value of the "name" field in the mutation.
  48944. func (m *UserAttributeDefinitionMutation) Name() (r string, exists bool) {
  48945. v := m.name
  48946. if v == nil {
  48947. return
  48948. }
  48949. return *v, true
  48950. }
  48951. // OldName returns the old "name" field's value of the UserAttributeDefinition entity.
  48952. // If the UserAttributeDefinition object wasn't provided to the builder, the object is fetched from the database.
  48953. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48954. func (m *UserAttributeDefinitionMutation) OldName(ctx context.Context) (v string, err error) {
  48955. if !m.op.Is(OpUpdateOne) {
  48956. return v, errors.New("OldName is only allowed on UpdateOne operations")
  48957. }
  48958. if m.id == nil || m.oldValue == nil {
  48959. return v, errors.New("OldName requires an ID field in the mutation")
  48960. }
  48961. oldValue, err := m.oldValue(ctx)
  48962. if err != nil {
  48963. return v, fmt.Errorf("querying old value for OldName: %w", err)
  48964. }
  48965. return oldValue.Name, nil
  48966. }
  48967. // ResetName resets all changes to the "name" field.
  48968. func (m *UserAttributeDefinitionMutation) ResetName() {
  48969. m.name = nil
  48970. }
  48971. // SetDescription sets the "description" field.
  48972. func (m *UserAttributeDefinitionMutation) SetDescription(s string) {
  48973. m.description = &s
  48974. }
  48975. // Description returns the value of the "description" field in the mutation.
  48976. func (m *UserAttributeDefinitionMutation) Description() (r string, exists bool) {
  48977. v := m.description
  48978. if v == nil {
  48979. return
  48980. }
  48981. return *v, true
  48982. }
  48983. // OldDescription returns the old "description" field's value of the UserAttributeDefinition entity.
  48984. // If the UserAttributeDefinition object wasn't provided to the builder, the object is fetched from the database.
  48985. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48986. func (m *UserAttributeDefinitionMutation) OldDescription(ctx context.Context) (v string, err error) {
  48987. if !m.op.Is(OpUpdateOne) {
  48988. return v, errors.New("OldDescription is only allowed on UpdateOne operations")
  48989. }
  48990. if m.id == nil || m.oldValue == nil {
  48991. return v, errors.New("OldDescription requires an ID field in the mutation")
  48992. }
  48993. oldValue, err := m.oldValue(ctx)
  48994. if err != nil {
  48995. return v, fmt.Errorf("querying old value for OldDescription: %w", err)
  48996. }
  48997. return oldValue.Description, nil
  48998. }
  48999. // ResetDescription resets all changes to the "description" field.
  49000. func (m *UserAttributeDefinitionMutation) ResetDescription() {
  49001. m.description = nil
  49002. }
  49003. // SetType sets the "type" field.
  49004. func (m *UserAttributeDefinitionMutation) SetType(s string) {
  49005. m._type = &s
  49006. }
  49007. // GetType returns the value of the "type" field in the mutation.
  49008. func (m *UserAttributeDefinitionMutation) GetType() (r string, exists bool) {
  49009. v := m._type
  49010. if v == nil {
  49011. return
  49012. }
  49013. return *v, true
  49014. }
  49015. // OldType returns the old "type" field's value of the UserAttributeDefinition entity.
  49016. // If the UserAttributeDefinition object wasn't provided to the builder, the object is fetched from the database.
  49017. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49018. func (m *UserAttributeDefinitionMutation) OldType(ctx context.Context) (v string, err error) {
  49019. if !m.op.Is(OpUpdateOne) {
  49020. return v, errors.New("OldType is only allowed on UpdateOne operations")
  49021. }
  49022. if m.id == nil || m.oldValue == nil {
  49023. return v, errors.New("OldType requires an ID field in the mutation")
  49024. }
  49025. oldValue, err := m.oldValue(ctx)
  49026. if err != nil {
  49027. return v, fmt.Errorf("querying old value for OldType: %w", err)
  49028. }
  49029. return oldValue.Type, nil
  49030. }
  49031. // ResetType resets all changes to the "type" field.
  49032. func (m *UserAttributeDefinitionMutation) ResetType() {
  49033. m._type = nil
  49034. }
  49035. // SetOptions sets the "options" field.
  49036. func (m *UserAttributeDefinitionMutation) SetOptions(value []map[string]interface{}) {
  49037. m.options = &value
  49038. m.appendoptions = nil
  49039. }
  49040. // Options returns the value of the "options" field in the mutation.
  49041. func (m *UserAttributeDefinitionMutation) Options() (r []map[string]interface{}, exists bool) {
  49042. v := m.options
  49043. if v == nil {
  49044. return
  49045. }
  49046. return *v, true
  49047. }
  49048. // OldOptions returns the old "options" field's value of the UserAttributeDefinition entity.
  49049. // If the UserAttributeDefinition object wasn't provided to the builder, the object is fetched from the database.
  49050. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49051. func (m *UserAttributeDefinitionMutation) OldOptions(ctx context.Context) (v []map[string]interface{}, err error) {
  49052. if !m.op.Is(OpUpdateOne) {
  49053. return v, errors.New("OldOptions is only allowed on UpdateOne operations")
  49054. }
  49055. if m.id == nil || m.oldValue == nil {
  49056. return v, errors.New("OldOptions requires an ID field in the mutation")
  49057. }
  49058. oldValue, err := m.oldValue(ctx)
  49059. if err != nil {
  49060. return v, fmt.Errorf("querying old value for OldOptions: %w", err)
  49061. }
  49062. return oldValue.Options, nil
  49063. }
  49064. // AppendOptions adds value to the "options" field.
  49065. func (m *UserAttributeDefinitionMutation) AppendOptions(value []map[string]interface{}) {
  49066. m.appendoptions = append(m.appendoptions, value...)
  49067. }
  49068. // AppendedOptions returns the list of values that were appended to the "options" field in this mutation.
  49069. func (m *UserAttributeDefinitionMutation) AppendedOptions() ([]map[string]interface{}, bool) {
  49070. if len(m.appendoptions) == 0 {
  49071. return nil, false
  49072. }
  49073. return m.appendoptions, true
  49074. }
  49075. // ResetOptions resets all changes to the "options" field.
  49076. func (m *UserAttributeDefinitionMutation) ResetOptions() {
  49077. m.options = nil
  49078. m.appendoptions = nil
  49079. }
  49080. // SetRequired sets the "required" field.
  49081. func (m *UserAttributeDefinitionMutation) SetRequired(b bool) {
  49082. m.required = &b
  49083. }
  49084. // Required returns the value of the "required" field in the mutation.
  49085. func (m *UserAttributeDefinitionMutation) Required() (r bool, exists bool) {
  49086. v := m.required
  49087. if v == nil {
  49088. return
  49089. }
  49090. return *v, true
  49091. }
  49092. // OldRequired returns the old "required" field's value of the UserAttributeDefinition entity.
  49093. // If the UserAttributeDefinition object wasn't provided to the builder, the object is fetched from the database.
  49094. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49095. func (m *UserAttributeDefinitionMutation) OldRequired(ctx context.Context) (v bool, err error) {
  49096. if !m.op.Is(OpUpdateOne) {
  49097. return v, errors.New("OldRequired is only allowed on UpdateOne operations")
  49098. }
  49099. if m.id == nil || m.oldValue == nil {
  49100. return v, errors.New("OldRequired requires an ID field in the mutation")
  49101. }
  49102. oldValue, err := m.oldValue(ctx)
  49103. if err != nil {
  49104. return v, fmt.Errorf("querying old value for OldRequired: %w", err)
  49105. }
  49106. return oldValue.Required, nil
  49107. }
  49108. // ResetRequired resets all changes to the "required" field.
  49109. func (m *UserAttributeDefinitionMutation) ResetRequired() {
  49110. m.required = nil
  49111. }
  49112. // SetValidation sets the "validation" field.
  49113. func (m *UserAttributeDefinitionMutation) SetValidation(value map[string]interface{}) {
  49114. m.validation = &value
  49115. }
  49116. // Validation returns the value of the "validation" field in the mutation.
  49117. func (m *UserAttributeDefinitionMutation) Validation() (r map[string]interface{}, exists bool) {
  49118. v := m.validation
  49119. if v == nil {
  49120. return
  49121. }
  49122. return *v, true
  49123. }
  49124. // OldValidation returns the old "validation" field's value of the UserAttributeDefinition entity.
  49125. // If the UserAttributeDefinition object wasn't provided to the builder, the object is fetched from the database.
  49126. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49127. func (m *UserAttributeDefinitionMutation) OldValidation(ctx context.Context) (v map[string]interface{}, err error) {
  49128. if !m.op.Is(OpUpdateOne) {
  49129. return v, errors.New("OldValidation is only allowed on UpdateOne operations")
  49130. }
  49131. if m.id == nil || m.oldValue == nil {
  49132. return v, errors.New("OldValidation requires an ID field in the mutation")
  49133. }
  49134. oldValue, err := m.oldValue(ctx)
  49135. if err != nil {
  49136. return v, fmt.Errorf("querying old value for OldValidation: %w", err)
  49137. }
  49138. return oldValue.Validation, nil
  49139. }
  49140. // ResetValidation resets all changes to the "validation" field.
  49141. func (m *UserAttributeDefinitionMutation) ResetValidation() {
  49142. m.validation = nil
  49143. }
  49144. // SetPlaceholder sets the "placeholder" field.
  49145. func (m *UserAttributeDefinitionMutation) SetPlaceholder(s string) {
  49146. m.placeholder = &s
  49147. }
  49148. // Placeholder returns the value of the "placeholder" field in the mutation.
  49149. func (m *UserAttributeDefinitionMutation) Placeholder() (r string, exists bool) {
  49150. v := m.placeholder
  49151. if v == nil {
  49152. return
  49153. }
  49154. return *v, true
  49155. }
  49156. // OldPlaceholder returns the old "placeholder" field's value of the UserAttributeDefinition entity.
  49157. // If the UserAttributeDefinition object wasn't provided to the builder, the object is fetched from the database.
  49158. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49159. func (m *UserAttributeDefinitionMutation) OldPlaceholder(ctx context.Context) (v string, err error) {
  49160. if !m.op.Is(OpUpdateOne) {
  49161. return v, errors.New("OldPlaceholder is only allowed on UpdateOne operations")
  49162. }
  49163. if m.id == nil || m.oldValue == nil {
  49164. return v, errors.New("OldPlaceholder requires an ID field in the mutation")
  49165. }
  49166. oldValue, err := m.oldValue(ctx)
  49167. if err != nil {
  49168. return v, fmt.Errorf("querying old value for OldPlaceholder: %w", err)
  49169. }
  49170. return oldValue.Placeholder, nil
  49171. }
  49172. // ResetPlaceholder resets all changes to the "placeholder" field.
  49173. func (m *UserAttributeDefinitionMutation) ResetPlaceholder() {
  49174. m.placeholder = nil
  49175. }
  49176. // SetDisplayOrder sets the "display_order" field.
  49177. func (m *UserAttributeDefinitionMutation) SetDisplayOrder(i int) {
  49178. m.display_order = &i
  49179. m.adddisplay_order = nil
  49180. }
  49181. // DisplayOrder returns the value of the "display_order" field in the mutation.
  49182. func (m *UserAttributeDefinitionMutation) DisplayOrder() (r int, exists bool) {
  49183. v := m.display_order
  49184. if v == nil {
  49185. return
  49186. }
  49187. return *v, true
  49188. }
  49189. // OldDisplayOrder returns the old "display_order" field's value of the UserAttributeDefinition entity.
  49190. // If the UserAttributeDefinition object wasn't provided to the builder, the object is fetched from the database.
  49191. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49192. func (m *UserAttributeDefinitionMutation) OldDisplayOrder(ctx context.Context) (v int, err error) {
  49193. if !m.op.Is(OpUpdateOne) {
  49194. return v, errors.New("OldDisplayOrder is only allowed on UpdateOne operations")
  49195. }
  49196. if m.id == nil || m.oldValue == nil {
  49197. return v, errors.New("OldDisplayOrder requires an ID field in the mutation")
  49198. }
  49199. oldValue, err := m.oldValue(ctx)
  49200. if err != nil {
  49201. return v, fmt.Errorf("querying old value for OldDisplayOrder: %w", err)
  49202. }
  49203. return oldValue.DisplayOrder, nil
  49204. }
  49205. // AddDisplayOrder adds i to the "display_order" field.
  49206. func (m *UserAttributeDefinitionMutation) AddDisplayOrder(i int) {
  49207. if m.adddisplay_order != nil {
  49208. *m.adddisplay_order += i
  49209. } else {
  49210. m.adddisplay_order = &i
  49211. }
  49212. }
  49213. // AddedDisplayOrder returns the value that was added to the "display_order" field in this mutation.
  49214. func (m *UserAttributeDefinitionMutation) AddedDisplayOrder() (r int, exists bool) {
  49215. v := m.adddisplay_order
  49216. if v == nil {
  49217. return
  49218. }
  49219. return *v, true
  49220. }
  49221. // ResetDisplayOrder resets all changes to the "display_order" field.
  49222. func (m *UserAttributeDefinitionMutation) ResetDisplayOrder() {
  49223. m.display_order = nil
  49224. m.adddisplay_order = nil
  49225. }
  49226. // SetEnabled sets the "enabled" field.
  49227. func (m *UserAttributeDefinitionMutation) SetEnabled(b bool) {
  49228. m.enabled = &b
  49229. }
  49230. // Enabled returns the value of the "enabled" field in the mutation.
  49231. func (m *UserAttributeDefinitionMutation) Enabled() (r bool, exists bool) {
  49232. v := m.enabled
  49233. if v == nil {
  49234. return
  49235. }
  49236. return *v, true
  49237. }
  49238. // OldEnabled returns the old "enabled" field's value of the UserAttributeDefinition entity.
  49239. // If the UserAttributeDefinition object wasn't provided to the builder, the object is fetched from the database.
  49240. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49241. func (m *UserAttributeDefinitionMutation) OldEnabled(ctx context.Context) (v bool, err error) {
  49242. if !m.op.Is(OpUpdateOne) {
  49243. return v, errors.New("OldEnabled is only allowed on UpdateOne operations")
  49244. }
  49245. if m.id == nil || m.oldValue == nil {
  49246. return v, errors.New("OldEnabled requires an ID field in the mutation")
  49247. }
  49248. oldValue, err := m.oldValue(ctx)
  49249. if err != nil {
  49250. return v, fmt.Errorf("querying old value for OldEnabled: %w", err)
  49251. }
  49252. return oldValue.Enabled, nil
  49253. }
  49254. // ResetEnabled resets all changes to the "enabled" field.
  49255. func (m *UserAttributeDefinitionMutation) ResetEnabled() {
  49256. m.enabled = nil
  49257. }
  49258. // AddValueIDs adds the "values" edge to the UserAttributeValue entity by ids.
  49259. func (m *UserAttributeDefinitionMutation) AddValueIDs(ids ...int64) {
  49260. if m.values == nil {
  49261. m.values = make(map[int64]struct{})
  49262. }
  49263. for i := range ids {
  49264. m.values[ids[i]] = struct{}{}
  49265. }
  49266. }
  49267. // ClearValues clears the "values" edge to the UserAttributeValue entity.
  49268. func (m *UserAttributeDefinitionMutation) ClearValues() {
  49269. m.clearedvalues = true
  49270. }
  49271. // ValuesCleared reports if the "values" edge to the UserAttributeValue entity was cleared.
  49272. func (m *UserAttributeDefinitionMutation) ValuesCleared() bool {
  49273. return m.clearedvalues
  49274. }
  49275. // RemoveValueIDs removes the "values" edge to the UserAttributeValue entity by IDs.
  49276. func (m *UserAttributeDefinitionMutation) RemoveValueIDs(ids ...int64) {
  49277. if m.removedvalues == nil {
  49278. m.removedvalues = make(map[int64]struct{})
  49279. }
  49280. for i := range ids {
  49281. delete(m.values, ids[i])
  49282. m.removedvalues[ids[i]] = struct{}{}
  49283. }
  49284. }
  49285. // RemovedValues returns the removed IDs of the "values" edge to the UserAttributeValue entity.
  49286. func (m *UserAttributeDefinitionMutation) RemovedValuesIDs() (ids []int64) {
  49287. for id := range m.removedvalues {
  49288. ids = append(ids, id)
  49289. }
  49290. return
  49291. }
  49292. // ValuesIDs returns the "values" edge IDs in the mutation.
  49293. func (m *UserAttributeDefinitionMutation) ValuesIDs() (ids []int64) {
  49294. for id := range m.values {
  49295. ids = append(ids, id)
  49296. }
  49297. return
  49298. }
  49299. // ResetValues resets all changes to the "values" edge.
  49300. func (m *UserAttributeDefinitionMutation) ResetValues() {
  49301. m.values = nil
  49302. m.clearedvalues = false
  49303. m.removedvalues = nil
  49304. }
  49305. // Where appends a list predicates to the UserAttributeDefinitionMutation builder.
  49306. func (m *UserAttributeDefinitionMutation) Where(ps ...predicate.UserAttributeDefinition) {
  49307. m.predicates = append(m.predicates, ps...)
  49308. }
  49309. // WhereP appends storage-level predicates to the UserAttributeDefinitionMutation builder. Using this method,
  49310. // users can use type-assertion to append predicates that do not depend on any generated package.
  49311. func (m *UserAttributeDefinitionMutation) WhereP(ps ...func(*sql.Selector)) {
  49312. p := make([]predicate.UserAttributeDefinition, len(ps))
  49313. for i := range ps {
  49314. p[i] = ps[i]
  49315. }
  49316. m.Where(p...)
  49317. }
  49318. // Op returns the operation name.
  49319. func (m *UserAttributeDefinitionMutation) Op() Op {
  49320. return m.op
  49321. }
  49322. // SetOp allows setting the mutation operation.
  49323. func (m *UserAttributeDefinitionMutation) SetOp(op Op) {
  49324. m.op = op
  49325. }
  49326. // Type returns the node type of this mutation (UserAttributeDefinition).
  49327. func (m *UserAttributeDefinitionMutation) Type() string {
  49328. return m.typ
  49329. }
  49330. // Fields returns all fields that were changed during this mutation. Note that in
  49331. // order to get all numeric fields that were incremented/decremented, call
  49332. // AddedFields().
  49333. func (m *UserAttributeDefinitionMutation) Fields() []string {
  49334. fields := make([]string, 0, 13)
  49335. if m.created_at != nil {
  49336. fields = append(fields, userattributedefinition.FieldCreatedAt)
  49337. }
  49338. if m.updated_at != nil {
  49339. fields = append(fields, userattributedefinition.FieldUpdatedAt)
  49340. }
  49341. if m.deleted_at != nil {
  49342. fields = append(fields, userattributedefinition.FieldDeletedAt)
  49343. }
  49344. if m.key != nil {
  49345. fields = append(fields, userattributedefinition.FieldKey)
  49346. }
  49347. if m.name != nil {
  49348. fields = append(fields, userattributedefinition.FieldName)
  49349. }
  49350. if m.description != nil {
  49351. fields = append(fields, userattributedefinition.FieldDescription)
  49352. }
  49353. if m._type != nil {
  49354. fields = append(fields, userattributedefinition.FieldType)
  49355. }
  49356. if m.options != nil {
  49357. fields = append(fields, userattributedefinition.FieldOptions)
  49358. }
  49359. if m.required != nil {
  49360. fields = append(fields, userattributedefinition.FieldRequired)
  49361. }
  49362. if m.validation != nil {
  49363. fields = append(fields, userattributedefinition.FieldValidation)
  49364. }
  49365. if m.placeholder != nil {
  49366. fields = append(fields, userattributedefinition.FieldPlaceholder)
  49367. }
  49368. if m.display_order != nil {
  49369. fields = append(fields, userattributedefinition.FieldDisplayOrder)
  49370. }
  49371. if m.enabled != nil {
  49372. fields = append(fields, userattributedefinition.FieldEnabled)
  49373. }
  49374. return fields
  49375. }
  49376. // Field returns the value of a field with the given name. The second boolean
  49377. // return value indicates that this field was not set, or was not defined in the
  49378. // schema.
  49379. func (m *UserAttributeDefinitionMutation) Field(name string) (ent.Value, bool) {
  49380. switch name {
  49381. case userattributedefinition.FieldCreatedAt:
  49382. return m.CreatedAt()
  49383. case userattributedefinition.FieldUpdatedAt:
  49384. return m.UpdatedAt()
  49385. case userattributedefinition.FieldDeletedAt:
  49386. return m.DeletedAt()
  49387. case userattributedefinition.FieldKey:
  49388. return m.Key()
  49389. case userattributedefinition.FieldName:
  49390. return m.Name()
  49391. case userattributedefinition.FieldDescription:
  49392. return m.Description()
  49393. case userattributedefinition.FieldType:
  49394. return m.GetType()
  49395. case userattributedefinition.FieldOptions:
  49396. return m.Options()
  49397. case userattributedefinition.FieldRequired:
  49398. return m.Required()
  49399. case userattributedefinition.FieldValidation:
  49400. return m.Validation()
  49401. case userattributedefinition.FieldPlaceholder:
  49402. return m.Placeholder()
  49403. case userattributedefinition.FieldDisplayOrder:
  49404. return m.DisplayOrder()
  49405. case userattributedefinition.FieldEnabled:
  49406. return m.Enabled()
  49407. }
  49408. return nil, false
  49409. }
  49410. // OldField returns the old value of the field from the database. An error is
  49411. // returned if the mutation operation is not UpdateOne, or the query to the
  49412. // database failed.
  49413. func (m *UserAttributeDefinitionMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  49414. switch name {
  49415. case userattributedefinition.FieldCreatedAt:
  49416. return m.OldCreatedAt(ctx)
  49417. case userattributedefinition.FieldUpdatedAt:
  49418. return m.OldUpdatedAt(ctx)
  49419. case userattributedefinition.FieldDeletedAt:
  49420. return m.OldDeletedAt(ctx)
  49421. case userattributedefinition.FieldKey:
  49422. return m.OldKey(ctx)
  49423. case userattributedefinition.FieldName:
  49424. return m.OldName(ctx)
  49425. case userattributedefinition.FieldDescription:
  49426. return m.OldDescription(ctx)
  49427. case userattributedefinition.FieldType:
  49428. return m.OldType(ctx)
  49429. case userattributedefinition.FieldOptions:
  49430. return m.OldOptions(ctx)
  49431. case userattributedefinition.FieldRequired:
  49432. return m.OldRequired(ctx)
  49433. case userattributedefinition.FieldValidation:
  49434. return m.OldValidation(ctx)
  49435. case userattributedefinition.FieldPlaceholder:
  49436. return m.OldPlaceholder(ctx)
  49437. case userattributedefinition.FieldDisplayOrder:
  49438. return m.OldDisplayOrder(ctx)
  49439. case userattributedefinition.FieldEnabled:
  49440. return m.OldEnabled(ctx)
  49441. }
  49442. return nil, fmt.Errorf("unknown UserAttributeDefinition field %s", name)
  49443. }
  49444. // SetField sets the value of a field with the given name. It returns an error if
  49445. // the field is not defined in the schema, or if the type mismatched the field
  49446. // type.
  49447. func (m *UserAttributeDefinitionMutation) SetField(name string, value ent.Value) error {
  49448. switch name {
  49449. case userattributedefinition.FieldCreatedAt:
  49450. v, ok := value.(time.Time)
  49451. if !ok {
  49452. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49453. }
  49454. m.SetCreatedAt(v)
  49455. return nil
  49456. case userattributedefinition.FieldUpdatedAt:
  49457. v, ok := value.(time.Time)
  49458. if !ok {
  49459. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49460. }
  49461. m.SetUpdatedAt(v)
  49462. return nil
  49463. case userattributedefinition.FieldDeletedAt:
  49464. v, ok := value.(time.Time)
  49465. if !ok {
  49466. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49467. }
  49468. m.SetDeletedAt(v)
  49469. return nil
  49470. case userattributedefinition.FieldKey:
  49471. v, ok := value.(string)
  49472. if !ok {
  49473. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49474. }
  49475. m.SetKey(v)
  49476. return nil
  49477. case userattributedefinition.FieldName:
  49478. v, ok := value.(string)
  49479. if !ok {
  49480. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49481. }
  49482. m.SetName(v)
  49483. return nil
  49484. case userattributedefinition.FieldDescription:
  49485. v, ok := value.(string)
  49486. if !ok {
  49487. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49488. }
  49489. m.SetDescription(v)
  49490. return nil
  49491. case userattributedefinition.FieldType:
  49492. v, ok := value.(string)
  49493. if !ok {
  49494. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49495. }
  49496. m.SetType(v)
  49497. return nil
  49498. case userattributedefinition.FieldOptions:
  49499. v, ok := value.([]map[string]interface{})
  49500. if !ok {
  49501. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49502. }
  49503. m.SetOptions(v)
  49504. return nil
  49505. case userattributedefinition.FieldRequired:
  49506. v, ok := value.(bool)
  49507. if !ok {
  49508. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49509. }
  49510. m.SetRequired(v)
  49511. return nil
  49512. case userattributedefinition.FieldValidation:
  49513. v, ok := value.(map[string]interface{})
  49514. if !ok {
  49515. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49516. }
  49517. m.SetValidation(v)
  49518. return nil
  49519. case userattributedefinition.FieldPlaceholder:
  49520. v, ok := value.(string)
  49521. if !ok {
  49522. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49523. }
  49524. m.SetPlaceholder(v)
  49525. return nil
  49526. case userattributedefinition.FieldDisplayOrder:
  49527. v, ok := value.(int)
  49528. if !ok {
  49529. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49530. }
  49531. m.SetDisplayOrder(v)
  49532. return nil
  49533. case userattributedefinition.FieldEnabled:
  49534. v, ok := value.(bool)
  49535. if !ok {
  49536. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49537. }
  49538. m.SetEnabled(v)
  49539. return nil
  49540. }
  49541. return fmt.Errorf("unknown UserAttributeDefinition field %s", name)
  49542. }
  49543. // AddedFields returns all numeric fields that were incremented/decremented during
  49544. // this mutation.
  49545. func (m *UserAttributeDefinitionMutation) AddedFields() []string {
  49546. var fields []string
  49547. if m.adddisplay_order != nil {
  49548. fields = append(fields, userattributedefinition.FieldDisplayOrder)
  49549. }
  49550. return fields
  49551. }
  49552. // AddedField returns the numeric value that was incremented/decremented on a field
  49553. // with the given name. The second boolean return value indicates that this field
  49554. // was not set, or was not defined in the schema.
  49555. func (m *UserAttributeDefinitionMutation) AddedField(name string) (ent.Value, bool) {
  49556. switch name {
  49557. case userattributedefinition.FieldDisplayOrder:
  49558. return m.AddedDisplayOrder()
  49559. }
  49560. return nil, false
  49561. }
  49562. // AddField adds the value to the field with the given name. It returns an error if
  49563. // the field is not defined in the schema, or if the type mismatched the field
  49564. // type.
  49565. func (m *UserAttributeDefinitionMutation) AddField(name string, value ent.Value) error {
  49566. switch name {
  49567. case userattributedefinition.FieldDisplayOrder:
  49568. v, ok := value.(int)
  49569. if !ok {
  49570. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49571. }
  49572. m.AddDisplayOrder(v)
  49573. return nil
  49574. }
  49575. return fmt.Errorf("unknown UserAttributeDefinition numeric field %s", name)
  49576. }
  49577. // ClearedFields returns all nullable fields that were cleared during this
  49578. // mutation.
  49579. func (m *UserAttributeDefinitionMutation) ClearedFields() []string {
  49580. var fields []string
  49581. if m.FieldCleared(userattributedefinition.FieldDeletedAt) {
  49582. fields = append(fields, userattributedefinition.FieldDeletedAt)
  49583. }
  49584. return fields
  49585. }
  49586. // FieldCleared returns a boolean indicating if a field with the given name was
  49587. // cleared in this mutation.
  49588. func (m *UserAttributeDefinitionMutation) FieldCleared(name string) bool {
  49589. _, ok := m.clearedFields[name]
  49590. return ok
  49591. }
  49592. // ClearField clears the value of the field with the given name. It returns an
  49593. // error if the field is not defined in the schema.
  49594. func (m *UserAttributeDefinitionMutation) ClearField(name string) error {
  49595. switch name {
  49596. case userattributedefinition.FieldDeletedAt:
  49597. m.ClearDeletedAt()
  49598. return nil
  49599. }
  49600. return fmt.Errorf("unknown UserAttributeDefinition nullable field %s", name)
  49601. }
  49602. // ResetField resets all changes in the mutation for the field with the given name.
  49603. // It returns an error if the field is not defined in the schema.
  49604. func (m *UserAttributeDefinitionMutation) ResetField(name string) error {
  49605. switch name {
  49606. case userattributedefinition.FieldCreatedAt:
  49607. m.ResetCreatedAt()
  49608. return nil
  49609. case userattributedefinition.FieldUpdatedAt:
  49610. m.ResetUpdatedAt()
  49611. return nil
  49612. case userattributedefinition.FieldDeletedAt:
  49613. m.ResetDeletedAt()
  49614. return nil
  49615. case userattributedefinition.FieldKey:
  49616. m.ResetKey()
  49617. return nil
  49618. case userattributedefinition.FieldName:
  49619. m.ResetName()
  49620. return nil
  49621. case userattributedefinition.FieldDescription:
  49622. m.ResetDescription()
  49623. return nil
  49624. case userattributedefinition.FieldType:
  49625. m.ResetType()
  49626. return nil
  49627. case userattributedefinition.FieldOptions:
  49628. m.ResetOptions()
  49629. return nil
  49630. case userattributedefinition.FieldRequired:
  49631. m.ResetRequired()
  49632. return nil
  49633. case userattributedefinition.FieldValidation:
  49634. m.ResetValidation()
  49635. return nil
  49636. case userattributedefinition.FieldPlaceholder:
  49637. m.ResetPlaceholder()
  49638. return nil
  49639. case userattributedefinition.FieldDisplayOrder:
  49640. m.ResetDisplayOrder()
  49641. return nil
  49642. case userattributedefinition.FieldEnabled:
  49643. m.ResetEnabled()
  49644. return nil
  49645. }
  49646. return fmt.Errorf("unknown UserAttributeDefinition field %s", name)
  49647. }
  49648. // AddedEdges returns all edge names that were set/added in this mutation.
  49649. func (m *UserAttributeDefinitionMutation) AddedEdges() []string {
  49650. edges := make([]string, 0, 1)
  49651. if m.values != nil {
  49652. edges = append(edges, userattributedefinition.EdgeValues)
  49653. }
  49654. return edges
  49655. }
  49656. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  49657. // name in this mutation.
  49658. func (m *UserAttributeDefinitionMutation) AddedIDs(name string) []ent.Value {
  49659. switch name {
  49660. case userattributedefinition.EdgeValues:
  49661. ids := make([]ent.Value, 0, len(m.values))
  49662. for id := range m.values {
  49663. ids = append(ids, id)
  49664. }
  49665. return ids
  49666. }
  49667. return nil
  49668. }
  49669. // RemovedEdges returns all edge names that were removed in this mutation.
  49670. func (m *UserAttributeDefinitionMutation) RemovedEdges() []string {
  49671. edges := make([]string, 0, 1)
  49672. if m.removedvalues != nil {
  49673. edges = append(edges, userattributedefinition.EdgeValues)
  49674. }
  49675. return edges
  49676. }
  49677. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  49678. // the given name in this mutation.
  49679. func (m *UserAttributeDefinitionMutation) RemovedIDs(name string) []ent.Value {
  49680. switch name {
  49681. case userattributedefinition.EdgeValues:
  49682. ids := make([]ent.Value, 0, len(m.removedvalues))
  49683. for id := range m.removedvalues {
  49684. ids = append(ids, id)
  49685. }
  49686. return ids
  49687. }
  49688. return nil
  49689. }
  49690. // ClearedEdges returns all edge names that were cleared in this mutation.
  49691. func (m *UserAttributeDefinitionMutation) ClearedEdges() []string {
  49692. edges := make([]string, 0, 1)
  49693. if m.clearedvalues {
  49694. edges = append(edges, userattributedefinition.EdgeValues)
  49695. }
  49696. return edges
  49697. }
  49698. // EdgeCleared returns a boolean which indicates if the edge with the given name
  49699. // was cleared in this mutation.
  49700. func (m *UserAttributeDefinitionMutation) EdgeCleared(name string) bool {
  49701. switch name {
  49702. case userattributedefinition.EdgeValues:
  49703. return m.clearedvalues
  49704. }
  49705. return false
  49706. }
  49707. // ClearEdge clears the value of the edge with the given name. It returns an error
  49708. // if that edge is not defined in the schema.
  49709. func (m *UserAttributeDefinitionMutation) ClearEdge(name string) error {
  49710. switch name {
  49711. }
  49712. return fmt.Errorf("unknown UserAttributeDefinition unique edge %s", name)
  49713. }
  49714. // ResetEdge resets all changes to the edge with the given name in this mutation.
  49715. // It returns an error if the edge is not defined in the schema.
  49716. func (m *UserAttributeDefinitionMutation) ResetEdge(name string) error {
  49717. switch name {
  49718. case userattributedefinition.EdgeValues:
  49719. m.ResetValues()
  49720. return nil
  49721. }
  49722. return fmt.Errorf("unknown UserAttributeDefinition edge %s", name)
  49723. }
  49724. // UserAttributeValueMutation represents an operation that mutates the UserAttributeValue nodes in the graph.
  49725. type UserAttributeValueMutation struct {
  49726. config
  49727. op Op
  49728. typ string
  49729. id *int64
  49730. created_at *time.Time
  49731. updated_at *time.Time
  49732. value *string
  49733. clearedFields map[string]struct{}
  49734. user *int64
  49735. cleareduser bool
  49736. definition *int64
  49737. cleareddefinition bool
  49738. done bool
  49739. oldValue func(context.Context) (*UserAttributeValue, error)
  49740. predicates []predicate.UserAttributeValue
  49741. }
  49742. var _ ent.Mutation = (*UserAttributeValueMutation)(nil)
  49743. // userattributevalueOption allows management of the mutation configuration using functional options.
  49744. type userattributevalueOption func(*UserAttributeValueMutation)
  49745. // newUserAttributeValueMutation creates new mutation for the UserAttributeValue entity.
  49746. func newUserAttributeValueMutation(c config, op Op, opts ...userattributevalueOption) *UserAttributeValueMutation {
  49747. m := &UserAttributeValueMutation{
  49748. config: c,
  49749. op: op,
  49750. typ: TypeUserAttributeValue,
  49751. clearedFields: make(map[string]struct{}),
  49752. }
  49753. for _, opt := range opts {
  49754. opt(m)
  49755. }
  49756. return m
  49757. }
  49758. // withUserAttributeValueID sets the ID field of the mutation.
  49759. func withUserAttributeValueID(id int64) userattributevalueOption {
  49760. return func(m *UserAttributeValueMutation) {
  49761. var (
  49762. err error
  49763. once sync.Once
  49764. value *UserAttributeValue
  49765. )
  49766. m.oldValue = func(ctx context.Context) (*UserAttributeValue, error) {
  49767. once.Do(func() {
  49768. if m.done {
  49769. err = errors.New("querying old values post mutation is not allowed")
  49770. } else {
  49771. value, err = m.Client().UserAttributeValue.Get(ctx, id)
  49772. }
  49773. })
  49774. return value, err
  49775. }
  49776. m.id = &id
  49777. }
  49778. }
  49779. // withUserAttributeValue sets the old UserAttributeValue of the mutation.
  49780. func withUserAttributeValue(node *UserAttributeValue) userattributevalueOption {
  49781. return func(m *UserAttributeValueMutation) {
  49782. m.oldValue = func(context.Context) (*UserAttributeValue, error) {
  49783. return node, nil
  49784. }
  49785. m.id = &node.ID
  49786. }
  49787. }
  49788. // Client returns a new `ent.Client` from the mutation. If the mutation was
  49789. // executed in a transaction (ent.Tx), a transactional client is returned.
  49790. func (m UserAttributeValueMutation) Client() *Client {
  49791. client := &Client{config: m.config}
  49792. client.init()
  49793. return client
  49794. }
  49795. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  49796. // it returns an error otherwise.
  49797. func (m UserAttributeValueMutation) Tx() (*Tx, error) {
  49798. if _, ok := m.driver.(*txDriver); !ok {
  49799. return nil, errors.New("ent: mutation is not running in a transaction")
  49800. }
  49801. tx := &Tx{config: m.config}
  49802. tx.init()
  49803. return tx, nil
  49804. }
  49805. // ID returns the ID value in the mutation. Note that the ID is only available
  49806. // if it was provided to the builder or after it was returned from the database.
  49807. func (m *UserAttributeValueMutation) ID() (id int64, exists bool) {
  49808. if m.id == nil {
  49809. return
  49810. }
  49811. return *m.id, true
  49812. }
  49813. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  49814. // That means, if the mutation is applied within a transaction with an isolation level such
  49815. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  49816. // or updated by the mutation.
  49817. func (m *UserAttributeValueMutation) IDs(ctx context.Context) ([]int64, error) {
  49818. switch {
  49819. case m.op.Is(OpUpdateOne | OpDeleteOne):
  49820. id, exists := m.ID()
  49821. if exists {
  49822. return []int64{id}, nil
  49823. }
  49824. fallthrough
  49825. case m.op.Is(OpUpdate | OpDelete):
  49826. return m.Client().UserAttributeValue.Query().Where(m.predicates...).IDs(ctx)
  49827. default:
  49828. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  49829. }
  49830. }
  49831. // SetCreatedAt sets the "created_at" field.
  49832. func (m *UserAttributeValueMutation) SetCreatedAt(t time.Time) {
  49833. m.created_at = &t
  49834. }
  49835. // CreatedAt returns the value of the "created_at" field in the mutation.
  49836. func (m *UserAttributeValueMutation) CreatedAt() (r time.Time, exists bool) {
  49837. v := m.created_at
  49838. if v == nil {
  49839. return
  49840. }
  49841. return *v, true
  49842. }
  49843. // OldCreatedAt returns the old "created_at" field's value of the UserAttributeValue entity.
  49844. // If the UserAttributeValue object wasn't provided to the builder, the object is fetched from the database.
  49845. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49846. func (m *UserAttributeValueMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  49847. if !m.op.Is(OpUpdateOne) {
  49848. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  49849. }
  49850. if m.id == nil || m.oldValue == nil {
  49851. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  49852. }
  49853. oldValue, err := m.oldValue(ctx)
  49854. if err != nil {
  49855. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  49856. }
  49857. return oldValue.CreatedAt, nil
  49858. }
  49859. // ResetCreatedAt resets all changes to the "created_at" field.
  49860. func (m *UserAttributeValueMutation) ResetCreatedAt() {
  49861. m.created_at = nil
  49862. }
  49863. // SetUpdatedAt sets the "updated_at" field.
  49864. func (m *UserAttributeValueMutation) SetUpdatedAt(t time.Time) {
  49865. m.updated_at = &t
  49866. }
  49867. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  49868. func (m *UserAttributeValueMutation) UpdatedAt() (r time.Time, exists bool) {
  49869. v := m.updated_at
  49870. if v == nil {
  49871. return
  49872. }
  49873. return *v, true
  49874. }
  49875. // OldUpdatedAt returns the old "updated_at" field's value of the UserAttributeValue entity.
  49876. // If the UserAttributeValue object wasn't provided to the builder, the object is fetched from the database.
  49877. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49878. func (m *UserAttributeValueMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  49879. if !m.op.Is(OpUpdateOne) {
  49880. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  49881. }
  49882. if m.id == nil || m.oldValue == nil {
  49883. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  49884. }
  49885. oldValue, err := m.oldValue(ctx)
  49886. if err != nil {
  49887. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  49888. }
  49889. return oldValue.UpdatedAt, nil
  49890. }
  49891. // ResetUpdatedAt resets all changes to the "updated_at" field.
  49892. func (m *UserAttributeValueMutation) ResetUpdatedAt() {
  49893. m.updated_at = nil
  49894. }
  49895. // SetUserID sets the "user_id" field.
  49896. func (m *UserAttributeValueMutation) SetUserID(i int64) {
  49897. m.user = &i
  49898. }
  49899. // UserID returns the value of the "user_id" field in the mutation.
  49900. func (m *UserAttributeValueMutation) UserID() (r int64, exists bool) {
  49901. v := m.user
  49902. if v == nil {
  49903. return
  49904. }
  49905. return *v, true
  49906. }
  49907. // OldUserID returns the old "user_id" field's value of the UserAttributeValue entity.
  49908. // If the UserAttributeValue object wasn't provided to the builder, the object is fetched from the database.
  49909. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49910. func (m *UserAttributeValueMutation) OldUserID(ctx context.Context) (v int64, err error) {
  49911. if !m.op.Is(OpUpdateOne) {
  49912. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  49913. }
  49914. if m.id == nil || m.oldValue == nil {
  49915. return v, errors.New("OldUserID requires an ID field in the mutation")
  49916. }
  49917. oldValue, err := m.oldValue(ctx)
  49918. if err != nil {
  49919. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  49920. }
  49921. return oldValue.UserID, nil
  49922. }
  49923. // ResetUserID resets all changes to the "user_id" field.
  49924. func (m *UserAttributeValueMutation) ResetUserID() {
  49925. m.user = nil
  49926. }
  49927. // SetAttributeID sets the "attribute_id" field.
  49928. func (m *UserAttributeValueMutation) SetAttributeID(i int64) {
  49929. m.definition = &i
  49930. }
  49931. // AttributeID returns the value of the "attribute_id" field in the mutation.
  49932. func (m *UserAttributeValueMutation) AttributeID() (r int64, exists bool) {
  49933. v := m.definition
  49934. if v == nil {
  49935. return
  49936. }
  49937. return *v, true
  49938. }
  49939. // OldAttributeID returns the old "attribute_id" field's value of the UserAttributeValue entity.
  49940. // If the UserAttributeValue object wasn't provided to the builder, the object is fetched from the database.
  49941. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49942. func (m *UserAttributeValueMutation) OldAttributeID(ctx context.Context) (v int64, err error) {
  49943. if !m.op.Is(OpUpdateOne) {
  49944. return v, errors.New("OldAttributeID is only allowed on UpdateOne operations")
  49945. }
  49946. if m.id == nil || m.oldValue == nil {
  49947. return v, errors.New("OldAttributeID requires an ID field in the mutation")
  49948. }
  49949. oldValue, err := m.oldValue(ctx)
  49950. if err != nil {
  49951. return v, fmt.Errorf("querying old value for OldAttributeID: %w", err)
  49952. }
  49953. return oldValue.AttributeID, nil
  49954. }
  49955. // ResetAttributeID resets all changes to the "attribute_id" field.
  49956. func (m *UserAttributeValueMutation) ResetAttributeID() {
  49957. m.definition = nil
  49958. }
  49959. // SetValue sets the "value" field.
  49960. func (m *UserAttributeValueMutation) SetValue(s string) {
  49961. m.value = &s
  49962. }
  49963. // Value returns the value of the "value" field in the mutation.
  49964. func (m *UserAttributeValueMutation) Value() (r string, exists bool) {
  49965. v := m.value
  49966. if v == nil {
  49967. return
  49968. }
  49969. return *v, true
  49970. }
  49971. // OldValue returns the old "value" field's value of the UserAttributeValue entity.
  49972. // If the UserAttributeValue object wasn't provided to the builder, the object is fetched from the database.
  49973. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49974. func (m *UserAttributeValueMutation) OldValue(ctx context.Context) (v string, err error) {
  49975. if !m.op.Is(OpUpdateOne) {
  49976. return v, errors.New("OldValue is only allowed on UpdateOne operations")
  49977. }
  49978. if m.id == nil || m.oldValue == nil {
  49979. return v, errors.New("OldValue requires an ID field in the mutation")
  49980. }
  49981. oldValue, err := m.oldValue(ctx)
  49982. if err != nil {
  49983. return v, fmt.Errorf("querying old value for OldValue: %w", err)
  49984. }
  49985. return oldValue.Value, nil
  49986. }
  49987. // ResetValue resets all changes to the "value" field.
  49988. func (m *UserAttributeValueMutation) ResetValue() {
  49989. m.value = nil
  49990. }
  49991. // ClearUser clears the "user" edge to the User entity.
  49992. func (m *UserAttributeValueMutation) ClearUser() {
  49993. m.cleareduser = true
  49994. m.clearedFields[userattributevalue.FieldUserID] = struct{}{}
  49995. }
  49996. // UserCleared reports if the "user" edge to the User entity was cleared.
  49997. func (m *UserAttributeValueMutation) UserCleared() bool {
  49998. return m.cleareduser
  49999. }
  50000. // UserIDs returns the "user" edge IDs in the mutation.
  50001. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  50002. // UserID instead. It exists only for internal usage by the builders.
  50003. func (m *UserAttributeValueMutation) UserIDs() (ids []int64) {
  50004. if id := m.user; id != nil {
  50005. ids = append(ids, *id)
  50006. }
  50007. return
  50008. }
  50009. // ResetUser resets all changes to the "user" edge.
  50010. func (m *UserAttributeValueMutation) ResetUser() {
  50011. m.user = nil
  50012. m.cleareduser = false
  50013. }
  50014. // SetDefinitionID sets the "definition" edge to the UserAttributeDefinition entity by id.
  50015. func (m *UserAttributeValueMutation) SetDefinitionID(id int64) {
  50016. m.definition = &id
  50017. }
  50018. // ClearDefinition clears the "definition" edge to the UserAttributeDefinition entity.
  50019. func (m *UserAttributeValueMutation) ClearDefinition() {
  50020. m.cleareddefinition = true
  50021. m.clearedFields[userattributevalue.FieldAttributeID] = struct{}{}
  50022. }
  50023. // DefinitionCleared reports if the "definition" edge to the UserAttributeDefinition entity was cleared.
  50024. func (m *UserAttributeValueMutation) DefinitionCleared() bool {
  50025. return m.cleareddefinition
  50026. }
  50027. // DefinitionID returns the "definition" edge ID in the mutation.
  50028. func (m *UserAttributeValueMutation) DefinitionID() (id int64, exists bool) {
  50029. if m.definition != nil {
  50030. return *m.definition, true
  50031. }
  50032. return
  50033. }
  50034. // DefinitionIDs returns the "definition" edge IDs in the mutation.
  50035. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  50036. // DefinitionID instead. It exists only for internal usage by the builders.
  50037. func (m *UserAttributeValueMutation) DefinitionIDs() (ids []int64) {
  50038. if id := m.definition; id != nil {
  50039. ids = append(ids, *id)
  50040. }
  50041. return
  50042. }
  50043. // ResetDefinition resets all changes to the "definition" edge.
  50044. func (m *UserAttributeValueMutation) ResetDefinition() {
  50045. m.definition = nil
  50046. m.cleareddefinition = false
  50047. }
  50048. // Where appends a list predicates to the UserAttributeValueMutation builder.
  50049. func (m *UserAttributeValueMutation) Where(ps ...predicate.UserAttributeValue) {
  50050. m.predicates = append(m.predicates, ps...)
  50051. }
  50052. // WhereP appends storage-level predicates to the UserAttributeValueMutation builder. Using this method,
  50053. // users can use type-assertion to append predicates that do not depend on any generated package.
  50054. func (m *UserAttributeValueMutation) WhereP(ps ...func(*sql.Selector)) {
  50055. p := make([]predicate.UserAttributeValue, len(ps))
  50056. for i := range ps {
  50057. p[i] = ps[i]
  50058. }
  50059. m.Where(p...)
  50060. }
  50061. // Op returns the operation name.
  50062. func (m *UserAttributeValueMutation) Op() Op {
  50063. return m.op
  50064. }
  50065. // SetOp allows setting the mutation operation.
  50066. func (m *UserAttributeValueMutation) SetOp(op Op) {
  50067. m.op = op
  50068. }
  50069. // Type returns the node type of this mutation (UserAttributeValue).
  50070. func (m *UserAttributeValueMutation) Type() string {
  50071. return m.typ
  50072. }
  50073. // Fields returns all fields that were changed during this mutation. Note that in
  50074. // order to get all numeric fields that were incremented/decremented, call
  50075. // AddedFields().
  50076. func (m *UserAttributeValueMutation) Fields() []string {
  50077. fields := make([]string, 0, 5)
  50078. if m.created_at != nil {
  50079. fields = append(fields, userattributevalue.FieldCreatedAt)
  50080. }
  50081. if m.updated_at != nil {
  50082. fields = append(fields, userattributevalue.FieldUpdatedAt)
  50083. }
  50084. if m.user != nil {
  50085. fields = append(fields, userattributevalue.FieldUserID)
  50086. }
  50087. if m.definition != nil {
  50088. fields = append(fields, userattributevalue.FieldAttributeID)
  50089. }
  50090. if m.value != nil {
  50091. fields = append(fields, userattributevalue.FieldValue)
  50092. }
  50093. return fields
  50094. }
  50095. // Field returns the value of a field with the given name. The second boolean
  50096. // return value indicates that this field was not set, or was not defined in the
  50097. // schema.
  50098. func (m *UserAttributeValueMutation) Field(name string) (ent.Value, bool) {
  50099. switch name {
  50100. case userattributevalue.FieldCreatedAt:
  50101. return m.CreatedAt()
  50102. case userattributevalue.FieldUpdatedAt:
  50103. return m.UpdatedAt()
  50104. case userattributevalue.FieldUserID:
  50105. return m.UserID()
  50106. case userattributevalue.FieldAttributeID:
  50107. return m.AttributeID()
  50108. case userattributevalue.FieldValue:
  50109. return m.Value()
  50110. }
  50111. return nil, false
  50112. }
  50113. // OldField returns the old value of the field from the database. An error is
  50114. // returned if the mutation operation is not UpdateOne, or the query to the
  50115. // database failed.
  50116. func (m *UserAttributeValueMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  50117. switch name {
  50118. case userattributevalue.FieldCreatedAt:
  50119. return m.OldCreatedAt(ctx)
  50120. case userattributevalue.FieldUpdatedAt:
  50121. return m.OldUpdatedAt(ctx)
  50122. case userattributevalue.FieldUserID:
  50123. return m.OldUserID(ctx)
  50124. case userattributevalue.FieldAttributeID:
  50125. return m.OldAttributeID(ctx)
  50126. case userattributevalue.FieldValue:
  50127. return m.OldValue(ctx)
  50128. }
  50129. return nil, fmt.Errorf("unknown UserAttributeValue field %s", name)
  50130. }
  50131. // SetField sets the value of a field with the given name. It returns an error if
  50132. // the field is not defined in the schema, or if the type mismatched the field
  50133. // type.
  50134. func (m *UserAttributeValueMutation) SetField(name string, value ent.Value) error {
  50135. switch name {
  50136. case userattributevalue.FieldCreatedAt:
  50137. v, ok := value.(time.Time)
  50138. if !ok {
  50139. return fmt.Errorf("unexpected type %T for field %s", value, name)
  50140. }
  50141. m.SetCreatedAt(v)
  50142. return nil
  50143. case userattributevalue.FieldUpdatedAt:
  50144. v, ok := value.(time.Time)
  50145. if !ok {
  50146. return fmt.Errorf("unexpected type %T for field %s", value, name)
  50147. }
  50148. m.SetUpdatedAt(v)
  50149. return nil
  50150. case userattributevalue.FieldUserID:
  50151. v, ok := value.(int64)
  50152. if !ok {
  50153. return fmt.Errorf("unexpected type %T for field %s", value, name)
  50154. }
  50155. m.SetUserID(v)
  50156. return nil
  50157. case userattributevalue.FieldAttributeID:
  50158. v, ok := value.(int64)
  50159. if !ok {
  50160. return fmt.Errorf("unexpected type %T for field %s", value, name)
  50161. }
  50162. m.SetAttributeID(v)
  50163. return nil
  50164. case userattributevalue.FieldValue:
  50165. v, ok := value.(string)
  50166. if !ok {
  50167. return fmt.Errorf("unexpected type %T for field %s", value, name)
  50168. }
  50169. m.SetValue(v)
  50170. return nil
  50171. }
  50172. return fmt.Errorf("unknown UserAttributeValue field %s", name)
  50173. }
  50174. // AddedFields returns all numeric fields that were incremented/decremented during
  50175. // this mutation.
  50176. func (m *UserAttributeValueMutation) AddedFields() []string {
  50177. var fields []string
  50178. return fields
  50179. }
  50180. // AddedField returns the numeric value that was incremented/decremented on a field
  50181. // with the given name. The second boolean return value indicates that this field
  50182. // was not set, or was not defined in the schema.
  50183. func (m *UserAttributeValueMutation) AddedField(name string) (ent.Value, bool) {
  50184. switch name {
  50185. }
  50186. return nil, false
  50187. }
  50188. // AddField adds the value to the field with the given name. It returns an error if
  50189. // the field is not defined in the schema, or if the type mismatched the field
  50190. // type.
  50191. func (m *UserAttributeValueMutation) AddField(name string, value ent.Value) error {
  50192. switch name {
  50193. }
  50194. return fmt.Errorf("unknown UserAttributeValue numeric field %s", name)
  50195. }
  50196. // ClearedFields returns all nullable fields that were cleared during this
  50197. // mutation.
  50198. func (m *UserAttributeValueMutation) ClearedFields() []string {
  50199. return nil
  50200. }
  50201. // FieldCleared returns a boolean indicating if a field with the given name was
  50202. // cleared in this mutation.
  50203. func (m *UserAttributeValueMutation) FieldCleared(name string) bool {
  50204. _, ok := m.clearedFields[name]
  50205. return ok
  50206. }
  50207. // ClearField clears the value of the field with the given name. It returns an
  50208. // error if the field is not defined in the schema.
  50209. func (m *UserAttributeValueMutation) ClearField(name string) error {
  50210. return fmt.Errorf("unknown UserAttributeValue nullable field %s", name)
  50211. }
  50212. // ResetField resets all changes in the mutation for the field with the given name.
  50213. // It returns an error if the field is not defined in the schema.
  50214. func (m *UserAttributeValueMutation) ResetField(name string) error {
  50215. switch name {
  50216. case userattributevalue.FieldCreatedAt:
  50217. m.ResetCreatedAt()
  50218. return nil
  50219. case userattributevalue.FieldUpdatedAt:
  50220. m.ResetUpdatedAt()
  50221. return nil
  50222. case userattributevalue.FieldUserID:
  50223. m.ResetUserID()
  50224. return nil
  50225. case userattributevalue.FieldAttributeID:
  50226. m.ResetAttributeID()
  50227. return nil
  50228. case userattributevalue.FieldValue:
  50229. m.ResetValue()
  50230. return nil
  50231. }
  50232. return fmt.Errorf("unknown UserAttributeValue field %s", name)
  50233. }
  50234. // AddedEdges returns all edge names that were set/added in this mutation.
  50235. func (m *UserAttributeValueMutation) AddedEdges() []string {
  50236. edges := make([]string, 0, 2)
  50237. if m.user != nil {
  50238. edges = append(edges, userattributevalue.EdgeUser)
  50239. }
  50240. if m.definition != nil {
  50241. edges = append(edges, userattributevalue.EdgeDefinition)
  50242. }
  50243. return edges
  50244. }
  50245. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  50246. // name in this mutation.
  50247. func (m *UserAttributeValueMutation) AddedIDs(name string) []ent.Value {
  50248. switch name {
  50249. case userattributevalue.EdgeUser:
  50250. if id := m.user; id != nil {
  50251. return []ent.Value{*id}
  50252. }
  50253. case userattributevalue.EdgeDefinition:
  50254. if id := m.definition; id != nil {
  50255. return []ent.Value{*id}
  50256. }
  50257. }
  50258. return nil
  50259. }
  50260. // RemovedEdges returns all edge names that were removed in this mutation.
  50261. func (m *UserAttributeValueMutation) RemovedEdges() []string {
  50262. edges := make([]string, 0, 2)
  50263. return edges
  50264. }
  50265. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  50266. // the given name in this mutation.
  50267. func (m *UserAttributeValueMutation) RemovedIDs(name string) []ent.Value {
  50268. return nil
  50269. }
  50270. // ClearedEdges returns all edge names that were cleared in this mutation.
  50271. func (m *UserAttributeValueMutation) ClearedEdges() []string {
  50272. edges := make([]string, 0, 2)
  50273. if m.cleareduser {
  50274. edges = append(edges, userattributevalue.EdgeUser)
  50275. }
  50276. if m.cleareddefinition {
  50277. edges = append(edges, userattributevalue.EdgeDefinition)
  50278. }
  50279. return edges
  50280. }
  50281. // EdgeCleared returns a boolean which indicates if the edge with the given name
  50282. // was cleared in this mutation.
  50283. func (m *UserAttributeValueMutation) EdgeCleared(name string) bool {
  50284. switch name {
  50285. case userattributevalue.EdgeUser:
  50286. return m.cleareduser
  50287. case userattributevalue.EdgeDefinition:
  50288. return m.cleareddefinition
  50289. }
  50290. return false
  50291. }
  50292. // ClearEdge clears the value of the edge with the given name. It returns an error
  50293. // if that edge is not defined in the schema.
  50294. func (m *UserAttributeValueMutation) ClearEdge(name string) error {
  50295. switch name {
  50296. case userattributevalue.EdgeUser:
  50297. m.ClearUser()
  50298. return nil
  50299. case userattributevalue.EdgeDefinition:
  50300. m.ClearDefinition()
  50301. return nil
  50302. }
  50303. return fmt.Errorf("unknown UserAttributeValue unique edge %s", name)
  50304. }
  50305. // ResetEdge resets all changes to the edge with the given name in this mutation.
  50306. // It returns an error if the edge is not defined in the schema.
  50307. func (m *UserAttributeValueMutation) ResetEdge(name string) error {
  50308. switch name {
  50309. case userattributevalue.EdgeUser:
  50310. m.ResetUser()
  50311. return nil
  50312. case userattributevalue.EdgeDefinition:
  50313. m.ResetDefinition()
  50314. return nil
  50315. }
  50316. return fmt.Errorf("unknown UserAttributeValue edge %s", name)
  50317. }
  50318. // UserPlatformQuotaMutation represents an operation that mutates the UserPlatformQuota nodes in the graph.
  50319. type UserPlatformQuotaMutation struct {
  50320. config
  50321. op Op
  50322. typ string
  50323. id *int64
  50324. created_at *time.Time
  50325. updated_at *time.Time
  50326. deleted_at *time.Time
  50327. platform *string
  50328. daily_limit_usd *float64
  50329. adddaily_limit_usd *float64
  50330. weekly_limit_usd *float64
  50331. addweekly_limit_usd *float64
  50332. monthly_limit_usd *float64
  50333. addmonthly_limit_usd *float64
  50334. daily_usage_usd *float64
  50335. adddaily_usage_usd *float64
  50336. weekly_usage_usd *float64
  50337. addweekly_usage_usd *float64
  50338. monthly_usage_usd *float64
  50339. addmonthly_usage_usd *float64
  50340. daily_window_start *time.Time
  50341. weekly_window_start *time.Time
  50342. monthly_window_start *time.Time
  50343. clearedFields map[string]struct{}
  50344. user *int64
  50345. cleareduser bool
  50346. done bool
  50347. oldValue func(context.Context) (*UserPlatformQuota, error)
  50348. predicates []predicate.UserPlatformQuota
  50349. }
  50350. var _ ent.Mutation = (*UserPlatformQuotaMutation)(nil)
  50351. // userplatformquotaOption allows management of the mutation configuration using functional options.
  50352. type userplatformquotaOption func(*UserPlatformQuotaMutation)
  50353. // newUserPlatformQuotaMutation creates new mutation for the UserPlatformQuota entity.
  50354. func newUserPlatformQuotaMutation(c config, op Op, opts ...userplatformquotaOption) *UserPlatformQuotaMutation {
  50355. m := &UserPlatformQuotaMutation{
  50356. config: c,
  50357. op: op,
  50358. typ: TypeUserPlatformQuota,
  50359. clearedFields: make(map[string]struct{}),
  50360. }
  50361. for _, opt := range opts {
  50362. opt(m)
  50363. }
  50364. return m
  50365. }
  50366. // withUserPlatformQuotaID sets the ID field of the mutation.
  50367. func withUserPlatformQuotaID(id int64) userplatformquotaOption {
  50368. return func(m *UserPlatformQuotaMutation) {
  50369. var (
  50370. err error
  50371. once sync.Once
  50372. value *UserPlatformQuota
  50373. )
  50374. m.oldValue = func(ctx context.Context) (*UserPlatformQuota, error) {
  50375. once.Do(func() {
  50376. if m.done {
  50377. err = errors.New("querying old values post mutation is not allowed")
  50378. } else {
  50379. value, err = m.Client().UserPlatformQuota.Get(ctx, id)
  50380. }
  50381. })
  50382. return value, err
  50383. }
  50384. m.id = &id
  50385. }
  50386. }
  50387. // withUserPlatformQuota sets the old UserPlatformQuota of the mutation.
  50388. func withUserPlatformQuota(node *UserPlatformQuota) userplatformquotaOption {
  50389. return func(m *UserPlatformQuotaMutation) {
  50390. m.oldValue = func(context.Context) (*UserPlatformQuota, error) {
  50391. return node, nil
  50392. }
  50393. m.id = &node.ID
  50394. }
  50395. }
  50396. // Client returns a new `ent.Client` from the mutation. If the mutation was
  50397. // executed in a transaction (ent.Tx), a transactional client is returned.
  50398. func (m UserPlatformQuotaMutation) Client() *Client {
  50399. client := &Client{config: m.config}
  50400. client.init()
  50401. return client
  50402. }
  50403. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  50404. // it returns an error otherwise.
  50405. func (m UserPlatformQuotaMutation) Tx() (*Tx, error) {
  50406. if _, ok := m.driver.(*txDriver); !ok {
  50407. return nil, errors.New("ent: mutation is not running in a transaction")
  50408. }
  50409. tx := &Tx{config: m.config}
  50410. tx.init()
  50411. return tx, nil
  50412. }
  50413. // ID returns the ID value in the mutation. Note that the ID is only available
  50414. // if it was provided to the builder or after it was returned from the database.
  50415. func (m *UserPlatformQuotaMutation) ID() (id int64, exists bool) {
  50416. if m.id == nil {
  50417. return
  50418. }
  50419. return *m.id, true
  50420. }
  50421. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  50422. // That means, if the mutation is applied within a transaction with an isolation level such
  50423. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  50424. // or updated by the mutation.
  50425. func (m *UserPlatformQuotaMutation) IDs(ctx context.Context) ([]int64, error) {
  50426. switch {
  50427. case m.op.Is(OpUpdateOne | OpDeleteOne):
  50428. id, exists := m.ID()
  50429. if exists {
  50430. return []int64{id}, nil
  50431. }
  50432. fallthrough
  50433. case m.op.Is(OpUpdate | OpDelete):
  50434. return m.Client().UserPlatformQuota.Query().Where(m.predicates...).IDs(ctx)
  50435. default:
  50436. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  50437. }
  50438. }
  50439. // SetCreatedAt sets the "created_at" field.
  50440. func (m *UserPlatformQuotaMutation) SetCreatedAt(t time.Time) {
  50441. m.created_at = &t
  50442. }
  50443. // CreatedAt returns the value of the "created_at" field in the mutation.
  50444. func (m *UserPlatformQuotaMutation) CreatedAt() (r time.Time, exists bool) {
  50445. v := m.created_at
  50446. if v == nil {
  50447. return
  50448. }
  50449. return *v, true
  50450. }
  50451. // OldCreatedAt returns the old "created_at" field's value of the UserPlatformQuota entity.
  50452. // If the UserPlatformQuota object wasn't provided to the builder, the object is fetched from the database.
  50453. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  50454. func (m *UserPlatformQuotaMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  50455. if !m.op.Is(OpUpdateOne) {
  50456. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  50457. }
  50458. if m.id == nil || m.oldValue == nil {
  50459. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  50460. }
  50461. oldValue, err := m.oldValue(ctx)
  50462. if err != nil {
  50463. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  50464. }
  50465. return oldValue.CreatedAt, nil
  50466. }
  50467. // ResetCreatedAt resets all changes to the "created_at" field.
  50468. func (m *UserPlatformQuotaMutation) ResetCreatedAt() {
  50469. m.created_at = nil
  50470. }
  50471. // SetUpdatedAt sets the "updated_at" field.
  50472. func (m *UserPlatformQuotaMutation) SetUpdatedAt(t time.Time) {
  50473. m.updated_at = &t
  50474. }
  50475. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  50476. func (m *UserPlatformQuotaMutation) UpdatedAt() (r time.Time, exists bool) {
  50477. v := m.updated_at
  50478. if v == nil {
  50479. return
  50480. }
  50481. return *v, true
  50482. }
  50483. // OldUpdatedAt returns the old "updated_at" field's value of the UserPlatformQuota entity.
  50484. // If the UserPlatformQuota object wasn't provided to the builder, the object is fetched from the database.
  50485. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  50486. func (m *UserPlatformQuotaMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  50487. if !m.op.Is(OpUpdateOne) {
  50488. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  50489. }
  50490. if m.id == nil || m.oldValue == nil {
  50491. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  50492. }
  50493. oldValue, err := m.oldValue(ctx)
  50494. if err != nil {
  50495. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  50496. }
  50497. return oldValue.UpdatedAt, nil
  50498. }
  50499. // ResetUpdatedAt resets all changes to the "updated_at" field.
  50500. func (m *UserPlatformQuotaMutation) ResetUpdatedAt() {
  50501. m.updated_at = nil
  50502. }
  50503. // SetDeletedAt sets the "deleted_at" field.
  50504. func (m *UserPlatformQuotaMutation) SetDeletedAt(t time.Time) {
  50505. m.deleted_at = &t
  50506. }
  50507. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  50508. func (m *UserPlatformQuotaMutation) DeletedAt() (r time.Time, exists bool) {
  50509. v := m.deleted_at
  50510. if v == nil {
  50511. return
  50512. }
  50513. return *v, true
  50514. }
  50515. // OldDeletedAt returns the old "deleted_at" field's value of the UserPlatformQuota entity.
  50516. // If the UserPlatformQuota object wasn't provided to the builder, the object is fetched from the database.
  50517. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  50518. func (m *UserPlatformQuotaMutation) OldDeletedAt(ctx context.Context) (v *time.Time, err error) {
  50519. if !m.op.Is(OpUpdateOne) {
  50520. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  50521. }
  50522. if m.id == nil || m.oldValue == nil {
  50523. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  50524. }
  50525. oldValue, err := m.oldValue(ctx)
  50526. if err != nil {
  50527. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  50528. }
  50529. return oldValue.DeletedAt, nil
  50530. }
  50531. // ClearDeletedAt clears the value of the "deleted_at" field.
  50532. func (m *UserPlatformQuotaMutation) ClearDeletedAt() {
  50533. m.deleted_at = nil
  50534. m.clearedFields[userplatformquota.FieldDeletedAt] = struct{}{}
  50535. }
  50536. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  50537. func (m *UserPlatformQuotaMutation) DeletedAtCleared() bool {
  50538. _, ok := m.clearedFields[userplatformquota.FieldDeletedAt]
  50539. return ok
  50540. }
  50541. // ResetDeletedAt resets all changes to the "deleted_at" field.
  50542. func (m *UserPlatformQuotaMutation) ResetDeletedAt() {
  50543. m.deleted_at = nil
  50544. delete(m.clearedFields, userplatformquota.FieldDeletedAt)
  50545. }
  50546. // SetUserID sets the "user_id" field.
  50547. func (m *UserPlatformQuotaMutation) SetUserID(i int64) {
  50548. m.user = &i
  50549. }
  50550. // UserID returns the value of the "user_id" field in the mutation.
  50551. func (m *UserPlatformQuotaMutation) UserID() (r int64, exists bool) {
  50552. v := m.user
  50553. if v == nil {
  50554. return
  50555. }
  50556. return *v, true
  50557. }
  50558. // OldUserID returns the old "user_id" field's value of the UserPlatformQuota entity.
  50559. // If the UserPlatformQuota object wasn't provided to the builder, the object is fetched from the database.
  50560. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  50561. func (m *UserPlatformQuotaMutation) OldUserID(ctx context.Context) (v int64, err error) {
  50562. if !m.op.Is(OpUpdateOne) {
  50563. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  50564. }
  50565. if m.id == nil || m.oldValue == nil {
  50566. return v, errors.New("OldUserID requires an ID field in the mutation")
  50567. }
  50568. oldValue, err := m.oldValue(ctx)
  50569. if err != nil {
  50570. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  50571. }
  50572. return oldValue.UserID, nil
  50573. }
  50574. // ResetUserID resets all changes to the "user_id" field.
  50575. func (m *UserPlatformQuotaMutation) ResetUserID() {
  50576. m.user = nil
  50577. }
  50578. // SetPlatform sets the "platform" field.
  50579. func (m *UserPlatformQuotaMutation) SetPlatform(s string) {
  50580. m.platform = &s
  50581. }
  50582. // Platform returns the value of the "platform" field in the mutation.
  50583. func (m *UserPlatformQuotaMutation) Platform() (r string, exists bool) {
  50584. v := m.platform
  50585. if v == nil {
  50586. return
  50587. }
  50588. return *v, true
  50589. }
  50590. // OldPlatform returns the old "platform" field's value of the UserPlatformQuota entity.
  50591. // If the UserPlatformQuota object wasn't provided to the builder, the object is fetched from the database.
  50592. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  50593. func (m *UserPlatformQuotaMutation) OldPlatform(ctx context.Context) (v string, err error) {
  50594. if !m.op.Is(OpUpdateOne) {
  50595. return v, errors.New("OldPlatform is only allowed on UpdateOne operations")
  50596. }
  50597. if m.id == nil || m.oldValue == nil {
  50598. return v, errors.New("OldPlatform requires an ID field in the mutation")
  50599. }
  50600. oldValue, err := m.oldValue(ctx)
  50601. if err != nil {
  50602. return v, fmt.Errorf("querying old value for OldPlatform: %w", err)
  50603. }
  50604. return oldValue.Platform, nil
  50605. }
  50606. // ResetPlatform resets all changes to the "platform" field.
  50607. func (m *UserPlatformQuotaMutation) ResetPlatform() {
  50608. m.platform = nil
  50609. }
  50610. // SetDailyLimitUsd sets the "daily_limit_usd" field.
  50611. func (m *UserPlatformQuotaMutation) SetDailyLimitUsd(f float64) {
  50612. m.daily_limit_usd = &f
  50613. m.adddaily_limit_usd = nil
  50614. }
  50615. // DailyLimitUsd returns the value of the "daily_limit_usd" field in the mutation.
  50616. func (m *UserPlatformQuotaMutation) DailyLimitUsd() (r float64, exists bool) {
  50617. v := m.daily_limit_usd
  50618. if v == nil {
  50619. return
  50620. }
  50621. return *v, true
  50622. }
  50623. // OldDailyLimitUsd returns the old "daily_limit_usd" field's value of the UserPlatformQuota entity.
  50624. // If the UserPlatformQuota object wasn't provided to the builder, the object is fetched from the database.
  50625. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  50626. func (m *UserPlatformQuotaMutation) OldDailyLimitUsd(ctx context.Context) (v *float64, err error) {
  50627. if !m.op.Is(OpUpdateOne) {
  50628. return v, errors.New("OldDailyLimitUsd is only allowed on UpdateOne operations")
  50629. }
  50630. if m.id == nil || m.oldValue == nil {
  50631. return v, errors.New("OldDailyLimitUsd requires an ID field in the mutation")
  50632. }
  50633. oldValue, err := m.oldValue(ctx)
  50634. if err != nil {
  50635. return v, fmt.Errorf("querying old value for OldDailyLimitUsd: %w", err)
  50636. }
  50637. return oldValue.DailyLimitUsd, nil
  50638. }
  50639. // AddDailyLimitUsd adds f to the "daily_limit_usd" field.
  50640. func (m *UserPlatformQuotaMutation) AddDailyLimitUsd(f float64) {
  50641. if m.adddaily_limit_usd != nil {
  50642. *m.adddaily_limit_usd += f
  50643. } else {
  50644. m.adddaily_limit_usd = &f
  50645. }
  50646. }
  50647. // AddedDailyLimitUsd returns the value that was added to the "daily_limit_usd" field in this mutation.
  50648. func (m *UserPlatformQuotaMutation) AddedDailyLimitUsd() (r float64, exists bool) {
  50649. v := m.adddaily_limit_usd
  50650. if v == nil {
  50651. return
  50652. }
  50653. return *v, true
  50654. }
  50655. // ClearDailyLimitUsd clears the value of the "daily_limit_usd" field.
  50656. func (m *UserPlatformQuotaMutation) ClearDailyLimitUsd() {
  50657. m.daily_limit_usd = nil
  50658. m.adddaily_limit_usd = nil
  50659. m.clearedFields[userplatformquota.FieldDailyLimitUsd] = struct{}{}
  50660. }
  50661. // DailyLimitUsdCleared returns if the "daily_limit_usd" field was cleared in this mutation.
  50662. func (m *UserPlatformQuotaMutation) DailyLimitUsdCleared() bool {
  50663. _, ok := m.clearedFields[userplatformquota.FieldDailyLimitUsd]
  50664. return ok
  50665. }
  50666. // ResetDailyLimitUsd resets all changes to the "daily_limit_usd" field.
  50667. func (m *UserPlatformQuotaMutation) ResetDailyLimitUsd() {
  50668. m.daily_limit_usd = nil
  50669. m.adddaily_limit_usd = nil
  50670. delete(m.clearedFields, userplatformquota.FieldDailyLimitUsd)
  50671. }
  50672. // SetWeeklyLimitUsd sets the "weekly_limit_usd" field.
  50673. func (m *UserPlatformQuotaMutation) SetWeeklyLimitUsd(f float64) {
  50674. m.weekly_limit_usd = &f
  50675. m.addweekly_limit_usd = nil
  50676. }
  50677. // WeeklyLimitUsd returns the value of the "weekly_limit_usd" field in the mutation.
  50678. func (m *UserPlatformQuotaMutation) WeeklyLimitUsd() (r float64, exists bool) {
  50679. v := m.weekly_limit_usd
  50680. if v == nil {
  50681. return
  50682. }
  50683. return *v, true
  50684. }
  50685. // OldWeeklyLimitUsd returns the old "weekly_limit_usd" field's value of the UserPlatformQuota entity.
  50686. // If the UserPlatformQuota object wasn't provided to the builder, the object is fetched from the database.
  50687. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  50688. func (m *UserPlatformQuotaMutation) OldWeeklyLimitUsd(ctx context.Context) (v *float64, err error) {
  50689. if !m.op.Is(OpUpdateOne) {
  50690. return v, errors.New("OldWeeklyLimitUsd is only allowed on UpdateOne operations")
  50691. }
  50692. if m.id == nil || m.oldValue == nil {
  50693. return v, errors.New("OldWeeklyLimitUsd requires an ID field in the mutation")
  50694. }
  50695. oldValue, err := m.oldValue(ctx)
  50696. if err != nil {
  50697. return v, fmt.Errorf("querying old value for OldWeeklyLimitUsd: %w", err)
  50698. }
  50699. return oldValue.WeeklyLimitUsd, nil
  50700. }
  50701. // AddWeeklyLimitUsd adds f to the "weekly_limit_usd" field.
  50702. func (m *UserPlatformQuotaMutation) AddWeeklyLimitUsd(f float64) {
  50703. if m.addweekly_limit_usd != nil {
  50704. *m.addweekly_limit_usd += f
  50705. } else {
  50706. m.addweekly_limit_usd = &f
  50707. }
  50708. }
  50709. // AddedWeeklyLimitUsd returns the value that was added to the "weekly_limit_usd" field in this mutation.
  50710. func (m *UserPlatformQuotaMutation) AddedWeeklyLimitUsd() (r float64, exists bool) {
  50711. v := m.addweekly_limit_usd
  50712. if v == nil {
  50713. return
  50714. }
  50715. return *v, true
  50716. }
  50717. // ClearWeeklyLimitUsd clears the value of the "weekly_limit_usd" field.
  50718. func (m *UserPlatformQuotaMutation) ClearWeeklyLimitUsd() {
  50719. m.weekly_limit_usd = nil
  50720. m.addweekly_limit_usd = nil
  50721. m.clearedFields[userplatformquota.FieldWeeklyLimitUsd] = struct{}{}
  50722. }
  50723. // WeeklyLimitUsdCleared returns if the "weekly_limit_usd" field was cleared in this mutation.
  50724. func (m *UserPlatformQuotaMutation) WeeklyLimitUsdCleared() bool {
  50725. _, ok := m.clearedFields[userplatformquota.FieldWeeklyLimitUsd]
  50726. return ok
  50727. }
  50728. // ResetWeeklyLimitUsd resets all changes to the "weekly_limit_usd" field.
  50729. func (m *UserPlatformQuotaMutation) ResetWeeklyLimitUsd() {
  50730. m.weekly_limit_usd = nil
  50731. m.addweekly_limit_usd = nil
  50732. delete(m.clearedFields, userplatformquota.FieldWeeklyLimitUsd)
  50733. }
  50734. // SetMonthlyLimitUsd sets the "monthly_limit_usd" field.
  50735. func (m *UserPlatformQuotaMutation) SetMonthlyLimitUsd(f float64) {
  50736. m.monthly_limit_usd = &f
  50737. m.addmonthly_limit_usd = nil
  50738. }
  50739. // MonthlyLimitUsd returns the value of the "monthly_limit_usd" field in the mutation.
  50740. func (m *UserPlatformQuotaMutation) MonthlyLimitUsd() (r float64, exists bool) {
  50741. v := m.monthly_limit_usd
  50742. if v == nil {
  50743. return
  50744. }
  50745. return *v, true
  50746. }
  50747. // OldMonthlyLimitUsd returns the old "monthly_limit_usd" field's value of the UserPlatformQuota entity.
  50748. // If the UserPlatformQuota object wasn't provided to the builder, the object is fetched from the database.
  50749. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  50750. func (m *UserPlatformQuotaMutation) OldMonthlyLimitUsd(ctx context.Context) (v *float64, err error) {
  50751. if !m.op.Is(OpUpdateOne) {
  50752. return v, errors.New("OldMonthlyLimitUsd is only allowed on UpdateOne operations")
  50753. }
  50754. if m.id == nil || m.oldValue == nil {
  50755. return v, errors.New("OldMonthlyLimitUsd requires an ID field in the mutation")
  50756. }
  50757. oldValue, err := m.oldValue(ctx)
  50758. if err != nil {
  50759. return v, fmt.Errorf("querying old value for OldMonthlyLimitUsd: %w", err)
  50760. }
  50761. return oldValue.MonthlyLimitUsd, nil
  50762. }
  50763. // AddMonthlyLimitUsd adds f to the "monthly_limit_usd" field.
  50764. func (m *UserPlatformQuotaMutation) AddMonthlyLimitUsd(f float64) {
  50765. if m.addmonthly_limit_usd != nil {
  50766. *m.addmonthly_limit_usd += f
  50767. } else {
  50768. m.addmonthly_limit_usd = &f
  50769. }
  50770. }
  50771. // AddedMonthlyLimitUsd returns the value that was added to the "monthly_limit_usd" field in this mutation.
  50772. func (m *UserPlatformQuotaMutation) AddedMonthlyLimitUsd() (r float64, exists bool) {
  50773. v := m.addmonthly_limit_usd
  50774. if v == nil {
  50775. return
  50776. }
  50777. return *v, true
  50778. }
  50779. // ClearMonthlyLimitUsd clears the value of the "monthly_limit_usd" field.
  50780. func (m *UserPlatformQuotaMutation) ClearMonthlyLimitUsd() {
  50781. m.monthly_limit_usd = nil
  50782. m.addmonthly_limit_usd = nil
  50783. m.clearedFields[userplatformquota.FieldMonthlyLimitUsd] = struct{}{}
  50784. }
  50785. // MonthlyLimitUsdCleared returns if the "monthly_limit_usd" field was cleared in this mutation.
  50786. func (m *UserPlatformQuotaMutation) MonthlyLimitUsdCleared() bool {
  50787. _, ok := m.clearedFields[userplatformquota.FieldMonthlyLimitUsd]
  50788. return ok
  50789. }
  50790. // ResetMonthlyLimitUsd resets all changes to the "monthly_limit_usd" field.
  50791. func (m *UserPlatformQuotaMutation) ResetMonthlyLimitUsd() {
  50792. m.monthly_limit_usd = nil
  50793. m.addmonthly_limit_usd = nil
  50794. delete(m.clearedFields, userplatformquota.FieldMonthlyLimitUsd)
  50795. }
  50796. // SetDailyUsageUsd sets the "daily_usage_usd" field.
  50797. func (m *UserPlatformQuotaMutation) SetDailyUsageUsd(f float64) {
  50798. m.daily_usage_usd = &f
  50799. m.adddaily_usage_usd = nil
  50800. }
  50801. // DailyUsageUsd returns the value of the "daily_usage_usd" field in the mutation.
  50802. func (m *UserPlatformQuotaMutation) DailyUsageUsd() (r float64, exists bool) {
  50803. v := m.daily_usage_usd
  50804. if v == nil {
  50805. return
  50806. }
  50807. return *v, true
  50808. }
  50809. // OldDailyUsageUsd returns the old "daily_usage_usd" field's value of the UserPlatformQuota entity.
  50810. // If the UserPlatformQuota object wasn't provided to the builder, the object is fetched from the database.
  50811. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  50812. func (m *UserPlatformQuotaMutation) OldDailyUsageUsd(ctx context.Context) (v float64, err error) {
  50813. if !m.op.Is(OpUpdateOne) {
  50814. return v, errors.New("OldDailyUsageUsd is only allowed on UpdateOne operations")
  50815. }
  50816. if m.id == nil || m.oldValue == nil {
  50817. return v, errors.New("OldDailyUsageUsd requires an ID field in the mutation")
  50818. }
  50819. oldValue, err := m.oldValue(ctx)
  50820. if err != nil {
  50821. return v, fmt.Errorf("querying old value for OldDailyUsageUsd: %w", err)
  50822. }
  50823. return oldValue.DailyUsageUsd, nil
  50824. }
  50825. // AddDailyUsageUsd adds f to the "daily_usage_usd" field.
  50826. func (m *UserPlatformQuotaMutation) AddDailyUsageUsd(f float64) {
  50827. if m.adddaily_usage_usd != nil {
  50828. *m.adddaily_usage_usd += f
  50829. } else {
  50830. m.adddaily_usage_usd = &f
  50831. }
  50832. }
  50833. // AddedDailyUsageUsd returns the value that was added to the "daily_usage_usd" field in this mutation.
  50834. func (m *UserPlatformQuotaMutation) AddedDailyUsageUsd() (r float64, exists bool) {
  50835. v := m.adddaily_usage_usd
  50836. if v == nil {
  50837. return
  50838. }
  50839. return *v, true
  50840. }
  50841. // ResetDailyUsageUsd resets all changes to the "daily_usage_usd" field.
  50842. func (m *UserPlatformQuotaMutation) ResetDailyUsageUsd() {
  50843. m.daily_usage_usd = nil
  50844. m.adddaily_usage_usd = nil
  50845. }
  50846. // SetWeeklyUsageUsd sets the "weekly_usage_usd" field.
  50847. func (m *UserPlatformQuotaMutation) SetWeeklyUsageUsd(f float64) {
  50848. m.weekly_usage_usd = &f
  50849. m.addweekly_usage_usd = nil
  50850. }
  50851. // WeeklyUsageUsd returns the value of the "weekly_usage_usd" field in the mutation.
  50852. func (m *UserPlatformQuotaMutation) WeeklyUsageUsd() (r float64, exists bool) {
  50853. v := m.weekly_usage_usd
  50854. if v == nil {
  50855. return
  50856. }
  50857. return *v, true
  50858. }
  50859. // OldWeeklyUsageUsd returns the old "weekly_usage_usd" field's value of the UserPlatformQuota entity.
  50860. // If the UserPlatformQuota object wasn't provided to the builder, the object is fetched from the database.
  50861. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  50862. func (m *UserPlatformQuotaMutation) OldWeeklyUsageUsd(ctx context.Context) (v float64, err error) {
  50863. if !m.op.Is(OpUpdateOne) {
  50864. return v, errors.New("OldWeeklyUsageUsd is only allowed on UpdateOne operations")
  50865. }
  50866. if m.id == nil || m.oldValue == nil {
  50867. return v, errors.New("OldWeeklyUsageUsd requires an ID field in the mutation")
  50868. }
  50869. oldValue, err := m.oldValue(ctx)
  50870. if err != nil {
  50871. return v, fmt.Errorf("querying old value for OldWeeklyUsageUsd: %w", err)
  50872. }
  50873. return oldValue.WeeklyUsageUsd, nil
  50874. }
  50875. // AddWeeklyUsageUsd adds f to the "weekly_usage_usd" field.
  50876. func (m *UserPlatformQuotaMutation) AddWeeklyUsageUsd(f float64) {
  50877. if m.addweekly_usage_usd != nil {
  50878. *m.addweekly_usage_usd += f
  50879. } else {
  50880. m.addweekly_usage_usd = &f
  50881. }
  50882. }
  50883. // AddedWeeklyUsageUsd returns the value that was added to the "weekly_usage_usd" field in this mutation.
  50884. func (m *UserPlatformQuotaMutation) AddedWeeklyUsageUsd() (r float64, exists bool) {
  50885. v := m.addweekly_usage_usd
  50886. if v == nil {
  50887. return
  50888. }
  50889. return *v, true
  50890. }
  50891. // ResetWeeklyUsageUsd resets all changes to the "weekly_usage_usd" field.
  50892. func (m *UserPlatformQuotaMutation) ResetWeeklyUsageUsd() {
  50893. m.weekly_usage_usd = nil
  50894. m.addweekly_usage_usd = nil
  50895. }
  50896. // SetMonthlyUsageUsd sets the "monthly_usage_usd" field.
  50897. func (m *UserPlatformQuotaMutation) SetMonthlyUsageUsd(f float64) {
  50898. m.monthly_usage_usd = &f
  50899. m.addmonthly_usage_usd = nil
  50900. }
  50901. // MonthlyUsageUsd returns the value of the "monthly_usage_usd" field in the mutation.
  50902. func (m *UserPlatformQuotaMutation) MonthlyUsageUsd() (r float64, exists bool) {
  50903. v := m.monthly_usage_usd
  50904. if v == nil {
  50905. return
  50906. }
  50907. return *v, true
  50908. }
  50909. // OldMonthlyUsageUsd returns the old "monthly_usage_usd" field's value of the UserPlatformQuota entity.
  50910. // If the UserPlatformQuota object wasn't provided to the builder, the object is fetched from the database.
  50911. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  50912. func (m *UserPlatformQuotaMutation) OldMonthlyUsageUsd(ctx context.Context) (v float64, err error) {
  50913. if !m.op.Is(OpUpdateOne) {
  50914. return v, errors.New("OldMonthlyUsageUsd is only allowed on UpdateOne operations")
  50915. }
  50916. if m.id == nil || m.oldValue == nil {
  50917. return v, errors.New("OldMonthlyUsageUsd requires an ID field in the mutation")
  50918. }
  50919. oldValue, err := m.oldValue(ctx)
  50920. if err != nil {
  50921. return v, fmt.Errorf("querying old value for OldMonthlyUsageUsd: %w", err)
  50922. }
  50923. return oldValue.MonthlyUsageUsd, nil
  50924. }
  50925. // AddMonthlyUsageUsd adds f to the "monthly_usage_usd" field.
  50926. func (m *UserPlatformQuotaMutation) AddMonthlyUsageUsd(f float64) {
  50927. if m.addmonthly_usage_usd != nil {
  50928. *m.addmonthly_usage_usd += f
  50929. } else {
  50930. m.addmonthly_usage_usd = &f
  50931. }
  50932. }
  50933. // AddedMonthlyUsageUsd returns the value that was added to the "monthly_usage_usd" field in this mutation.
  50934. func (m *UserPlatformQuotaMutation) AddedMonthlyUsageUsd() (r float64, exists bool) {
  50935. v := m.addmonthly_usage_usd
  50936. if v == nil {
  50937. return
  50938. }
  50939. return *v, true
  50940. }
  50941. // ResetMonthlyUsageUsd resets all changes to the "monthly_usage_usd" field.
  50942. func (m *UserPlatformQuotaMutation) ResetMonthlyUsageUsd() {
  50943. m.monthly_usage_usd = nil
  50944. m.addmonthly_usage_usd = nil
  50945. }
  50946. // SetDailyWindowStart sets the "daily_window_start" field.
  50947. func (m *UserPlatformQuotaMutation) SetDailyWindowStart(t time.Time) {
  50948. m.daily_window_start = &t
  50949. }
  50950. // DailyWindowStart returns the value of the "daily_window_start" field in the mutation.
  50951. func (m *UserPlatformQuotaMutation) DailyWindowStart() (r time.Time, exists bool) {
  50952. v := m.daily_window_start
  50953. if v == nil {
  50954. return
  50955. }
  50956. return *v, true
  50957. }
  50958. // OldDailyWindowStart returns the old "daily_window_start" field's value of the UserPlatformQuota entity.
  50959. // If the UserPlatformQuota object wasn't provided to the builder, the object is fetched from the database.
  50960. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  50961. func (m *UserPlatformQuotaMutation) OldDailyWindowStart(ctx context.Context) (v *time.Time, err error) {
  50962. if !m.op.Is(OpUpdateOne) {
  50963. return v, errors.New("OldDailyWindowStart is only allowed on UpdateOne operations")
  50964. }
  50965. if m.id == nil || m.oldValue == nil {
  50966. return v, errors.New("OldDailyWindowStart requires an ID field in the mutation")
  50967. }
  50968. oldValue, err := m.oldValue(ctx)
  50969. if err != nil {
  50970. return v, fmt.Errorf("querying old value for OldDailyWindowStart: %w", err)
  50971. }
  50972. return oldValue.DailyWindowStart, nil
  50973. }
  50974. // ClearDailyWindowStart clears the value of the "daily_window_start" field.
  50975. func (m *UserPlatformQuotaMutation) ClearDailyWindowStart() {
  50976. m.daily_window_start = nil
  50977. m.clearedFields[userplatformquota.FieldDailyWindowStart] = struct{}{}
  50978. }
  50979. // DailyWindowStartCleared returns if the "daily_window_start" field was cleared in this mutation.
  50980. func (m *UserPlatformQuotaMutation) DailyWindowStartCleared() bool {
  50981. _, ok := m.clearedFields[userplatformquota.FieldDailyWindowStart]
  50982. return ok
  50983. }
  50984. // ResetDailyWindowStart resets all changes to the "daily_window_start" field.
  50985. func (m *UserPlatformQuotaMutation) ResetDailyWindowStart() {
  50986. m.daily_window_start = nil
  50987. delete(m.clearedFields, userplatformquota.FieldDailyWindowStart)
  50988. }
  50989. // SetWeeklyWindowStart sets the "weekly_window_start" field.
  50990. func (m *UserPlatformQuotaMutation) SetWeeklyWindowStart(t time.Time) {
  50991. m.weekly_window_start = &t
  50992. }
  50993. // WeeklyWindowStart returns the value of the "weekly_window_start" field in the mutation.
  50994. func (m *UserPlatformQuotaMutation) WeeklyWindowStart() (r time.Time, exists bool) {
  50995. v := m.weekly_window_start
  50996. if v == nil {
  50997. return
  50998. }
  50999. return *v, true
  51000. }
  51001. // OldWeeklyWindowStart returns the old "weekly_window_start" field's value of the UserPlatformQuota entity.
  51002. // If the UserPlatformQuota object wasn't provided to the builder, the object is fetched from the database.
  51003. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  51004. func (m *UserPlatformQuotaMutation) OldWeeklyWindowStart(ctx context.Context) (v *time.Time, err error) {
  51005. if !m.op.Is(OpUpdateOne) {
  51006. return v, errors.New("OldWeeklyWindowStart is only allowed on UpdateOne operations")
  51007. }
  51008. if m.id == nil || m.oldValue == nil {
  51009. return v, errors.New("OldWeeklyWindowStart requires an ID field in the mutation")
  51010. }
  51011. oldValue, err := m.oldValue(ctx)
  51012. if err != nil {
  51013. return v, fmt.Errorf("querying old value for OldWeeklyWindowStart: %w", err)
  51014. }
  51015. return oldValue.WeeklyWindowStart, nil
  51016. }
  51017. // ClearWeeklyWindowStart clears the value of the "weekly_window_start" field.
  51018. func (m *UserPlatformQuotaMutation) ClearWeeklyWindowStart() {
  51019. m.weekly_window_start = nil
  51020. m.clearedFields[userplatformquota.FieldWeeklyWindowStart] = struct{}{}
  51021. }
  51022. // WeeklyWindowStartCleared returns if the "weekly_window_start" field was cleared in this mutation.
  51023. func (m *UserPlatformQuotaMutation) WeeklyWindowStartCleared() bool {
  51024. _, ok := m.clearedFields[userplatformquota.FieldWeeklyWindowStart]
  51025. return ok
  51026. }
  51027. // ResetWeeklyWindowStart resets all changes to the "weekly_window_start" field.
  51028. func (m *UserPlatformQuotaMutation) ResetWeeklyWindowStart() {
  51029. m.weekly_window_start = nil
  51030. delete(m.clearedFields, userplatformquota.FieldWeeklyWindowStart)
  51031. }
  51032. // SetMonthlyWindowStart sets the "monthly_window_start" field.
  51033. func (m *UserPlatformQuotaMutation) SetMonthlyWindowStart(t time.Time) {
  51034. m.monthly_window_start = &t
  51035. }
  51036. // MonthlyWindowStart returns the value of the "monthly_window_start" field in the mutation.
  51037. func (m *UserPlatformQuotaMutation) MonthlyWindowStart() (r time.Time, exists bool) {
  51038. v := m.monthly_window_start
  51039. if v == nil {
  51040. return
  51041. }
  51042. return *v, true
  51043. }
  51044. // OldMonthlyWindowStart returns the old "monthly_window_start" field's value of the UserPlatformQuota entity.
  51045. // If the UserPlatformQuota object wasn't provided to the builder, the object is fetched from the database.
  51046. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  51047. func (m *UserPlatformQuotaMutation) OldMonthlyWindowStart(ctx context.Context) (v *time.Time, err error) {
  51048. if !m.op.Is(OpUpdateOne) {
  51049. return v, errors.New("OldMonthlyWindowStart is only allowed on UpdateOne operations")
  51050. }
  51051. if m.id == nil || m.oldValue == nil {
  51052. return v, errors.New("OldMonthlyWindowStart requires an ID field in the mutation")
  51053. }
  51054. oldValue, err := m.oldValue(ctx)
  51055. if err != nil {
  51056. return v, fmt.Errorf("querying old value for OldMonthlyWindowStart: %w", err)
  51057. }
  51058. return oldValue.MonthlyWindowStart, nil
  51059. }
  51060. // ClearMonthlyWindowStart clears the value of the "monthly_window_start" field.
  51061. func (m *UserPlatformQuotaMutation) ClearMonthlyWindowStart() {
  51062. m.monthly_window_start = nil
  51063. m.clearedFields[userplatformquota.FieldMonthlyWindowStart] = struct{}{}
  51064. }
  51065. // MonthlyWindowStartCleared returns if the "monthly_window_start" field was cleared in this mutation.
  51066. func (m *UserPlatformQuotaMutation) MonthlyWindowStartCleared() bool {
  51067. _, ok := m.clearedFields[userplatformquota.FieldMonthlyWindowStart]
  51068. return ok
  51069. }
  51070. // ResetMonthlyWindowStart resets all changes to the "monthly_window_start" field.
  51071. func (m *UserPlatformQuotaMutation) ResetMonthlyWindowStart() {
  51072. m.monthly_window_start = nil
  51073. delete(m.clearedFields, userplatformquota.FieldMonthlyWindowStart)
  51074. }
  51075. // ClearUser clears the "user" edge to the User entity.
  51076. func (m *UserPlatformQuotaMutation) ClearUser() {
  51077. m.cleareduser = true
  51078. m.clearedFields[userplatformquota.FieldUserID] = struct{}{}
  51079. }
  51080. // UserCleared reports if the "user" edge to the User entity was cleared.
  51081. func (m *UserPlatformQuotaMutation) UserCleared() bool {
  51082. return m.cleareduser
  51083. }
  51084. // UserIDs returns the "user" edge IDs in the mutation.
  51085. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  51086. // UserID instead. It exists only for internal usage by the builders.
  51087. func (m *UserPlatformQuotaMutation) UserIDs() (ids []int64) {
  51088. if id := m.user; id != nil {
  51089. ids = append(ids, *id)
  51090. }
  51091. return
  51092. }
  51093. // ResetUser resets all changes to the "user" edge.
  51094. func (m *UserPlatformQuotaMutation) ResetUser() {
  51095. m.user = nil
  51096. m.cleareduser = false
  51097. }
  51098. // Where appends a list predicates to the UserPlatformQuotaMutation builder.
  51099. func (m *UserPlatformQuotaMutation) Where(ps ...predicate.UserPlatformQuota) {
  51100. m.predicates = append(m.predicates, ps...)
  51101. }
  51102. // WhereP appends storage-level predicates to the UserPlatformQuotaMutation builder. Using this method,
  51103. // users can use type-assertion to append predicates that do not depend on any generated package.
  51104. func (m *UserPlatformQuotaMutation) WhereP(ps ...func(*sql.Selector)) {
  51105. p := make([]predicate.UserPlatformQuota, len(ps))
  51106. for i := range ps {
  51107. p[i] = ps[i]
  51108. }
  51109. m.Where(p...)
  51110. }
  51111. // Op returns the operation name.
  51112. func (m *UserPlatformQuotaMutation) Op() Op {
  51113. return m.op
  51114. }
  51115. // SetOp allows setting the mutation operation.
  51116. func (m *UserPlatformQuotaMutation) SetOp(op Op) {
  51117. m.op = op
  51118. }
  51119. // Type returns the node type of this mutation (UserPlatformQuota).
  51120. func (m *UserPlatformQuotaMutation) Type() string {
  51121. return m.typ
  51122. }
  51123. // Fields returns all fields that were changed during this mutation. Note that in
  51124. // order to get all numeric fields that were incremented/decremented, call
  51125. // AddedFields().
  51126. func (m *UserPlatformQuotaMutation) Fields() []string {
  51127. fields := make([]string, 0, 14)
  51128. if m.created_at != nil {
  51129. fields = append(fields, userplatformquota.FieldCreatedAt)
  51130. }
  51131. if m.updated_at != nil {
  51132. fields = append(fields, userplatformquota.FieldUpdatedAt)
  51133. }
  51134. if m.deleted_at != nil {
  51135. fields = append(fields, userplatformquota.FieldDeletedAt)
  51136. }
  51137. if m.user != nil {
  51138. fields = append(fields, userplatformquota.FieldUserID)
  51139. }
  51140. if m.platform != nil {
  51141. fields = append(fields, userplatformquota.FieldPlatform)
  51142. }
  51143. if m.daily_limit_usd != nil {
  51144. fields = append(fields, userplatformquota.FieldDailyLimitUsd)
  51145. }
  51146. if m.weekly_limit_usd != nil {
  51147. fields = append(fields, userplatformquota.FieldWeeklyLimitUsd)
  51148. }
  51149. if m.monthly_limit_usd != nil {
  51150. fields = append(fields, userplatformquota.FieldMonthlyLimitUsd)
  51151. }
  51152. if m.daily_usage_usd != nil {
  51153. fields = append(fields, userplatformquota.FieldDailyUsageUsd)
  51154. }
  51155. if m.weekly_usage_usd != nil {
  51156. fields = append(fields, userplatformquota.FieldWeeklyUsageUsd)
  51157. }
  51158. if m.monthly_usage_usd != nil {
  51159. fields = append(fields, userplatformquota.FieldMonthlyUsageUsd)
  51160. }
  51161. if m.daily_window_start != nil {
  51162. fields = append(fields, userplatformquota.FieldDailyWindowStart)
  51163. }
  51164. if m.weekly_window_start != nil {
  51165. fields = append(fields, userplatformquota.FieldWeeklyWindowStart)
  51166. }
  51167. if m.monthly_window_start != nil {
  51168. fields = append(fields, userplatformquota.FieldMonthlyWindowStart)
  51169. }
  51170. return fields
  51171. }
  51172. // Field returns the value of a field with the given name. The second boolean
  51173. // return value indicates that this field was not set, or was not defined in the
  51174. // schema.
  51175. func (m *UserPlatformQuotaMutation) Field(name string) (ent.Value, bool) {
  51176. switch name {
  51177. case userplatformquota.FieldCreatedAt:
  51178. return m.CreatedAt()
  51179. case userplatformquota.FieldUpdatedAt:
  51180. return m.UpdatedAt()
  51181. case userplatformquota.FieldDeletedAt:
  51182. return m.DeletedAt()
  51183. case userplatformquota.FieldUserID:
  51184. return m.UserID()
  51185. case userplatformquota.FieldPlatform:
  51186. return m.Platform()
  51187. case userplatformquota.FieldDailyLimitUsd:
  51188. return m.DailyLimitUsd()
  51189. case userplatformquota.FieldWeeklyLimitUsd:
  51190. return m.WeeklyLimitUsd()
  51191. case userplatformquota.FieldMonthlyLimitUsd:
  51192. return m.MonthlyLimitUsd()
  51193. case userplatformquota.FieldDailyUsageUsd:
  51194. return m.DailyUsageUsd()
  51195. case userplatformquota.FieldWeeklyUsageUsd:
  51196. return m.WeeklyUsageUsd()
  51197. case userplatformquota.FieldMonthlyUsageUsd:
  51198. return m.MonthlyUsageUsd()
  51199. case userplatformquota.FieldDailyWindowStart:
  51200. return m.DailyWindowStart()
  51201. case userplatformquota.FieldWeeklyWindowStart:
  51202. return m.WeeklyWindowStart()
  51203. case userplatformquota.FieldMonthlyWindowStart:
  51204. return m.MonthlyWindowStart()
  51205. }
  51206. return nil, false
  51207. }
  51208. // OldField returns the old value of the field from the database. An error is
  51209. // returned if the mutation operation is not UpdateOne, or the query to the
  51210. // database failed.
  51211. func (m *UserPlatformQuotaMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  51212. switch name {
  51213. case userplatformquota.FieldCreatedAt:
  51214. return m.OldCreatedAt(ctx)
  51215. case userplatformquota.FieldUpdatedAt:
  51216. return m.OldUpdatedAt(ctx)
  51217. case userplatformquota.FieldDeletedAt:
  51218. return m.OldDeletedAt(ctx)
  51219. case userplatformquota.FieldUserID:
  51220. return m.OldUserID(ctx)
  51221. case userplatformquota.FieldPlatform:
  51222. return m.OldPlatform(ctx)
  51223. case userplatformquota.FieldDailyLimitUsd:
  51224. return m.OldDailyLimitUsd(ctx)
  51225. case userplatformquota.FieldWeeklyLimitUsd:
  51226. return m.OldWeeklyLimitUsd(ctx)
  51227. case userplatformquota.FieldMonthlyLimitUsd:
  51228. return m.OldMonthlyLimitUsd(ctx)
  51229. case userplatformquota.FieldDailyUsageUsd:
  51230. return m.OldDailyUsageUsd(ctx)
  51231. case userplatformquota.FieldWeeklyUsageUsd:
  51232. return m.OldWeeklyUsageUsd(ctx)
  51233. case userplatformquota.FieldMonthlyUsageUsd:
  51234. return m.OldMonthlyUsageUsd(ctx)
  51235. case userplatformquota.FieldDailyWindowStart:
  51236. return m.OldDailyWindowStart(ctx)
  51237. case userplatformquota.FieldWeeklyWindowStart:
  51238. return m.OldWeeklyWindowStart(ctx)
  51239. case userplatformquota.FieldMonthlyWindowStart:
  51240. return m.OldMonthlyWindowStart(ctx)
  51241. }
  51242. return nil, fmt.Errorf("unknown UserPlatformQuota field %s", name)
  51243. }
  51244. // SetField sets the value of a field with the given name. It returns an error if
  51245. // the field is not defined in the schema, or if the type mismatched the field
  51246. // type.
  51247. func (m *UserPlatformQuotaMutation) SetField(name string, value ent.Value) error {
  51248. switch name {
  51249. case userplatformquota.FieldCreatedAt:
  51250. v, ok := value.(time.Time)
  51251. if !ok {
  51252. return fmt.Errorf("unexpected type %T for field %s", value, name)
  51253. }
  51254. m.SetCreatedAt(v)
  51255. return nil
  51256. case userplatformquota.FieldUpdatedAt:
  51257. v, ok := value.(time.Time)
  51258. if !ok {
  51259. return fmt.Errorf("unexpected type %T for field %s", value, name)
  51260. }
  51261. m.SetUpdatedAt(v)
  51262. return nil
  51263. case userplatformquota.FieldDeletedAt:
  51264. v, ok := value.(time.Time)
  51265. if !ok {
  51266. return fmt.Errorf("unexpected type %T for field %s", value, name)
  51267. }
  51268. m.SetDeletedAt(v)
  51269. return nil
  51270. case userplatformquota.FieldUserID:
  51271. v, ok := value.(int64)
  51272. if !ok {
  51273. return fmt.Errorf("unexpected type %T for field %s", value, name)
  51274. }
  51275. m.SetUserID(v)
  51276. return nil
  51277. case userplatformquota.FieldPlatform:
  51278. v, ok := value.(string)
  51279. if !ok {
  51280. return fmt.Errorf("unexpected type %T for field %s", value, name)
  51281. }
  51282. m.SetPlatform(v)
  51283. return nil
  51284. case userplatformquota.FieldDailyLimitUsd:
  51285. v, ok := value.(float64)
  51286. if !ok {
  51287. return fmt.Errorf("unexpected type %T for field %s", value, name)
  51288. }
  51289. m.SetDailyLimitUsd(v)
  51290. return nil
  51291. case userplatformquota.FieldWeeklyLimitUsd:
  51292. v, ok := value.(float64)
  51293. if !ok {
  51294. return fmt.Errorf("unexpected type %T for field %s", value, name)
  51295. }
  51296. m.SetWeeklyLimitUsd(v)
  51297. return nil
  51298. case userplatformquota.FieldMonthlyLimitUsd:
  51299. v, ok := value.(float64)
  51300. if !ok {
  51301. return fmt.Errorf("unexpected type %T for field %s", value, name)
  51302. }
  51303. m.SetMonthlyLimitUsd(v)
  51304. return nil
  51305. case userplatformquota.FieldDailyUsageUsd:
  51306. v, ok := value.(float64)
  51307. if !ok {
  51308. return fmt.Errorf("unexpected type %T for field %s", value, name)
  51309. }
  51310. m.SetDailyUsageUsd(v)
  51311. return nil
  51312. case userplatformquota.FieldWeeklyUsageUsd:
  51313. v, ok := value.(float64)
  51314. if !ok {
  51315. return fmt.Errorf("unexpected type %T for field %s", value, name)
  51316. }
  51317. m.SetWeeklyUsageUsd(v)
  51318. return nil
  51319. case userplatformquota.FieldMonthlyUsageUsd:
  51320. v, ok := value.(float64)
  51321. if !ok {
  51322. return fmt.Errorf("unexpected type %T for field %s", value, name)
  51323. }
  51324. m.SetMonthlyUsageUsd(v)
  51325. return nil
  51326. case userplatformquota.FieldDailyWindowStart:
  51327. v, ok := value.(time.Time)
  51328. if !ok {
  51329. return fmt.Errorf("unexpected type %T for field %s", value, name)
  51330. }
  51331. m.SetDailyWindowStart(v)
  51332. return nil
  51333. case userplatformquota.FieldWeeklyWindowStart:
  51334. v, ok := value.(time.Time)
  51335. if !ok {
  51336. return fmt.Errorf("unexpected type %T for field %s", value, name)
  51337. }
  51338. m.SetWeeklyWindowStart(v)
  51339. return nil
  51340. case userplatformquota.FieldMonthlyWindowStart:
  51341. v, ok := value.(time.Time)
  51342. if !ok {
  51343. return fmt.Errorf("unexpected type %T for field %s", value, name)
  51344. }
  51345. m.SetMonthlyWindowStart(v)
  51346. return nil
  51347. }
  51348. return fmt.Errorf("unknown UserPlatformQuota field %s", name)
  51349. }
  51350. // AddedFields returns all numeric fields that were incremented/decremented during
  51351. // this mutation.
  51352. func (m *UserPlatformQuotaMutation) AddedFields() []string {
  51353. var fields []string
  51354. if m.adddaily_limit_usd != nil {
  51355. fields = append(fields, userplatformquota.FieldDailyLimitUsd)
  51356. }
  51357. if m.addweekly_limit_usd != nil {
  51358. fields = append(fields, userplatformquota.FieldWeeklyLimitUsd)
  51359. }
  51360. if m.addmonthly_limit_usd != nil {
  51361. fields = append(fields, userplatformquota.FieldMonthlyLimitUsd)
  51362. }
  51363. if m.adddaily_usage_usd != nil {
  51364. fields = append(fields, userplatformquota.FieldDailyUsageUsd)
  51365. }
  51366. if m.addweekly_usage_usd != nil {
  51367. fields = append(fields, userplatformquota.FieldWeeklyUsageUsd)
  51368. }
  51369. if m.addmonthly_usage_usd != nil {
  51370. fields = append(fields, userplatformquota.FieldMonthlyUsageUsd)
  51371. }
  51372. return fields
  51373. }
  51374. // AddedField returns the numeric value that was incremented/decremented on a field
  51375. // with the given name. The second boolean return value indicates that this field
  51376. // was not set, or was not defined in the schema.
  51377. func (m *UserPlatformQuotaMutation) AddedField(name string) (ent.Value, bool) {
  51378. switch name {
  51379. case userplatformquota.FieldDailyLimitUsd:
  51380. return m.AddedDailyLimitUsd()
  51381. case userplatformquota.FieldWeeklyLimitUsd:
  51382. return m.AddedWeeklyLimitUsd()
  51383. case userplatformquota.FieldMonthlyLimitUsd:
  51384. return m.AddedMonthlyLimitUsd()
  51385. case userplatformquota.FieldDailyUsageUsd:
  51386. return m.AddedDailyUsageUsd()
  51387. case userplatformquota.FieldWeeklyUsageUsd:
  51388. return m.AddedWeeklyUsageUsd()
  51389. case userplatformquota.FieldMonthlyUsageUsd:
  51390. return m.AddedMonthlyUsageUsd()
  51391. }
  51392. return nil, false
  51393. }
  51394. // AddField adds the value to the field with the given name. It returns an error if
  51395. // the field is not defined in the schema, or if the type mismatched the field
  51396. // type.
  51397. func (m *UserPlatformQuotaMutation) AddField(name string, value ent.Value) error {
  51398. switch name {
  51399. case userplatformquota.FieldDailyLimitUsd:
  51400. v, ok := value.(float64)
  51401. if !ok {
  51402. return fmt.Errorf("unexpected type %T for field %s", value, name)
  51403. }
  51404. m.AddDailyLimitUsd(v)
  51405. return nil
  51406. case userplatformquota.FieldWeeklyLimitUsd:
  51407. v, ok := value.(float64)
  51408. if !ok {
  51409. return fmt.Errorf("unexpected type %T for field %s", value, name)
  51410. }
  51411. m.AddWeeklyLimitUsd(v)
  51412. return nil
  51413. case userplatformquota.FieldMonthlyLimitUsd:
  51414. v, ok := value.(float64)
  51415. if !ok {
  51416. return fmt.Errorf("unexpected type %T for field %s", value, name)
  51417. }
  51418. m.AddMonthlyLimitUsd(v)
  51419. return nil
  51420. case userplatformquota.FieldDailyUsageUsd:
  51421. v, ok := value.(float64)
  51422. if !ok {
  51423. return fmt.Errorf("unexpected type %T for field %s", value, name)
  51424. }
  51425. m.AddDailyUsageUsd(v)
  51426. return nil
  51427. case userplatformquota.FieldWeeklyUsageUsd:
  51428. v, ok := value.(float64)
  51429. if !ok {
  51430. return fmt.Errorf("unexpected type %T for field %s", value, name)
  51431. }
  51432. m.AddWeeklyUsageUsd(v)
  51433. return nil
  51434. case userplatformquota.FieldMonthlyUsageUsd:
  51435. v, ok := value.(float64)
  51436. if !ok {
  51437. return fmt.Errorf("unexpected type %T for field %s", value, name)
  51438. }
  51439. m.AddMonthlyUsageUsd(v)
  51440. return nil
  51441. }
  51442. return fmt.Errorf("unknown UserPlatformQuota numeric field %s", name)
  51443. }
  51444. // ClearedFields returns all nullable fields that were cleared during this
  51445. // mutation.
  51446. func (m *UserPlatformQuotaMutation) ClearedFields() []string {
  51447. var fields []string
  51448. if m.FieldCleared(userplatformquota.FieldDeletedAt) {
  51449. fields = append(fields, userplatformquota.FieldDeletedAt)
  51450. }
  51451. if m.FieldCleared(userplatformquota.FieldDailyLimitUsd) {
  51452. fields = append(fields, userplatformquota.FieldDailyLimitUsd)
  51453. }
  51454. if m.FieldCleared(userplatformquota.FieldWeeklyLimitUsd) {
  51455. fields = append(fields, userplatformquota.FieldWeeklyLimitUsd)
  51456. }
  51457. if m.FieldCleared(userplatformquota.FieldMonthlyLimitUsd) {
  51458. fields = append(fields, userplatformquota.FieldMonthlyLimitUsd)
  51459. }
  51460. if m.FieldCleared(userplatformquota.FieldDailyWindowStart) {
  51461. fields = append(fields, userplatformquota.FieldDailyWindowStart)
  51462. }
  51463. if m.FieldCleared(userplatformquota.FieldWeeklyWindowStart) {
  51464. fields = append(fields, userplatformquota.FieldWeeklyWindowStart)
  51465. }
  51466. if m.FieldCleared(userplatformquota.FieldMonthlyWindowStart) {
  51467. fields = append(fields, userplatformquota.FieldMonthlyWindowStart)
  51468. }
  51469. return fields
  51470. }
  51471. // FieldCleared returns a boolean indicating if a field with the given name was
  51472. // cleared in this mutation.
  51473. func (m *UserPlatformQuotaMutation) FieldCleared(name string) bool {
  51474. _, ok := m.clearedFields[name]
  51475. return ok
  51476. }
  51477. // ClearField clears the value of the field with the given name. It returns an
  51478. // error if the field is not defined in the schema.
  51479. func (m *UserPlatformQuotaMutation) ClearField(name string) error {
  51480. switch name {
  51481. case userplatformquota.FieldDeletedAt:
  51482. m.ClearDeletedAt()
  51483. return nil
  51484. case userplatformquota.FieldDailyLimitUsd:
  51485. m.ClearDailyLimitUsd()
  51486. return nil
  51487. case userplatformquota.FieldWeeklyLimitUsd:
  51488. m.ClearWeeklyLimitUsd()
  51489. return nil
  51490. case userplatformquota.FieldMonthlyLimitUsd:
  51491. m.ClearMonthlyLimitUsd()
  51492. return nil
  51493. case userplatformquota.FieldDailyWindowStart:
  51494. m.ClearDailyWindowStart()
  51495. return nil
  51496. case userplatformquota.FieldWeeklyWindowStart:
  51497. m.ClearWeeklyWindowStart()
  51498. return nil
  51499. case userplatformquota.FieldMonthlyWindowStart:
  51500. m.ClearMonthlyWindowStart()
  51501. return nil
  51502. }
  51503. return fmt.Errorf("unknown UserPlatformQuota nullable field %s", name)
  51504. }
  51505. // ResetField resets all changes in the mutation for the field with the given name.
  51506. // It returns an error if the field is not defined in the schema.
  51507. func (m *UserPlatformQuotaMutation) ResetField(name string) error {
  51508. switch name {
  51509. case userplatformquota.FieldCreatedAt:
  51510. m.ResetCreatedAt()
  51511. return nil
  51512. case userplatformquota.FieldUpdatedAt:
  51513. m.ResetUpdatedAt()
  51514. return nil
  51515. case userplatformquota.FieldDeletedAt:
  51516. m.ResetDeletedAt()
  51517. return nil
  51518. case userplatformquota.FieldUserID:
  51519. m.ResetUserID()
  51520. return nil
  51521. case userplatformquota.FieldPlatform:
  51522. m.ResetPlatform()
  51523. return nil
  51524. case userplatformquota.FieldDailyLimitUsd:
  51525. m.ResetDailyLimitUsd()
  51526. return nil
  51527. case userplatformquota.FieldWeeklyLimitUsd:
  51528. m.ResetWeeklyLimitUsd()
  51529. return nil
  51530. case userplatformquota.FieldMonthlyLimitUsd:
  51531. m.ResetMonthlyLimitUsd()
  51532. return nil
  51533. case userplatformquota.FieldDailyUsageUsd:
  51534. m.ResetDailyUsageUsd()
  51535. return nil
  51536. case userplatformquota.FieldWeeklyUsageUsd:
  51537. m.ResetWeeklyUsageUsd()
  51538. return nil
  51539. case userplatformquota.FieldMonthlyUsageUsd:
  51540. m.ResetMonthlyUsageUsd()
  51541. return nil
  51542. case userplatformquota.FieldDailyWindowStart:
  51543. m.ResetDailyWindowStart()
  51544. return nil
  51545. case userplatformquota.FieldWeeklyWindowStart:
  51546. m.ResetWeeklyWindowStart()
  51547. return nil
  51548. case userplatformquota.FieldMonthlyWindowStart:
  51549. m.ResetMonthlyWindowStart()
  51550. return nil
  51551. }
  51552. return fmt.Errorf("unknown UserPlatformQuota field %s", name)
  51553. }
  51554. // AddedEdges returns all edge names that were set/added in this mutation.
  51555. func (m *UserPlatformQuotaMutation) AddedEdges() []string {
  51556. edges := make([]string, 0, 1)
  51557. if m.user != nil {
  51558. edges = append(edges, userplatformquota.EdgeUser)
  51559. }
  51560. return edges
  51561. }
  51562. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  51563. // name in this mutation.
  51564. func (m *UserPlatformQuotaMutation) AddedIDs(name string) []ent.Value {
  51565. switch name {
  51566. case userplatformquota.EdgeUser:
  51567. if id := m.user; id != nil {
  51568. return []ent.Value{*id}
  51569. }
  51570. }
  51571. return nil
  51572. }
  51573. // RemovedEdges returns all edge names that were removed in this mutation.
  51574. func (m *UserPlatformQuotaMutation) RemovedEdges() []string {
  51575. edges := make([]string, 0, 1)
  51576. return edges
  51577. }
  51578. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  51579. // the given name in this mutation.
  51580. func (m *UserPlatformQuotaMutation) RemovedIDs(name string) []ent.Value {
  51581. return nil
  51582. }
  51583. // ClearedEdges returns all edge names that were cleared in this mutation.
  51584. func (m *UserPlatformQuotaMutation) ClearedEdges() []string {
  51585. edges := make([]string, 0, 1)
  51586. if m.cleareduser {
  51587. edges = append(edges, userplatformquota.EdgeUser)
  51588. }
  51589. return edges
  51590. }
  51591. // EdgeCleared returns a boolean which indicates if the edge with the given name
  51592. // was cleared in this mutation.
  51593. func (m *UserPlatformQuotaMutation) EdgeCleared(name string) bool {
  51594. switch name {
  51595. case userplatformquota.EdgeUser:
  51596. return m.cleareduser
  51597. }
  51598. return false
  51599. }
  51600. // ClearEdge clears the value of the edge with the given name. It returns an error
  51601. // if that edge is not defined in the schema.
  51602. func (m *UserPlatformQuotaMutation) ClearEdge(name string) error {
  51603. switch name {
  51604. case userplatformquota.EdgeUser:
  51605. m.ClearUser()
  51606. return nil
  51607. }
  51608. return fmt.Errorf("unknown UserPlatformQuota unique edge %s", name)
  51609. }
  51610. // ResetEdge resets all changes to the edge with the given name in this mutation.
  51611. // It returns an error if the edge is not defined in the schema.
  51612. func (m *UserPlatformQuotaMutation) ResetEdge(name string) error {
  51613. switch name {
  51614. case userplatformquota.EdgeUser:
  51615. m.ResetUser()
  51616. return nil
  51617. }
  51618. return fmt.Errorf("unknown UserPlatformQuota edge %s", name)
  51619. }
  51620. // UserSubscriptionMutation represents an operation that mutates the UserSubscription nodes in the graph.
  51621. type UserSubscriptionMutation struct {
  51622. config
  51623. op Op
  51624. typ string
  51625. id *int64
  51626. created_at *time.Time
  51627. updated_at *time.Time
  51628. deleted_at *time.Time
  51629. starts_at *time.Time
  51630. expires_at *time.Time
  51631. status *string
  51632. daily_window_start *time.Time
  51633. weekly_window_start *time.Time
  51634. monthly_window_start *time.Time
  51635. daily_usage_usd *float64
  51636. adddaily_usage_usd *float64
  51637. weekly_usage_usd *float64
  51638. addweekly_usage_usd *float64
  51639. monthly_usage_usd *float64
  51640. addmonthly_usage_usd *float64
  51641. assigned_at *time.Time
  51642. notes *string
  51643. clearedFields map[string]struct{}
  51644. user *int64
  51645. cleareduser bool
  51646. group *int64
  51647. clearedgroup bool
  51648. assigned_by_user *int64
  51649. clearedassigned_by_user bool
  51650. usage_logs map[int64]struct{}
  51651. removedusage_logs map[int64]struct{}
  51652. clearedusage_logs bool
  51653. done bool
  51654. oldValue func(context.Context) (*UserSubscription, error)
  51655. predicates []predicate.UserSubscription
  51656. }
  51657. var _ ent.Mutation = (*UserSubscriptionMutation)(nil)
  51658. // usersubscriptionOption allows management of the mutation configuration using functional options.
  51659. type usersubscriptionOption func(*UserSubscriptionMutation)
  51660. // newUserSubscriptionMutation creates new mutation for the UserSubscription entity.
  51661. func newUserSubscriptionMutation(c config, op Op, opts ...usersubscriptionOption) *UserSubscriptionMutation {
  51662. m := &UserSubscriptionMutation{
  51663. config: c,
  51664. op: op,
  51665. typ: TypeUserSubscription,
  51666. clearedFields: make(map[string]struct{}),
  51667. }
  51668. for _, opt := range opts {
  51669. opt(m)
  51670. }
  51671. return m
  51672. }
  51673. // withUserSubscriptionID sets the ID field of the mutation.
  51674. func withUserSubscriptionID(id int64) usersubscriptionOption {
  51675. return func(m *UserSubscriptionMutation) {
  51676. var (
  51677. err error
  51678. once sync.Once
  51679. value *UserSubscription
  51680. )
  51681. m.oldValue = func(ctx context.Context) (*UserSubscription, error) {
  51682. once.Do(func() {
  51683. if m.done {
  51684. err = errors.New("querying old values post mutation is not allowed")
  51685. } else {
  51686. value, err = m.Client().UserSubscription.Get(ctx, id)
  51687. }
  51688. })
  51689. return value, err
  51690. }
  51691. m.id = &id
  51692. }
  51693. }
  51694. // withUserSubscription sets the old UserSubscription of the mutation.
  51695. func withUserSubscription(node *UserSubscription) usersubscriptionOption {
  51696. return func(m *UserSubscriptionMutation) {
  51697. m.oldValue = func(context.Context) (*UserSubscription, error) {
  51698. return node, nil
  51699. }
  51700. m.id = &node.ID
  51701. }
  51702. }
  51703. // Client returns a new `ent.Client` from the mutation. If the mutation was
  51704. // executed in a transaction (ent.Tx), a transactional client is returned.
  51705. func (m UserSubscriptionMutation) Client() *Client {
  51706. client := &Client{config: m.config}
  51707. client.init()
  51708. return client
  51709. }
  51710. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  51711. // it returns an error otherwise.
  51712. func (m UserSubscriptionMutation) Tx() (*Tx, error) {
  51713. if _, ok := m.driver.(*txDriver); !ok {
  51714. return nil, errors.New("ent: mutation is not running in a transaction")
  51715. }
  51716. tx := &Tx{config: m.config}
  51717. tx.init()
  51718. return tx, nil
  51719. }
  51720. // ID returns the ID value in the mutation. Note that the ID is only available
  51721. // if it was provided to the builder or after it was returned from the database.
  51722. func (m *UserSubscriptionMutation) ID() (id int64, exists bool) {
  51723. if m.id == nil {
  51724. return
  51725. }
  51726. return *m.id, true
  51727. }
  51728. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  51729. // That means, if the mutation is applied within a transaction with an isolation level such
  51730. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  51731. // or updated by the mutation.
  51732. func (m *UserSubscriptionMutation) IDs(ctx context.Context) ([]int64, error) {
  51733. switch {
  51734. case m.op.Is(OpUpdateOne | OpDeleteOne):
  51735. id, exists := m.ID()
  51736. if exists {
  51737. return []int64{id}, nil
  51738. }
  51739. fallthrough
  51740. case m.op.Is(OpUpdate | OpDelete):
  51741. return m.Client().UserSubscription.Query().Where(m.predicates...).IDs(ctx)
  51742. default:
  51743. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  51744. }
  51745. }
  51746. // SetCreatedAt sets the "created_at" field.
  51747. func (m *UserSubscriptionMutation) SetCreatedAt(t time.Time) {
  51748. m.created_at = &t
  51749. }
  51750. // CreatedAt returns the value of the "created_at" field in the mutation.
  51751. func (m *UserSubscriptionMutation) CreatedAt() (r time.Time, exists bool) {
  51752. v := m.created_at
  51753. if v == nil {
  51754. return
  51755. }
  51756. return *v, true
  51757. }
  51758. // OldCreatedAt returns the old "created_at" field's value of the UserSubscription entity.
  51759. // If the UserSubscription object wasn't provided to the builder, the object is fetched from the database.
  51760. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  51761. func (m *UserSubscriptionMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  51762. if !m.op.Is(OpUpdateOne) {
  51763. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  51764. }
  51765. if m.id == nil || m.oldValue == nil {
  51766. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  51767. }
  51768. oldValue, err := m.oldValue(ctx)
  51769. if err != nil {
  51770. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  51771. }
  51772. return oldValue.CreatedAt, nil
  51773. }
  51774. // ResetCreatedAt resets all changes to the "created_at" field.
  51775. func (m *UserSubscriptionMutation) ResetCreatedAt() {
  51776. m.created_at = nil
  51777. }
  51778. // SetUpdatedAt sets the "updated_at" field.
  51779. func (m *UserSubscriptionMutation) SetUpdatedAt(t time.Time) {
  51780. m.updated_at = &t
  51781. }
  51782. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  51783. func (m *UserSubscriptionMutation) UpdatedAt() (r time.Time, exists bool) {
  51784. v := m.updated_at
  51785. if v == nil {
  51786. return
  51787. }
  51788. return *v, true
  51789. }
  51790. // OldUpdatedAt returns the old "updated_at" field's value of the UserSubscription entity.
  51791. // If the UserSubscription object wasn't provided to the builder, the object is fetched from the database.
  51792. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  51793. func (m *UserSubscriptionMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  51794. if !m.op.Is(OpUpdateOne) {
  51795. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  51796. }
  51797. if m.id == nil || m.oldValue == nil {
  51798. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  51799. }
  51800. oldValue, err := m.oldValue(ctx)
  51801. if err != nil {
  51802. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  51803. }
  51804. return oldValue.UpdatedAt, nil
  51805. }
  51806. // ResetUpdatedAt resets all changes to the "updated_at" field.
  51807. func (m *UserSubscriptionMutation) ResetUpdatedAt() {
  51808. m.updated_at = nil
  51809. }
  51810. // SetDeletedAt sets the "deleted_at" field.
  51811. func (m *UserSubscriptionMutation) SetDeletedAt(t time.Time) {
  51812. m.deleted_at = &t
  51813. }
  51814. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  51815. func (m *UserSubscriptionMutation) DeletedAt() (r time.Time, exists bool) {
  51816. v := m.deleted_at
  51817. if v == nil {
  51818. return
  51819. }
  51820. return *v, true
  51821. }
  51822. // OldDeletedAt returns the old "deleted_at" field's value of the UserSubscription entity.
  51823. // If the UserSubscription object wasn't provided to the builder, the object is fetched from the database.
  51824. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  51825. func (m *UserSubscriptionMutation) OldDeletedAt(ctx context.Context) (v *time.Time, err error) {
  51826. if !m.op.Is(OpUpdateOne) {
  51827. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  51828. }
  51829. if m.id == nil || m.oldValue == nil {
  51830. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  51831. }
  51832. oldValue, err := m.oldValue(ctx)
  51833. if err != nil {
  51834. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  51835. }
  51836. return oldValue.DeletedAt, nil
  51837. }
  51838. // ClearDeletedAt clears the value of the "deleted_at" field.
  51839. func (m *UserSubscriptionMutation) ClearDeletedAt() {
  51840. m.deleted_at = nil
  51841. m.clearedFields[usersubscription.FieldDeletedAt] = struct{}{}
  51842. }
  51843. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  51844. func (m *UserSubscriptionMutation) DeletedAtCleared() bool {
  51845. _, ok := m.clearedFields[usersubscription.FieldDeletedAt]
  51846. return ok
  51847. }
  51848. // ResetDeletedAt resets all changes to the "deleted_at" field.
  51849. func (m *UserSubscriptionMutation) ResetDeletedAt() {
  51850. m.deleted_at = nil
  51851. delete(m.clearedFields, usersubscription.FieldDeletedAt)
  51852. }
  51853. // SetUserID sets the "user_id" field.
  51854. func (m *UserSubscriptionMutation) SetUserID(i int64) {
  51855. m.user = &i
  51856. }
  51857. // UserID returns the value of the "user_id" field in the mutation.
  51858. func (m *UserSubscriptionMutation) UserID() (r int64, exists bool) {
  51859. v := m.user
  51860. if v == nil {
  51861. return
  51862. }
  51863. return *v, true
  51864. }
  51865. // OldUserID returns the old "user_id" field's value of the UserSubscription entity.
  51866. // If the UserSubscription object wasn't provided to the builder, the object is fetched from the database.
  51867. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  51868. func (m *UserSubscriptionMutation) OldUserID(ctx context.Context) (v int64, err error) {
  51869. if !m.op.Is(OpUpdateOne) {
  51870. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  51871. }
  51872. if m.id == nil || m.oldValue == nil {
  51873. return v, errors.New("OldUserID requires an ID field in the mutation")
  51874. }
  51875. oldValue, err := m.oldValue(ctx)
  51876. if err != nil {
  51877. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  51878. }
  51879. return oldValue.UserID, nil
  51880. }
  51881. // ResetUserID resets all changes to the "user_id" field.
  51882. func (m *UserSubscriptionMutation) ResetUserID() {
  51883. m.user = nil
  51884. }
  51885. // SetGroupID sets the "group_id" field.
  51886. func (m *UserSubscriptionMutation) SetGroupID(i int64) {
  51887. m.group = &i
  51888. }
  51889. // GroupID returns the value of the "group_id" field in the mutation.
  51890. func (m *UserSubscriptionMutation) GroupID() (r int64, exists bool) {
  51891. v := m.group
  51892. if v == nil {
  51893. return
  51894. }
  51895. return *v, true
  51896. }
  51897. // OldGroupID returns the old "group_id" field's value of the UserSubscription entity.
  51898. // If the UserSubscription object wasn't provided to the builder, the object is fetched from the database.
  51899. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  51900. func (m *UserSubscriptionMutation) OldGroupID(ctx context.Context) (v int64, err error) {
  51901. if !m.op.Is(OpUpdateOne) {
  51902. return v, errors.New("OldGroupID is only allowed on UpdateOne operations")
  51903. }
  51904. if m.id == nil || m.oldValue == nil {
  51905. return v, errors.New("OldGroupID requires an ID field in the mutation")
  51906. }
  51907. oldValue, err := m.oldValue(ctx)
  51908. if err != nil {
  51909. return v, fmt.Errorf("querying old value for OldGroupID: %w", err)
  51910. }
  51911. return oldValue.GroupID, nil
  51912. }
  51913. // ResetGroupID resets all changes to the "group_id" field.
  51914. func (m *UserSubscriptionMutation) ResetGroupID() {
  51915. m.group = nil
  51916. }
  51917. // SetStartsAt sets the "starts_at" field.
  51918. func (m *UserSubscriptionMutation) SetStartsAt(t time.Time) {
  51919. m.starts_at = &t
  51920. }
  51921. // StartsAt returns the value of the "starts_at" field in the mutation.
  51922. func (m *UserSubscriptionMutation) StartsAt() (r time.Time, exists bool) {
  51923. v := m.starts_at
  51924. if v == nil {
  51925. return
  51926. }
  51927. return *v, true
  51928. }
  51929. // OldStartsAt returns the old "starts_at" field's value of the UserSubscription entity.
  51930. // If the UserSubscription object wasn't provided to the builder, the object is fetched from the database.
  51931. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  51932. func (m *UserSubscriptionMutation) OldStartsAt(ctx context.Context) (v time.Time, err error) {
  51933. if !m.op.Is(OpUpdateOne) {
  51934. return v, errors.New("OldStartsAt is only allowed on UpdateOne operations")
  51935. }
  51936. if m.id == nil || m.oldValue == nil {
  51937. return v, errors.New("OldStartsAt requires an ID field in the mutation")
  51938. }
  51939. oldValue, err := m.oldValue(ctx)
  51940. if err != nil {
  51941. return v, fmt.Errorf("querying old value for OldStartsAt: %w", err)
  51942. }
  51943. return oldValue.StartsAt, nil
  51944. }
  51945. // ResetStartsAt resets all changes to the "starts_at" field.
  51946. func (m *UserSubscriptionMutation) ResetStartsAt() {
  51947. m.starts_at = nil
  51948. }
  51949. // SetExpiresAt sets the "expires_at" field.
  51950. func (m *UserSubscriptionMutation) SetExpiresAt(t time.Time) {
  51951. m.expires_at = &t
  51952. }
  51953. // ExpiresAt returns the value of the "expires_at" field in the mutation.
  51954. func (m *UserSubscriptionMutation) ExpiresAt() (r time.Time, exists bool) {
  51955. v := m.expires_at
  51956. if v == nil {
  51957. return
  51958. }
  51959. return *v, true
  51960. }
  51961. // OldExpiresAt returns the old "expires_at" field's value of the UserSubscription entity.
  51962. // If the UserSubscription object wasn't provided to the builder, the object is fetched from the database.
  51963. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  51964. func (m *UserSubscriptionMutation) OldExpiresAt(ctx context.Context) (v time.Time, err error) {
  51965. if !m.op.Is(OpUpdateOne) {
  51966. return v, errors.New("OldExpiresAt is only allowed on UpdateOne operations")
  51967. }
  51968. if m.id == nil || m.oldValue == nil {
  51969. return v, errors.New("OldExpiresAt requires an ID field in the mutation")
  51970. }
  51971. oldValue, err := m.oldValue(ctx)
  51972. if err != nil {
  51973. return v, fmt.Errorf("querying old value for OldExpiresAt: %w", err)
  51974. }
  51975. return oldValue.ExpiresAt, nil
  51976. }
  51977. // ResetExpiresAt resets all changes to the "expires_at" field.
  51978. func (m *UserSubscriptionMutation) ResetExpiresAt() {
  51979. m.expires_at = nil
  51980. }
  51981. // SetStatus sets the "status" field.
  51982. func (m *UserSubscriptionMutation) SetStatus(s string) {
  51983. m.status = &s
  51984. }
  51985. // Status returns the value of the "status" field in the mutation.
  51986. func (m *UserSubscriptionMutation) Status() (r string, exists bool) {
  51987. v := m.status
  51988. if v == nil {
  51989. return
  51990. }
  51991. return *v, true
  51992. }
  51993. // OldStatus returns the old "status" field's value of the UserSubscription entity.
  51994. // If the UserSubscription object wasn't provided to the builder, the object is fetched from the database.
  51995. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  51996. func (m *UserSubscriptionMutation) OldStatus(ctx context.Context) (v string, err error) {
  51997. if !m.op.Is(OpUpdateOne) {
  51998. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  51999. }
  52000. if m.id == nil || m.oldValue == nil {
  52001. return v, errors.New("OldStatus requires an ID field in the mutation")
  52002. }
  52003. oldValue, err := m.oldValue(ctx)
  52004. if err != nil {
  52005. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  52006. }
  52007. return oldValue.Status, nil
  52008. }
  52009. // ResetStatus resets all changes to the "status" field.
  52010. func (m *UserSubscriptionMutation) ResetStatus() {
  52011. m.status = nil
  52012. }
  52013. // SetDailyWindowStart sets the "daily_window_start" field.
  52014. func (m *UserSubscriptionMutation) SetDailyWindowStart(t time.Time) {
  52015. m.daily_window_start = &t
  52016. }
  52017. // DailyWindowStart returns the value of the "daily_window_start" field in the mutation.
  52018. func (m *UserSubscriptionMutation) DailyWindowStart() (r time.Time, exists bool) {
  52019. v := m.daily_window_start
  52020. if v == nil {
  52021. return
  52022. }
  52023. return *v, true
  52024. }
  52025. // OldDailyWindowStart returns the old "daily_window_start" field's value of the UserSubscription entity.
  52026. // If the UserSubscription object wasn't provided to the builder, the object is fetched from the database.
  52027. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  52028. func (m *UserSubscriptionMutation) OldDailyWindowStart(ctx context.Context) (v *time.Time, err error) {
  52029. if !m.op.Is(OpUpdateOne) {
  52030. return v, errors.New("OldDailyWindowStart is only allowed on UpdateOne operations")
  52031. }
  52032. if m.id == nil || m.oldValue == nil {
  52033. return v, errors.New("OldDailyWindowStart requires an ID field in the mutation")
  52034. }
  52035. oldValue, err := m.oldValue(ctx)
  52036. if err != nil {
  52037. return v, fmt.Errorf("querying old value for OldDailyWindowStart: %w", err)
  52038. }
  52039. return oldValue.DailyWindowStart, nil
  52040. }
  52041. // ClearDailyWindowStart clears the value of the "daily_window_start" field.
  52042. func (m *UserSubscriptionMutation) ClearDailyWindowStart() {
  52043. m.daily_window_start = nil
  52044. m.clearedFields[usersubscription.FieldDailyWindowStart] = struct{}{}
  52045. }
  52046. // DailyWindowStartCleared returns if the "daily_window_start" field was cleared in this mutation.
  52047. func (m *UserSubscriptionMutation) DailyWindowStartCleared() bool {
  52048. _, ok := m.clearedFields[usersubscription.FieldDailyWindowStart]
  52049. return ok
  52050. }
  52051. // ResetDailyWindowStart resets all changes to the "daily_window_start" field.
  52052. func (m *UserSubscriptionMutation) ResetDailyWindowStart() {
  52053. m.daily_window_start = nil
  52054. delete(m.clearedFields, usersubscription.FieldDailyWindowStart)
  52055. }
  52056. // SetWeeklyWindowStart sets the "weekly_window_start" field.
  52057. func (m *UserSubscriptionMutation) SetWeeklyWindowStart(t time.Time) {
  52058. m.weekly_window_start = &t
  52059. }
  52060. // WeeklyWindowStart returns the value of the "weekly_window_start" field in the mutation.
  52061. func (m *UserSubscriptionMutation) WeeklyWindowStart() (r time.Time, exists bool) {
  52062. v := m.weekly_window_start
  52063. if v == nil {
  52064. return
  52065. }
  52066. return *v, true
  52067. }
  52068. // OldWeeklyWindowStart returns the old "weekly_window_start" field's value of the UserSubscription entity.
  52069. // If the UserSubscription object wasn't provided to the builder, the object is fetched from the database.
  52070. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  52071. func (m *UserSubscriptionMutation) OldWeeklyWindowStart(ctx context.Context) (v *time.Time, err error) {
  52072. if !m.op.Is(OpUpdateOne) {
  52073. return v, errors.New("OldWeeklyWindowStart is only allowed on UpdateOne operations")
  52074. }
  52075. if m.id == nil || m.oldValue == nil {
  52076. return v, errors.New("OldWeeklyWindowStart requires an ID field in the mutation")
  52077. }
  52078. oldValue, err := m.oldValue(ctx)
  52079. if err != nil {
  52080. return v, fmt.Errorf("querying old value for OldWeeklyWindowStart: %w", err)
  52081. }
  52082. return oldValue.WeeklyWindowStart, nil
  52083. }
  52084. // ClearWeeklyWindowStart clears the value of the "weekly_window_start" field.
  52085. func (m *UserSubscriptionMutation) ClearWeeklyWindowStart() {
  52086. m.weekly_window_start = nil
  52087. m.clearedFields[usersubscription.FieldWeeklyWindowStart] = struct{}{}
  52088. }
  52089. // WeeklyWindowStartCleared returns if the "weekly_window_start" field was cleared in this mutation.
  52090. func (m *UserSubscriptionMutation) WeeklyWindowStartCleared() bool {
  52091. _, ok := m.clearedFields[usersubscription.FieldWeeklyWindowStart]
  52092. return ok
  52093. }
  52094. // ResetWeeklyWindowStart resets all changes to the "weekly_window_start" field.
  52095. func (m *UserSubscriptionMutation) ResetWeeklyWindowStart() {
  52096. m.weekly_window_start = nil
  52097. delete(m.clearedFields, usersubscription.FieldWeeklyWindowStart)
  52098. }
  52099. // SetMonthlyWindowStart sets the "monthly_window_start" field.
  52100. func (m *UserSubscriptionMutation) SetMonthlyWindowStart(t time.Time) {
  52101. m.monthly_window_start = &t
  52102. }
  52103. // MonthlyWindowStart returns the value of the "monthly_window_start" field in the mutation.
  52104. func (m *UserSubscriptionMutation) MonthlyWindowStart() (r time.Time, exists bool) {
  52105. v := m.monthly_window_start
  52106. if v == nil {
  52107. return
  52108. }
  52109. return *v, true
  52110. }
  52111. // OldMonthlyWindowStart returns the old "monthly_window_start" field's value of the UserSubscription entity.
  52112. // If the UserSubscription object wasn't provided to the builder, the object is fetched from the database.
  52113. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  52114. func (m *UserSubscriptionMutation) OldMonthlyWindowStart(ctx context.Context) (v *time.Time, err error) {
  52115. if !m.op.Is(OpUpdateOne) {
  52116. return v, errors.New("OldMonthlyWindowStart is only allowed on UpdateOne operations")
  52117. }
  52118. if m.id == nil || m.oldValue == nil {
  52119. return v, errors.New("OldMonthlyWindowStart requires an ID field in the mutation")
  52120. }
  52121. oldValue, err := m.oldValue(ctx)
  52122. if err != nil {
  52123. return v, fmt.Errorf("querying old value for OldMonthlyWindowStart: %w", err)
  52124. }
  52125. return oldValue.MonthlyWindowStart, nil
  52126. }
  52127. // ClearMonthlyWindowStart clears the value of the "monthly_window_start" field.
  52128. func (m *UserSubscriptionMutation) ClearMonthlyWindowStart() {
  52129. m.monthly_window_start = nil
  52130. m.clearedFields[usersubscription.FieldMonthlyWindowStart] = struct{}{}
  52131. }
  52132. // MonthlyWindowStartCleared returns if the "monthly_window_start" field was cleared in this mutation.
  52133. func (m *UserSubscriptionMutation) MonthlyWindowStartCleared() bool {
  52134. _, ok := m.clearedFields[usersubscription.FieldMonthlyWindowStart]
  52135. return ok
  52136. }
  52137. // ResetMonthlyWindowStart resets all changes to the "monthly_window_start" field.
  52138. func (m *UserSubscriptionMutation) ResetMonthlyWindowStart() {
  52139. m.monthly_window_start = nil
  52140. delete(m.clearedFields, usersubscription.FieldMonthlyWindowStart)
  52141. }
  52142. // SetDailyUsageUsd sets the "daily_usage_usd" field.
  52143. func (m *UserSubscriptionMutation) SetDailyUsageUsd(f float64) {
  52144. m.daily_usage_usd = &f
  52145. m.adddaily_usage_usd = nil
  52146. }
  52147. // DailyUsageUsd returns the value of the "daily_usage_usd" field in the mutation.
  52148. func (m *UserSubscriptionMutation) DailyUsageUsd() (r float64, exists bool) {
  52149. v := m.daily_usage_usd
  52150. if v == nil {
  52151. return
  52152. }
  52153. return *v, true
  52154. }
  52155. // OldDailyUsageUsd returns the old "daily_usage_usd" field's value of the UserSubscription entity.
  52156. // If the UserSubscription object wasn't provided to the builder, the object is fetched from the database.
  52157. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  52158. func (m *UserSubscriptionMutation) OldDailyUsageUsd(ctx context.Context) (v float64, err error) {
  52159. if !m.op.Is(OpUpdateOne) {
  52160. return v, errors.New("OldDailyUsageUsd is only allowed on UpdateOne operations")
  52161. }
  52162. if m.id == nil || m.oldValue == nil {
  52163. return v, errors.New("OldDailyUsageUsd requires an ID field in the mutation")
  52164. }
  52165. oldValue, err := m.oldValue(ctx)
  52166. if err != nil {
  52167. return v, fmt.Errorf("querying old value for OldDailyUsageUsd: %w", err)
  52168. }
  52169. return oldValue.DailyUsageUsd, nil
  52170. }
  52171. // AddDailyUsageUsd adds f to the "daily_usage_usd" field.
  52172. func (m *UserSubscriptionMutation) AddDailyUsageUsd(f float64) {
  52173. if m.adddaily_usage_usd != nil {
  52174. *m.adddaily_usage_usd += f
  52175. } else {
  52176. m.adddaily_usage_usd = &f
  52177. }
  52178. }
  52179. // AddedDailyUsageUsd returns the value that was added to the "daily_usage_usd" field in this mutation.
  52180. func (m *UserSubscriptionMutation) AddedDailyUsageUsd() (r float64, exists bool) {
  52181. v := m.adddaily_usage_usd
  52182. if v == nil {
  52183. return
  52184. }
  52185. return *v, true
  52186. }
  52187. // ResetDailyUsageUsd resets all changes to the "daily_usage_usd" field.
  52188. func (m *UserSubscriptionMutation) ResetDailyUsageUsd() {
  52189. m.daily_usage_usd = nil
  52190. m.adddaily_usage_usd = nil
  52191. }
  52192. // SetWeeklyUsageUsd sets the "weekly_usage_usd" field.
  52193. func (m *UserSubscriptionMutation) SetWeeklyUsageUsd(f float64) {
  52194. m.weekly_usage_usd = &f
  52195. m.addweekly_usage_usd = nil
  52196. }
  52197. // WeeklyUsageUsd returns the value of the "weekly_usage_usd" field in the mutation.
  52198. func (m *UserSubscriptionMutation) WeeklyUsageUsd() (r float64, exists bool) {
  52199. v := m.weekly_usage_usd
  52200. if v == nil {
  52201. return
  52202. }
  52203. return *v, true
  52204. }
  52205. // OldWeeklyUsageUsd returns the old "weekly_usage_usd" field's value of the UserSubscription entity.
  52206. // If the UserSubscription object wasn't provided to the builder, the object is fetched from the database.
  52207. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  52208. func (m *UserSubscriptionMutation) OldWeeklyUsageUsd(ctx context.Context) (v float64, err error) {
  52209. if !m.op.Is(OpUpdateOne) {
  52210. return v, errors.New("OldWeeklyUsageUsd is only allowed on UpdateOne operations")
  52211. }
  52212. if m.id == nil || m.oldValue == nil {
  52213. return v, errors.New("OldWeeklyUsageUsd requires an ID field in the mutation")
  52214. }
  52215. oldValue, err := m.oldValue(ctx)
  52216. if err != nil {
  52217. return v, fmt.Errorf("querying old value for OldWeeklyUsageUsd: %w", err)
  52218. }
  52219. return oldValue.WeeklyUsageUsd, nil
  52220. }
  52221. // AddWeeklyUsageUsd adds f to the "weekly_usage_usd" field.
  52222. func (m *UserSubscriptionMutation) AddWeeklyUsageUsd(f float64) {
  52223. if m.addweekly_usage_usd != nil {
  52224. *m.addweekly_usage_usd += f
  52225. } else {
  52226. m.addweekly_usage_usd = &f
  52227. }
  52228. }
  52229. // AddedWeeklyUsageUsd returns the value that was added to the "weekly_usage_usd" field in this mutation.
  52230. func (m *UserSubscriptionMutation) AddedWeeklyUsageUsd() (r float64, exists bool) {
  52231. v := m.addweekly_usage_usd
  52232. if v == nil {
  52233. return
  52234. }
  52235. return *v, true
  52236. }
  52237. // ResetWeeklyUsageUsd resets all changes to the "weekly_usage_usd" field.
  52238. func (m *UserSubscriptionMutation) ResetWeeklyUsageUsd() {
  52239. m.weekly_usage_usd = nil
  52240. m.addweekly_usage_usd = nil
  52241. }
  52242. // SetMonthlyUsageUsd sets the "monthly_usage_usd" field.
  52243. func (m *UserSubscriptionMutation) SetMonthlyUsageUsd(f float64) {
  52244. m.monthly_usage_usd = &f
  52245. m.addmonthly_usage_usd = nil
  52246. }
  52247. // MonthlyUsageUsd returns the value of the "monthly_usage_usd" field in the mutation.
  52248. func (m *UserSubscriptionMutation) MonthlyUsageUsd() (r float64, exists bool) {
  52249. v := m.monthly_usage_usd
  52250. if v == nil {
  52251. return
  52252. }
  52253. return *v, true
  52254. }
  52255. // OldMonthlyUsageUsd returns the old "monthly_usage_usd" field's value of the UserSubscription entity.
  52256. // If the UserSubscription object wasn't provided to the builder, the object is fetched from the database.
  52257. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  52258. func (m *UserSubscriptionMutation) OldMonthlyUsageUsd(ctx context.Context) (v float64, err error) {
  52259. if !m.op.Is(OpUpdateOne) {
  52260. return v, errors.New("OldMonthlyUsageUsd is only allowed on UpdateOne operations")
  52261. }
  52262. if m.id == nil || m.oldValue == nil {
  52263. return v, errors.New("OldMonthlyUsageUsd requires an ID field in the mutation")
  52264. }
  52265. oldValue, err := m.oldValue(ctx)
  52266. if err != nil {
  52267. return v, fmt.Errorf("querying old value for OldMonthlyUsageUsd: %w", err)
  52268. }
  52269. return oldValue.MonthlyUsageUsd, nil
  52270. }
  52271. // AddMonthlyUsageUsd adds f to the "monthly_usage_usd" field.
  52272. func (m *UserSubscriptionMutation) AddMonthlyUsageUsd(f float64) {
  52273. if m.addmonthly_usage_usd != nil {
  52274. *m.addmonthly_usage_usd += f
  52275. } else {
  52276. m.addmonthly_usage_usd = &f
  52277. }
  52278. }
  52279. // AddedMonthlyUsageUsd returns the value that was added to the "monthly_usage_usd" field in this mutation.
  52280. func (m *UserSubscriptionMutation) AddedMonthlyUsageUsd() (r float64, exists bool) {
  52281. v := m.addmonthly_usage_usd
  52282. if v == nil {
  52283. return
  52284. }
  52285. return *v, true
  52286. }
  52287. // ResetMonthlyUsageUsd resets all changes to the "monthly_usage_usd" field.
  52288. func (m *UserSubscriptionMutation) ResetMonthlyUsageUsd() {
  52289. m.monthly_usage_usd = nil
  52290. m.addmonthly_usage_usd = nil
  52291. }
  52292. // SetAssignedBy sets the "assigned_by" field.
  52293. func (m *UserSubscriptionMutation) SetAssignedBy(i int64) {
  52294. m.assigned_by_user = &i
  52295. }
  52296. // AssignedBy returns the value of the "assigned_by" field in the mutation.
  52297. func (m *UserSubscriptionMutation) AssignedBy() (r int64, exists bool) {
  52298. v := m.assigned_by_user
  52299. if v == nil {
  52300. return
  52301. }
  52302. return *v, true
  52303. }
  52304. // OldAssignedBy returns the old "assigned_by" field's value of the UserSubscription entity.
  52305. // If the UserSubscription object wasn't provided to the builder, the object is fetched from the database.
  52306. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  52307. func (m *UserSubscriptionMutation) OldAssignedBy(ctx context.Context) (v *int64, err error) {
  52308. if !m.op.Is(OpUpdateOne) {
  52309. return v, errors.New("OldAssignedBy is only allowed on UpdateOne operations")
  52310. }
  52311. if m.id == nil || m.oldValue == nil {
  52312. return v, errors.New("OldAssignedBy requires an ID field in the mutation")
  52313. }
  52314. oldValue, err := m.oldValue(ctx)
  52315. if err != nil {
  52316. return v, fmt.Errorf("querying old value for OldAssignedBy: %w", err)
  52317. }
  52318. return oldValue.AssignedBy, nil
  52319. }
  52320. // ClearAssignedBy clears the value of the "assigned_by" field.
  52321. func (m *UserSubscriptionMutation) ClearAssignedBy() {
  52322. m.assigned_by_user = nil
  52323. m.clearedFields[usersubscription.FieldAssignedBy] = struct{}{}
  52324. }
  52325. // AssignedByCleared returns if the "assigned_by" field was cleared in this mutation.
  52326. func (m *UserSubscriptionMutation) AssignedByCleared() bool {
  52327. _, ok := m.clearedFields[usersubscription.FieldAssignedBy]
  52328. return ok
  52329. }
  52330. // ResetAssignedBy resets all changes to the "assigned_by" field.
  52331. func (m *UserSubscriptionMutation) ResetAssignedBy() {
  52332. m.assigned_by_user = nil
  52333. delete(m.clearedFields, usersubscription.FieldAssignedBy)
  52334. }
  52335. // SetAssignedAt sets the "assigned_at" field.
  52336. func (m *UserSubscriptionMutation) SetAssignedAt(t time.Time) {
  52337. m.assigned_at = &t
  52338. }
  52339. // AssignedAt returns the value of the "assigned_at" field in the mutation.
  52340. func (m *UserSubscriptionMutation) AssignedAt() (r time.Time, exists bool) {
  52341. v := m.assigned_at
  52342. if v == nil {
  52343. return
  52344. }
  52345. return *v, true
  52346. }
  52347. // OldAssignedAt returns the old "assigned_at" field's value of the UserSubscription entity.
  52348. // If the UserSubscription object wasn't provided to the builder, the object is fetched from the database.
  52349. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  52350. func (m *UserSubscriptionMutation) OldAssignedAt(ctx context.Context) (v time.Time, err error) {
  52351. if !m.op.Is(OpUpdateOne) {
  52352. return v, errors.New("OldAssignedAt is only allowed on UpdateOne operations")
  52353. }
  52354. if m.id == nil || m.oldValue == nil {
  52355. return v, errors.New("OldAssignedAt requires an ID field in the mutation")
  52356. }
  52357. oldValue, err := m.oldValue(ctx)
  52358. if err != nil {
  52359. return v, fmt.Errorf("querying old value for OldAssignedAt: %w", err)
  52360. }
  52361. return oldValue.AssignedAt, nil
  52362. }
  52363. // ResetAssignedAt resets all changes to the "assigned_at" field.
  52364. func (m *UserSubscriptionMutation) ResetAssignedAt() {
  52365. m.assigned_at = nil
  52366. }
  52367. // SetNotes sets the "notes" field.
  52368. func (m *UserSubscriptionMutation) SetNotes(s string) {
  52369. m.notes = &s
  52370. }
  52371. // Notes returns the value of the "notes" field in the mutation.
  52372. func (m *UserSubscriptionMutation) Notes() (r string, exists bool) {
  52373. v := m.notes
  52374. if v == nil {
  52375. return
  52376. }
  52377. return *v, true
  52378. }
  52379. // OldNotes returns the old "notes" field's value of the UserSubscription entity.
  52380. // If the UserSubscription object wasn't provided to the builder, the object is fetched from the database.
  52381. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  52382. func (m *UserSubscriptionMutation) OldNotes(ctx context.Context) (v *string, err error) {
  52383. if !m.op.Is(OpUpdateOne) {
  52384. return v, errors.New("OldNotes is only allowed on UpdateOne operations")
  52385. }
  52386. if m.id == nil || m.oldValue == nil {
  52387. return v, errors.New("OldNotes requires an ID field in the mutation")
  52388. }
  52389. oldValue, err := m.oldValue(ctx)
  52390. if err != nil {
  52391. return v, fmt.Errorf("querying old value for OldNotes: %w", err)
  52392. }
  52393. return oldValue.Notes, nil
  52394. }
  52395. // ClearNotes clears the value of the "notes" field.
  52396. func (m *UserSubscriptionMutation) ClearNotes() {
  52397. m.notes = nil
  52398. m.clearedFields[usersubscription.FieldNotes] = struct{}{}
  52399. }
  52400. // NotesCleared returns if the "notes" field was cleared in this mutation.
  52401. func (m *UserSubscriptionMutation) NotesCleared() bool {
  52402. _, ok := m.clearedFields[usersubscription.FieldNotes]
  52403. return ok
  52404. }
  52405. // ResetNotes resets all changes to the "notes" field.
  52406. func (m *UserSubscriptionMutation) ResetNotes() {
  52407. m.notes = nil
  52408. delete(m.clearedFields, usersubscription.FieldNotes)
  52409. }
  52410. // ClearUser clears the "user" edge to the User entity.
  52411. func (m *UserSubscriptionMutation) ClearUser() {
  52412. m.cleareduser = true
  52413. m.clearedFields[usersubscription.FieldUserID] = struct{}{}
  52414. }
  52415. // UserCleared reports if the "user" edge to the User entity was cleared.
  52416. func (m *UserSubscriptionMutation) UserCleared() bool {
  52417. return m.cleareduser
  52418. }
  52419. // UserIDs returns the "user" edge IDs in the mutation.
  52420. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  52421. // UserID instead. It exists only for internal usage by the builders.
  52422. func (m *UserSubscriptionMutation) UserIDs() (ids []int64) {
  52423. if id := m.user; id != nil {
  52424. ids = append(ids, *id)
  52425. }
  52426. return
  52427. }
  52428. // ResetUser resets all changes to the "user" edge.
  52429. func (m *UserSubscriptionMutation) ResetUser() {
  52430. m.user = nil
  52431. m.cleareduser = false
  52432. }
  52433. // ClearGroup clears the "group" edge to the Group entity.
  52434. func (m *UserSubscriptionMutation) ClearGroup() {
  52435. m.clearedgroup = true
  52436. m.clearedFields[usersubscription.FieldGroupID] = struct{}{}
  52437. }
  52438. // GroupCleared reports if the "group" edge to the Group entity was cleared.
  52439. func (m *UserSubscriptionMutation) GroupCleared() bool {
  52440. return m.clearedgroup
  52441. }
  52442. // GroupIDs returns the "group" edge IDs in the mutation.
  52443. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  52444. // GroupID instead. It exists only for internal usage by the builders.
  52445. func (m *UserSubscriptionMutation) GroupIDs() (ids []int64) {
  52446. if id := m.group; id != nil {
  52447. ids = append(ids, *id)
  52448. }
  52449. return
  52450. }
  52451. // ResetGroup resets all changes to the "group" edge.
  52452. func (m *UserSubscriptionMutation) ResetGroup() {
  52453. m.group = nil
  52454. m.clearedgroup = false
  52455. }
  52456. // SetAssignedByUserID sets the "assigned_by_user" edge to the User entity by id.
  52457. func (m *UserSubscriptionMutation) SetAssignedByUserID(id int64) {
  52458. m.assigned_by_user = &id
  52459. }
  52460. // ClearAssignedByUser clears the "assigned_by_user" edge to the User entity.
  52461. func (m *UserSubscriptionMutation) ClearAssignedByUser() {
  52462. m.clearedassigned_by_user = true
  52463. m.clearedFields[usersubscription.FieldAssignedBy] = struct{}{}
  52464. }
  52465. // AssignedByUserCleared reports if the "assigned_by_user" edge to the User entity was cleared.
  52466. func (m *UserSubscriptionMutation) AssignedByUserCleared() bool {
  52467. return m.AssignedByCleared() || m.clearedassigned_by_user
  52468. }
  52469. // AssignedByUserID returns the "assigned_by_user" edge ID in the mutation.
  52470. func (m *UserSubscriptionMutation) AssignedByUserID() (id int64, exists bool) {
  52471. if m.assigned_by_user != nil {
  52472. return *m.assigned_by_user, true
  52473. }
  52474. return
  52475. }
  52476. // AssignedByUserIDs returns the "assigned_by_user" edge IDs in the mutation.
  52477. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  52478. // AssignedByUserID instead. It exists only for internal usage by the builders.
  52479. func (m *UserSubscriptionMutation) AssignedByUserIDs() (ids []int64) {
  52480. if id := m.assigned_by_user; id != nil {
  52481. ids = append(ids, *id)
  52482. }
  52483. return
  52484. }
  52485. // ResetAssignedByUser resets all changes to the "assigned_by_user" edge.
  52486. func (m *UserSubscriptionMutation) ResetAssignedByUser() {
  52487. m.assigned_by_user = nil
  52488. m.clearedassigned_by_user = false
  52489. }
  52490. // AddUsageLogIDs adds the "usage_logs" edge to the UsageLog entity by ids.
  52491. func (m *UserSubscriptionMutation) AddUsageLogIDs(ids ...int64) {
  52492. if m.usage_logs == nil {
  52493. m.usage_logs = make(map[int64]struct{})
  52494. }
  52495. for i := range ids {
  52496. m.usage_logs[ids[i]] = struct{}{}
  52497. }
  52498. }
  52499. // ClearUsageLogs clears the "usage_logs" edge to the UsageLog entity.
  52500. func (m *UserSubscriptionMutation) ClearUsageLogs() {
  52501. m.clearedusage_logs = true
  52502. }
  52503. // UsageLogsCleared reports if the "usage_logs" edge to the UsageLog entity was cleared.
  52504. func (m *UserSubscriptionMutation) UsageLogsCleared() bool {
  52505. return m.clearedusage_logs
  52506. }
  52507. // RemoveUsageLogIDs removes the "usage_logs" edge to the UsageLog entity by IDs.
  52508. func (m *UserSubscriptionMutation) RemoveUsageLogIDs(ids ...int64) {
  52509. if m.removedusage_logs == nil {
  52510. m.removedusage_logs = make(map[int64]struct{})
  52511. }
  52512. for i := range ids {
  52513. delete(m.usage_logs, ids[i])
  52514. m.removedusage_logs[ids[i]] = struct{}{}
  52515. }
  52516. }
  52517. // RemovedUsageLogs returns the removed IDs of the "usage_logs" edge to the UsageLog entity.
  52518. func (m *UserSubscriptionMutation) RemovedUsageLogsIDs() (ids []int64) {
  52519. for id := range m.removedusage_logs {
  52520. ids = append(ids, id)
  52521. }
  52522. return
  52523. }
  52524. // UsageLogsIDs returns the "usage_logs" edge IDs in the mutation.
  52525. func (m *UserSubscriptionMutation) UsageLogsIDs() (ids []int64) {
  52526. for id := range m.usage_logs {
  52527. ids = append(ids, id)
  52528. }
  52529. return
  52530. }
  52531. // ResetUsageLogs resets all changes to the "usage_logs" edge.
  52532. func (m *UserSubscriptionMutation) ResetUsageLogs() {
  52533. m.usage_logs = nil
  52534. m.clearedusage_logs = false
  52535. m.removedusage_logs = nil
  52536. }
  52537. // Where appends a list predicates to the UserSubscriptionMutation builder.
  52538. func (m *UserSubscriptionMutation) Where(ps ...predicate.UserSubscription) {
  52539. m.predicates = append(m.predicates, ps...)
  52540. }
  52541. // WhereP appends storage-level predicates to the UserSubscriptionMutation builder. Using this method,
  52542. // users can use type-assertion to append predicates that do not depend on any generated package.
  52543. func (m *UserSubscriptionMutation) WhereP(ps ...func(*sql.Selector)) {
  52544. p := make([]predicate.UserSubscription, len(ps))
  52545. for i := range ps {
  52546. p[i] = ps[i]
  52547. }
  52548. m.Where(p...)
  52549. }
  52550. // Op returns the operation name.
  52551. func (m *UserSubscriptionMutation) Op() Op {
  52552. return m.op
  52553. }
  52554. // SetOp allows setting the mutation operation.
  52555. func (m *UserSubscriptionMutation) SetOp(op Op) {
  52556. m.op = op
  52557. }
  52558. // Type returns the node type of this mutation (UserSubscription).
  52559. func (m *UserSubscriptionMutation) Type() string {
  52560. return m.typ
  52561. }
  52562. // Fields returns all fields that were changed during this mutation. Note that in
  52563. // order to get all numeric fields that were incremented/decremented, call
  52564. // AddedFields().
  52565. func (m *UserSubscriptionMutation) Fields() []string {
  52566. fields := make([]string, 0, 17)
  52567. if m.created_at != nil {
  52568. fields = append(fields, usersubscription.FieldCreatedAt)
  52569. }
  52570. if m.updated_at != nil {
  52571. fields = append(fields, usersubscription.FieldUpdatedAt)
  52572. }
  52573. if m.deleted_at != nil {
  52574. fields = append(fields, usersubscription.FieldDeletedAt)
  52575. }
  52576. if m.user != nil {
  52577. fields = append(fields, usersubscription.FieldUserID)
  52578. }
  52579. if m.group != nil {
  52580. fields = append(fields, usersubscription.FieldGroupID)
  52581. }
  52582. if m.starts_at != nil {
  52583. fields = append(fields, usersubscription.FieldStartsAt)
  52584. }
  52585. if m.expires_at != nil {
  52586. fields = append(fields, usersubscription.FieldExpiresAt)
  52587. }
  52588. if m.status != nil {
  52589. fields = append(fields, usersubscription.FieldStatus)
  52590. }
  52591. if m.daily_window_start != nil {
  52592. fields = append(fields, usersubscription.FieldDailyWindowStart)
  52593. }
  52594. if m.weekly_window_start != nil {
  52595. fields = append(fields, usersubscription.FieldWeeklyWindowStart)
  52596. }
  52597. if m.monthly_window_start != nil {
  52598. fields = append(fields, usersubscription.FieldMonthlyWindowStart)
  52599. }
  52600. if m.daily_usage_usd != nil {
  52601. fields = append(fields, usersubscription.FieldDailyUsageUsd)
  52602. }
  52603. if m.weekly_usage_usd != nil {
  52604. fields = append(fields, usersubscription.FieldWeeklyUsageUsd)
  52605. }
  52606. if m.monthly_usage_usd != nil {
  52607. fields = append(fields, usersubscription.FieldMonthlyUsageUsd)
  52608. }
  52609. if m.assigned_by_user != nil {
  52610. fields = append(fields, usersubscription.FieldAssignedBy)
  52611. }
  52612. if m.assigned_at != nil {
  52613. fields = append(fields, usersubscription.FieldAssignedAt)
  52614. }
  52615. if m.notes != nil {
  52616. fields = append(fields, usersubscription.FieldNotes)
  52617. }
  52618. return fields
  52619. }
  52620. // Field returns the value of a field with the given name. The second boolean
  52621. // return value indicates that this field was not set, or was not defined in the
  52622. // schema.
  52623. func (m *UserSubscriptionMutation) Field(name string) (ent.Value, bool) {
  52624. switch name {
  52625. case usersubscription.FieldCreatedAt:
  52626. return m.CreatedAt()
  52627. case usersubscription.FieldUpdatedAt:
  52628. return m.UpdatedAt()
  52629. case usersubscription.FieldDeletedAt:
  52630. return m.DeletedAt()
  52631. case usersubscription.FieldUserID:
  52632. return m.UserID()
  52633. case usersubscription.FieldGroupID:
  52634. return m.GroupID()
  52635. case usersubscription.FieldStartsAt:
  52636. return m.StartsAt()
  52637. case usersubscription.FieldExpiresAt:
  52638. return m.ExpiresAt()
  52639. case usersubscription.FieldStatus:
  52640. return m.Status()
  52641. case usersubscription.FieldDailyWindowStart:
  52642. return m.DailyWindowStart()
  52643. case usersubscription.FieldWeeklyWindowStart:
  52644. return m.WeeklyWindowStart()
  52645. case usersubscription.FieldMonthlyWindowStart:
  52646. return m.MonthlyWindowStart()
  52647. case usersubscription.FieldDailyUsageUsd:
  52648. return m.DailyUsageUsd()
  52649. case usersubscription.FieldWeeklyUsageUsd:
  52650. return m.WeeklyUsageUsd()
  52651. case usersubscription.FieldMonthlyUsageUsd:
  52652. return m.MonthlyUsageUsd()
  52653. case usersubscription.FieldAssignedBy:
  52654. return m.AssignedBy()
  52655. case usersubscription.FieldAssignedAt:
  52656. return m.AssignedAt()
  52657. case usersubscription.FieldNotes:
  52658. return m.Notes()
  52659. }
  52660. return nil, false
  52661. }
  52662. // OldField returns the old value of the field from the database. An error is
  52663. // returned if the mutation operation is not UpdateOne, or the query to the
  52664. // database failed.
  52665. func (m *UserSubscriptionMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  52666. switch name {
  52667. case usersubscription.FieldCreatedAt:
  52668. return m.OldCreatedAt(ctx)
  52669. case usersubscription.FieldUpdatedAt:
  52670. return m.OldUpdatedAt(ctx)
  52671. case usersubscription.FieldDeletedAt:
  52672. return m.OldDeletedAt(ctx)
  52673. case usersubscription.FieldUserID:
  52674. return m.OldUserID(ctx)
  52675. case usersubscription.FieldGroupID:
  52676. return m.OldGroupID(ctx)
  52677. case usersubscription.FieldStartsAt:
  52678. return m.OldStartsAt(ctx)
  52679. case usersubscription.FieldExpiresAt:
  52680. return m.OldExpiresAt(ctx)
  52681. case usersubscription.FieldStatus:
  52682. return m.OldStatus(ctx)
  52683. case usersubscription.FieldDailyWindowStart:
  52684. return m.OldDailyWindowStart(ctx)
  52685. case usersubscription.FieldWeeklyWindowStart:
  52686. return m.OldWeeklyWindowStart(ctx)
  52687. case usersubscription.FieldMonthlyWindowStart:
  52688. return m.OldMonthlyWindowStart(ctx)
  52689. case usersubscription.FieldDailyUsageUsd:
  52690. return m.OldDailyUsageUsd(ctx)
  52691. case usersubscription.FieldWeeklyUsageUsd:
  52692. return m.OldWeeklyUsageUsd(ctx)
  52693. case usersubscription.FieldMonthlyUsageUsd:
  52694. return m.OldMonthlyUsageUsd(ctx)
  52695. case usersubscription.FieldAssignedBy:
  52696. return m.OldAssignedBy(ctx)
  52697. case usersubscription.FieldAssignedAt:
  52698. return m.OldAssignedAt(ctx)
  52699. case usersubscription.FieldNotes:
  52700. return m.OldNotes(ctx)
  52701. }
  52702. return nil, fmt.Errorf("unknown UserSubscription field %s", name)
  52703. }
  52704. // SetField sets the value of a field with the given name. It returns an error if
  52705. // the field is not defined in the schema, or if the type mismatched the field
  52706. // type.
  52707. func (m *UserSubscriptionMutation) SetField(name string, value ent.Value) error {
  52708. switch name {
  52709. case usersubscription.FieldCreatedAt:
  52710. v, ok := value.(time.Time)
  52711. if !ok {
  52712. return fmt.Errorf("unexpected type %T for field %s", value, name)
  52713. }
  52714. m.SetCreatedAt(v)
  52715. return nil
  52716. case usersubscription.FieldUpdatedAt:
  52717. v, ok := value.(time.Time)
  52718. if !ok {
  52719. return fmt.Errorf("unexpected type %T for field %s", value, name)
  52720. }
  52721. m.SetUpdatedAt(v)
  52722. return nil
  52723. case usersubscription.FieldDeletedAt:
  52724. v, ok := value.(time.Time)
  52725. if !ok {
  52726. return fmt.Errorf("unexpected type %T for field %s", value, name)
  52727. }
  52728. m.SetDeletedAt(v)
  52729. return nil
  52730. case usersubscription.FieldUserID:
  52731. v, ok := value.(int64)
  52732. if !ok {
  52733. return fmt.Errorf("unexpected type %T for field %s", value, name)
  52734. }
  52735. m.SetUserID(v)
  52736. return nil
  52737. case usersubscription.FieldGroupID:
  52738. v, ok := value.(int64)
  52739. if !ok {
  52740. return fmt.Errorf("unexpected type %T for field %s", value, name)
  52741. }
  52742. m.SetGroupID(v)
  52743. return nil
  52744. case usersubscription.FieldStartsAt:
  52745. v, ok := value.(time.Time)
  52746. if !ok {
  52747. return fmt.Errorf("unexpected type %T for field %s", value, name)
  52748. }
  52749. m.SetStartsAt(v)
  52750. return nil
  52751. case usersubscription.FieldExpiresAt:
  52752. v, ok := value.(time.Time)
  52753. if !ok {
  52754. return fmt.Errorf("unexpected type %T for field %s", value, name)
  52755. }
  52756. m.SetExpiresAt(v)
  52757. return nil
  52758. case usersubscription.FieldStatus:
  52759. v, ok := value.(string)
  52760. if !ok {
  52761. return fmt.Errorf("unexpected type %T for field %s", value, name)
  52762. }
  52763. m.SetStatus(v)
  52764. return nil
  52765. case usersubscription.FieldDailyWindowStart:
  52766. v, ok := value.(time.Time)
  52767. if !ok {
  52768. return fmt.Errorf("unexpected type %T for field %s", value, name)
  52769. }
  52770. m.SetDailyWindowStart(v)
  52771. return nil
  52772. case usersubscription.FieldWeeklyWindowStart:
  52773. v, ok := value.(time.Time)
  52774. if !ok {
  52775. return fmt.Errorf("unexpected type %T for field %s", value, name)
  52776. }
  52777. m.SetWeeklyWindowStart(v)
  52778. return nil
  52779. case usersubscription.FieldMonthlyWindowStart:
  52780. v, ok := value.(time.Time)
  52781. if !ok {
  52782. return fmt.Errorf("unexpected type %T for field %s", value, name)
  52783. }
  52784. m.SetMonthlyWindowStart(v)
  52785. return nil
  52786. case usersubscription.FieldDailyUsageUsd:
  52787. v, ok := value.(float64)
  52788. if !ok {
  52789. return fmt.Errorf("unexpected type %T for field %s", value, name)
  52790. }
  52791. m.SetDailyUsageUsd(v)
  52792. return nil
  52793. case usersubscription.FieldWeeklyUsageUsd:
  52794. v, ok := value.(float64)
  52795. if !ok {
  52796. return fmt.Errorf("unexpected type %T for field %s", value, name)
  52797. }
  52798. m.SetWeeklyUsageUsd(v)
  52799. return nil
  52800. case usersubscription.FieldMonthlyUsageUsd:
  52801. v, ok := value.(float64)
  52802. if !ok {
  52803. return fmt.Errorf("unexpected type %T for field %s", value, name)
  52804. }
  52805. m.SetMonthlyUsageUsd(v)
  52806. return nil
  52807. case usersubscription.FieldAssignedBy:
  52808. v, ok := value.(int64)
  52809. if !ok {
  52810. return fmt.Errorf("unexpected type %T for field %s", value, name)
  52811. }
  52812. m.SetAssignedBy(v)
  52813. return nil
  52814. case usersubscription.FieldAssignedAt:
  52815. v, ok := value.(time.Time)
  52816. if !ok {
  52817. return fmt.Errorf("unexpected type %T for field %s", value, name)
  52818. }
  52819. m.SetAssignedAt(v)
  52820. return nil
  52821. case usersubscription.FieldNotes:
  52822. v, ok := value.(string)
  52823. if !ok {
  52824. return fmt.Errorf("unexpected type %T for field %s", value, name)
  52825. }
  52826. m.SetNotes(v)
  52827. return nil
  52828. }
  52829. return fmt.Errorf("unknown UserSubscription field %s", name)
  52830. }
  52831. // AddedFields returns all numeric fields that were incremented/decremented during
  52832. // this mutation.
  52833. func (m *UserSubscriptionMutation) AddedFields() []string {
  52834. var fields []string
  52835. if m.adddaily_usage_usd != nil {
  52836. fields = append(fields, usersubscription.FieldDailyUsageUsd)
  52837. }
  52838. if m.addweekly_usage_usd != nil {
  52839. fields = append(fields, usersubscription.FieldWeeklyUsageUsd)
  52840. }
  52841. if m.addmonthly_usage_usd != nil {
  52842. fields = append(fields, usersubscription.FieldMonthlyUsageUsd)
  52843. }
  52844. return fields
  52845. }
  52846. // AddedField returns the numeric value that was incremented/decremented on a field
  52847. // with the given name. The second boolean return value indicates that this field
  52848. // was not set, or was not defined in the schema.
  52849. func (m *UserSubscriptionMutation) AddedField(name string) (ent.Value, bool) {
  52850. switch name {
  52851. case usersubscription.FieldDailyUsageUsd:
  52852. return m.AddedDailyUsageUsd()
  52853. case usersubscription.FieldWeeklyUsageUsd:
  52854. return m.AddedWeeklyUsageUsd()
  52855. case usersubscription.FieldMonthlyUsageUsd:
  52856. return m.AddedMonthlyUsageUsd()
  52857. }
  52858. return nil, false
  52859. }
  52860. // AddField adds the value to the field with the given name. It returns an error if
  52861. // the field is not defined in the schema, or if the type mismatched the field
  52862. // type.
  52863. func (m *UserSubscriptionMutation) AddField(name string, value ent.Value) error {
  52864. switch name {
  52865. case usersubscription.FieldDailyUsageUsd:
  52866. v, ok := value.(float64)
  52867. if !ok {
  52868. return fmt.Errorf("unexpected type %T for field %s", value, name)
  52869. }
  52870. m.AddDailyUsageUsd(v)
  52871. return nil
  52872. case usersubscription.FieldWeeklyUsageUsd:
  52873. v, ok := value.(float64)
  52874. if !ok {
  52875. return fmt.Errorf("unexpected type %T for field %s", value, name)
  52876. }
  52877. m.AddWeeklyUsageUsd(v)
  52878. return nil
  52879. case usersubscription.FieldMonthlyUsageUsd:
  52880. v, ok := value.(float64)
  52881. if !ok {
  52882. return fmt.Errorf("unexpected type %T for field %s", value, name)
  52883. }
  52884. m.AddMonthlyUsageUsd(v)
  52885. return nil
  52886. }
  52887. return fmt.Errorf("unknown UserSubscription numeric field %s", name)
  52888. }
  52889. // ClearedFields returns all nullable fields that were cleared during this
  52890. // mutation.
  52891. func (m *UserSubscriptionMutation) ClearedFields() []string {
  52892. var fields []string
  52893. if m.FieldCleared(usersubscription.FieldDeletedAt) {
  52894. fields = append(fields, usersubscription.FieldDeletedAt)
  52895. }
  52896. if m.FieldCleared(usersubscription.FieldDailyWindowStart) {
  52897. fields = append(fields, usersubscription.FieldDailyWindowStart)
  52898. }
  52899. if m.FieldCleared(usersubscription.FieldWeeklyWindowStart) {
  52900. fields = append(fields, usersubscription.FieldWeeklyWindowStart)
  52901. }
  52902. if m.FieldCleared(usersubscription.FieldMonthlyWindowStart) {
  52903. fields = append(fields, usersubscription.FieldMonthlyWindowStart)
  52904. }
  52905. if m.FieldCleared(usersubscription.FieldAssignedBy) {
  52906. fields = append(fields, usersubscription.FieldAssignedBy)
  52907. }
  52908. if m.FieldCleared(usersubscription.FieldNotes) {
  52909. fields = append(fields, usersubscription.FieldNotes)
  52910. }
  52911. return fields
  52912. }
  52913. // FieldCleared returns a boolean indicating if a field with the given name was
  52914. // cleared in this mutation.
  52915. func (m *UserSubscriptionMutation) FieldCleared(name string) bool {
  52916. _, ok := m.clearedFields[name]
  52917. return ok
  52918. }
  52919. // ClearField clears the value of the field with the given name. It returns an
  52920. // error if the field is not defined in the schema.
  52921. func (m *UserSubscriptionMutation) ClearField(name string) error {
  52922. switch name {
  52923. case usersubscription.FieldDeletedAt:
  52924. m.ClearDeletedAt()
  52925. return nil
  52926. case usersubscription.FieldDailyWindowStart:
  52927. m.ClearDailyWindowStart()
  52928. return nil
  52929. case usersubscription.FieldWeeklyWindowStart:
  52930. m.ClearWeeklyWindowStart()
  52931. return nil
  52932. case usersubscription.FieldMonthlyWindowStart:
  52933. m.ClearMonthlyWindowStart()
  52934. return nil
  52935. case usersubscription.FieldAssignedBy:
  52936. m.ClearAssignedBy()
  52937. return nil
  52938. case usersubscription.FieldNotes:
  52939. m.ClearNotes()
  52940. return nil
  52941. }
  52942. return fmt.Errorf("unknown UserSubscription nullable field %s", name)
  52943. }
  52944. // ResetField resets all changes in the mutation for the field with the given name.
  52945. // It returns an error if the field is not defined in the schema.
  52946. func (m *UserSubscriptionMutation) ResetField(name string) error {
  52947. switch name {
  52948. case usersubscription.FieldCreatedAt:
  52949. m.ResetCreatedAt()
  52950. return nil
  52951. case usersubscription.FieldUpdatedAt:
  52952. m.ResetUpdatedAt()
  52953. return nil
  52954. case usersubscription.FieldDeletedAt:
  52955. m.ResetDeletedAt()
  52956. return nil
  52957. case usersubscription.FieldUserID:
  52958. m.ResetUserID()
  52959. return nil
  52960. case usersubscription.FieldGroupID:
  52961. m.ResetGroupID()
  52962. return nil
  52963. case usersubscription.FieldStartsAt:
  52964. m.ResetStartsAt()
  52965. return nil
  52966. case usersubscription.FieldExpiresAt:
  52967. m.ResetExpiresAt()
  52968. return nil
  52969. case usersubscription.FieldStatus:
  52970. m.ResetStatus()
  52971. return nil
  52972. case usersubscription.FieldDailyWindowStart:
  52973. m.ResetDailyWindowStart()
  52974. return nil
  52975. case usersubscription.FieldWeeklyWindowStart:
  52976. m.ResetWeeklyWindowStart()
  52977. return nil
  52978. case usersubscription.FieldMonthlyWindowStart:
  52979. m.ResetMonthlyWindowStart()
  52980. return nil
  52981. case usersubscription.FieldDailyUsageUsd:
  52982. m.ResetDailyUsageUsd()
  52983. return nil
  52984. case usersubscription.FieldWeeklyUsageUsd:
  52985. m.ResetWeeklyUsageUsd()
  52986. return nil
  52987. case usersubscription.FieldMonthlyUsageUsd:
  52988. m.ResetMonthlyUsageUsd()
  52989. return nil
  52990. case usersubscription.FieldAssignedBy:
  52991. m.ResetAssignedBy()
  52992. return nil
  52993. case usersubscription.FieldAssignedAt:
  52994. m.ResetAssignedAt()
  52995. return nil
  52996. case usersubscription.FieldNotes:
  52997. m.ResetNotes()
  52998. return nil
  52999. }
  53000. return fmt.Errorf("unknown UserSubscription field %s", name)
  53001. }
  53002. // AddedEdges returns all edge names that were set/added in this mutation.
  53003. func (m *UserSubscriptionMutation) AddedEdges() []string {
  53004. edges := make([]string, 0, 4)
  53005. if m.user != nil {
  53006. edges = append(edges, usersubscription.EdgeUser)
  53007. }
  53008. if m.group != nil {
  53009. edges = append(edges, usersubscription.EdgeGroup)
  53010. }
  53011. if m.assigned_by_user != nil {
  53012. edges = append(edges, usersubscription.EdgeAssignedByUser)
  53013. }
  53014. if m.usage_logs != nil {
  53015. edges = append(edges, usersubscription.EdgeUsageLogs)
  53016. }
  53017. return edges
  53018. }
  53019. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  53020. // name in this mutation.
  53021. func (m *UserSubscriptionMutation) AddedIDs(name string) []ent.Value {
  53022. switch name {
  53023. case usersubscription.EdgeUser:
  53024. if id := m.user; id != nil {
  53025. return []ent.Value{*id}
  53026. }
  53027. case usersubscription.EdgeGroup:
  53028. if id := m.group; id != nil {
  53029. return []ent.Value{*id}
  53030. }
  53031. case usersubscription.EdgeAssignedByUser:
  53032. if id := m.assigned_by_user; id != nil {
  53033. return []ent.Value{*id}
  53034. }
  53035. case usersubscription.EdgeUsageLogs:
  53036. ids := make([]ent.Value, 0, len(m.usage_logs))
  53037. for id := range m.usage_logs {
  53038. ids = append(ids, id)
  53039. }
  53040. return ids
  53041. }
  53042. return nil
  53043. }
  53044. // RemovedEdges returns all edge names that were removed in this mutation.
  53045. func (m *UserSubscriptionMutation) RemovedEdges() []string {
  53046. edges := make([]string, 0, 4)
  53047. if m.removedusage_logs != nil {
  53048. edges = append(edges, usersubscription.EdgeUsageLogs)
  53049. }
  53050. return edges
  53051. }
  53052. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  53053. // the given name in this mutation.
  53054. func (m *UserSubscriptionMutation) RemovedIDs(name string) []ent.Value {
  53055. switch name {
  53056. case usersubscription.EdgeUsageLogs:
  53057. ids := make([]ent.Value, 0, len(m.removedusage_logs))
  53058. for id := range m.removedusage_logs {
  53059. ids = append(ids, id)
  53060. }
  53061. return ids
  53062. }
  53063. return nil
  53064. }
  53065. // ClearedEdges returns all edge names that were cleared in this mutation.
  53066. func (m *UserSubscriptionMutation) ClearedEdges() []string {
  53067. edges := make([]string, 0, 4)
  53068. if m.cleareduser {
  53069. edges = append(edges, usersubscription.EdgeUser)
  53070. }
  53071. if m.clearedgroup {
  53072. edges = append(edges, usersubscription.EdgeGroup)
  53073. }
  53074. if m.clearedassigned_by_user {
  53075. edges = append(edges, usersubscription.EdgeAssignedByUser)
  53076. }
  53077. if m.clearedusage_logs {
  53078. edges = append(edges, usersubscription.EdgeUsageLogs)
  53079. }
  53080. return edges
  53081. }
  53082. // EdgeCleared returns a boolean which indicates if the edge with the given name
  53083. // was cleared in this mutation.
  53084. func (m *UserSubscriptionMutation) EdgeCleared(name string) bool {
  53085. switch name {
  53086. case usersubscription.EdgeUser:
  53087. return m.cleareduser
  53088. case usersubscription.EdgeGroup:
  53089. return m.clearedgroup
  53090. case usersubscription.EdgeAssignedByUser:
  53091. return m.clearedassigned_by_user
  53092. case usersubscription.EdgeUsageLogs:
  53093. return m.clearedusage_logs
  53094. }
  53095. return false
  53096. }
  53097. // ClearEdge clears the value of the edge with the given name. It returns an error
  53098. // if that edge is not defined in the schema.
  53099. func (m *UserSubscriptionMutation) ClearEdge(name string) error {
  53100. switch name {
  53101. case usersubscription.EdgeUser:
  53102. m.ClearUser()
  53103. return nil
  53104. case usersubscription.EdgeGroup:
  53105. m.ClearGroup()
  53106. return nil
  53107. case usersubscription.EdgeAssignedByUser:
  53108. m.ClearAssignedByUser()
  53109. return nil
  53110. }
  53111. return fmt.Errorf("unknown UserSubscription unique edge %s", name)
  53112. }
  53113. // ResetEdge resets all changes to the edge with the given name in this mutation.
  53114. // It returns an error if the edge is not defined in the schema.
  53115. func (m *UserSubscriptionMutation) ResetEdge(name string) error {
  53116. switch name {
  53117. case usersubscription.EdgeUser:
  53118. m.ResetUser()
  53119. return nil
  53120. case usersubscription.EdgeGroup:
  53121. m.ResetGroup()
  53122. return nil
  53123. case usersubscription.EdgeAssignedByUser:
  53124. m.ResetAssignedByUser()
  53125. return nil
  53126. case usersubscription.EdgeUsageLogs:
  53127. m.ResetUsageLogs()
  53128. return nil
  53129. }
  53130. return fmt.Errorf("unknown UserSubscription edge %s", name)
  53131. }