| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998479994800048001480024800348004480054800648007480084800948010480114801248013480144801548016480174801848019480204802148022480234802448025480264802748028480294803048031480324803348034480354803648037480384803948040480414804248043480444804548046480474804848049480504805148052480534805448055480564805748058480594806048061480624806348064480654806648067480684806948070480714807248073480744807548076480774807848079480804808148082480834808448085480864808748088480894809048091480924809348094480954809648097480984809948100481014810248103481044810548106481074810848109481104811148112481134811448115481164811748118481194812048121481224812348124481254812648127481284812948130481314813248133481344813548136481374813848139481404814148142481434814448145481464814748148481494815048151481524815348154481554815648157481584815948160481614816248163481644816548166481674816848169481704817148172481734817448175481764817748178481794818048181481824818348184481854818648187481884818948190481914819248193481944819548196481974819848199482004820148202482034820448205482064820748208482094821048211482124821348214482154821648217482184821948220482214822248223482244822548226482274822848229482304823148232482334823448235482364823748238482394824048241482424824348244482454824648247482484824948250482514825248253482544825548256482574825848259482604826148262482634826448265482664826748268482694827048271482724827348274482754827648277482784827948280482814828248283482844828548286482874828848289482904829148292482934829448295482964829748298482994830048301483024830348304483054830648307483084830948310483114831248313483144831548316483174831848319483204832148322483234832448325483264832748328483294833048331483324833348334483354833648337483384833948340483414834248343483444834548346483474834848349483504835148352483534835448355483564835748358483594836048361483624836348364483654836648367483684836948370483714837248373483744837548376483774837848379483804838148382483834838448385483864838748388483894839048391483924839348394483954839648397483984839948400484014840248403484044840548406484074840848409484104841148412484134841448415484164841748418484194842048421484224842348424484254842648427484284842948430484314843248433484344843548436484374843848439484404844148442484434844448445484464844748448484494845048451484524845348454484554845648457484584845948460484614846248463484644846548466484674846848469484704847148472484734847448475484764847748478484794848048481484824848348484484854848648487484884848948490484914849248493484944849548496484974849848499485004850148502485034850448505485064850748508485094851048511485124851348514485154851648517485184851948520485214852248523485244852548526485274852848529485304853148532485334853448535485364853748538485394854048541485424854348544485454854648547485484854948550485514855248553485544855548556485574855848559485604856148562485634856448565485664856748568485694857048571485724857348574485754857648577485784857948580485814858248583485844858548586485874858848589485904859148592485934859448595485964859748598485994860048601486024860348604486054860648607486084860948610486114861248613486144861548616486174861848619486204862148622486234862448625486264862748628486294863048631486324863348634486354863648637486384863948640486414864248643486444864548646486474864848649486504865148652486534865448655486564865748658486594866048661486624866348664486654866648667486684866948670486714867248673486744867548676486774867848679486804868148682486834868448685486864868748688486894869048691486924869348694486954869648697486984869948700487014870248703487044870548706487074870848709487104871148712487134871448715487164871748718487194872048721487224872348724487254872648727487284872948730487314873248733487344873548736487374873848739487404874148742487434874448745487464874748748487494875048751487524875348754487554875648757487584875948760487614876248763487644876548766487674876848769487704877148772487734877448775487764877748778487794878048781487824878348784487854878648787487884878948790487914879248793487944879548796487974879848799488004880148802488034880448805488064880748808488094881048811488124881348814488154881648817488184881948820488214882248823488244882548826488274882848829488304883148832488334883448835488364883748838488394884048841488424884348844488454884648847488484884948850488514885248853488544885548856488574885848859488604886148862488634886448865488664886748868488694887048871488724887348874488754887648877488784887948880488814888248883488844888548886488874888848889488904889148892488934889448895488964889748898488994890048901489024890348904489054890648907489084890948910489114891248913489144891548916489174891848919489204892148922489234892448925489264892748928489294893048931489324893348934489354893648937489384893948940489414894248943489444894548946489474894848949489504895148952489534895448955489564895748958489594896048961489624896348964489654896648967489684896948970489714897248973489744897548976489774897848979489804898148982489834898448985489864898748988489894899048991489924899348994489954899648997489984899949000490014900249003490044900549006490074900849009490104901149012490134901449015490164901749018490194902049021490224902349024490254902649027490284902949030490314903249033490344903549036490374903849039490404904149042490434904449045490464904749048490494905049051490524905349054490554905649057490584905949060490614906249063490644906549066490674906849069490704907149072490734907449075490764907749078490794908049081490824908349084490854908649087490884908949090490914909249093490944909549096490974909849099491004910149102491034910449105491064910749108491094911049111491124911349114491154911649117491184911949120491214912249123491244912549126491274912849129491304913149132491334913449135491364913749138491394914049141491424914349144491454914649147491484914949150491514915249153491544915549156491574915849159491604916149162491634916449165491664916749168491694917049171491724917349174491754917649177491784917949180491814918249183491844918549186491874918849189491904919149192491934919449195491964919749198491994920049201492024920349204492054920649207492084920949210492114921249213492144921549216492174921849219492204922149222492234922449225492264922749228492294923049231492324923349234492354923649237492384923949240492414924249243492444924549246492474924849249492504925149252492534925449255492564925749258492594926049261492624926349264492654926649267492684926949270492714927249273492744927549276492774927849279492804928149282492834928449285492864928749288492894929049291492924929349294492954929649297492984929949300493014930249303493044930549306493074930849309493104931149312493134931449315493164931749318493194932049321493224932349324493254932649327493284932949330493314933249333493344933549336493374933849339493404934149342493434934449345493464934749348493494935049351493524935349354493554935649357493584935949360493614936249363493644936549366493674936849369493704937149372493734937449375493764937749378493794938049381493824938349384493854938649387493884938949390493914939249393493944939549396493974939849399494004940149402494034940449405494064940749408494094941049411494124941349414494154941649417494184941949420494214942249423494244942549426494274942849429494304943149432494334943449435494364943749438494394944049441494424944349444494454944649447494484944949450494514945249453494544945549456494574945849459494604946149462494634946449465494664946749468494694947049471494724947349474494754947649477494784947949480494814948249483494844948549486494874948849489494904949149492494934949449495494964949749498494994950049501495024950349504495054950649507495084950949510495114951249513495144951549516495174951849519495204952149522495234952449525495264952749528495294953049531495324953349534495354953649537495384953949540495414954249543495444954549546495474954849549495504955149552495534955449555495564955749558495594956049561495624956349564495654956649567495684956949570495714957249573495744957549576495774957849579495804958149582495834958449585495864958749588495894959049591495924959349594495954959649597495984959949600496014960249603496044960549606496074960849609496104961149612496134961449615496164961749618496194962049621496224962349624496254962649627496284962949630496314963249633496344963549636496374963849639496404964149642496434964449645496464964749648496494965049651496524965349654496554965649657496584965949660496614966249663496644966549666496674966849669496704967149672496734967449675496764967749678496794968049681496824968349684496854968649687496884968949690496914969249693496944969549696496974969849699497004970149702497034970449705497064970749708497094971049711497124971349714497154971649717497184971949720497214972249723497244972549726497274972849729497304973149732497334973449735497364973749738497394974049741497424974349744497454974649747497484974949750497514975249753497544975549756497574975849759497604976149762497634976449765497664976749768497694977049771497724977349774497754977649777497784977949780497814978249783497844978549786497874978849789497904979149792497934979449795497964979749798497994980049801498024980349804498054980649807498084980949810498114981249813498144981549816498174981849819498204982149822498234982449825498264982749828498294983049831498324983349834498354983649837498384983949840498414984249843498444984549846498474984849849498504985149852498534985449855498564985749858498594986049861498624986349864498654986649867498684986949870498714987249873498744987549876498774987849879498804988149882498834988449885498864988749888498894989049891498924989349894498954989649897498984989949900499014990249903499044990549906499074990849909499104991149912499134991449915499164991749918499194992049921499224992349924499254992649927499284992949930499314993249933499344993549936499374993849939499404994149942499434994449945499464994749948499494995049951499524995349954499554995649957499584995949960499614996249963499644996549966499674996849969499704997149972499734997449975499764997749978499794998049981499824998349984499854998649987499884998949990499914999249993499944999549996499974999849999500005000150002500035000450005500065000750008500095001050011500125001350014500155001650017500185001950020500215002250023500245002550026500275002850029500305003150032500335003450035500365003750038500395004050041500425004350044500455004650047500485004950050500515005250053500545005550056500575005850059500605006150062500635006450065500665006750068500695007050071500725007350074500755007650077500785007950080500815008250083500845008550086500875008850089500905009150092500935009450095500965009750098500995010050101501025010350104501055010650107501085010950110501115011250113501145011550116501175011850119501205012150122501235012450125501265012750128501295013050131501325013350134501355013650137501385013950140501415014250143501445014550146501475014850149501505015150152501535015450155501565015750158501595016050161501625016350164501655016650167501685016950170501715017250173501745017550176501775017850179501805018150182501835018450185501865018750188501895019050191501925019350194501955019650197501985019950200502015020250203502045020550206502075020850209502105021150212502135021450215502165021750218502195022050221502225022350224502255022650227502285022950230502315023250233502345023550236502375023850239502405024150242502435024450245502465024750248502495025050251502525025350254502555025650257502585025950260502615026250263502645026550266502675026850269502705027150272502735027450275502765027750278502795028050281502825028350284502855028650287502885028950290502915029250293502945029550296502975029850299503005030150302503035030450305503065030750308503095031050311503125031350314503155031650317503185031950320503215032250323503245032550326503275032850329503305033150332503335033450335503365033750338503395034050341503425034350344503455034650347503485034950350503515035250353503545035550356503575035850359503605036150362503635036450365503665036750368503695037050371503725037350374503755037650377503785037950380503815038250383503845038550386503875038850389503905039150392503935039450395503965039750398503995040050401504025040350404504055040650407504085040950410504115041250413504145041550416504175041850419504205042150422504235042450425504265042750428504295043050431504325043350434504355043650437504385043950440504415044250443504445044550446504475044850449504505045150452504535045450455504565045750458504595046050461504625046350464504655046650467504685046950470504715047250473504745047550476504775047850479504805048150482504835048450485504865048750488504895049050491504925049350494504955049650497504985049950500505015050250503505045050550506505075050850509505105051150512505135051450515505165051750518505195052050521505225052350524505255052650527505285052950530505315053250533505345053550536505375053850539505405054150542505435054450545505465054750548505495055050551505525055350554505555055650557505585055950560505615056250563505645056550566505675056850569505705057150572505735057450575505765057750578505795058050581505825058350584505855058650587505885058950590505915059250593505945059550596505975059850599506005060150602506035060450605506065060750608506095061050611506125061350614506155061650617506185061950620506215062250623506245062550626506275062850629506305063150632506335063450635506365063750638506395064050641506425064350644506455064650647506485064950650506515065250653506545065550656506575065850659506605066150662506635066450665506665066750668506695067050671506725067350674506755067650677506785067950680506815068250683506845068550686506875068850689506905069150692506935069450695506965069750698506995070050701507025070350704507055070650707507085070950710507115071250713507145071550716507175071850719507205072150722507235072450725507265072750728507295073050731507325073350734507355073650737507385073950740507415074250743507445074550746507475074850749507505075150752507535075450755507565075750758507595076050761507625076350764507655076650767507685076950770507715077250773507745077550776507775077850779507805078150782507835078450785507865078750788507895079050791507925079350794507955079650797507985079950800508015080250803508045080550806508075080850809508105081150812508135081450815508165081750818508195082050821508225082350824508255082650827508285082950830508315083250833508345083550836508375083850839508405084150842508435084450845508465084750848508495085050851508525085350854508555085650857508585085950860508615086250863508645086550866508675086850869508705087150872508735087450875508765087750878508795088050881508825088350884508855088650887508885088950890508915089250893508945089550896508975089850899509005090150902509035090450905509065090750908509095091050911509125091350914509155091650917509185091950920509215092250923509245092550926509275092850929509305093150932509335093450935509365093750938509395094050941509425094350944509455094650947509485094950950509515095250953509545095550956509575095850959509605096150962509635096450965509665096750968509695097050971509725097350974509755097650977509785097950980509815098250983509845098550986509875098850989509905099150992509935099450995509965099750998509995100051001510025100351004510055100651007510085100951010510115101251013510145101551016510175101851019510205102151022510235102451025510265102751028510295103051031510325103351034510355103651037510385103951040510415104251043510445104551046510475104851049510505105151052510535105451055510565105751058510595106051061510625106351064510655106651067510685106951070510715107251073510745107551076510775107851079510805108151082510835108451085510865108751088510895109051091510925109351094510955109651097510985109951100511015110251103511045110551106511075110851109511105111151112511135111451115511165111751118511195112051121511225112351124511255112651127511285112951130511315113251133511345113551136511375113851139511405114151142511435114451145511465114751148511495115051151511525115351154511555115651157511585115951160511615116251163511645116551166511675116851169511705117151172511735117451175511765117751178511795118051181511825118351184511855118651187511885118951190511915119251193511945119551196511975119851199512005120151202512035120451205512065120751208512095121051211512125121351214512155121651217512185121951220512215122251223512245122551226512275122851229512305123151232512335123451235512365123751238512395124051241512425124351244512455124651247512485124951250512515125251253512545125551256512575125851259512605126151262512635126451265512665126751268512695127051271512725127351274512755127651277512785127951280512815128251283512845128551286512875128851289512905129151292512935129451295512965129751298512995130051301513025130351304513055130651307513085130951310513115131251313513145131551316513175131851319513205132151322513235132451325513265132751328513295133051331513325133351334513355133651337513385133951340513415134251343513445134551346513475134851349513505135151352513535135451355513565135751358513595136051361513625136351364513655136651367513685136951370513715137251373513745137551376513775137851379513805138151382513835138451385513865138751388513895139051391513925139351394513955139651397513985139951400514015140251403514045140551406514075140851409514105141151412514135141451415514165141751418514195142051421514225142351424514255142651427514285142951430514315143251433514345143551436514375143851439514405144151442514435144451445514465144751448514495145051451514525145351454514555145651457514585145951460514615146251463514645146551466514675146851469514705147151472514735147451475514765147751478514795148051481514825148351484514855148651487514885148951490514915149251493514945149551496514975149851499515005150151502515035150451505515065150751508515095151051511515125151351514515155151651517515185151951520515215152251523515245152551526515275152851529515305153151532515335153451535515365153751538515395154051541515425154351544515455154651547515485154951550515515155251553515545155551556515575155851559515605156151562515635156451565515665156751568515695157051571515725157351574515755157651577515785157951580515815158251583515845158551586515875158851589515905159151592515935159451595515965159751598515995160051601516025160351604516055160651607516085160951610516115161251613516145161551616516175161851619516205162151622516235162451625516265162751628516295163051631516325163351634516355163651637516385163951640516415164251643516445164551646516475164851649516505165151652516535165451655516565165751658516595166051661516625166351664516655166651667516685166951670516715167251673516745167551676516775167851679516805168151682516835168451685516865168751688516895169051691516925169351694516955169651697516985169951700517015170251703517045170551706517075170851709517105171151712517135171451715517165171751718517195172051721517225172351724517255172651727517285172951730517315173251733517345173551736517375173851739517405174151742517435174451745517465174751748517495175051751517525175351754517555175651757517585175951760517615176251763517645176551766517675176851769517705177151772517735177451775517765177751778517795178051781517825178351784517855178651787517885178951790517915179251793517945179551796517975179851799518005180151802518035180451805518065180751808518095181051811518125181351814518155181651817518185181951820518215182251823518245182551826518275182851829518305183151832518335183451835518365183751838518395184051841518425184351844518455184651847518485184951850518515185251853518545185551856518575185851859518605186151862518635186451865518665186751868518695187051871518725187351874518755187651877518785187951880518815188251883518845188551886518875188851889518905189151892518935189451895518965189751898518995190051901519025190351904519055190651907519085190951910519115191251913519145191551916519175191851919519205192151922519235192451925519265192751928519295193051931519325193351934519355193651937519385193951940519415194251943519445194551946519475194851949519505195151952519535195451955519565195751958519595196051961519625196351964519655196651967519685196951970519715197251973519745197551976519775197851979519805198151982519835198451985519865198751988519895199051991519925199351994519955199651997519985199952000520015200252003520045200552006520075200852009520105201152012520135201452015520165201752018520195202052021520225202352024520255202652027520285202952030520315203252033520345203552036520375203852039520405204152042520435204452045520465204752048520495205052051520525205352054520555205652057520585205952060520615206252063520645206552066520675206852069520705207152072520735207452075520765207752078520795208052081520825208352084520855208652087520885208952090520915209252093520945209552096520975209852099521005210152102521035210452105521065210752108521095211052111521125211352114521155211652117521185211952120521215212252123521245212552126521275212852129521305213152132521335213452135521365213752138521395214052141521425214352144521455214652147521485214952150521515215252153521545215552156521575215852159521605216152162521635216452165521665216752168521695217052171521725217352174521755217652177521785217952180521815218252183521845218552186521875218852189521905219152192521935219452195521965219752198521995220052201522025220352204522055220652207522085220952210522115221252213522145221552216522175221852219522205222152222522235222452225522265222752228522295223052231522325223352234522355223652237522385223952240522415224252243522445224552246522475224852249522505225152252522535225452255522565225752258522595226052261522625226352264522655226652267522685226952270522715227252273522745227552276522775227852279522805228152282522835228452285522865228752288522895229052291522925229352294522955229652297522985229952300523015230252303523045230552306523075230852309523105231152312523135231452315523165231752318523195232052321523225232352324523255232652327523285232952330523315233252333523345233552336523375233852339523405234152342523435234452345523465234752348523495235052351523525235352354523555235652357523585235952360523615236252363523645236552366523675236852369523705237152372523735237452375523765237752378523795238052381523825238352384523855238652387523885238952390523915239252393523945239552396523975239852399524005240152402524035240452405524065240752408524095241052411524125241352414524155241652417524185241952420524215242252423524245242552426524275242852429524305243152432524335243452435524365243752438524395244052441524425244352444524455244652447524485244952450524515245252453524545245552456524575245852459524605246152462524635246452465524665246752468524695247052471524725247352474524755247652477524785247952480524815248252483524845248552486524875248852489524905249152492524935249452495524965249752498524995250052501525025250352504525055250652507525085250952510525115251252513525145251552516525175251852519525205252152522525235252452525525265252752528525295253052531525325253352534525355253652537525385253952540525415254252543525445254552546525475254852549525505255152552525535255452555525565255752558525595256052561525625256352564525655256652567525685256952570525715257252573525745257552576525775257852579525805258152582525835258452585525865258752588525895259052591525925259352594525955259652597525985259952600526015260252603526045260552606526075260852609526105261152612526135261452615526165261752618526195262052621526225262352624526255262652627526285262952630526315263252633526345263552636526375263852639526405264152642526435264452645526465264752648526495265052651526525265352654526555265652657526585265952660526615266252663526645266552666526675266852669526705267152672526735267452675526765267752678526795268052681526825268352684526855268652687526885268952690526915269252693526945269552696526975269852699527005270152702527035270452705527065270752708527095271052711527125271352714527155271652717527185271952720527215272252723527245272552726527275272852729527305273152732527335273452735527365273752738527395274052741527425274352744527455274652747527485274952750527515275252753527545275552756527575275852759527605276152762527635276452765527665276752768527695277052771527725277352774527755277652777527785277952780527815278252783527845278552786527875278852789527905279152792527935279452795527965279752798527995280052801528025280352804528055280652807528085280952810528115281252813528145281552816528175281852819528205282152822528235282452825528265282752828528295283052831528325283352834528355283652837528385283952840528415284252843528445284552846528475284852849528505285152852528535285452855528565285752858528595286052861528625286352864528655286652867528685286952870528715287252873528745287552876528775287852879528805288152882528835288452885528865288752888528895289052891528925289352894528955289652897528985289952900529015290252903529045290552906529075290852909529105291152912529135291452915529165291752918529195292052921529225292352924529255292652927529285292952930529315293252933529345293552936529375293852939529405294152942529435294452945529465294752948529495295052951529525295352954529555295652957529585295952960529615296252963529645296552966529675296852969529705297152972529735297452975529765297752978529795298052981529825298352984529855298652987529885298952990529915299252993529945299552996529975299852999530005300153002530035300453005530065300753008530095301053011530125301353014530155301653017530185301953020530215302253023530245302553026530275302853029530305303153032530335303453035530365303753038530395304053041530425304353044530455304653047530485304953050530515305253053530545305553056530575305853059530605306153062530635306453065530665306753068530695307053071530725307353074530755307653077530785307953080530815308253083530845308553086530875308853089530905309153092530935309453095530965309753098530995310053101531025310353104531055310653107531085310953110531115311253113531145311553116531175311853119531205312153122531235312453125531265312753128531295313053131531325313353134531355313653137531385313953140531415314253143531445314553146531475314853149531505315153152531535315453155531565315753158531595316053161531625316353164531655316653167531685316953170531715317253173531745317553176531775317853179531805318153182531835318453185531865318753188531895319053191531925319353194531955319653197531985319953200532015320253203532045320553206532075320853209532105321153212532135321453215532165321753218532195322053221532225322353224532255322653227532285322953230532315323253233532345323553236532375323853239532405324153242532435324453245532465324753248532495325053251532525325353254532555325653257532585325953260532615326253263532645326553266532675326853269532705327153272532735327453275532765327753278532795328053281532825328353284532855328653287532885328953290532915329253293532945329553296532975329853299533005330153302533035330453305533065330753308533095331053311533125331353314533155331653317533185331953320533215332253323533245332553326533275332853329533305333153332533335333453335533365333753338533395334053341533425334353344533455334653347533485334953350533515335253353533545335553356533575335853359533605336153362533635336453365533665336753368533695337053371533725337353374533755337653377533785337953380533815338253383533845338553386533875338853389533905339153392533935339453395533965339753398533995340053401534025340353404534055340653407534085340953410534115341253413534145341553416534175341853419534205342153422534235342453425534265342753428534295343053431534325343353434534355343653437534385343953440534415344253443534445344553446534475344853449534505345153452534535345453455534565345753458534595346053461534625346353464534655346653467534685346953470534715347253473534745347553476534775347853479534805348153482534835348453485534865348753488534895349053491534925349353494534955349653497534985349953500535015350253503535045350553506535075350853509535105351153512535135351453515535165351753518535195352053521535225352353524535255352653527535285352953530535315353253533535345353553536535375353853539535405354153542535435354453545535465354753548535495355053551535525355353554535555355653557535585355953560535615356253563535645356553566535675356853569535705357153572535735357453575535765357753578535795358053581535825358353584535855358653587535885358953590535915359253593535945359553596535975359853599536005360153602536035360453605536065360753608536095361053611536125361353614536155361653617536185361953620536215362253623536245362553626536275362853629536305363153632536335363453635536365363753638536395364053641536425364353644536455364653647536485364953650536515365253653536545365553656536575365853659536605366153662536635366453665536665366753668536695367053671536725367353674536755367653677536785367953680536815368253683536845368553686536875368853689536905369153692536935369453695536965369753698536995370053701537025370353704537055370653707537085370953710537115371253713537145371553716537175371853719537205372153722537235372453725537265372753728537295373053731537325373353734537355373653737537385373953740537415374253743537445374553746537475374853749537505375153752537535375453755537565375753758537595376053761537625376353764537655376653767537685376953770537715377253773537745377553776537775377853779537805378153782537835378453785537865378753788537895379053791537925379353794537955379653797537985379953800538015380253803538045380553806538075380853809538105381153812538135381453815538165381753818538195382053821538225382353824538255382653827538285382953830538315383253833538345383553836538375383853839538405384153842538435384453845538465384753848538495385053851538525385353854538555385653857538585385953860538615386253863538645386553866538675386853869538705387153872538735387453875538765387753878538795388053881538825388353884538855388653887538885388953890538915389253893538945389553896538975389853899539005390153902539035390453905539065390753908539095391053911539125391353914539155391653917539185391953920539215392253923539245392553926539275392853929539305393153932539335393453935539365393753938539395394053941539425394353944539455394653947539485394953950539515395253953539545395553956539575395853959539605396153962539635396453965539665396753968539695397053971539725397353974539755397653977539785397953980539815398253983539845398553986539875398853989539905399153992539935399453995539965399753998539995400054001540025400354004540055400654007540085400954010540115401254013540145401554016540175401854019540205402154022540235402454025540265402754028540295403054031540325403354034540355403654037540385403954040540415404254043540445404554046540475404854049540505405154052540535405454055540565405754058540595406054061540625406354064540655406654067540685406954070540715407254073540745407554076540775407854079540805408154082540835408454085540865408754088540895409054091540925409354094540955409654097540985409954100541015410254103541045410554106541075410854109541105411154112541135411454115541165411754118541195412054121541225412354124541255412654127541285412954130541315413254133541345413554136541375413854139541405414154142541435414454145541465414754148541495415054151541525415354154541555415654157541585415954160541615416254163541645416554166541675416854169541705417154172541735417454175541765417754178541795418054181541825418354184541855418654187541885418954190541915419254193541945419554196541975419854199542005420154202542035420454205542065420754208542095421054211542125421354214542155421654217542185421954220542215422254223542245422554226542275422854229542305423154232542335423454235542365423754238542395424054241542425424354244542455424654247542485424954250542515425254253542545425554256542575425854259542605426154262542635426454265542665426754268542695427054271542725427354274542755427654277542785427954280542815428254283542845428554286542875428854289542905429154292542935429454295542965429754298542995430054301543025430354304543055430654307543085430954310543115431254313543145431554316543175431854319543205432154322543235432454325543265432754328543295433054331543325433354334543355433654337543385433954340543415434254343543445434554346543475434854349543505435154352543535435454355543565435754358543595436054361543625436354364543655436654367543685436954370543715437254373543745437554376543775437854379543805438154382543835438454385543865438754388543895439054391543925439354394543955439654397543985439954400544015440254403544045440554406544075440854409544105441154412544135441454415544165441754418544195442054421544225442354424544255442654427544285442954430544315443254433544345443554436544375443854439544405444154442544435444454445544465444754448544495445054451544525445354454544555445654457544585445954460544615446254463544645446554466544675446854469544705447154472544735447454475544765447754478544795448054481544825448354484544855448654487544885448954490544915449254493544945449554496544975449854499545005450154502545035450454505545065450754508545095451054511545125451354514545155451654517545185451954520545215452254523545245452554526545275452854529545305453154532545335453454535545365453754538545395454054541545425454354544545455454654547545485454954550545515455254553545545455554556545575455854559545605456154562545635456454565545665456754568545695457054571545725457354574545755457654577545785457954580545815458254583545845458554586545875458854589545905459154592545935459454595545965459754598545995460054601546025460354604546055460654607546085460954610546115461254613546145461554616546175461854619546205462154622546235462454625546265462754628546295463054631546325463354634546355463654637546385463954640546415464254643546445464554646546475464854649546505465154652546535465454655546565465754658546595466054661546625466354664546655466654667546685466954670546715467254673546745467554676546775467854679546805468154682546835468454685546865468754688546895469054691546925469354694546955469654697546985469954700547015470254703547045470554706547075470854709547105471154712547135471454715547165471754718547195472054721547225472354724547255472654727547285472954730547315473254733547345473554736547375473854739547405474154742547435474454745547465474754748547495475054751547525475354754547555475654757547585475954760547615476254763547645476554766547675476854769547705477154772547735477454775547765477754778547795478054781547825478354784547855478654787547885478954790547915479254793547945479554796547975479854799548005480154802548035480454805548065480754808548095481054811548125481354814548155481654817548185481954820548215482254823548245482554826548275482854829548305483154832548335483454835548365483754838548395484054841548425484354844548455484654847548485484954850548515485254853548545485554856548575485854859548605486154862548635486454865548665486754868548695487054871548725487354874548755487654877548785487954880548815488254883548845488554886548875488854889548905489154892548935489454895548965489754898548995490054901549025490354904549055490654907549085490954910549115491254913549145491554916549175491854919549205492154922549235492454925549265492754928549295493054931549325493354934549355493654937549385493954940549415494254943549445494554946549475494854949549505495154952549535495454955549565495754958549595496054961549625496354964549655496654967549685496954970549715497254973549745497554976549775497854979549805498154982549835498454985549865498754988549895499054991549925499354994549955499654997549985499955000550015500255003550045500555006550075500855009550105501155012550135501455015550165501755018550195502055021550225502355024550255502655027550285502955030550315503255033550345503555036550375503855039550405504155042550435504455045550465504755048550495505055051550525505355054550555505655057550585505955060550615506255063550645506555066550675506855069550705507155072550735507455075550765507755078550795508055081550825508355084550855508655087550885508955090550915509255093550945509555096550975509855099551005510155102551035510455105551065510755108551095511055111551125511355114551155511655117551185511955120551215512255123551245512555126551275512855129551305513155132551335513455135551365513755138551395514055141551425514355144551455514655147551485514955150551515515255153551545515555156551575515855159551605516155162551635516455165551665516755168551695517055171551725517355174551755517655177551785517955180551815518255183551845518555186551875518855189551905519155192551935519455195551965519755198551995520055201552025520355204552055520655207552085520955210552115521255213552145521555216552175521855219552205522155222552235522455225552265522755228552295523055231552325523355234552355523655237552385523955240552415524255243552445524555246552475524855249552505525155252552535525455255552565525755258552595526055261552625526355264552655526655267552685526955270552715527255273552745527555276552775527855279552805528155282552835528455285552865528755288552895529055291552925529355294552955529655297552985529955300553015530255303553045530555306553075530855309553105531155312553135531455315553165531755318553195532055321553225532355324553255532655327553285532955330553315533255333553345533555336553375533855339553405534155342553435534455345553465534755348553495535055351553525535355354553555535655357553585535955360553615536255363553645536555366553675536855369553705537155372553735537455375553765537755378553795538055381553825538355384553855538655387553885538955390553915539255393553945539555396553975539855399554005540155402554035540455405554065540755408554095541055411554125541355414554155541655417554185541955420554215542255423554245542555426554275542855429554305543155432554335543455435554365543755438554395544055441554425544355444554455544655447554485544955450554515545255453554545545555456554575545855459554605546155462554635546455465554665546755468554695547055471554725547355474554755547655477554785547955480554815548255483554845548555486554875548855489554905549155492554935549455495554965549755498554995550055501555025550355504555055550655507555085550955510555115551255513555145551555516555175551855519555205552155522555235552455525555265552755528555295553055531555325553355534555355553655537555385553955540555415554255543555445554555546555475554855549555505555155552555535555455555555565555755558555595556055561555625556355564555655556655567555685556955570555715557255573555745557555576555775557855579555805558155582555835558455585555865558755588555895559055591555925559355594555955559655597555985559955600556015560255603556045560555606556075560855609556105561155612556135561455615556165561755618556195562055621556225562355624556255562655627556285562955630556315563255633556345563555636556375563855639556405564155642556435564455645556465564755648556495565055651556525565355654556555565655657556585565955660556615566255663556645566555666556675566855669556705567155672556735567455675556765567755678556795568055681556825568355684556855568655687556885568955690556915569255693556945569555696556975569855699557005570155702557035570455705557065570755708557095571055711557125571355714557155571655717557185571955720557215572255723557245572555726557275572855729557305573155732557335573455735557365573755738557395574055741557425574355744557455574655747557485574955750557515575255753557545575555756557575575855759557605576155762557635576455765557665576755768557695577055771557725577355774557755577655777557785577955780557815578255783557845578555786557875578855789557905579155792557935579455795557965579755798557995580055801558025580355804558055580655807558085580955810558115581255813558145581555816558175581855819558205582155822558235582455825558265582755828558295583055831558325583355834558355583655837558385583955840558415584255843558445584555846558475584855849558505585155852558535585455855558565585755858558595586055861558625586355864558655586655867558685586955870558715587255873558745587555876558775587855879558805588155882558835588455885558865588755888558895589055891558925589355894558955589655897558985589955900559015590255903559045590555906559075590855909559105591155912559135591455915559165591755918559195592055921559225592355924559255592655927559285592955930559315593255933559345593555936559375593855939559405594155942559435594455945559465594755948559495595055951559525595355954559555595655957559585595955960559615596255963559645596555966559675596855969559705597155972559735597455975559765597755978559795598055981559825598355984559855598655987559885598955990559915599255993559945599555996559975599855999560005600156002560035600456005560065600756008560095601056011560125601356014560155601656017560185601956020560215602256023560245602556026560275602856029560305603156032560335603456035560365603756038560395604056041560425604356044560455604656047560485604956050560515605256053560545605556056560575605856059560605606156062560635606456065560665606756068560695607056071560725607356074560755607656077560785607956080560815608256083560845608556086560875608856089560905609156092560935609456095560965609756098560995610056101561025610356104561055610656107561085610956110561115611256113561145611556116561175611856119561205612156122561235612456125561265612756128561295613056131561325613356134561355613656137561385613956140561415614256143561445614556146561475614856149561505615156152561535615456155561565615756158561595616056161561625616356164561655616656167561685616956170561715617256173561745617556176561775617856179561805618156182561835618456185561865618756188561895619056191561925619356194561955619656197561985619956200562015620256203562045620556206562075620856209562105621156212562135621456215562165621756218562195622056221562225622356224562255622656227562285622956230562315623256233562345623556236562375623856239562405624156242562435624456245562465624756248562495625056251562525625356254562555625656257562585625956260562615626256263562645626556266562675626856269562705627156272562735627456275562765627756278562795628056281562825628356284562855628656287562885628956290562915629256293562945629556296562975629856299563005630156302563035630456305563065630756308563095631056311563125631356314563155631656317563185631956320563215632256323563245632556326563275632856329563305633156332563335633456335563365633756338563395634056341563425634356344563455634656347563485634956350563515635256353563545635556356563575635856359563605636156362563635636456365563665636756368563695637056371563725637356374563755637656377563785637956380563815638256383563845638556386563875638856389563905639156392563935639456395563965639756398563995640056401564025640356404564055640656407564085640956410564115641256413564145641556416564175641856419564205642156422564235642456425564265642756428564295643056431564325643356434564355643656437564385643956440564415644256443564445644556446564475644856449564505645156452564535645456455564565645756458564595646056461564625646356464564655646656467564685646956470564715647256473564745647556476564775647856479564805648156482564835648456485564865648756488564895649056491564925649356494564955649656497564985649956500565015650256503565045650556506565075650856509565105651156512565135651456515565165651756518565195652056521565225652356524565255652656527565285652956530565315653256533565345653556536565375653856539565405654156542565435654456545565465654756548565495655056551565525655356554565555655656557565585655956560565615656256563565645656556566565675656856569565705657156572565735657456575565765657756578565795658056581565825658356584565855658656587565885658956590565915659256593565945659556596565975659856599566005660156602566035660456605566065660756608566095661056611566125661356614566155661656617566185661956620566215662256623566245662556626566275662856629566305663156632566335663456635566365663756638566395664056641566425664356644566455664656647566485664956650566515665256653566545665556656566575665856659566605666156662566635666456665566665666756668566695667056671566725667356674566755667656677566785667956680566815668256683566845668556686566875668856689566905669156692566935669456695566965669756698566995670056701567025670356704567055670656707567085670956710567115671256713567145671556716567175671856719567205672156722567235672456725567265672756728567295673056731567325673356734567355673656737567385673956740567415674256743567445674556746567475674856749567505675156752567535675456755567565675756758567595676056761567625676356764567655676656767567685676956770567715677256773567745677556776567775677856779567805678156782567835678456785567865678756788567895679056791567925679356794567955679656797567985679956800568015680256803568045680556806568075680856809568105681156812568135681456815568165681756818568195682056821568225682356824568255682656827568285682956830568315683256833568345683556836568375683856839568405684156842568435684456845568465684756848568495685056851568525685356854568555685656857568585685956860568615686256863568645686556866568675686856869568705687156872568735687456875568765687756878568795688056881568825688356884568855688656887568885688956890568915689256893568945689556896568975689856899569005690156902569035690456905569065690756908569095691056911569125691356914569155691656917569185691956920569215692256923569245692556926569275692856929569305693156932569335693456935569365693756938569395694056941569425694356944569455694656947569485694956950569515695256953569545695556956569575695856959569605696156962569635696456965569665696756968569695697056971569725697356974569755697656977569785697956980569815698256983569845698556986569875698856989569905699156992569935699456995569965699756998569995700057001570025700357004570055700657007570085700957010570115701257013570145701557016570175701857019570205702157022570235702457025570265702757028570295703057031570325703357034570355703657037570385703957040570415704257043570445704557046570475704857049570505705157052570535705457055570565705757058570595706057061570625706357064570655706657067570685706957070570715707257073570745707557076570775707857079570805708157082570835708457085570865708757088570895709057091570925709357094570955709657097570985709957100571015710257103571045710557106571075710857109571105711157112571135711457115571165711757118571195712057121571225712357124571255712657127571285712957130571315713257133571345713557136571375713857139571405714157142571435714457145571465714757148571495715057151571525715357154571555715657157571585715957160571615716257163571645716557166571675716857169571705717157172571735717457175571765717757178571795718057181571825718357184571855718657187571885718957190571915719257193571945719557196571975719857199572005720157202572035720457205572065720757208572095721057211572125721357214572155721657217572185721957220572215722257223572245722557226572275722857229572305723157232572335723457235572365723757238572395724057241572425724357244572455724657247572485724957250572515725257253572545725557256572575725857259572605726157262572635726457265572665726757268572695727057271572725727357274572755727657277572785727957280572815728257283572845728557286572875728857289572905729157292572935729457295572965729757298572995730057301573025730357304573055730657307573085730957310573115731257313573145731557316573175731857319573205732157322573235732457325573265732757328573295733057331573325733357334573355733657337573385733957340573415734257343573445734557346573475734857349573505735157352573535735457355573565735757358573595736057361573625736357364573655736657367573685736957370573715737257373573745737557376573775737857379573805738157382573835738457385573865738757388573895739057391573925739357394573955739657397573985739957400574015740257403574045740557406574075740857409574105741157412574135741457415574165741757418574195742057421574225742357424574255742657427574285742957430574315743257433574345743557436574375743857439574405744157442574435744457445574465744757448574495745057451574525745357454574555745657457574585745957460574615746257463574645746557466574675746857469574705747157472574735747457475574765747757478574795748057481574825748357484574855748657487574885748957490574915749257493574945749557496574975749857499575005750157502575035750457505575065750757508575095751057511575125751357514575155751657517575185751957520575215752257523575245752557526575275752857529575305753157532575335753457535575365753757538575395754057541575425754357544575455754657547575485754957550575515755257553575545755557556575575755857559575605756157562575635756457565575665756757568575695757057571575725757357574575755757657577575785757957580575815758257583575845758557586575875758857589575905759157592575935759457595575965759757598575995760057601576025760357604576055760657607576085760957610576115761257613576145761557616576175761857619576205762157622576235762457625576265762757628576295763057631576325763357634576355763657637576385763957640576415764257643576445764557646576475764857649576505765157652576535765457655576565765757658576595766057661576625766357664576655766657667576685766957670576715767257673576745767557676576775767857679576805768157682576835768457685576865768757688576895769057691576925769357694576955769657697576985769957700577015770257703577045770557706577075770857709577105771157712577135771457715577165771757718577195772057721577225772357724577255772657727577285772957730577315773257733577345773557736577375773857739577405774157742577435774457745577465774757748577495775057751577525775357754577555775657757577585775957760577615776257763577645776557766577675776857769577705777157772577735777457775577765777757778577795778057781577825778357784577855778657787577885778957790577915779257793577945779557796577975779857799578005780157802578035780457805578065780757808578095781057811578125781357814578155781657817578185781957820578215782257823578245782557826578275782857829578305783157832578335783457835578365783757838578395784057841578425784357844578455784657847578485784957850578515785257853578545785557856578575785857859578605786157862578635786457865578665786757868578695787057871578725787357874578755787657877578785787957880578815788257883578845788557886578875788857889578905789157892578935789457895578965789757898578995790057901579025790357904579055790657907579085790957910579115791257913579145791557916579175791857919579205792157922579235792457925579265792757928579295793057931579325793357934579355793657937579385793957940579415794257943579445794557946579475794857949579505795157952579535795457955579565795757958579595796057961579625796357964579655796657967579685796957970579715797257973579745797557976579775797857979579805798157982579835798457985579865798757988579895799057991579925799357994579955799657997579985799958000580015800258003580045800558006580075800858009580105801158012580135801458015580165801758018580195802058021580225802358024580255802658027580285802958030580315803258033580345803558036580375803858039580405804158042580435804458045580465804758048580495805058051580525805358054580555805658057580585805958060580615806258063580645806558066580675806858069580705807158072580735807458075580765807758078580795808058081580825808358084580855808658087580885808958090580915809258093 |
- // Code generated by ent, DO NOT EDIT.
- package ent
- import (
- "context"
- "encoding/json/jsontext"
- "errors"
- "fmt"
- "sync"
- "time"
- "entgo.io/ent"
- "entgo.io/ent/dialect/sql"
- "github.com/Wei-Shaw/sub2api/ent/account"
- "github.com/Wei-Shaw/sub2api/ent/accountgroup"
- "github.com/Wei-Shaw/sub2api/ent/announcement"
- "github.com/Wei-Shaw/sub2api/ent/announcementread"
- "github.com/Wei-Shaw/sub2api/ent/apikey"
- "github.com/Wei-Shaw/sub2api/ent/authidentity"
- "github.com/Wei-Shaw/sub2api/ent/authidentitychannel"
- "github.com/Wei-Shaw/sub2api/ent/batchimageevent"
- "github.com/Wei-Shaw/sub2api/ent/batchimageitem"
- "github.com/Wei-Shaw/sub2api/ent/batchimagejob"
- "github.com/Wei-Shaw/sub2api/ent/channelmonitor"
- "github.com/Wei-Shaw/sub2api/ent/channelmonitordailyrollup"
- "github.com/Wei-Shaw/sub2api/ent/channelmonitorhistory"
- "github.com/Wei-Shaw/sub2api/ent/channelmonitorrequesttemplate"
- "github.com/Wei-Shaw/sub2api/ent/compositemodelroute"
- "github.com/Wei-Shaw/sub2api/ent/errorpassthroughrule"
- "github.com/Wei-Shaw/sub2api/ent/group"
- "github.com/Wei-Shaw/sub2api/ent/idempotencyrecord"
- "github.com/Wei-Shaw/sub2api/ent/identityadoptiondecision"
- "github.com/Wei-Shaw/sub2api/ent/paymentauditlog"
- "github.com/Wei-Shaw/sub2api/ent/paymentorder"
- "github.com/Wei-Shaw/sub2api/ent/paymentproviderinstance"
- "github.com/Wei-Shaw/sub2api/ent/pendingauthsession"
- "github.com/Wei-Shaw/sub2api/ent/predicate"
- "github.com/Wei-Shaw/sub2api/ent/promocode"
- "github.com/Wei-Shaw/sub2api/ent/promocodeusage"
- "github.com/Wei-Shaw/sub2api/ent/proxy"
- "github.com/Wei-Shaw/sub2api/ent/redeemcode"
- "github.com/Wei-Shaw/sub2api/ent/securitypolicykeyword"
- "github.com/Wei-Shaw/sub2api/ent/securitysecret"
- "github.com/Wei-Shaw/sub2api/ent/setting"
- "github.com/Wei-Shaw/sub2api/ent/subscriptionplan"
- "github.com/Wei-Shaw/sub2api/ent/tlsfingerprintprofile"
- "github.com/Wei-Shaw/sub2api/ent/usagecleanuptask"
- "github.com/Wei-Shaw/sub2api/ent/usagelog"
- "github.com/Wei-Shaw/sub2api/ent/user"
- "github.com/Wei-Shaw/sub2api/ent/userallowedgroup"
- "github.com/Wei-Shaw/sub2api/ent/userattributedefinition"
- "github.com/Wei-Shaw/sub2api/ent/userattributevalue"
- "github.com/Wei-Shaw/sub2api/ent/userplatformquota"
- "github.com/Wei-Shaw/sub2api/ent/usersubscription"
- "github.com/Wei-Shaw/sub2api/internal/domain"
- )
- const (
- // Operation types.
- OpCreate = ent.OpCreate
- OpDelete = ent.OpDelete
- OpDeleteOne = ent.OpDeleteOne
- OpUpdate = ent.OpUpdate
- OpUpdateOne = ent.OpUpdateOne
- // Node types.
- TypeAPIKey = "APIKey"
- TypeAccount = "Account"
- TypeAccountGroup = "AccountGroup"
- TypeAnnouncement = "Announcement"
- TypeAnnouncementRead = "AnnouncementRead"
- TypeAuthIdentity = "AuthIdentity"
- TypeAuthIdentityChannel = "AuthIdentityChannel"
- TypeBatchImageEvent = "BatchImageEvent"
- TypeBatchImageItem = "BatchImageItem"
- TypeBatchImageJob = "BatchImageJob"
- TypeChannelMonitor = "ChannelMonitor"
- TypeChannelMonitorDailyRollup = "ChannelMonitorDailyRollup"
- TypeChannelMonitorHistory = "ChannelMonitorHistory"
- TypeChannelMonitorRequestTemplate = "ChannelMonitorRequestTemplate"
- TypeCompositeModelRoute = "CompositeModelRoute"
- TypeErrorPassthroughRule = "ErrorPassthroughRule"
- TypeGroup = "Group"
- TypeIdempotencyRecord = "IdempotencyRecord"
- TypeIdentityAdoptionDecision = "IdentityAdoptionDecision"
- TypePaymentAuditLog = "PaymentAuditLog"
- TypePaymentOrder = "PaymentOrder"
- TypePaymentProviderInstance = "PaymentProviderInstance"
- TypePendingAuthSession = "PendingAuthSession"
- TypePromoCode = "PromoCode"
- TypePromoCodeUsage = "PromoCodeUsage"
- TypeProxy = "Proxy"
- TypeRedeemCode = "RedeemCode"
- TypeSecurityPolicyKeyword = "SecurityPolicyKeyword"
- TypeSecuritySecret = "SecuritySecret"
- TypeSetting = "Setting"
- TypeSubscriptionPlan = "SubscriptionPlan"
- TypeTLSFingerprintProfile = "TLSFingerprintProfile"
- TypeUsageCleanupTask = "UsageCleanupTask"
- TypeUsageLog = "UsageLog"
- TypeUser = "User"
- TypeUserAllowedGroup = "UserAllowedGroup"
- TypeUserAttributeDefinition = "UserAttributeDefinition"
- TypeUserAttributeValue = "UserAttributeValue"
- TypeUserPlatformQuota = "UserPlatformQuota"
- TypeUserSubscription = "UserSubscription"
- )
- // APIKeyMutation represents an operation that mutates the APIKey nodes in the graph.
- type APIKeyMutation struct {
- config
- op Op
- typ string
- id *int64
- created_at *time.Time
- updated_at *time.Time
- deleted_at *time.Time
- key *string
- key_hash *string
- key_prefix *string
- name *string
- status *string
- last_used_at *time.Time
- ip_whitelist *[]string
- appendip_whitelist []string
- ip_blacklist *[]string
- appendip_blacklist []string
- quota *float64
- addquota *float64
- quota_used *float64
- addquota_used *float64
- expires_at *time.Time
- rate_limit_5h *float64
- addrate_limit_5h *float64
- rate_limit_1d *float64
- addrate_limit_1d *float64
- rate_limit_7d *float64
- addrate_limit_7d *float64
- usage_5h *float64
- addusage_5h *float64
- usage_1d *float64
- addusage_1d *float64
- usage_7d *float64
- addusage_7d *float64
- window_5h_start *time.Time
- window_1d_start *time.Time
- window_7d_start *time.Time
- clearedFields map[string]struct{}
- user *int64
- cleareduser bool
- group *int64
- clearedgroup bool
- usage_logs map[int64]struct{}
- removedusage_logs map[int64]struct{}
- clearedusage_logs bool
- done bool
- oldValue func(context.Context) (*APIKey, error)
- predicates []predicate.APIKey
- }
- var _ ent.Mutation = (*APIKeyMutation)(nil)
- // apikeyOption allows management of the mutation configuration using functional options.
- type apikeyOption func(*APIKeyMutation)
- // newAPIKeyMutation creates new mutation for the APIKey entity.
- func newAPIKeyMutation(c config, op Op, opts ...apikeyOption) *APIKeyMutation {
- m := &APIKeyMutation{
- config: c,
- op: op,
- typ: TypeAPIKey,
- clearedFields: make(map[string]struct{}),
- }
- for _, opt := range opts {
- opt(m)
- }
- return m
- }
- // withAPIKeyID sets the ID field of the mutation.
- func withAPIKeyID(id int64) apikeyOption {
- return func(m *APIKeyMutation) {
- var (
- err error
- once sync.Once
- value *APIKey
- )
- m.oldValue = func(ctx context.Context) (*APIKey, error) {
- once.Do(func() {
- if m.done {
- err = errors.New("querying old values post mutation is not allowed")
- } else {
- value, err = m.Client().APIKey.Get(ctx, id)
- }
- })
- return value, err
- }
- m.id = &id
- }
- }
- // withAPIKey sets the old APIKey of the mutation.
- func withAPIKey(node *APIKey) apikeyOption {
- return func(m *APIKeyMutation) {
- m.oldValue = func(context.Context) (*APIKey, error) {
- return node, nil
- }
- m.id = &node.ID
- }
- }
- // Client returns a new `ent.Client` from the mutation. If the mutation was
- // executed in a transaction (ent.Tx), a transactional client is returned.
- func (m APIKeyMutation) Client() *Client {
- client := &Client{config: m.config}
- client.init()
- return client
- }
- // Tx returns an `ent.Tx` for mutations that were executed in transactions;
- // it returns an error otherwise.
- func (m APIKeyMutation) Tx() (*Tx, error) {
- if _, ok := m.driver.(*txDriver); !ok {
- return nil, errors.New("ent: mutation is not running in a transaction")
- }
- tx := &Tx{config: m.config}
- tx.init()
- return tx, nil
- }
- // ID returns the ID value in the mutation. Note that the ID is only available
- // if it was provided to the builder or after it was returned from the database.
- func (m *APIKeyMutation) ID() (id int64, exists bool) {
- if m.id == nil {
- return
- }
- return *m.id, true
- }
- // IDs queries the database and returns the entity ids that match the mutation's predicate.
- // That means, if the mutation is applied within a transaction with an isolation level such
- // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
- // or updated by the mutation.
- func (m *APIKeyMutation) IDs(ctx context.Context) ([]int64, error) {
- switch {
- case m.op.Is(OpUpdateOne | OpDeleteOne):
- id, exists := m.ID()
- if exists {
- return []int64{id}, nil
- }
- fallthrough
- case m.op.Is(OpUpdate | OpDelete):
- return m.Client().APIKey.Query().Where(m.predicates...).IDs(ctx)
- default:
- return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
- }
- }
- // SetCreatedAt sets the "created_at" field.
- func (m *APIKeyMutation) SetCreatedAt(t time.Time) {
- m.created_at = &t
- }
- // CreatedAt returns the value of the "created_at" field in the mutation.
- func (m *APIKeyMutation) CreatedAt() (r time.Time, exists bool) {
- v := m.created_at
- if v == nil {
- return
- }
- return *v, true
- }
- // OldCreatedAt returns the old "created_at" field's value of the APIKey entity.
- // If the APIKey object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *APIKeyMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldCreatedAt requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
- }
- return oldValue.CreatedAt, nil
- }
- // ResetCreatedAt resets all changes to the "created_at" field.
- func (m *APIKeyMutation) ResetCreatedAt() {
- m.created_at = nil
- }
- // SetUpdatedAt sets the "updated_at" field.
- func (m *APIKeyMutation) SetUpdatedAt(t time.Time) {
- m.updated_at = &t
- }
- // UpdatedAt returns the value of the "updated_at" field in the mutation.
- func (m *APIKeyMutation) UpdatedAt() (r time.Time, exists bool) {
- v := m.updated_at
- if v == nil {
- return
- }
- return *v, true
- }
- // OldUpdatedAt returns the old "updated_at" field's value of the APIKey entity.
- // If the APIKey object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *APIKeyMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
- }
- return oldValue.UpdatedAt, nil
- }
- // ResetUpdatedAt resets all changes to the "updated_at" field.
- func (m *APIKeyMutation) ResetUpdatedAt() {
- m.updated_at = nil
- }
- // SetDeletedAt sets the "deleted_at" field.
- func (m *APIKeyMutation) SetDeletedAt(t time.Time) {
- m.deleted_at = &t
- }
- // DeletedAt returns the value of the "deleted_at" field in the mutation.
- func (m *APIKeyMutation) DeletedAt() (r time.Time, exists bool) {
- v := m.deleted_at
- if v == nil {
- return
- }
- return *v, true
- }
- // OldDeletedAt returns the old "deleted_at" field's value of the APIKey entity.
- // If the APIKey object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *APIKeyMutation) OldDeletedAt(ctx context.Context) (v *time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldDeletedAt requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
- }
- return oldValue.DeletedAt, nil
- }
- // ClearDeletedAt clears the value of the "deleted_at" field.
- func (m *APIKeyMutation) ClearDeletedAt() {
- m.deleted_at = nil
- m.clearedFields[apikey.FieldDeletedAt] = struct{}{}
- }
- // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
- func (m *APIKeyMutation) DeletedAtCleared() bool {
- _, ok := m.clearedFields[apikey.FieldDeletedAt]
- return ok
- }
- // ResetDeletedAt resets all changes to the "deleted_at" field.
- func (m *APIKeyMutation) ResetDeletedAt() {
- m.deleted_at = nil
- delete(m.clearedFields, apikey.FieldDeletedAt)
- }
- // SetUserID sets the "user_id" field.
- func (m *APIKeyMutation) SetUserID(i int64) {
- m.user = &i
- }
- // UserID returns the value of the "user_id" field in the mutation.
- func (m *APIKeyMutation) UserID() (r int64, exists bool) {
- v := m.user
- if v == nil {
- return
- }
- return *v, true
- }
- // OldUserID returns the old "user_id" field's value of the APIKey entity.
- // If the APIKey object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *APIKeyMutation) OldUserID(ctx context.Context) (v int64, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldUserID is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldUserID requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldUserID: %w", err)
- }
- return oldValue.UserID, nil
- }
- // ResetUserID resets all changes to the "user_id" field.
- func (m *APIKeyMutation) ResetUserID() {
- m.user = nil
- }
- // SetKey sets the "key" field.
- func (m *APIKeyMutation) SetKey(s string) {
- m.key = &s
- }
- // Key returns the value of the "key" field in the mutation.
- func (m *APIKeyMutation) Key() (r string, exists bool) {
- v := m.key
- if v == nil {
- return
- }
- return *v, true
- }
- // OldKey returns the old "key" field's value of the APIKey entity.
- // If the APIKey object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *APIKeyMutation) OldKey(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldKey is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldKey requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldKey: %w", err)
- }
- return oldValue.Key, nil
- }
- // ClearKey clears the value of the "key" field.
- func (m *APIKeyMutation) ClearKey() {
- m.key = nil
- m.clearedFields[apikey.FieldKey] = struct{}{}
- }
- // KeyCleared returns if the "key" field was cleared in this mutation.
- func (m *APIKeyMutation) KeyCleared() bool {
- _, ok := m.clearedFields[apikey.FieldKey]
- return ok
- }
- // ResetKey resets all changes to the "key" field.
- func (m *APIKeyMutation) ResetKey() {
- m.key = nil
- delete(m.clearedFields, apikey.FieldKey)
- }
- // SetKeyHash sets the "key_hash" field.
- func (m *APIKeyMutation) SetKeyHash(s string) {
- m.key_hash = &s
- }
- // KeyHash returns the value of the "key_hash" field in the mutation.
- func (m *APIKeyMutation) KeyHash() (r string, exists bool) {
- v := m.key_hash
- if v == nil {
- return
- }
- return *v, true
- }
- // OldKeyHash returns the old "key_hash" field's value of the APIKey entity.
- // If the APIKey object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *APIKeyMutation) OldKeyHash(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldKeyHash is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldKeyHash requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldKeyHash: %w", err)
- }
- return oldValue.KeyHash, nil
- }
- // ClearKeyHash clears the value of the "key_hash" field.
- func (m *APIKeyMutation) ClearKeyHash() {
- m.key_hash = nil
- m.clearedFields[apikey.FieldKeyHash] = struct{}{}
- }
- // KeyHashCleared returns if the "key_hash" field was cleared in this mutation.
- func (m *APIKeyMutation) KeyHashCleared() bool {
- _, ok := m.clearedFields[apikey.FieldKeyHash]
- return ok
- }
- // ResetKeyHash resets all changes to the "key_hash" field.
- func (m *APIKeyMutation) ResetKeyHash() {
- m.key_hash = nil
- delete(m.clearedFields, apikey.FieldKeyHash)
- }
- // SetKeyPrefix sets the "key_prefix" field.
- func (m *APIKeyMutation) SetKeyPrefix(s string) {
- m.key_prefix = &s
- }
- // KeyPrefix returns the value of the "key_prefix" field in the mutation.
- func (m *APIKeyMutation) KeyPrefix() (r string, exists bool) {
- v := m.key_prefix
- if v == nil {
- return
- }
- return *v, true
- }
- // OldKeyPrefix returns the old "key_prefix" field's value of the APIKey entity.
- // If the APIKey object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *APIKeyMutation) OldKeyPrefix(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldKeyPrefix is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldKeyPrefix requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldKeyPrefix: %w", err)
- }
- return oldValue.KeyPrefix, nil
- }
- // ClearKeyPrefix clears the value of the "key_prefix" field.
- func (m *APIKeyMutation) ClearKeyPrefix() {
- m.key_prefix = nil
- m.clearedFields[apikey.FieldKeyPrefix] = struct{}{}
- }
- // KeyPrefixCleared returns if the "key_prefix" field was cleared in this mutation.
- func (m *APIKeyMutation) KeyPrefixCleared() bool {
- _, ok := m.clearedFields[apikey.FieldKeyPrefix]
- return ok
- }
- // ResetKeyPrefix resets all changes to the "key_prefix" field.
- func (m *APIKeyMutation) ResetKeyPrefix() {
- m.key_prefix = nil
- delete(m.clearedFields, apikey.FieldKeyPrefix)
- }
- // SetName sets the "name" field.
- func (m *APIKeyMutation) SetName(s string) {
- m.name = &s
- }
- // Name returns the value of the "name" field in the mutation.
- func (m *APIKeyMutation) Name() (r string, exists bool) {
- v := m.name
- if v == nil {
- return
- }
- return *v, true
- }
- // OldName returns the old "name" field's value of the APIKey entity.
- // If the APIKey object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *APIKeyMutation) OldName(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldName is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldName requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldName: %w", err)
- }
- return oldValue.Name, nil
- }
- // ResetName resets all changes to the "name" field.
- func (m *APIKeyMutation) ResetName() {
- m.name = nil
- }
- // SetGroupID sets the "group_id" field.
- func (m *APIKeyMutation) SetGroupID(i int64) {
- m.group = &i
- }
- // GroupID returns the value of the "group_id" field in the mutation.
- func (m *APIKeyMutation) GroupID() (r int64, exists bool) {
- v := m.group
- if v == nil {
- return
- }
- return *v, true
- }
- // OldGroupID returns the old "group_id" field's value of the APIKey entity.
- // If the APIKey object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *APIKeyMutation) OldGroupID(ctx context.Context) (v *int64, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldGroupID is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldGroupID requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldGroupID: %w", err)
- }
- return oldValue.GroupID, nil
- }
- // ClearGroupID clears the value of the "group_id" field.
- func (m *APIKeyMutation) ClearGroupID() {
- m.group = nil
- m.clearedFields[apikey.FieldGroupID] = struct{}{}
- }
- // GroupIDCleared returns if the "group_id" field was cleared in this mutation.
- func (m *APIKeyMutation) GroupIDCleared() bool {
- _, ok := m.clearedFields[apikey.FieldGroupID]
- return ok
- }
- // ResetGroupID resets all changes to the "group_id" field.
- func (m *APIKeyMutation) ResetGroupID() {
- m.group = nil
- delete(m.clearedFields, apikey.FieldGroupID)
- }
- // SetStatus sets the "status" field.
- func (m *APIKeyMutation) SetStatus(s string) {
- m.status = &s
- }
- // Status returns the value of the "status" field in the mutation.
- func (m *APIKeyMutation) Status() (r string, exists bool) {
- v := m.status
- if v == nil {
- return
- }
- return *v, true
- }
- // OldStatus returns the old "status" field's value of the APIKey entity.
- // If the APIKey object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *APIKeyMutation) OldStatus(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldStatus is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldStatus requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldStatus: %w", err)
- }
- return oldValue.Status, nil
- }
- // ResetStatus resets all changes to the "status" field.
- func (m *APIKeyMutation) ResetStatus() {
- m.status = nil
- }
- // SetLastUsedAt sets the "last_used_at" field.
- func (m *APIKeyMutation) SetLastUsedAt(t time.Time) {
- m.last_used_at = &t
- }
- // LastUsedAt returns the value of the "last_used_at" field in the mutation.
- func (m *APIKeyMutation) LastUsedAt() (r time.Time, exists bool) {
- v := m.last_used_at
- if v == nil {
- return
- }
- return *v, true
- }
- // OldLastUsedAt returns the old "last_used_at" field's value of the APIKey entity.
- // If the APIKey object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *APIKeyMutation) OldLastUsedAt(ctx context.Context) (v *time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldLastUsedAt is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldLastUsedAt requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldLastUsedAt: %w", err)
- }
- return oldValue.LastUsedAt, nil
- }
- // ClearLastUsedAt clears the value of the "last_used_at" field.
- func (m *APIKeyMutation) ClearLastUsedAt() {
- m.last_used_at = nil
- m.clearedFields[apikey.FieldLastUsedAt] = struct{}{}
- }
- // LastUsedAtCleared returns if the "last_used_at" field was cleared in this mutation.
- func (m *APIKeyMutation) LastUsedAtCleared() bool {
- _, ok := m.clearedFields[apikey.FieldLastUsedAt]
- return ok
- }
- // ResetLastUsedAt resets all changes to the "last_used_at" field.
- func (m *APIKeyMutation) ResetLastUsedAt() {
- m.last_used_at = nil
- delete(m.clearedFields, apikey.FieldLastUsedAt)
- }
- // SetIPWhitelist sets the "ip_whitelist" field.
- func (m *APIKeyMutation) SetIPWhitelist(s []string) {
- m.ip_whitelist = &s
- m.appendip_whitelist = nil
- }
- // IPWhitelist returns the value of the "ip_whitelist" field in the mutation.
- func (m *APIKeyMutation) IPWhitelist() (r []string, exists bool) {
- v := m.ip_whitelist
- if v == nil {
- return
- }
- return *v, true
- }
- // OldIPWhitelist returns the old "ip_whitelist" field's value of the APIKey entity.
- // If the APIKey object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *APIKeyMutation) OldIPWhitelist(ctx context.Context) (v []string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldIPWhitelist is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldIPWhitelist requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldIPWhitelist: %w", err)
- }
- return oldValue.IPWhitelist, nil
- }
- // AppendIPWhitelist adds s to the "ip_whitelist" field.
- func (m *APIKeyMutation) AppendIPWhitelist(s []string) {
- m.appendip_whitelist = append(m.appendip_whitelist, s...)
- }
- // AppendedIPWhitelist returns the list of values that were appended to the "ip_whitelist" field in this mutation.
- func (m *APIKeyMutation) AppendedIPWhitelist() ([]string, bool) {
- if len(m.appendip_whitelist) == 0 {
- return nil, false
- }
- return m.appendip_whitelist, true
- }
- // ClearIPWhitelist clears the value of the "ip_whitelist" field.
- func (m *APIKeyMutation) ClearIPWhitelist() {
- m.ip_whitelist = nil
- m.appendip_whitelist = nil
- m.clearedFields[apikey.FieldIPWhitelist] = struct{}{}
- }
- // IPWhitelistCleared returns if the "ip_whitelist" field was cleared in this mutation.
- func (m *APIKeyMutation) IPWhitelistCleared() bool {
- _, ok := m.clearedFields[apikey.FieldIPWhitelist]
- return ok
- }
- // ResetIPWhitelist resets all changes to the "ip_whitelist" field.
- func (m *APIKeyMutation) ResetIPWhitelist() {
- m.ip_whitelist = nil
- m.appendip_whitelist = nil
- delete(m.clearedFields, apikey.FieldIPWhitelist)
- }
- // SetIPBlacklist sets the "ip_blacklist" field.
- func (m *APIKeyMutation) SetIPBlacklist(s []string) {
- m.ip_blacklist = &s
- m.appendip_blacklist = nil
- }
- // IPBlacklist returns the value of the "ip_blacklist" field in the mutation.
- func (m *APIKeyMutation) IPBlacklist() (r []string, exists bool) {
- v := m.ip_blacklist
- if v == nil {
- return
- }
- return *v, true
- }
- // OldIPBlacklist returns the old "ip_blacklist" field's value of the APIKey entity.
- // If the APIKey object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *APIKeyMutation) OldIPBlacklist(ctx context.Context) (v []string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldIPBlacklist is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldIPBlacklist requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldIPBlacklist: %w", err)
- }
- return oldValue.IPBlacklist, nil
- }
- // AppendIPBlacklist adds s to the "ip_blacklist" field.
- func (m *APIKeyMutation) AppendIPBlacklist(s []string) {
- m.appendip_blacklist = append(m.appendip_blacklist, s...)
- }
- // AppendedIPBlacklist returns the list of values that were appended to the "ip_blacklist" field in this mutation.
- func (m *APIKeyMutation) AppendedIPBlacklist() ([]string, bool) {
- if len(m.appendip_blacklist) == 0 {
- return nil, false
- }
- return m.appendip_blacklist, true
- }
- // ClearIPBlacklist clears the value of the "ip_blacklist" field.
- func (m *APIKeyMutation) ClearIPBlacklist() {
- m.ip_blacklist = nil
- m.appendip_blacklist = nil
- m.clearedFields[apikey.FieldIPBlacklist] = struct{}{}
- }
- // IPBlacklistCleared returns if the "ip_blacklist" field was cleared in this mutation.
- func (m *APIKeyMutation) IPBlacklistCleared() bool {
- _, ok := m.clearedFields[apikey.FieldIPBlacklist]
- return ok
- }
- // ResetIPBlacklist resets all changes to the "ip_blacklist" field.
- func (m *APIKeyMutation) ResetIPBlacklist() {
- m.ip_blacklist = nil
- m.appendip_blacklist = nil
- delete(m.clearedFields, apikey.FieldIPBlacklist)
- }
- // SetQuota sets the "quota" field.
- func (m *APIKeyMutation) SetQuota(f float64) {
- m.quota = &f
- m.addquota = nil
- }
- // Quota returns the value of the "quota" field in the mutation.
- func (m *APIKeyMutation) Quota() (r float64, exists bool) {
- v := m.quota
- if v == nil {
- return
- }
- return *v, true
- }
- // OldQuota returns the old "quota" field's value of the APIKey entity.
- // If the APIKey object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *APIKeyMutation) OldQuota(ctx context.Context) (v float64, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldQuota is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldQuota requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldQuota: %w", err)
- }
- return oldValue.Quota, nil
- }
- // AddQuota adds f to the "quota" field.
- func (m *APIKeyMutation) AddQuota(f float64) {
- if m.addquota != nil {
- *m.addquota += f
- } else {
- m.addquota = &f
- }
- }
- // AddedQuota returns the value that was added to the "quota" field in this mutation.
- func (m *APIKeyMutation) AddedQuota() (r float64, exists bool) {
- v := m.addquota
- if v == nil {
- return
- }
- return *v, true
- }
- // ResetQuota resets all changes to the "quota" field.
- func (m *APIKeyMutation) ResetQuota() {
- m.quota = nil
- m.addquota = nil
- }
- // SetQuotaUsed sets the "quota_used" field.
- func (m *APIKeyMutation) SetQuotaUsed(f float64) {
- m.quota_used = &f
- m.addquota_used = nil
- }
- // QuotaUsed returns the value of the "quota_used" field in the mutation.
- func (m *APIKeyMutation) QuotaUsed() (r float64, exists bool) {
- v := m.quota_used
- if v == nil {
- return
- }
- return *v, true
- }
- // OldQuotaUsed returns the old "quota_used" field's value of the APIKey entity.
- // If the APIKey object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *APIKeyMutation) OldQuotaUsed(ctx context.Context) (v float64, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldQuotaUsed is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldQuotaUsed requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldQuotaUsed: %w", err)
- }
- return oldValue.QuotaUsed, nil
- }
- // AddQuotaUsed adds f to the "quota_used" field.
- func (m *APIKeyMutation) AddQuotaUsed(f float64) {
- if m.addquota_used != nil {
- *m.addquota_used += f
- } else {
- m.addquota_used = &f
- }
- }
- // AddedQuotaUsed returns the value that was added to the "quota_used" field in this mutation.
- func (m *APIKeyMutation) AddedQuotaUsed() (r float64, exists bool) {
- v := m.addquota_used
- if v == nil {
- return
- }
- return *v, true
- }
- // ResetQuotaUsed resets all changes to the "quota_used" field.
- func (m *APIKeyMutation) ResetQuotaUsed() {
- m.quota_used = nil
- m.addquota_used = nil
- }
- // SetExpiresAt sets the "expires_at" field.
- func (m *APIKeyMutation) SetExpiresAt(t time.Time) {
- m.expires_at = &t
- }
- // ExpiresAt returns the value of the "expires_at" field in the mutation.
- func (m *APIKeyMutation) ExpiresAt() (r time.Time, exists bool) {
- v := m.expires_at
- if v == nil {
- return
- }
- return *v, true
- }
- // OldExpiresAt returns the old "expires_at" field's value of the APIKey entity.
- // If the APIKey object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *APIKeyMutation) OldExpiresAt(ctx context.Context) (v *time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldExpiresAt is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldExpiresAt requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldExpiresAt: %w", err)
- }
- return oldValue.ExpiresAt, nil
- }
- // ClearExpiresAt clears the value of the "expires_at" field.
- func (m *APIKeyMutation) ClearExpiresAt() {
- m.expires_at = nil
- m.clearedFields[apikey.FieldExpiresAt] = struct{}{}
- }
- // ExpiresAtCleared returns if the "expires_at" field was cleared in this mutation.
- func (m *APIKeyMutation) ExpiresAtCleared() bool {
- _, ok := m.clearedFields[apikey.FieldExpiresAt]
- return ok
- }
- // ResetExpiresAt resets all changes to the "expires_at" field.
- func (m *APIKeyMutation) ResetExpiresAt() {
- m.expires_at = nil
- delete(m.clearedFields, apikey.FieldExpiresAt)
- }
- // SetRateLimit5h sets the "rate_limit_5h" field.
- func (m *APIKeyMutation) SetRateLimit5h(f float64) {
- m.rate_limit_5h = &f
- m.addrate_limit_5h = nil
- }
- // RateLimit5h returns the value of the "rate_limit_5h" field in the mutation.
- func (m *APIKeyMutation) RateLimit5h() (r float64, exists bool) {
- v := m.rate_limit_5h
- if v == nil {
- return
- }
- return *v, true
- }
- // OldRateLimit5h returns the old "rate_limit_5h" field's value of the APIKey entity.
- // If the APIKey object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *APIKeyMutation) OldRateLimit5h(ctx context.Context) (v float64, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldRateLimit5h is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldRateLimit5h requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldRateLimit5h: %w", err)
- }
- return oldValue.RateLimit5h, nil
- }
- // AddRateLimit5h adds f to the "rate_limit_5h" field.
- func (m *APIKeyMutation) AddRateLimit5h(f float64) {
- if m.addrate_limit_5h != nil {
- *m.addrate_limit_5h += f
- } else {
- m.addrate_limit_5h = &f
- }
- }
- // AddedRateLimit5h returns the value that was added to the "rate_limit_5h" field in this mutation.
- func (m *APIKeyMutation) AddedRateLimit5h() (r float64, exists bool) {
- v := m.addrate_limit_5h
- if v == nil {
- return
- }
- return *v, true
- }
- // ResetRateLimit5h resets all changes to the "rate_limit_5h" field.
- func (m *APIKeyMutation) ResetRateLimit5h() {
- m.rate_limit_5h = nil
- m.addrate_limit_5h = nil
- }
- // SetRateLimit1d sets the "rate_limit_1d" field.
- func (m *APIKeyMutation) SetRateLimit1d(f float64) {
- m.rate_limit_1d = &f
- m.addrate_limit_1d = nil
- }
- // RateLimit1d returns the value of the "rate_limit_1d" field in the mutation.
- func (m *APIKeyMutation) RateLimit1d() (r float64, exists bool) {
- v := m.rate_limit_1d
- if v == nil {
- return
- }
- return *v, true
- }
- // OldRateLimit1d returns the old "rate_limit_1d" field's value of the APIKey entity.
- // If the APIKey object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *APIKeyMutation) OldRateLimit1d(ctx context.Context) (v float64, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldRateLimit1d is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldRateLimit1d requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldRateLimit1d: %w", err)
- }
- return oldValue.RateLimit1d, nil
- }
- // AddRateLimit1d adds f to the "rate_limit_1d" field.
- func (m *APIKeyMutation) AddRateLimit1d(f float64) {
- if m.addrate_limit_1d != nil {
- *m.addrate_limit_1d += f
- } else {
- m.addrate_limit_1d = &f
- }
- }
- // AddedRateLimit1d returns the value that was added to the "rate_limit_1d" field in this mutation.
- func (m *APIKeyMutation) AddedRateLimit1d() (r float64, exists bool) {
- v := m.addrate_limit_1d
- if v == nil {
- return
- }
- return *v, true
- }
- // ResetRateLimit1d resets all changes to the "rate_limit_1d" field.
- func (m *APIKeyMutation) ResetRateLimit1d() {
- m.rate_limit_1d = nil
- m.addrate_limit_1d = nil
- }
- // SetRateLimit7d sets the "rate_limit_7d" field.
- func (m *APIKeyMutation) SetRateLimit7d(f float64) {
- m.rate_limit_7d = &f
- m.addrate_limit_7d = nil
- }
- // RateLimit7d returns the value of the "rate_limit_7d" field in the mutation.
- func (m *APIKeyMutation) RateLimit7d() (r float64, exists bool) {
- v := m.rate_limit_7d
- if v == nil {
- return
- }
- return *v, true
- }
- // OldRateLimit7d returns the old "rate_limit_7d" field's value of the APIKey entity.
- // If the APIKey object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *APIKeyMutation) OldRateLimit7d(ctx context.Context) (v float64, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldRateLimit7d is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldRateLimit7d requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldRateLimit7d: %w", err)
- }
- return oldValue.RateLimit7d, nil
- }
- // AddRateLimit7d adds f to the "rate_limit_7d" field.
- func (m *APIKeyMutation) AddRateLimit7d(f float64) {
- if m.addrate_limit_7d != nil {
- *m.addrate_limit_7d += f
- } else {
- m.addrate_limit_7d = &f
- }
- }
- // AddedRateLimit7d returns the value that was added to the "rate_limit_7d" field in this mutation.
- func (m *APIKeyMutation) AddedRateLimit7d() (r float64, exists bool) {
- v := m.addrate_limit_7d
- if v == nil {
- return
- }
- return *v, true
- }
- // ResetRateLimit7d resets all changes to the "rate_limit_7d" field.
- func (m *APIKeyMutation) ResetRateLimit7d() {
- m.rate_limit_7d = nil
- m.addrate_limit_7d = nil
- }
- // SetUsage5h sets the "usage_5h" field.
- func (m *APIKeyMutation) SetUsage5h(f float64) {
- m.usage_5h = &f
- m.addusage_5h = nil
- }
- // Usage5h returns the value of the "usage_5h" field in the mutation.
- func (m *APIKeyMutation) Usage5h() (r float64, exists bool) {
- v := m.usage_5h
- if v == nil {
- return
- }
- return *v, true
- }
- // OldUsage5h returns the old "usage_5h" field's value of the APIKey entity.
- // If the APIKey object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *APIKeyMutation) OldUsage5h(ctx context.Context) (v float64, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldUsage5h is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldUsage5h requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldUsage5h: %w", err)
- }
- return oldValue.Usage5h, nil
- }
- // AddUsage5h adds f to the "usage_5h" field.
- func (m *APIKeyMutation) AddUsage5h(f float64) {
- if m.addusage_5h != nil {
- *m.addusage_5h += f
- } else {
- m.addusage_5h = &f
- }
- }
- // AddedUsage5h returns the value that was added to the "usage_5h" field in this mutation.
- func (m *APIKeyMutation) AddedUsage5h() (r float64, exists bool) {
- v := m.addusage_5h
- if v == nil {
- return
- }
- return *v, true
- }
- // ResetUsage5h resets all changes to the "usage_5h" field.
- func (m *APIKeyMutation) ResetUsage5h() {
- m.usage_5h = nil
- m.addusage_5h = nil
- }
- // SetUsage1d sets the "usage_1d" field.
- func (m *APIKeyMutation) SetUsage1d(f float64) {
- m.usage_1d = &f
- m.addusage_1d = nil
- }
- // Usage1d returns the value of the "usage_1d" field in the mutation.
- func (m *APIKeyMutation) Usage1d() (r float64, exists bool) {
- v := m.usage_1d
- if v == nil {
- return
- }
- return *v, true
- }
- // OldUsage1d returns the old "usage_1d" field's value of the APIKey entity.
- // If the APIKey object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *APIKeyMutation) OldUsage1d(ctx context.Context) (v float64, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldUsage1d is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldUsage1d requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldUsage1d: %w", err)
- }
- return oldValue.Usage1d, nil
- }
- // AddUsage1d adds f to the "usage_1d" field.
- func (m *APIKeyMutation) AddUsage1d(f float64) {
- if m.addusage_1d != nil {
- *m.addusage_1d += f
- } else {
- m.addusage_1d = &f
- }
- }
- // AddedUsage1d returns the value that was added to the "usage_1d" field in this mutation.
- func (m *APIKeyMutation) AddedUsage1d() (r float64, exists bool) {
- v := m.addusage_1d
- if v == nil {
- return
- }
- return *v, true
- }
- // ResetUsage1d resets all changes to the "usage_1d" field.
- func (m *APIKeyMutation) ResetUsage1d() {
- m.usage_1d = nil
- m.addusage_1d = nil
- }
- // SetUsage7d sets the "usage_7d" field.
- func (m *APIKeyMutation) SetUsage7d(f float64) {
- m.usage_7d = &f
- m.addusage_7d = nil
- }
- // Usage7d returns the value of the "usage_7d" field in the mutation.
- func (m *APIKeyMutation) Usage7d() (r float64, exists bool) {
- v := m.usage_7d
- if v == nil {
- return
- }
- return *v, true
- }
- // OldUsage7d returns the old "usage_7d" field's value of the APIKey entity.
- // If the APIKey object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *APIKeyMutation) OldUsage7d(ctx context.Context) (v float64, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldUsage7d is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldUsage7d requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldUsage7d: %w", err)
- }
- return oldValue.Usage7d, nil
- }
- // AddUsage7d adds f to the "usage_7d" field.
- func (m *APIKeyMutation) AddUsage7d(f float64) {
- if m.addusage_7d != nil {
- *m.addusage_7d += f
- } else {
- m.addusage_7d = &f
- }
- }
- // AddedUsage7d returns the value that was added to the "usage_7d" field in this mutation.
- func (m *APIKeyMutation) AddedUsage7d() (r float64, exists bool) {
- v := m.addusage_7d
- if v == nil {
- return
- }
- return *v, true
- }
- // ResetUsage7d resets all changes to the "usage_7d" field.
- func (m *APIKeyMutation) ResetUsage7d() {
- m.usage_7d = nil
- m.addusage_7d = nil
- }
- // SetWindow5hStart sets the "window_5h_start" field.
- func (m *APIKeyMutation) SetWindow5hStart(t time.Time) {
- m.window_5h_start = &t
- }
- // Window5hStart returns the value of the "window_5h_start" field in the mutation.
- func (m *APIKeyMutation) Window5hStart() (r time.Time, exists bool) {
- v := m.window_5h_start
- if v == nil {
- return
- }
- return *v, true
- }
- // OldWindow5hStart returns the old "window_5h_start" field's value of the APIKey entity.
- // If the APIKey object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *APIKeyMutation) OldWindow5hStart(ctx context.Context) (v *time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldWindow5hStart is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldWindow5hStart requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldWindow5hStart: %w", err)
- }
- return oldValue.Window5hStart, nil
- }
- // ClearWindow5hStart clears the value of the "window_5h_start" field.
- func (m *APIKeyMutation) ClearWindow5hStart() {
- m.window_5h_start = nil
- m.clearedFields[apikey.FieldWindow5hStart] = struct{}{}
- }
- // Window5hStartCleared returns if the "window_5h_start" field was cleared in this mutation.
- func (m *APIKeyMutation) Window5hStartCleared() bool {
- _, ok := m.clearedFields[apikey.FieldWindow5hStart]
- return ok
- }
- // ResetWindow5hStart resets all changes to the "window_5h_start" field.
- func (m *APIKeyMutation) ResetWindow5hStart() {
- m.window_5h_start = nil
- delete(m.clearedFields, apikey.FieldWindow5hStart)
- }
- // SetWindow1dStart sets the "window_1d_start" field.
- func (m *APIKeyMutation) SetWindow1dStart(t time.Time) {
- m.window_1d_start = &t
- }
- // Window1dStart returns the value of the "window_1d_start" field in the mutation.
- func (m *APIKeyMutation) Window1dStart() (r time.Time, exists bool) {
- v := m.window_1d_start
- if v == nil {
- return
- }
- return *v, true
- }
- // OldWindow1dStart returns the old "window_1d_start" field's value of the APIKey entity.
- // If the APIKey object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *APIKeyMutation) OldWindow1dStart(ctx context.Context) (v *time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldWindow1dStart is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldWindow1dStart requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldWindow1dStart: %w", err)
- }
- return oldValue.Window1dStart, nil
- }
- // ClearWindow1dStart clears the value of the "window_1d_start" field.
- func (m *APIKeyMutation) ClearWindow1dStart() {
- m.window_1d_start = nil
- m.clearedFields[apikey.FieldWindow1dStart] = struct{}{}
- }
- // Window1dStartCleared returns if the "window_1d_start" field was cleared in this mutation.
- func (m *APIKeyMutation) Window1dStartCleared() bool {
- _, ok := m.clearedFields[apikey.FieldWindow1dStart]
- return ok
- }
- // ResetWindow1dStart resets all changes to the "window_1d_start" field.
- func (m *APIKeyMutation) ResetWindow1dStart() {
- m.window_1d_start = nil
- delete(m.clearedFields, apikey.FieldWindow1dStart)
- }
- // SetWindow7dStart sets the "window_7d_start" field.
- func (m *APIKeyMutation) SetWindow7dStart(t time.Time) {
- m.window_7d_start = &t
- }
- // Window7dStart returns the value of the "window_7d_start" field in the mutation.
- func (m *APIKeyMutation) Window7dStart() (r time.Time, exists bool) {
- v := m.window_7d_start
- if v == nil {
- return
- }
- return *v, true
- }
- // OldWindow7dStart returns the old "window_7d_start" field's value of the APIKey entity.
- // If the APIKey object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *APIKeyMutation) OldWindow7dStart(ctx context.Context) (v *time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldWindow7dStart is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldWindow7dStart requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldWindow7dStart: %w", err)
- }
- return oldValue.Window7dStart, nil
- }
- // ClearWindow7dStart clears the value of the "window_7d_start" field.
- func (m *APIKeyMutation) ClearWindow7dStart() {
- m.window_7d_start = nil
- m.clearedFields[apikey.FieldWindow7dStart] = struct{}{}
- }
- // Window7dStartCleared returns if the "window_7d_start" field was cleared in this mutation.
- func (m *APIKeyMutation) Window7dStartCleared() bool {
- _, ok := m.clearedFields[apikey.FieldWindow7dStart]
- return ok
- }
- // ResetWindow7dStart resets all changes to the "window_7d_start" field.
- func (m *APIKeyMutation) ResetWindow7dStart() {
- m.window_7d_start = nil
- delete(m.clearedFields, apikey.FieldWindow7dStart)
- }
- // ClearUser clears the "user" edge to the User entity.
- func (m *APIKeyMutation) ClearUser() {
- m.cleareduser = true
- m.clearedFields[apikey.FieldUserID] = struct{}{}
- }
- // UserCleared reports if the "user" edge to the User entity was cleared.
- func (m *APIKeyMutation) UserCleared() bool {
- return m.cleareduser
- }
- // UserIDs returns the "user" edge IDs in the mutation.
- // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
- // UserID instead. It exists only for internal usage by the builders.
- func (m *APIKeyMutation) UserIDs() (ids []int64) {
- if id := m.user; id != nil {
- ids = append(ids, *id)
- }
- return
- }
- // ResetUser resets all changes to the "user" edge.
- func (m *APIKeyMutation) ResetUser() {
- m.user = nil
- m.cleareduser = false
- }
- // ClearGroup clears the "group" edge to the Group entity.
- func (m *APIKeyMutation) ClearGroup() {
- m.clearedgroup = true
- m.clearedFields[apikey.FieldGroupID] = struct{}{}
- }
- // GroupCleared reports if the "group" edge to the Group entity was cleared.
- func (m *APIKeyMutation) GroupCleared() bool {
- return m.GroupIDCleared() || m.clearedgroup
- }
- // GroupIDs returns the "group" edge IDs in the mutation.
- // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
- // GroupID instead. It exists only for internal usage by the builders.
- func (m *APIKeyMutation) GroupIDs() (ids []int64) {
- if id := m.group; id != nil {
- ids = append(ids, *id)
- }
- return
- }
- // ResetGroup resets all changes to the "group" edge.
- func (m *APIKeyMutation) ResetGroup() {
- m.group = nil
- m.clearedgroup = false
- }
- // AddUsageLogIDs adds the "usage_logs" edge to the UsageLog entity by ids.
- func (m *APIKeyMutation) AddUsageLogIDs(ids ...int64) {
- if m.usage_logs == nil {
- m.usage_logs = make(map[int64]struct{})
- }
- for i := range ids {
- m.usage_logs[ids[i]] = struct{}{}
- }
- }
- // ClearUsageLogs clears the "usage_logs" edge to the UsageLog entity.
- func (m *APIKeyMutation) ClearUsageLogs() {
- m.clearedusage_logs = true
- }
- // UsageLogsCleared reports if the "usage_logs" edge to the UsageLog entity was cleared.
- func (m *APIKeyMutation) UsageLogsCleared() bool {
- return m.clearedusage_logs
- }
- // RemoveUsageLogIDs removes the "usage_logs" edge to the UsageLog entity by IDs.
- func (m *APIKeyMutation) RemoveUsageLogIDs(ids ...int64) {
- if m.removedusage_logs == nil {
- m.removedusage_logs = make(map[int64]struct{})
- }
- for i := range ids {
- delete(m.usage_logs, ids[i])
- m.removedusage_logs[ids[i]] = struct{}{}
- }
- }
- // RemovedUsageLogs returns the removed IDs of the "usage_logs" edge to the UsageLog entity.
- func (m *APIKeyMutation) RemovedUsageLogsIDs() (ids []int64) {
- for id := range m.removedusage_logs {
- ids = append(ids, id)
- }
- return
- }
- // UsageLogsIDs returns the "usage_logs" edge IDs in the mutation.
- func (m *APIKeyMutation) UsageLogsIDs() (ids []int64) {
- for id := range m.usage_logs {
- ids = append(ids, id)
- }
- return
- }
- // ResetUsageLogs resets all changes to the "usage_logs" edge.
- func (m *APIKeyMutation) ResetUsageLogs() {
- m.usage_logs = nil
- m.clearedusage_logs = false
- m.removedusage_logs = nil
- }
- // Where appends a list predicates to the APIKeyMutation builder.
- func (m *APIKeyMutation) Where(ps ...predicate.APIKey) {
- m.predicates = append(m.predicates, ps...)
- }
- // WhereP appends storage-level predicates to the APIKeyMutation builder. Using this method,
- // users can use type-assertion to append predicates that do not depend on any generated package.
- func (m *APIKeyMutation) WhereP(ps ...func(*sql.Selector)) {
- p := make([]predicate.APIKey, len(ps))
- for i := range ps {
- p[i] = ps[i]
- }
- m.Where(p...)
- }
- // Op returns the operation name.
- func (m *APIKeyMutation) Op() Op {
- return m.op
- }
- // SetOp allows setting the mutation operation.
- func (m *APIKeyMutation) SetOp(op Op) {
- m.op = op
- }
- // Type returns the node type of this mutation (APIKey).
- func (m *APIKeyMutation) Type() string {
- return m.typ
- }
- // Fields returns all fields that were changed during this mutation. Note that in
- // order to get all numeric fields that were incremented/decremented, call
- // AddedFields().
- func (m *APIKeyMutation) Fields() []string {
- fields := make([]string, 0, 25)
- if m.created_at != nil {
- fields = append(fields, apikey.FieldCreatedAt)
- }
- if m.updated_at != nil {
- fields = append(fields, apikey.FieldUpdatedAt)
- }
- if m.deleted_at != nil {
- fields = append(fields, apikey.FieldDeletedAt)
- }
- if m.user != nil {
- fields = append(fields, apikey.FieldUserID)
- }
- if m.key != nil {
- fields = append(fields, apikey.FieldKey)
- }
- if m.key_hash != nil {
- fields = append(fields, apikey.FieldKeyHash)
- }
- if m.key_prefix != nil {
- fields = append(fields, apikey.FieldKeyPrefix)
- }
- if m.name != nil {
- fields = append(fields, apikey.FieldName)
- }
- if m.group != nil {
- fields = append(fields, apikey.FieldGroupID)
- }
- if m.status != nil {
- fields = append(fields, apikey.FieldStatus)
- }
- if m.last_used_at != nil {
- fields = append(fields, apikey.FieldLastUsedAt)
- }
- if m.ip_whitelist != nil {
- fields = append(fields, apikey.FieldIPWhitelist)
- }
- if m.ip_blacklist != nil {
- fields = append(fields, apikey.FieldIPBlacklist)
- }
- if m.quota != nil {
- fields = append(fields, apikey.FieldQuota)
- }
- if m.quota_used != nil {
- fields = append(fields, apikey.FieldQuotaUsed)
- }
- if m.expires_at != nil {
- fields = append(fields, apikey.FieldExpiresAt)
- }
- if m.rate_limit_5h != nil {
- fields = append(fields, apikey.FieldRateLimit5h)
- }
- if m.rate_limit_1d != nil {
- fields = append(fields, apikey.FieldRateLimit1d)
- }
- if m.rate_limit_7d != nil {
- fields = append(fields, apikey.FieldRateLimit7d)
- }
- if m.usage_5h != nil {
- fields = append(fields, apikey.FieldUsage5h)
- }
- if m.usage_1d != nil {
- fields = append(fields, apikey.FieldUsage1d)
- }
- if m.usage_7d != nil {
- fields = append(fields, apikey.FieldUsage7d)
- }
- if m.window_5h_start != nil {
- fields = append(fields, apikey.FieldWindow5hStart)
- }
- if m.window_1d_start != nil {
- fields = append(fields, apikey.FieldWindow1dStart)
- }
- if m.window_7d_start != nil {
- fields = append(fields, apikey.FieldWindow7dStart)
- }
- return fields
- }
- // Field returns the value of a field with the given name. The second boolean
- // return value indicates that this field was not set, or was not defined in the
- // schema.
- func (m *APIKeyMutation) Field(name string) (ent.Value, bool) {
- switch name {
- case apikey.FieldCreatedAt:
- return m.CreatedAt()
- case apikey.FieldUpdatedAt:
- return m.UpdatedAt()
- case apikey.FieldDeletedAt:
- return m.DeletedAt()
- case apikey.FieldUserID:
- return m.UserID()
- case apikey.FieldKey:
- return m.Key()
- case apikey.FieldKeyHash:
- return m.KeyHash()
- case apikey.FieldKeyPrefix:
- return m.KeyPrefix()
- case apikey.FieldName:
- return m.Name()
- case apikey.FieldGroupID:
- return m.GroupID()
- case apikey.FieldStatus:
- return m.Status()
- case apikey.FieldLastUsedAt:
- return m.LastUsedAt()
- case apikey.FieldIPWhitelist:
- return m.IPWhitelist()
- case apikey.FieldIPBlacklist:
- return m.IPBlacklist()
- case apikey.FieldQuota:
- return m.Quota()
- case apikey.FieldQuotaUsed:
- return m.QuotaUsed()
- case apikey.FieldExpiresAt:
- return m.ExpiresAt()
- case apikey.FieldRateLimit5h:
- return m.RateLimit5h()
- case apikey.FieldRateLimit1d:
- return m.RateLimit1d()
- case apikey.FieldRateLimit7d:
- return m.RateLimit7d()
- case apikey.FieldUsage5h:
- return m.Usage5h()
- case apikey.FieldUsage1d:
- return m.Usage1d()
- case apikey.FieldUsage7d:
- return m.Usage7d()
- case apikey.FieldWindow5hStart:
- return m.Window5hStart()
- case apikey.FieldWindow1dStart:
- return m.Window1dStart()
- case apikey.FieldWindow7dStart:
- return m.Window7dStart()
- }
- return nil, false
- }
- // OldField returns the old value of the field from the database. An error is
- // returned if the mutation operation is not UpdateOne, or the query to the
- // database failed.
- func (m *APIKeyMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
- switch name {
- case apikey.FieldCreatedAt:
- return m.OldCreatedAt(ctx)
- case apikey.FieldUpdatedAt:
- return m.OldUpdatedAt(ctx)
- case apikey.FieldDeletedAt:
- return m.OldDeletedAt(ctx)
- case apikey.FieldUserID:
- return m.OldUserID(ctx)
- case apikey.FieldKey:
- return m.OldKey(ctx)
- case apikey.FieldKeyHash:
- return m.OldKeyHash(ctx)
- case apikey.FieldKeyPrefix:
- return m.OldKeyPrefix(ctx)
- case apikey.FieldName:
- return m.OldName(ctx)
- case apikey.FieldGroupID:
- return m.OldGroupID(ctx)
- case apikey.FieldStatus:
- return m.OldStatus(ctx)
- case apikey.FieldLastUsedAt:
- return m.OldLastUsedAt(ctx)
- case apikey.FieldIPWhitelist:
- return m.OldIPWhitelist(ctx)
- case apikey.FieldIPBlacklist:
- return m.OldIPBlacklist(ctx)
- case apikey.FieldQuota:
- return m.OldQuota(ctx)
- case apikey.FieldQuotaUsed:
- return m.OldQuotaUsed(ctx)
- case apikey.FieldExpiresAt:
- return m.OldExpiresAt(ctx)
- case apikey.FieldRateLimit5h:
- return m.OldRateLimit5h(ctx)
- case apikey.FieldRateLimit1d:
- return m.OldRateLimit1d(ctx)
- case apikey.FieldRateLimit7d:
- return m.OldRateLimit7d(ctx)
- case apikey.FieldUsage5h:
- return m.OldUsage5h(ctx)
- case apikey.FieldUsage1d:
- return m.OldUsage1d(ctx)
- case apikey.FieldUsage7d:
- return m.OldUsage7d(ctx)
- case apikey.FieldWindow5hStart:
- return m.OldWindow5hStart(ctx)
- case apikey.FieldWindow1dStart:
- return m.OldWindow1dStart(ctx)
- case apikey.FieldWindow7dStart:
- return m.OldWindow7dStart(ctx)
- }
- return nil, fmt.Errorf("unknown APIKey field %s", name)
- }
- // SetField sets the value of a field with the given name. It returns an error if
- // the field is not defined in the schema, or if the type mismatched the field
- // type.
- func (m *APIKeyMutation) SetField(name string, value ent.Value) error {
- switch name {
- case apikey.FieldCreatedAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetCreatedAt(v)
- return nil
- case apikey.FieldUpdatedAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetUpdatedAt(v)
- return nil
- case apikey.FieldDeletedAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetDeletedAt(v)
- return nil
- case apikey.FieldUserID:
- v, ok := value.(int64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetUserID(v)
- return nil
- case apikey.FieldKey:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetKey(v)
- return nil
- case apikey.FieldKeyHash:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetKeyHash(v)
- return nil
- case apikey.FieldKeyPrefix:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetKeyPrefix(v)
- return nil
- case apikey.FieldName:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetName(v)
- return nil
- case apikey.FieldGroupID:
- v, ok := value.(int64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetGroupID(v)
- return nil
- case apikey.FieldStatus:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetStatus(v)
- return nil
- case apikey.FieldLastUsedAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetLastUsedAt(v)
- return nil
- case apikey.FieldIPWhitelist:
- v, ok := value.([]string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetIPWhitelist(v)
- return nil
- case apikey.FieldIPBlacklist:
- v, ok := value.([]string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetIPBlacklist(v)
- return nil
- case apikey.FieldQuota:
- v, ok := value.(float64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetQuota(v)
- return nil
- case apikey.FieldQuotaUsed:
- v, ok := value.(float64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetQuotaUsed(v)
- return nil
- case apikey.FieldExpiresAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetExpiresAt(v)
- return nil
- case apikey.FieldRateLimit5h:
- v, ok := value.(float64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetRateLimit5h(v)
- return nil
- case apikey.FieldRateLimit1d:
- v, ok := value.(float64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetRateLimit1d(v)
- return nil
- case apikey.FieldRateLimit7d:
- v, ok := value.(float64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetRateLimit7d(v)
- return nil
- case apikey.FieldUsage5h:
- v, ok := value.(float64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetUsage5h(v)
- return nil
- case apikey.FieldUsage1d:
- v, ok := value.(float64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetUsage1d(v)
- return nil
- case apikey.FieldUsage7d:
- v, ok := value.(float64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetUsage7d(v)
- return nil
- case apikey.FieldWindow5hStart:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetWindow5hStart(v)
- return nil
- case apikey.FieldWindow1dStart:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetWindow1dStart(v)
- return nil
- case apikey.FieldWindow7dStart:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetWindow7dStart(v)
- return nil
- }
- return fmt.Errorf("unknown APIKey field %s", name)
- }
- // AddedFields returns all numeric fields that were incremented/decremented during
- // this mutation.
- func (m *APIKeyMutation) AddedFields() []string {
- var fields []string
- if m.addquota != nil {
- fields = append(fields, apikey.FieldQuota)
- }
- if m.addquota_used != nil {
- fields = append(fields, apikey.FieldQuotaUsed)
- }
- if m.addrate_limit_5h != nil {
- fields = append(fields, apikey.FieldRateLimit5h)
- }
- if m.addrate_limit_1d != nil {
- fields = append(fields, apikey.FieldRateLimit1d)
- }
- if m.addrate_limit_7d != nil {
- fields = append(fields, apikey.FieldRateLimit7d)
- }
- if m.addusage_5h != nil {
- fields = append(fields, apikey.FieldUsage5h)
- }
- if m.addusage_1d != nil {
- fields = append(fields, apikey.FieldUsage1d)
- }
- if m.addusage_7d != nil {
- fields = append(fields, apikey.FieldUsage7d)
- }
- return fields
- }
- // AddedField returns the numeric value that was incremented/decremented on a field
- // with the given name. The second boolean return value indicates that this field
- // was not set, or was not defined in the schema.
- func (m *APIKeyMutation) AddedField(name string) (ent.Value, bool) {
- switch name {
- case apikey.FieldQuota:
- return m.AddedQuota()
- case apikey.FieldQuotaUsed:
- return m.AddedQuotaUsed()
- case apikey.FieldRateLimit5h:
- return m.AddedRateLimit5h()
- case apikey.FieldRateLimit1d:
- return m.AddedRateLimit1d()
- case apikey.FieldRateLimit7d:
- return m.AddedRateLimit7d()
- case apikey.FieldUsage5h:
- return m.AddedUsage5h()
- case apikey.FieldUsage1d:
- return m.AddedUsage1d()
- case apikey.FieldUsage7d:
- return m.AddedUsage7d()
- }
- return nil, false
- }
- // AddField adds the value to the field with the given name. It returns an error if
- // the field is not defined in the schema, or if the type mismatched the field
- // type.
- func (m *APIKeyMutation) AddField(name string, value ent.Value) error {
- switch name {
- case apikey.FieldQuota:
- v, ok := value.(float64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.AddQuota(v)
- return nil
- case apikey.FieldQuotaUsed:
- v, ok := value.(float64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.AddQuotaUsed(v)
- return nil
- case apikey.FieldRateLimit5h:
- v, ok := value.(float64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.AddRateLimit5h(v)
- return nil
- case apikey.FieldRateLimit1d:
- v, ok := value.(float64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.AddRateLimit1d(v)
- return nil
- case apikey.FieldRateLimit7d:
- v, ok := value.(float64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.AddRateLimit7d(v)
- return nil
- case apikey.FieldUsage5h:
- v, ok := value.(float64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.AddUsage5h(v)
- return nil
- case apikey.FieldUsage1d:
- v, ok := value.(float64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.AddUsage1d(v)
- return nil
- case apikey.FieldUsage7d:
- v, ok := value.(float64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.AddUsage7d(v)
- return nil
- }
- return fmt.Errorf("unknown APIKey numeric field %s", name)
- }
- // ClearedFields returns all nullable fields that were cleared during this
- // mutation.
- func (m *APIKeyMutation) ClearedFields() []string {
- var fields []string
- if m.FieldCleared(apikey.FieldDeletedAt) {
- fields = append(fields, apikey.FieldDeletedAt)
- }
- if m.FieldCleared(apikey.FieldKey) {
- fields = append(fields, apikey.FieldKey)
- }
- if m.FieldCleared(apikey.FieldKeyHash) {
- fields = append(fields, apikey.FieldKeyHash)
- }
- if m.FieldCleared(apikey.FieldKeyPrefix) {
- fields = append(fields, apikey.FieldKeyPrefix)
- }
- if m.FieldCleared(apikey.FieldGroupID) {
- fields = append(fields, apikey.FieldGroupID)
- }
- if m.FieldCleared(apikey.FieldLastUsedAt) {
- fields = append(fields, apikey.FieldLastUsedAt)
- }
- if m.FieldCleared(apikey.FieldIPWhitelist) {
- fields = append(fields, apikey.FieldIPWhitelist)
- }
- if m.FieldCleared(apikey.FieldIPBlacklist) {
- fields = append(fields, apikey.FieldIPBlacklist)
- }
- if m.FieldCleared(apikey.FieldExpiresAt) {
- fields = append(fields, apikey.FieldExpiresAt)
- }
- if m.FieldCleared(apikey.FieldWindow5hStart) {
- fields = append(fields, apikey.FieldWindow5hStart)
- }
- if m.FieldCleared(apikey.FieldWindow1dStart) {
- fields = append(fields, apikey.FieldWindow1dStart)
- }
- if m.FieldCleared(apikey.FieldWindow7dStart) {
- fields = append(fields, apikey.FieldWindow7dStart)
- }
- return fields
- }
- // FieldCleared returns a boolean indicating if a field with the given name was
- // cleared in this mutation.
- func (m *APIKeyMutation) FieldCleared(name string) bool {
- _, ok := m.clearedFields[name]
- return ok
- }
- // ClearField clears the value of the field with the given name. It returns an
- // error if the field is not defined in the schema.
- func (m *APIKeyMutation) ClearField(name string) error {
- switch name {
- case apikey.FieldDeletedAt:
- m.ClearDeletedAt()
- return nil
- case apikey.FieldKey:
- m.ClearKey()
- return nil
- case apikey.FieldKeyHash:
- m.ClearKeyHash()
- return nil
- case apikey.FieldKeyPrefix:
- m.ClearKeyPrefix()
- return nil
- case apikey.FieldGroupID:
- m.ClearGroupID()
- return nil
- case apikey.FieldLastUsedAt:
- m.ClearLastUsedAt()
- return nil
- case apikey.FieldIPWhitelist:
- m.ClearIPWhitelist()
- return nil
- case apikey.FieldIPBlacklist:
- m.ClearIPBlacklist()
- return nil
- case apikey.FieldExpiresAt:
- m.ClearExpiresAt()
- return nil
- case apikey.FieldWindow5hStart:
- m.ClearWindow5hStart()
- return nil
- case apikey.FieldWindow1dStart:
- m.ClearWindow1dStart()
- return nil
- case apikey.FieldWindow7dStart:
- m.ClearWindow7dStart()
- return nil
- }
- return fmt.Errorf("unknown APIKey nullable field %s", name)
- }
- // ResetField resets all changes in the mutation for the field with the given name.
- // It returns an error if the field is not defined in the schema.
- func (m *APIKeyMutation) ResetField(name string) error {
- switch name {
- case apikey.FieldCreatedAt:
- m.ResetCreatedAt()
- return nil
- case apikey.FieldUpdatedAt:
- m.ResetUpdatedAt()
- return nil
- case apikey.FieldDeletedAt:
- m.ResetDeletedAt()
- return nil
- case apikey.FieldUserID:
- m.ResetUserID()
- return nil
- case apikey.FieldKey:
- m.ResetKey()
- return nil
- case apikey.FieldKeyHash:
- m.ResetKeyHash()
- return nil
- case apikey.FieldKeyPrefix:
- m.ResetKeyPrefix()
- return nil
- case apikey.FieldName:
- m.ResetName()
- return nil
- case apikey.FieldGroupID:
- m.ResetGroupID()
- return nil
- case apikey.FieldStatus:
- m.ResetStatus()
- return nil
- case apikey.FieldLastUsedAt:
- m.ResetLastUsedAt()
- return nil
- case apikey.FieldIPWhitelist:
- m.ResetIPWhitelist()
- return nil
- case apikey.FieldIPBlacklist:
- m.ResetIPBlacklist()
- return nil
- case apikey.FieldQuota:
- m.ResetQuota()
- return nil
- case apikey.FieldQuotaUsed:
- m.ResetQuotaUsed()
- return nil
- case apikey.FieldExpiresAt:
- m.ResetExpiresAt()
- return nil
- case apikey.FieldRateLimit5h:
- m.ResetRateLimit5h()
- return nil
- case apikey.FieldRateLimit1d:
- m.ResetRateLimit1d()
- return nil
- case apikey.FieldRateLimit7d:
- m.ResetRateLimit7d()
- return nil
- case apikey.FieldUsage5h:
- m.ResetUsage5h()
- return nil
- case apikey.FieldUsage1d:
- m.ResetUsage1d()
- return nil
- case apikey.FieldUsage7d:
- m.ResetUsage7d()
- return nil
- case apikey.FieldWindow5hStart:
- m.ResetWindow5hStart()
- return nil
- case apikey.FieldWindow1dStart:
- m.ResetWindow1dStart()
- return nil
- case apikey.FieldWindow7dStart:
- m.ResetWindow7dStart()
- return nil
- }
- return fmt.Errorf("unknown APIKey field %s", name)
- }
- // AddedEdges returns all edge names that were set/added in this mutation.
- func (m *APIKeyMutation) AddedEdges() []string {
- edges := make([]string, 0, 3)
- if m.user != nil {
- edges = append(edges, apikey.EdgeUser)
- }
- if m.group != nil {
- edges = append(edges, apikey.EdgeGroup)
- }
- if m.usage_logs != nil {
- edges = append(edges, apikey.EdgeUsageLogs)
- }
- return edges
- }
- // AddedIDs returns all IDs (to other nodes) that were added for the given edge
- // name in this mutation.
- func (m *APIKeyMutation) AddedIDs(name string) []ent.Value {
- switch name {
- case apikey.EdgeUser:
- if id := m.user; id != nil {
- return []ent.Value{*id}
- }
- case apikey.EdgeGroup:
- if id := m.group; id != nil {
- return []ent.Value{*id}
- }
- case apikey.EdgeUsageLogs:
- ids := make([]ent.Value, 0, len(m.usage_logs))
- for id := range m.usage_logs {
- ids = append(ids, id)
- }
- return ids
- }
- return nil
- }
- // RemovedEdges returns all edge names that were removed in this mutation.
- func (m *APIKeyMutation) RemovedEdges() []string {
- edges := make([]string, 0, 3)
- if m.removedusage_logs != nil {
- edges = append(edges, apikey.EdgeUsageLogs)
- }
- return edges
- }
- // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
- // the given name in this mutation.
- func (m *APIKeyMutation) RemovedIDs(name string) []ent.Value {
- switch name {
- case apikey.EdgeUsageLogs:
- ids := make([]ent.Value, 0, len(m.removedusage_logs))
- for id := range m.removedusage_logs {
- ids = append(ids, id)
- }
- return ids
- }
- return nil
- }
- // ClearedEdges returns all edge names that were cleared in this mutation.
- func (m *APIKeyMutation) ClearedEdges() []string {
- edges := make([]string, 0, 3)
- if m.cleareduser {
- edges = append(edges, apikey.EdgeUser)
- }
- if m.clearedgroup {
- edges = append(edges, apikey.EdgeGroup)
- }
- if m.clearedusage_logs {
- edges = append(edges, apikey.EdgeUsageLogs)
- }
- return edges
- }
- // EdgeCleared returns a boolean which indicates if the edge with the given name
- // was cleared in this mutation.
- func (m *APIKeyMutation) EdgeCleared(name string) bool {
- switch name {
- case apikey.EdgeUser:
- return m.cleareduser
- case apikey.EdgeGroup:
- return m.clearedgroup
- case apikey.EdgeUsageLogs:
- return m.clearedusage_logs
- }
- return false
- }
- // ClearEdge clears the value of the edge with the given name. It returns an error
- // if that edge is not defined in the schema.
- func (m *APIKeyMutation) ClearEdge(name string) error {
- switch name {
- case apikey.EdgeUser:
- m.ClearUser()
- return nil
- case apikey.EdgeGroup:
- m.ClearGroup()
- return nil
- }
- return fmt.Errorf("unknown APIKey unique edge %s", name)
- }
- // ResetEdge resets all changes to the edge with the given name in this mutation.
- // It returns an error if the edge is not defined in the schema.
- func (m *APIKeyMutation) ResetEdge(name string) error {
- switch name {
- case apikey.EdgeUser:
- m.ResetUser()
- return nil
- case apikey.EdgeGroup:
- m.ResetGroup()
- return nil
- case apikey.EdgeUsageLogs:
- m.ResetUsageLogs()
- return nil
- }
- return fmt.Errorf("unknown APIKey edge %s", name)
- }
- // AccountMutation represents an operation that mutates the Account nodes in the graph.
- type AccountMutation struct {
- config
- op Op
- typ string
- id *int64
- created_at *time.Time
- updated_at *time.Time
- deleted_at *time.Time
- name *string
- notes *string
- platform *string
- _type *string
- credentials *map[string]interface{}
- extra *map[string]interface{}
- proxy_fallback_origin_id *int64
- addproxy_fallback_origin_id *int64
- concurrency *int
- addconcurrency *int
- load_factor *int
- addload_factor *int
- priority *int
- addpriority *int
- rate_multiplier *float64
- addrate_multiplier *float64
- status *string
- error_message *string
- last_used_at *time.Time
- expires_at *time.Time
- auto_pause_on_expired *bool
- schedulable *bool
- rate_limited_at *time.Time
- rate_limit_reset_at *time.Time
- overload_until *time.Time
- temp_unschedulable_until *time.Time
- temp_unschedulable_reason *string
- session_window_start *time.Time
- session_window_end *time.Time
- session_window_status *string
- quota_dimension *account.QuotaDimension
- clearedFields map[string]struct{}
- groups map[int64]struct{}
- removedgroups map[int64]struct{}
- clearedgroups bool
- proxy *int64
- clearedproxy bool
- parent *int64
- clearedparent bool
- children map[int64]struct{}
- removedchildren map[int64]struct{}
- clearedchildren bool
- usage_logs map[int64]struct{}
- removedusage_logs map[int64]struct{}
- clearedusage_logs bool
- done bool
- oldValue func(context.Context) (*Account, error)
- predicates []predicate.Account
- }
- var _ ent.Mutation = (*AccountMutation)(nil)
- // accountOption allows management of the mutation configuration using functional options.
- type accountOption func(*AccountMutation)
- // newAccountMutation creates new mutation for the Account entity.
- func newAccountMutation(c config, op Op, opts ...accountOption) *AccountMutation {
- m := &AccountMutation{
- config: c,
- op: op,
- typ: TypeAccount,
- clearedFields: make(map[string]struct{}),
- }
- for _, opt := range opts {
- opt(m)
- }
- return m
- }
- // withAccountID sets the ID field of the mutation.
- func withAccountID(id int64) accountOption {
- return func(m *AccountMutation) {
- var (
- err error
- once sync.Once
- value *Account
- )
- m.oldValue = func(ctx context.Context) (*Account, error) {
- once.Do(func() {
- if m.done {
- err = errors.New("querying old values post mutation is not allowed")
- } else {
- value, err = m.Client().Account.Get(ctx, id)
- }
- })
- return value, err
- }
- m.id = &id
- }
- }
- // withAccount sets the old Account of the mutation.
- func withAccount(node *Account) accountOption {
- return func(m *AccountMutation) {
- m.oldValue = func(context.Context) (*Account, error) {
- return node, nil
- }
- m.id = &node.ID
- }
- }
- // Client returns a new `ent.Client` from the mutation. If the mutation was
- // executed in a transaction (ent.Tx), a transactional client is returned.
- func (m AccountMutation) Client() *Client {
- client := &Client{config: m.config}
- client.init()
- return client
- }
- // Tx returns an `ent.Tx` for mutations that were executed in transactions;
- // it returns an error otherwise.
- func (m AccountMutation) Tx() (*Tx, error) {
- if _, ok := m.driver.(*txDriver); !ok {
- return nil, errors.New("ent: mutation is not running in a transaction")
- }
- tx := &Tx{config: m.config}
- tx.init()
- return tx, nil
- }
- // ID returns the ID value in the mutation. Note that the ID is only available
- // if it was provided to the builder or after it was returned from the database.
- func (m *AccountMutation) ID() (id int64, exists bool) {
- if m.id == nil {
- return
- }
- return *m.id, true
- }
- // IDs queries the database and returns the entity ids that match the mutation's predicate.
- // That means, if the mutation is applied within a transaction with an isolation level such
- // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
- // or updated by the mutation.
- func (m *AccountMutation) IDs(ctx context.Context) ([]int64, error) {
- switch {
- case m.op.Is(OpUpdateOne | OpDeleteOne):
- id, exists := m.ID()
- if exists {
- return []int64{id}, nil
- }
- fallthrough
- case m.op.Is(OpUpdate | OpDelete):
- return m.Client().Account.Query().Where(m.predicates...).IDs(ctx)
- default:
- return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
- }
- }
- // SetCreatedAt sets the "created_at" field.
- func (m *AccountMutation) SetCreatedAt(t time.Time) {
- m.created_at = &t
- }
- // CreatedAt returns the value of the "created_at" field in the mutation.
- func (m *AccountMutation) CreatedAt() (r time.Time, exists bool) {
- v := m.created_at
- if v == nil {
- return
- }
- return *v, true
- }
- // OldCreatedAt returns the old "created_at" field's value of the Account entity.
- // If the Account object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *AccountMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldCreatedAt requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
- }
- return oldValue.CreatedAt, nil
- }
- // ResetCreatedAt resets all changes to the "created_at" field.
- func (m *AccountMutation) ResetCreatedAt() {
- m.created_at = nil
- }
- // SetUpdatedAt sets the "updated_at" field.
- func (m *AccountMutation) SetUpdatedAt(t time.Time) {
- m.updated_at = &t
- }
- // UpdatedAt returns the value of the "updated_at" field in the mutation.
- func (m *AccountMutation) UpdatedAt() (r time.Time, exists bool) {
- v := m.updated_at
- if v == nil {
- return
- }
- return *v, true
- }
- // OldUpdatedAt returns the old "updated_at" field's value of the Account entity.
- // If the Account object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *AccountMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
- }
- return oldValue.UpdatedAt, nil
- }
- // ResetUpdatedAt resets all changes to the "updated_at" field.
- func (m *AccountMutation) ResetUpdatedAt() {
- m.updated_at = nil
- }
- // SetDeletedAt sets the "deleted_at" field.
- func (m *AccountMutation) SetDeletedAt(t time.Time) {
- m.deleted_at = &t
- }
- // DeletedAt returns the value of the "deleted_at" field in the mutation.
- func (m *AccountMutation) DeletedAt() (r time.Time, exists bool) {
- v := m.deleted_at
- if v == nil {
- return
- }
- return *v, true
- }
- // OldDeletedAt returns the old "deleted_at" field's value of the Account entity.
- // If the Account object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *AccountMutation) OldDeletedAt(ctx context.Context) (v *time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldDeletedAt requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
- }
- return oldValue.DeletedAt, nil
- }
- // ClearDeletedAt clears the value of the "deleted_at" field.
- func (m *AccountMutation) ClearDeletedAt() {
- m.deleted_at = nil
- m.clearedFields[account.FieldDeletedAt] = struct{}{}
- }
- // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
- func (m *AccountMutation) DeletedAtCleared() bool {
- _, ok := m.clearedFields[account.FieldDeletedAt]
- return ok
- }
- // ResetDeletedAt resets all changes to the "deleted_at" field.
- func (m *AccountMutation) ResetDeletedAt() {
- m.deleted_at = nil
- delete(m.clearedFields, account.FieldDeletedAt)
- }
- // SetName sets the "name" field.
- func (m *AccountMutation) SetName(s string) {
- m.name = &s
- }
- // Name returns the value of the "name" field in the mutation.
- func (m *AccountMutation) Name() (r string, exists bool) {
- v := m.name
- if v == nil {
- return
- }
- return *v, true
- }
- // OldName returns the old "name" field's value of the Account entity.
- // If the Account object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *AccountMutation) OldName(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldName is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldName requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldName: %w", err)
- }
- return oldValue.Name, nil
- }
- // ResetName resets all changes to the "name" field.
- func (m *AccountMutation) ResetName() {
- m.name = nil
- }
- // SetNotes sets the "notes" field.
- func (m *AccountMutation) SetNotes(s string) {
- m.notes = &s
- }
- // Notes returns the value of the "notes" field in the mutation.
- func (m *AccountMutation) Notes() (r string, exists bool) {
- v := m.notes
- if v == nil {
- return
- }
- return *v, true
- }
- // OldNotes returns the old "notes" field's value of the Account entity.
- // If the Account object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *AccountMutation) OldNotes(ctx context.Context) (v *string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldNotes is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldNotes requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldNotes: %w", err)
- }
- return oldValue.Notes, nil
- }
- // ClearNotes clears the value of the "notes" field.
- func (m *AccountMutation) ClearNotes() {
- m.notes = nil
- m.clearedFields[account.FieldNotes] = struct{}{}
- }
- // NotesCleared returns if the "notes" field was cleared in this mutation.
- func (m *AccountMutation) NotesCleared() bool {
- _, ok := m.clearedFields[account.FieldNotes]
- return ok
- }
- // ResetNotes resets all changes to the "notes" field.
- func (m *AccountMutation) ResetNotes() {
- m.notes = nil
- delete(m.clearedFields, account.FieldNotes)
- }
- // SetPlatform sets the "platform" field.
- func (m *AccountMutation) SetPlatform(s string) {
- m.platform = &s
- }
- // Platform returns the value of the "platform" field in the mutation.
- func (m *AccountMutation) Platform() (r string, exists bool) {
- v := m.platform
- if v == nil {
- return
- }
- return *v, true
- }
- // OldPlatform returns the old "platform" field's value of the Account entity.
- // If the Account object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *AccountMutation) OldPlatform(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldPlatform is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldPlatform requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldPlatform: %w", err)
- }
- return oldValue.Platform, nil
- }
- // ResetPlatform resets all changes to the "platform" field.
- func (m *AccountMutation) ResetPlatform() {
- m.platform = nil
- }
- // SetType sets the "type" field.
- func (m *AccountMutation) SetType(s string) {
- m._type = &s
- }
- // GetType returns the value of the "type" field in the mutation.
- func (m *AccountMutation) GetType() (r string, exists bool) {
- v := m._type
- if v == nil {
- return
- }
- return *v, true
- }
- // OldType returns the old "type" field's value of the Account entity.
- // If the Account object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *AccountMutation) OldType(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldType is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldType requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldType: %w", err)
- }
- return oldValue.Type, nil
- }
- // ResetType resets all changes to the "type" field.
- func (m *AccountMutation) ResetType() {
- m._type = nil
- }
- // SetCredentials sets the "credentials" field.
- func (m *AccountMutation) SetCredentials(value map[string]interface{}) {
- m.credentials = &value
- }
- // Credentials returns the value of the "credentials" field in the mutation.
- func (m *AccountMutation) Credentials() (r map[string]interface{}, exists bool) {
- v := m.credentials
- if v == nil {
- return
- }
- return *v, true
- }
- // OldCredentials returns the old "credentials" field's value of the Account entity.
- // If the Account object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *AccountMutation) OldCredentials(ctx context.Context) (v map[string]interface{}, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldCredentials is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldCredentials requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldCredentials: %w", err)
- }
- return oldValue.Credentials, nil
- }
- // ResetCredentials resets all changes to the "credentials" field.
- func (m *AccountMutation) ResetCredentials() {
- m.credentials = nil
- }
- // SetExtra sets the "extra" field.
- func (m *AccountMutation) SetExtra(value map[string]interface{}) {
- m.extra = &value
- }
- // Extra returns the value of the "extra" field in the mutation.
- func (m *AccountMutation) Extra() (r map[string]interface{}, exists bool) {
- v := m.extra
- if v == nil {
- return
- }
- return *v, true
- }
- // OldExtra returns the old "extra" field's value of the Account entity.
- // If the Account object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *AccountMutation) OldExtra(ctx context.Context) (v map[string]interface{}, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldExtra is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldExtra requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldExtra: %w", err)
- }
- return oldValue.Extra, nil
- }
- // ResetExtra resets all changes to the "extra" field.
- func (m *AccountMutation) ResetExtra() {
- m.extra = nil
- }
- // SetProxyID sets the "proxy_id" field.
- func (m *AccountMutation) SetProxyID(i int64) {
- m.proxy = &i
- }
- // ProxyID returns the value of the "proxy_id" field in the mutation.
- func (m *AccountMutation) ProxyID() (r int64, exists bool) {
- v := m.proxy
- if v == nil {
- return
- }
- return *v, true
- }
- // OldProxyID returns the old "proxy_id" field's value of the Account entity.
- // If the Account object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *AccountMutation) OldProxyID(ctx context.Context) (v *int64, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldProxyID is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldProxyID requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldProxyID: %w", err)
- }
- return oldValue.ProxyID, nil
- }
- // ClearProxyID clears the value of the "proxy_id" field.
- func (m *AccountMutation) ClearProxyID() {
- m.proxy = nil
- m.clearedFields[account.FieldProxyID] = struct{}{}
- }
- // ProxyIDCleared returns if the "proxy_id" field was cleared in this mutation.
- func (m *AccountMutation) ProxyIDCleared() bool {
- _, ok := m.clearedFields[account.FieldProxyID]
- return ok
- }
- // ResetProxyID resets all changes to the "proxy_id" field.
- func (m *AccountMutation) ResetProxyID() {
- m.proxy = nil
- delete(m.clearedFields, account.FieldProxyID)
- }
- // SetProxyFallbackOriginID sets the "proxy_fallback_origin_id" field.
- func (m *AccountMutation) SetProxyFallbackOriginID(i int64) {
- m.proxy_fallback_origin_id = &i
- m.addproxy_fallback_origin_id = nil
- }
- // ProxyFallbackOriginID returns the value of the "proxy_fallback_origin_id" field in the mutation.
- func (m *AccountMutation) ProxyFallbackOriginID() (r int64, exists bool) {
- v := m.proxy_fallback_origin_id
- if v == nil {
- return
- }
- return *v, true
- }
- // OldProxyFallbackOriginID returns the old "proxy_fallback_origin_id" field's value of the Account entity.
- // If the Account object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *AccountMutation) OldProxyFallbackOriginID(ctx context.Context) (v *int64, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldProxyFallbackOriginID is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldProxyFallbackOriginID requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldProxyFallbackOriginID: %w", err)
- }
- return oldValue.ProxyFallbackOriginID, nil
- }
- // AddProxyFallbackOriginID adds i to the "proxy_fallback_origin_id" field.
- func (m *AccountMutation) AddProxyFallbackOriginID(i int64) {
- if m.addproxy_fallback_origin_id != nil {
- *m.addproxy_fallback_origin_id += i
- } else {
- m.addproxy_fallback_origin_id = &i
- }
- }
- // AddedProxyFallbackOriginID returns the value that was added to the "proxy_fallback_origin_id" field in this mutation.
- func (m *AccountMutation) AddedProxyFallbackOriginID() (r int64, exists bool) {
- v := m.addproxy_fallback_origin_id
- if v == nil {
- return
- }
- return *v, true
- }
- // ClearProxyFallbackOriginID clears the value of the "proxy_fallback_origin_id" field.
- func (m *AccountMutation) ClearProxyFallbackOriginID() {
- m.proxy_fallback_origin_id = nil
- m.addproxy_fallback_origin_id = nil
- m.clearedFields[account.FieldProxyFallbackOriginID] = struct{}{}
- }
- // ProxyFallbackOriginIDCleared returns if the "proxy_fallback_origin_id" field was cleared in this mutation.
- func (m *AccountMutation) ProxyFallbackOriginIDCleared() bool {
- _, ok := m.clearedFields[account.FieldProxyFallbackOriginID]
- return ok
- }
- // ResetProxyFallbackOriginID resets all changes to the "proxy_fallback_origin_id" field.
- func (m *AccountMutation) ResetProxyFallbackOriginID() {
- m.proxy_fallback_origin_id = nil
- m.addproxy_fallback_origin_id = nil
- delete(m.clearedFields, account.FieldProxyFallbackOriginID)
- }
- // SetConcurrency sets the "concurrency" field.
- func (m *AccountMutation) SetConcurrency(i int) {
- m.concurrency = &i
- m.addconcurrency = nil
- }
- // Concurrency returns the value of the "concurrency" field in the mutation.
- func (m *AccountMutation) Concurrency() (r int, exists bool) {
- v := m.concurrency
- if v == nil {
- return
- }
- return *v, true
- }
- // OldConcurrency returns the old "concurrency" field's value of the Account entity.
- // If the Account object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *AccountMutation) OldConcurrency(ctx context.Context) (v int, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldConcurrency is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldConcurrency requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldConcurrency: %w", err)
- }
- return oldValue.Concurrency, nil
- }
- // AddConcurrency adds i to the "concurrency" field.
- func (m *AccountMutation) AddConcurrency(i int) {
- if m.addconcurrency != nil {
- *m.addconcurrency += i
- } else {
- m.addconcurrency = &i
- }
- }
- // AddedConcurrency returns the value that was added to the "concurrency" field in this mutation.
- func (m *AccountMutation) AddedConcurrency() (r int, exists bool) {
- v := m.addconcurrency
- if v == nil {
- return
- }
- return *v, true
- }
- // ResetConcurrency resets all changes to the "concurrency" field.
- func (m *AccountMutation) ResetConcurrency() {
- m.concurrency = nil
- m.addconcurrency = nil
- }
- // SetLoadFactor sets the "load_factor" field.
- func (m *AccountMutation) SetLoadFactor(i int) {
- m.load_factor = &i
- m.addload_factor = nil
- }
- // LoadFactor returns the value of the "load_factor" field in the mutation.
- func (m *AccountMutation) LoadFactor() (r int, exists bool) {
- v := m.load_factor
- if v == nil {
- return
- }
- return *v, true
- }
- // OldLoadFactor returns the old "load_factor" field's value of the Account entity.
- // If the Account object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *AccountMutation) OldLoadFactor(ctx context.Context) (v *int, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldLoadFactor is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldLoadFactor requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldLoadFactor: %w", err)
- }
- return oldValue.LoadFactor, nil
- }
- // AddLoadFactor adds i to the "load_factor" field.
- func (m *AccountMutation) AddLoadFactor(i int) {
- if m.addload_factor != nil {
- *m.addload_factor += i
- } else {
- m.addload_factor = &i
- }
- }
- // AddedLoadFactor returns the value that was added to the "load_factor" field in this mutation.
- func (m *AccountMutation) AddedLoadFactor() (r int, exists bool) {
- v := m.addload_factor
- if v == nil {
- return
- }
- return *v, true
- }
- // ClearLoadFactor clears the value of the "load_factor" field.
- func (m *AccountMutation) ClearLoadFactor() {
- m.load_factor = nil
- m.addload_factor = nil
- m.clearedFields[account.FieldLoadFactor] = struct{}{}
- }
- // LoadFactorCleared returns if the "load_factor" field was cleared in this mutation.
- func (m *AccountMutation) LoadFactorCleared() bool {
- _, ok := m.clearedFields[account.FieldLoadFactor]
- return ok
- }
- // ResetLoadFactor resets all changes to the "load_factor" field.
- func (m *AccountMutation) ResetLoadFactor() {
- m.load_factor = nil
- m.addload_factor = nil
- delete(m.clearedFields, account.FieldLoadFactor)
- }
- // SetPriority sets the "priority" field.
- func (m *AccountMutation) SetPriority(i int) {
- m.priority = &i
- m.addpriority = nil
- }
- // Priority returns the value of the "priority" field in the mutation.
- func (m *AccountMutation) Priority() (r int, exists bool) {
- v := m.priority
- if v == nil {
- return
- }
- return *v, true
- }
- // OldPriority returns the old "priority" field's value of the Account entity.
- // If the Account object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *AccountMutation) OldPriority(ctx context.Context) (v int, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldPriority is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldPriority requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldPriority: %w", err)
- }
- return oldValue.Priority, nil
- }
- // AddPriority adds i to the "priority" field.
- func (m *AccountMutation) AddPriority(i int) {
- if m.addpriority != nil {
- *m.addpriority += i
- } else {
- m.addpriority = &i
- }
- }
- // AddedPriority returns the value that was added to the "priority" field in this mutation.
- func (m *AccountMutation) AddedPriority() (r int, exists bool) {
- v := m.addpriority
- if v == nil {
- return
- }
- return *v, true
- }
- // ResetPriority resets all changes to the "priority" field.
- func (m *AccountMutation) ResetPriority() {
- m.priority = nil
- m.addpriority = nil
- }
- // SetRateMultiplier sets the "rate_multiplier" field.
- func (m *AccountMutation) SetRateMultiplier(f float64) {
- m.rate_multiplier = &f
- m.addrate_multiplier = nil
- }
- // RateMultiplier returns the value of the "rate_multiplier" field in the mutation.
- func (m *AccountMutation) RateMultiplier() (r float64, exists bool) {
- v := m.rate_multiplier
- if v == nil {
- return
- }
- return *v, true
- }
- // OldRateMultiplier returns the old "rate_multiplier" field's value of the Account entity.
- // If the Account object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *AccountMutation) OldRateMultiplier(ctx context.Context) (v float64, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldRateMultiplier is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldRateMultiplier requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldRateMultiplier: %w", err)
- }
- return oldValue.RateMultiplier, nil
- }
- // AddRateMultiplier adds f to the "rate_multiplier" field.
- func (m *AccountMutation) AddRateMultiplier(f float64) {
- if m.addrate_multiplier != nil {
- *m.addrate_multiplier += f
- } else {
- m.addrate_multiplier = &f
- }
- }
- // AddedRateMultiplier returns the value that was added to the "rate_multiplier" field in this mutation.
- func (m *AccountMutation) AddedRateMultiplier() (r float64, exists bool) {
- v := m.addrate_multiplier
- if v == nil {
- return
- }
- return *v, true
- }
- // ResetRateMultiplier resets all changes to the "rate_multiplier" field.
- func (m *AccountMutation) ResetRateMultiplier() {
- m.rate_multiplier = nil
- m.addrate_multiplier = nil
- }
- // SetStatus sets the "status" field.
- func (m *AccountMutation) SetStatus(s string) {
- m.status = &s
- }
- // Status returns the value of the "status" field in the mutation.
- func (m *AccountMutation) Status() (r string, exists bool) {
- v := m.status
- if v == nil {
- return
- }
- return *v, true
- }
- // OldStatus returns the old "status" field's value of the Account entity.
- // If the Account object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *AccountMutation) OldStatus(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldStatus is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldStatus requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldStatus: %w", err)
- }
- return oldValue.Status, nil
- }
- // ResetStatus resets all changes to the "status" field.
- func (m *AccountMutation) ResetStatus() {
- m.status = nil
- }
- // SetErrorMessage sets the "error_message" field.
- func (m *AccountMutation) SetErrorMessage(s string) {
- m.error_message = &s
- }
- // ErrorMessage returns the value of the "error_message" field in the mutation.
- func (m *AccountMutation) ErrorMessage() (r string, exists bool) {
- v := m.error_message
- if v == nil {
- return
- }
- return *v, true
- }
- // OldErrorMessage returns the old "error_message" field's value of the Account entity.
- // If the Account object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *AccountMutation) OldErrorMessage(ctx context.Context) (v *string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldErrorMessage is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldErrorMessage requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldErrorMessage: %w", err)
- }
- return oldValue.ErrorMessage, nil
- }
- // ClearErrorMessage clears the value of the "error_message" field.
- func (m *AccountMutation) ClearErrorMessage() {
- m.error_message = nil
- m.clearedFields[account.FieldErrorMessage] = struct{}{}
- }
- // ErrorMessageCleared returns if the "error_message" field was cleared in this mutation.
- func (m *AccountMutation) ErrorMessageCleared() bool {
- _, ok := m.clearedFields[account.FieldErrorMessage]
- return ok
- }
- // ResetErrorMessage resets all changes to the "error_message" field.
- func (m *AccountMutation) ResetErrorMessage() {
- m.error_message = nil
- delete(m.clearedFields, account.FieldErrorMessage)
- }
- // SetLastUsedAt sets the "last_used_at" field.
- func (m *AccountMutation) SetLastUsedAt(t time.Time) {
- m.last_used_at = &t
- }
- // LastUsedAt returns the value of the "last_used_at" field in the mutation.
- func (m *AccountMutation) LastUsedAt() (r time.Time, exists bool) {
- v := m.last_used_at
- if v == nil {
- return
- }
- return *v, true
- }
- // OldLastUsedAt returns the old "last_used_at" field's value of the Account entity.
- // If the Account object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *AccountMutation) OldLastUsedAt(ctx context.Context) (v *time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldLastUsedAt is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldLastUsedAt requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldLastUsedAt: %w", err)
- }
- return oldValue.LastUsedAt, nil
- }
- // ClearLastUsedAt clears the value of the "last_used_at" field.
- func (m *AccountMutation) ClearLastUsedAt() {
- m.last_used_at = nil
- m.clearedFields[account.FieldLastUsedAt] = struct{}{}
- }
- // LastUsedAtCleared returns if the "last_used_at" field was cleared in this mutation.
- func (m *AccountMutation) LastUsedAtCleared() bool {
- _, ok := m.clearedFields[account.FieldLastUsedAt]
- return ok
- }
- // ResetLastUsedAt resets all changes to the "last_used_at" field.
- func (m *AccountMutation) ResetLastUsedAt() {
- m.last_used_at = nil
- delete(m.clearedFields, account.FieldLastUsedAt)
- }
- // SetExpiresAt sets the "expires_at" field.
- func (m *AccountMutation) SetExpiresAt(t time.Time) {
- m.expires_at = &t
- }
- // ExpiresAt returns the value of the "expires_at" field in the mutation.
- func (m *AccountMutation) ExpiresAt() (r time.Time, exists bool) {
- v := m.expires_at
- if v == nil {
- return
- }
- return *v, true
- }
- // OldExpiresAt returns the old "expires_at" field's value of the Account entity.
- // If the Account object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *AccountMutation) OldExpiresAt(ctx context.Context) (v *time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldExpiresAt is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldExpiresAt requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldExpiresAt: %w", err)
- }
- return oldValue.ExpiresAt, nil
- }
- // ClearExpiresAt clears the value of the "expires_at" field.
- func (m *AccountMutation) ClearExpiresAt() {
- m.expires_at = nil
- m.clearedFields[account.FieldExpiresAt] = struct{}{}
- }
- // ExpiresAtCleared returns if the "expires_at" field was cleared in this mutation.
- func (m *AccountMutation) ExpiresAtCleared() bool {
- _, ok := m.clearedFields[account.FieldExpiresAt]
- return ok
- }
- // ResetExpiresAt resets all changes to the "expires_at" field.
- func (m *AccountMutation) ResetExpiresAt() {
- m.expires_at = nil
- delete(m.clearedFields, account.FieldExpiresAt)
- }
- // SetAutoPauseOnExpired sets the "auto_pause_on_expired" field.
- func (m *AccountMutation) SetAutoPauseOnExpired(b bool) {
- m.auto_pause_on_expired = &b
- }
- // AutoPauseOnExpired returns the value of the "auto_pause_on_expired" field in the mutation.
- func (m *AccountMutation) AutoPauseOnExpired() (r bool, exists bool) {
- v := m.auto_pause_on_expired
- if v == nil {
- return
- }
- return *v, true
- }
- // OldAutoPauseOnExpired returns the old "auto_pause_on_expired" field's value of the Account entity.
- // If the Account object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *AccountMutation) OldAutoPauseOnExpired(ctx context.Context) (v bool, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldAutoPauseOnExpired is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldAutoPauseOnExpired requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldAutoPauseOnExpired: %w", err)
- }
- return oldValue.AutoPauseOnExpired, nil
- }
- // ResetAutoPauseOnExpired resets all changes to the "auto_pause_on_expired" field.
- func (m *AccountMutation) ResetAutoPauseOnExpired() {
- m.auto_pause_on_expired = nil
- }
- // SetSchedulable sets the "schedulable" field.
- func (m *AccountMutation) SetSchedulable(b bool) {
- m.schedulable = &b
- }
- // Schedulable returns the value of the "schedulable" field in the mutation.
- func (m *AccountMutation) Schedulable() (r bool, exists bool) {
- v := m.schedulable
- if v == nil {
- return
- }
- return *v, true
- }
- // OldSchedulable returns the old "schedulable" field's value of the Account entity.
- // If the Account object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *AccountMutation) OldSchedulable(ctx context.Context) (v bool, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldSchedulable is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldSchedulable requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldSchedulable: %w", err)
- }
- return oldValue.Schedulable, nil
- }
- // ResetSchedulable resets all changes to the "schedulable" field.
- func (m *AccountMutation) ResetSchedulable() {
- m.schedulable = nil
- }
- // SetRateLimitedAt sets the "rate_limited_at" field.
- func (m *AccountMutation) SetRateLimitedAt(t time.Time) {
- m.rate_limited_at = &t
- }
- // RateLimitedAt returns the value of the "rate_limited_at" field in the mutation.
- func (m *AccountMutation) RateLimitedAt() (r time.Time, exists bool) {
- v := m.rate_limited_at
- if v == nil {
- return
- }
- return *v, true
- }
- // OldRateLimitedAt returns the old "rate_limited_at" field's value of the Account entity.
- // If the Account object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *AccountMutation) OldRateLimitedAt(ctx context.Context) (v *time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldRateLimitedAt is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldRateLimitedAt requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldRateLimitedAt: %w", err)
- }
- return oldValue.RateLimitedAt, nil
- }
- // ClearRateLimitedAt clears the value of the "rate_limited_at" field.
- func (m *AccountMutation) ClearRateLimitedAt() {
- m.rate_limited_at = nil
- m.clearedFields[account.FieldRateLimitedAt] = struct{}{}
- }
- // RateLimitedAtCleared returns if the "rate_limited_at" field was cleared in this mutation.
- func (m *AccountMutation) RateLimitedAtCleared() bool {
- _, ok := m.clearedFields[account.FieldRateLimitedAt]
- return ok
- }
- // ResetRateLimitedAt resets all changes to the "rate_limited_at" field.
- func (m *AccountMutation) ResetRateLimitedAt() {
- m.rate_limited_at = nil
- delete(m.clearedFields, account.FieldRateLimitedAt)
- }
- // SetRateLimitResetAt sets the "rate_limit_reset_at" field.
- func (m *AccountMutation) SetRateLimitResetAt(t time.Time) {
- m.rate_limit_reset_at = &t
- }
- // RateLimitResetAt returns the value of the "rate_limit_reset_at" field in the mutation.
- func (m *AccountMutation) RateLimitResetAt() (r time.Time, exists bool) {
- v := m.rate_limit_reset_at
- if v == nil {
- return
- }
- return *v, true
- }
- // OldRateLimitResetAt returns the old "rate_limit_reset_at" field's value of the Account entity.
- // If the Account object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *AccountMutation) OldRateLimitResetAt(ctx context.Context) (v *time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldRateLimitResetAt is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldRateLimitResetAt requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldRateLimitResetAt: %w", err)
- }
- return oldValue.RateLimitResetAt, nil
- }
- // ClearRateLimitResetAt clears the value of the "rate_limit_reset_at" field.
- func (m *AccountMutation) ClearRateLimitResetAt() {
- m.rate_limit_reset_at = nil
- m.clearedFields[account.FieldRateLimitResetAt] = struct{}{}
- }
- // RateLimitResetAtCleared returns if the "rate_limit_reset_at" field was cleared in this mutation.
- func (m *AccountMutation) RateLimitResetAtCleared() bool {
- _, ok := m.clearedFields[account.FieldRateLimitResetAt]
- return ok
- }
- // ResetRateLimitResetAt resets all changes to the "rate_limit_reset_at" field.
- func (m *AccountMutation) ResetRateLimitResetAt() {
- m.rate_limit_reset_at = nil
- delete(m.clearedFields, account.FieldRateLimitResetAt)
- }
- // SetOverloadUntil sets the "overload_until" field.
- func (m *AccountMutation) SetOverloadUntil(t time.Time) {
- m.overload_until = &t
- }
- // OverloadUntil returns the value of the "overload_until" field in the mutation.
- func (m *AccountMutation) OverloadUntil() (r time.Time, exists bool) {
- v := m.overload_until
- if v == nil {
- return
- }
- return *v, true
- }
- // OldOverloadUntil returns the old "overload_until" field's value of the Account entity.
- // If the Account object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *AccountMutation) OldOverloadUntil(ctx context.Context) (v *time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldOverloadUntil is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldOverloadUntil requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldOverloadUntil: %w", err)
- }
- return oldValue.OverloadUntil, nil
- }
- // ClearOverloadUntil clears the value of the "overload_until" field.
- func (m *AccountMutation) ClearOverloadUntil() {
- m.overload_until = nil
- m.clearedFields[account.FieldOverloadUntil] = struct{}{}
- }
- // OverloadUntilCleared returns if the "overload_until" field was cleared in this mutation.
- func (m *AccountMutation) OverloadUntilCleared() bool {
- _, ok := m.clearedFields[account.FieldOverloadUntil]
- return ok
- }
- // ResetOverloadUntil resets all changes to the "overload_until" field.
- func (m *AccountMutation) ResetOverloadUntil() {
- m.overload_until = nil
- delete(m.clearedFields, account.FieldOverloadUntil)
- }
- // SetTempUnschedulableUntil sets the "temp_unschedulable_until" field.
- func (m *AccountMutation) SetTempUnschedulableUntil(t time.Time) {
- m.temp_unschedulable_until = &t
- }
- // TempUnschedulableUntil returns the value of the "temp_unschedulable_until" field in the mutation.
- func (m *AccountMutation) TempUnschedulableUntil() (r time.Time, exists bool) {
- v := m.temp_unschedulable_until
- if v == nil {
- return
- }
- return *v, true
- }
- // OldTempUnschedulableUntil returns the old "temp_unschedulable_until" field's value of the Account entity.
- // If the Account object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *AccountMutation) OldTempUnschedulableUntil(ctx context.Context) (v *time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldTempUnschedulableUntil is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldTempUnschedulableUntil requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldTempUnschedulableUntil: %w", err)
- }
- return oldValue.TempUnschedulableUntil, nil
- }
- // ClearTempUnschedulableUntil clears the value of the "temp_unschedulable_until" field.
- func (m *AccountMutation) ClearTempUnschedulableUntil() {
- m.temp_unschedulable_until = nil
- m.clearedFields[account.FieldTempUnschedulableUntil] = struct{}{}
- }
- // TempUnschedulableUntilCleared returns if the "temp_unschedulable_until" field was cleared in this mutation.
- func (m *AccountMutation) TempUnschedulableUntilCleared() bool {
- _, ok := m.clearedFields[account.FieldTempUnschedulableUntil]
- return ok
- }
- // ResetTempUnschedulableUntil resets all changes to the "temp_unschedulable_until" field.
- func (m *AccountMutation) ResetTempUnschedulableUntil() {
- m.temp_unschedulable_until = nil
- delete(m.clearedFields, account.FieldTempUnschedulableUntil)
- }
- // SetTempUnschedulableReason sets the "temp_unschedulable_reason" field.
- func (m *AccountMutation) SetTempUnschedulableReason(s string) {
- m.temp_unschedulable_reason = &s
- }
- // TempUnschedulableReason returns the value of the "temp_unschedulable_reason" field in the mutation.
- func (m *AccountMutation) TempUnschedulableReason() (r string, exists bool) {
- v := m.temp_unschedulable_reason
- if v == nil {
- return
- }
- return *v, true
- }
- // OldTempUnschedulableReason returns the old "temp_unschedulable_reason" field's value of the Account entity.
- // If the Account object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *AccountMutation) OldTempUnschedulableReason(ctx context.Context) (v *string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldTempUnschedulableReason is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldTempUnschedulableReason requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldTempUnschedulableReason: %w", err)
- }
- return oldValue.TempUnschedulableReason, nil
- }
- // ClearTempUnschedulableReason clears the value of the "temp_unschedulable_reason" field.
- func (m *AccountMutation) ClearTempUnschedulableReason() {
- m.temp_unschedulable_reason = nil
- m.clearedFields[account.FieldTempUnschedulableReason] = struct{}{}
- }
- // TempUnschedulableReasonCleared returns if the "temp_unschedulable_reason" field was cleared in this mutation.
- func (m *AccountMutation) TempUnschedulableReasonCleared() bool {
- _, ok := m.clearedFields[account.FieldTempUnschedulableReason]
- return ok
- }
- // ResetTempUnschedulableReason resets all changes to the "temp_unschedulable_reason" field.
- func (m *AccountMutation) ResetTempUnschedulableReason() {
- m.temp_unschedulable_reason = nil
- delete(m.clearedFields, account.FieldTempUnschedulableReason)
- }
- // SetSessionWindowStart sets the "session_window_start" field.
- func (m *AccountMutation) SetSessionWindowStart(t time.Time) {
- m.session_window_start = &t
- }
- // SessionWindowStart returns the value of the "session_window_start" field in the mutation.
- func (m *AccountMutation) SessionWindowStart() (r time.Time, exists bool) {
- v := m.session_window_start
- if v == nil {
- return
- }
- return *v, true
- }
- // OldSessionWindowStart returns the old "session_window_start" field's value of the Account entity.
- // If the Account object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *AccountMutation) OldSessionWindowStart(ctx context.Context) (v *time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldSessionWindowStart is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldSessionWindowStart requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldSessionWindowStart: %w", err)
- }
- return oldValue.SessionWindowStart, nil
- }
- // ClearSessionWindowStart clears the value of the "session_window_start" field.
- func (m *AccountMutation) ClearSessionWindowStart() {
- m.session_window_start = nil
- m.clearedFields[account.FieldSessionWindowStart] = struct{}{}
- }
- // SessionWindowStartCleared returns if the "session_window_start" field was cleared in this mutation.
- func (m *AccountMutation) SessionWindowStartCleared() bool {
- _, ok := m.clearedFields[account.FieldSessionWindowStart]
- return ok
- }
- // ResetSessionWindowStart resets all changes to the "session_window_start" field.
- func (m *AccountMutation) ResetSessionWindowStart() {
- m.session_window_start = nil
- delete(m.clearedFields, account.FieldSessionWindowStart)
- }
- // SetSessionWindowEnd sets the "session_window_end" field.
- func (m *AccountMutation) SetSessionWindowEnd(t time.Time) {
- m.session_window_end = &t
- }
- // SessionWindowEnd returns the value of the "session_window_end" field in the mutation.
- func (m *AccountMutation) SessionWindowEnd() (r time.Time, exists bool) {
- v := m.session_window_end
- if v == nil {
- return
- }
- return *v, true
- }
- // OldSessionWindowEnd returns the old "session_window_end" field's value of the Account entity.
- // If the Account object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *AccountMutation) OldSessionWindowEnd(ctx context.Context) (v *time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldSessionWindowEnd is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldSessionWindowEnd requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldSessionWindowEnd: %w", err)
- }
- return oldValue.SessionWindowEnd, nil
- }
- // ClearSessionWindowEnd clears the value of the "session_window_end" field.
- func (m *AccountMutation) ClearSessionWindowEnd() {
- m.session_window_end = nil
- m.clearedFields[account.FieldSessionWindowEnd] = struct{}{}
- }
- // SessionWindowEndCleared returns if the "session_window_end" field was cleared in this mutation.
- func (m *AccountMutation) SessionWindowEndCleared() bool {
- _, ok := m.clearedFields[account.FieldSessionWindowEnd]
- return ok
- }
- // ResetSessionWindowEnd resets all changes to the "session_window_end" field.
- func (m *AccountMutation) ResetSessionWindowEnd() {
- m.session_window_end = nil
- delete(m.clearedFields, account.FieldSessionWindowEnd)
- }
- // SetSessionWindowStatus sets the "session_window_status" field.
- func (m *AccountMutation) SetSessionWindowStatus(s string) {
- m.session_window_status = &s
- }
- // SessionWindowStatus returns the value of the "session_window_status" field in the mutation.
- func (m *AccountMutation) SessionWindowStatus() (r string, exists bool) {
- v := m.session_window_status
- if v == nil {
- return
- }
- return *v, true
- }
- // OldSessionWindowStatus returns the old "session_window_status" field's value of the Account entity.
- // If the Account object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *AccountMutation) OldSessionWindowStatus(ctx context.Context) (v *string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldSessionWindowStatus is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldSessionWindowStatus requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldSessionWindowStatus: %w", err)
- }
- return oldValue.SessionWindowStatus, nil
- }
- // ClearSessionWindowStatus clears the value of the "session_window_status" field.
- func (m *AccountMutation) ClearSessionWindowStatus() {
- m.session_window_status = nil
- m.clearedFields[account.FieldSessionWindowStatus] = struct{}{}
- }
- // SessionWindowStatusCleared returns if the "session_window_status" field was cleared in this mutation.
- func (m *AccountMutation) SessionWindowStatusCleared() bool {
- _, ok := m.clearedFields[account.FieldSessionWindowStatus]
- return ok
- }
- // ResetSessionWindowStatus resets all changes to the "session_window_status" field.
- func (m *AccountMutation) ResetSessionWindowStatus() {
- m.session_window_status = nil
- delete(m.clearedFields, account.FieldSessionWindowStatus)
- }
- // SetParentAccountID sets the "parent_account_id" field.
- func (m *AccountMutation) SetParentAccountID(i int64) {
- m.parent = &i
- }
- // ParentAccountID returns the value of the "parent_account_id" field in the mutation.
- func (m *AccountMutation) ParentAccountID() (r int64, exists bool) {
- v := m.parent
- if v == nil {
- return
- }
- return *v, true
- }
- // OldParentAccountID returns the old "parent_account_id" field's value of the Account entity.
- // If the Account object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *AccountMutation) OldParentAccountID(ctx context.Context) (v *int64, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldParentAccountID is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldParentAccountID requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldParentAccountID: %w", err)
- }
- return oldValue.ParentAccountID, nil
- }
- // ClearParentAccountID clears the value of the "parent_account_id" field.
- func (m *AccountMutation) ClearParentAccountID() {
- m.parent = nil
- m.clearedFields[account.FieldParentAccountID] = struct{}{}
- }
- // ParentAccountIDCleared returns if the "parent_account_id" field was cleared in this mutation.
- func (m *AccountMutation) ParentAccountIDCleared() bool {
- _, ok := m.clearedFields[account.FieldParentAccountID]
- return ok
- }
- // ResetParentAccountID resets all changes to the "parent_account_id" field.
- func (m *AccountMutation) ResetParentAccountID() {
- m.parent = nil
- delete(m.clearedFields, account.FieldParentAccountID)
- }
- // SetQuotaDimension sets the "quota_dimension" field.
- func (m *AccountMutation) SetQuotaDimension(ad account.QuotaDimension) {
- m.quota_dimension = &ad
- }
- // QuotaDimension returns the value of the "quota_dimension" field in the mutation.
- func (m *AccountMutation) QuotaDimension() (r account.QuotaDimension, exists bool) {
- v := m.quota_dimension
- if v == nil {
- return
- }
- return *v, true
- }
- // OldQuotaDimension returns the old "quota_dimension" field's value of the Account entity.
- // If the Account object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *AccountMutation) OldQuotaDimension(ctx context.Context) (v account.QuotaDimension, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldQuotaDimension is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldQuotaDimension requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldQuotaDimension: %w", err)
- }
- return oldValue.QuotaDimension, nil
- }
- // ResetQuotaDimension resets all changes to the "quota_dimension" field.
- func (m *AccountMutation) ResetQuotaDimension() {
- m.quota_dimension = nil
- }
- // AddGroupIDs adds the "groups" edge to the Group entity by ids.
- func (m *AccountMutation) AddGroupIDs(ids ...int64) {
- if m.groups == nil {
- m.groups = make(map[int64]struct{})
- }
- for i := range ids {
- m.groups[ids[i]] = struct{}{}
- }
- }
- // ClearGroups clears the "groups" edge to the Group entity.
- func (m *AccountMutation) ClearGroups() {
- m.clearedgroups = true
- }
- // GroupsCleared reports if the "groups" edge to the Group entity was cleared.
- func (m *AccountMutation) GroupsCleared() bool {
- return m.clearedgroups
- }
- // RemoveGroupIDs removes the "groups" edge to the Group entity by IDs.
- func (m *AccountMutation) RemoveGroupIDs(ids ...int64) {
- if m.removedgroups == nil {
- m.removedgroups = make(map[int64]struct{})
- }
- for i := range ids {
- delete(m.groups, ids[i])
- m.removedgroups[ids[i]] = struct{}{}
- }
- }
- // RemovedGroups returns the removed IDs of the "groups" edge to the Group entity.
- func (m *AccountMutation) RemovedGroupsIDs() (ids []int64) {
- for id := range m.removedgroups {
- ids = append(ids, id)
- }
- return
- }
- // GroupsIDs returns the "groups" edge IDs in the mutation.
- func (m *AccountMutation) GroupsIDs() (ids []int64) {
- for id := range m.groups {
- ids = append(ids, id)
- }
- return
- }
- // ResetGroups resets all changes to the "groups" edge.
- func (m *AccountMutation) ResetGroups() {
- m.groups = nil
- m.clearedgroups = false
- m.removedgroups = nil
- }
- // ClearProxy clears the "proxy" edge to the Proxy entity.
- func (m *AccountMutation) ClearProxy() {
- m.clearedproxy = true
- m.clearedFields[account.FieldProxyID] = struct{}{}
- }
- // ProxyCleared reports if the "proxy" edge to the Proxy entity was cleared.
- func (m *AccountMutation) ProxyCleared() bool {
- return m.ProxyIDCleared() || m.clearedproxy
- }
- // ProxyIDs returns the "proxy" edge IDs in the mutation.
- // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
- // ProxyID instead. It exists only for internal usage by the builders.
- func (m *AccountMutation) ProxyIDs() (ids []int64) {
- if id := m.proxy; id != nil {
- ids = append(ids, *id)
- }
- return
- }
- // ResetProxy resets all changes to the "proxy" edge.
- func (m *AccountMutation) ResetProxy() {
- m.proxy = nil
- m.clearedproxy = false
- }
- // SetParentID sets the "parent" edge to the Account entity by id.
- func (m *AccountMutation) SetParentID(id int64) {
- m.parent = &id
- }
- // ClearParent clears the "parent" edge to the Account entity.
- func (m *AccountMutation) ClearParent() {
- m.clearedparent = true
- m.clearedFields[account.FieldParentAccountID] = struct{}{}
- }
- // ParentCleared reports if the "parent" edge to the Account entity was cleared.
- func (m *AccountMutation) ParentCleared() bool {
- return m.ParentAccountIDCleared() || m.clearedparent
- }
- // ParentID returns the "parent" edge ID in the mutation.
- func (m *AccountMutation) ParentID() (id int64, exists bool) {
- if m.parent != nil {
- return *m.parent, true
- }
- return
- }
- // ParentIDs returns the "parent" edge IDs in the mutation.
- // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
- // ParentID instead. It exists only for internal usage by the builders.
- func (m *AccountMutation) ParentIDs() (ids []int64) {
- if id := m.parent; id != nil {
- ids = append(ids, *id)
- }
- return
- }
- // ResetParent resets all changes to the "parent" edge.
- func (m *AccountMutation) ResetParent() {
- m.parent = nil
- m.clearedparent = false
- }
- // AddChildIDs adds the "children" edge to the Account entity by ids.
- func (m *AccountMutation) AddChildIDs(ids ...int64) {
- if m.children == nil {
- m.children = make(map[int64]struct{})
- }
- for i := range ids {
- m.children[ids[i]] = struct{}{}
- }
- }
- // ClearChildren clears the "children" edge to the Account entity.
- func (m *AccountMutation) ClearChildren() {
- m.clearedchildren = true
- }
- // ChildrenCleared reports if the "children" edge to the Account entity was cleared.
- func (m *AccountMutation) ChildrenCleared() bool {
- return m.clearedchildren
- }
- // RemoveChildIDs removes the "children" edge to the Account entity by IDs.
- func (m *AccountMutation) RemoveChildIDs(ids ...int64) {
- if m.removedchildren == nil {
- m.removedchildren = make(map[int64]struct{})
- }
- for i := range ids {
- delete(m.children, ids[i])
- m.removedchildren[ids[i]] = struct{}{}
- }
- }
- // RemovedChildren returns the removed IDs of the "children" edge to the Account entity.
- func (m *AccountMutation) RemovedChildrenIDs() (ids []int64) {
- for id := range m.removedchildren {
- ids = append(ids, id)
- }
- return
- }
- // ChildrenIDs returns the "children" edge IDs in the mutation.
- func (m *AccountMutation) ChildrenIDs() (ids []int64) {
- for id := range m.children {
- ids = append(ids, id)
- }
- return
- }
- // ResetChildren resets all changes to the "children" edge.
- func (m *AccountMutation) ResetChildren() {
- m.children = nil
- m.clearedchildren = false
- m.removedchildren = nil
- }
- // AddUsageLogIDs adds the "usage_logs" edge to the UsageLog entity by ids.
- func (m *AccountMutation) AddUsageLogIDs(ids ...int64) {
- if m.usage_logs == nil {
- m.usage_logs = make(map[int64]struct{})
- }
- for i := range ids {
- m.usage_logs[ids[i]] = struct{}{}
- }
- }
- // ClearUsageLogs clears the "usage_logs" edge to the UsageLog entity.
- func (m *AccountMutation) ClearUsageLogs() {
- m.clearedusage_logs = true
- }
- // UsageLogsCleared reports if the "usage_logs" edge to the UsageLog entity was cleared.
- func (m *AccountMutation) UsageLogsCleared() bool {
- return m.clearedusage_logs
- }
- // RemoveUsageLogIDs removes the "usage_logs" edge to the UsageLog entity by IDs.
- func (m *AccountMutation) RemoveUsageLogIDs(ids ...int64) {
- if m.removedusage_logs == nil {
- m.removedusage_logs = make(map[int64]struct{})
- }
- for i := range ids {
- delete(m.usage_logs, ids[i])
- m.removedusage_logs[ids[i]] = struct{}{}
- }
- }
- // RemovedUsageLogs returns the removed IDs of the "usage_logs" edge to the UsageLog entity.
- func (m *AccountMutation) RemovedUsageLogsIDs() (ids []int64) {
- for id := range m.removedusage_logs {
- ids = append(ids, id)
- }
- return
- }
- // UsageLogsIDs returns the "usage_logs" edge IDs in the mutation.
- func (m *AccountMutation) UsageLogsIDs() (ids []int64) {
- for id := range m.usage_logs {
- ids = append(ids, id)
- }
- return
- }
- // ResetUsageLogs resets all changes to the "usage_logs" edge.
- func (m *AccountMutation) ResetUsageLogs() {
- m.usage_logs = nil
- m.clearedusage_logs = false
- m.removedusage_logs = nil
- }
- // Where appends a list predicates to the AccountMutation builder.
- func (m *AccountMutation) Where(ps ...predicate.Account) {
- m.predicates = append(m.predicates, ps...)
- }
- // WhereP appends storage-level predicates to the AccountMutation builder. Using this method,
- // users can use type-assertion to append predicates that do not depend on any generated package.
- func (m *AccountMutation) WhereP(ps ...func(*sql.Selector)) {
- p := make([]predicate.Account, len(ps))
- for i := range ps {
- p[i] = ps[i]
- }
- m.Where(p...)
- }
- // Op returns the operation name.
- func (m *AccountMutation) Op() Op {
- return m.op
- }
- // SetOp allows setting the mutation operation.
- func (m *AccountMutation) SetOp(op Op) {
- m.op = op
- }
- // Type returns the node type of this mutation (Account).
- func (m *AccountMutation) Type() string {
- return m.typ
- }
- // Fields returns all fields that were changed during this mutation. Note that in
- // order to get all numeric fields that were incremented/decremented, call
- // AddedFields().
- func (m *AccountMutation) Fields() []string {
- fields := make([]string, 0, 31)
- if m.created_at != nil {
- fields = append(fields, account.FieldCreatedAt)
- }
- if m.updated_at != nil {
- fields = append(fields, account.FieldUpdatedAt)
- }
- if m.deleted_at != nil {
- fields = append(fields, account.FieldDeletedAt)
- }
- if m.name != nil {
- fields = append(fields, account.FieldName)
- }
- if m.notes != nil {
- fields = append(fields, account.FieldNotes)
- }
- if m.platform != nil {
- fields = append(fields, account.FieldPlatform)
- }
- if m._type != nil {
- fields = append(fields, account.FieldType)
- }
- if m.credentials != nil {
- fields = append(fields, account.FieldCredentials)
- }
- if m.extra != nil {
- fields = append(fields, account.FieldExtra)
- }
- if m.proxy != nil {
- fields = append(fields, account.FieldProxyID)
- }
- if m.proxy_fallback_origin_id != nil {
- fields = append(fields, account.FieldProxyFallbackOriginID)
- }
- if m.concurrency != nil {
- fields = append(fields, account.FieldConcurrency)
- }
- if m.load_factor != nil {
- fields = append(fields, account.FieldLoadFactor)
- }
- if m.priority != nil {
- fields = append(fields, account.FieldPriority)
- }
- if m.rate_multiplier != nil {
- fields = append(fields, account.FieldRateMultiplier)
- }
- if m.status != nil {
- fields = append(fields, account.FieldStatus)
- }
- if m.error_message != nil {
- fields = append(fields, account.FieldErrorMessage)
- }
- if m.last_used_at != nil {
- fields = append(fields, account.FieldLastUsedAt)
- }
- if m.expires_at != nil {
- fields = append(fields, account.FieldExpiresAt)
- }
- if m.auto_pause_on_expired != nil {
- fields = append(fields, account.FieldAutoPauseOnExpired)
- }
- if m.schedulable != nil {
- fields = append(fields, account.FieldSchedulable)
- }
- if m.rate_limited_at != nil {
- fields = append(fields, account.FieldRateLimitedAt)
- }
- if m.rate_limit_reset_at != nil {
- fields = append(fields, account.FieldRateLimitResetAt)
- }
- if m.overload_until != nil {
- fields = append(fields, account.FieldOverloadUntil)
- }
- if m.temp_unschedulable_until != nil {
- fields = append(fields, account.FieldTempUnschedulableUntil)
- }
- if m.temp_unschedulable_reason != nil {
- fields = append(fields, account.FieldTempUnschedulableReason)
- }
- if m.session_window_start != nil {
- fields = append(fields, account.FieldSessionWindowStart)
- }
- if m.session_window_end != nil {
- fields = append(fields, account.FieldSessionWindowEnd)
- }
- if m.session_window_status != nil {
- fields = append(fields, account.FieldSessionWindowStatus)
- }
- if m.parent != nil {
- fields = append(fields, account.FieldParentAccountID)
- }
- if m.quota_dimension != nil {
- fields = append(fields, account.FieldQuotaDimension)
- }
- return fields
- }
- // Field returns the value of a field with the given name. The second boolean
- // return value indicates that this field was not set, or was not defined in the
- // schema.
- func (m *AccountMutation) Field(name string) (ent.Value, bool) {
- switch name {
- case account.FieldCreatedAt:
- return m.CreatedAt()
- case account.FieldUpdatedAt:
- return m.UpdatedAt()
- case account.FieldDeletedAt:
- return m.DeletedAt()
- case account.FieldName:
- return m.Name()
- case account.FieldNotes:
- return m.Notes()
- case account.FieldPlatform:
- return m.Platform()
- case account.FieldType:
- return m.GetType()
- case account.FieldCredentials:
- return m.Credentials()
- case account.FieldExtra:
- return m.Extra()
- case account.FieldProxyID:
- return m.ProxyID()
- case account.FieldProxyFallbackOriginID:
- return m.ProxyFallbackOriginID()
- case account.FieldConcurrency:
- return m.Concurrency()
- case account.FieldLoadFactor:
- return m.LoadFactor()
- case account.FieldPriority:
- return m.Priority()
- case account.FieldRateMultiplier:
- return m.RateMultiplier()
- case account.FieldStatus:
- return m.Status()
- case account.FieldErrorMessage:
- return m.ErrorMessage()
- case account.FieldLastUsedAt:
- return m.LastUsedAt()
- case account.FieldExpiresAt:
- return m.ExpiresAt()
- case account.FieldAutoPauseOnExpired:
- return m.AutoPauseOnExpired()
- case account.FieldSchedulable:
- return m.Schedulable()
- case account.FieldRateLimitedAt:
- return m.RateLimitedAt()
- case account.FieldRateLimitResetAt:
- return m.RateLimitResetAt()
- case account.FieldOverloadUntil:
- return m.OverloadUntil()
- case account.FieldTempUnschedulableUntil:
- return m.TempUnschedulableUntil()
- case account.FieldTempUnschedulableReason:
- return m.TempUnschedulableReason()
- case account.FieldSessionWindowStart:
- return m.SessionWindowStart()
- case account.FieldSessionWindowEnd:
- return m.SessionWindowEnd()
- case account.FieldSessionWindowStatus:
- return m.SessionWindowStatus()
- case account.FieldParentAccountID:
- return m.ParentAccountID()
- case account.FieldQuotaDimension:
- return m.QuotaDimension()
- }
- return nil, false
- }
- // OldField returns the old value of the field from the database. An error is
- // returned if the mutation operation is not UpdateOne, or the query to the
- // database failed.
- func (m *AccountMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
- switch name {
- case account.FieldCreatedAt:
- return m.OldCreatedAt(ctx)
- case account.FieldUpdatedAt:
- return m.OldUpdatedAt(ctx)
- case account.FieldDeletedAt:
- return m.OldDeletedAt(ctx)
- case account.FieldName:
- return m.OldName(ctx)
- case account.FieldNotes:
- return m.OldNotes(ctx)
- case account.FieldPlatform:
- return m.OldPlatform(ctx)
- case account.FieldType:
- return m.OldType(ctx)
- case account.FieldCredentials:
- return m.OldCredentials(ctx)
- case account.FieldExtra:
- return m.OldExtra(ctx)
- case account.FieldProxyID:
- return m.OldProxyID(ctx)
- case account.FieldProxyFallbackOriginID:
- return m.OldProxyFallbackOriginID(ctx)
- case account.FieldConcurrency:
- return m.OldConcurrency(ctx)
- case account.FieldLoadFactor:
- return m.OldLoadFactor(ctx)
- case account.FieldPriority:
- return m.OldPriority(ctx)
- case account.FieldRateMultiplier:
- return m.OldRateMultiplier(ctx)
- case account.FieldStatus:
- return m.OldStatus(ctx)
- case account.FieldErrorMessage:
- return m.OldErrorMessage(ctx)
- case account.FieldLastUsedAt:
- return m.OldLastUsedAt(ctx)
- case account.FieldExpiresAt:
- return m.OldExpiresAt(ctx)
- case account.FieldAutoPauseOnExpired:
- return m.OldAutoPauseOnExpired(ctx)
- case account.FieldSchedulable:
- return m.OldSchedulable(ctx)
- case account.FieldRateLimitedAt:
- return m.OldRateLimitedAt(ctx)
- case account.FieldRateLimitResetAt:
- return m.OldRateLimitResetAt(ctx)
- case account.FieldOverloadUntil:
- return m.OldOverloadUntil(ctx)
- case account.FieldTempUnschedulableUntil:
- return m.OldTempUnschedulableUntil(ctx)
- case account.FieldTempUnschedulableReason:
- return m.OldTempUnschedulableReason(ctx)
- case account.FieldSessionWindowStart:
- return m.OldSessionWindowStart(ctx)
- case account.FieldSessionWindowEnd:
- return m.OldSessionWindowEnd(ctx)
- case account.FieldSessionWindowStatus:
- return m.OldSessionWindowStatus(ctx)
- case account.FieldParentAccountID:
- return m.OldParentAccountID(ctx)
- case account.FieldQuotaDimension:
- return m.OldQuotaDimension(ctx)
- }
- return nil, fmt.Errorf("unknown Account field %s", name)
- }
- // SetField sets the value of a field with the given name. It returns an error if
- // the field is not defined in the schema, or if the type mismatched the field
- // type.
- func (m *AccountMutation) SetField(name string, value ent.Value) error {
- switch name {
- case account.FieldCreatedAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetCreatedAt(v)
- return nil
- case account.FieldUpdatedAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetUpdatedAt(v)
- return nil
- case account.FieldDeletedAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetDeletedAt(v)
- return nil
- case account.FieldName:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetName(v)
- return nil
- case account.FieldNotes:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetNotes(v)
- return nil
- case account.FieldPlatform:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetPlatform(v)
- return nil
- case account.FieldType:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetType(v)
- return nil
- case account.FieldCredentials:
- v, ok := value.(map[string]interface{})
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetCredentials(v)
- return nil
- case account.FieldExtra:
- v, ok := value.(map[string]interface{})
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetExtra(v)
- return nil
- case account.FieldProxyID:
- v, ok := value.(int64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetProxyID(v)
- return nil
- case account.FieldProxyFallbackOriginID:
- v, ok := value.(int64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetProxyFallbackOriginID(v)
- return nil
- case account.FieldConcurrency:
- v, ok := value.(int)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetConcurrency(v)
- return nil
- case account.FieldLoadFactor:
- v, ok := value.(int)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetLoadFactor(v)
- return nil
- case account.FieldPriority:
- v, ok := value.(int)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetPriority(v)
- return nil
- case account.FieldRateMultiplier:
- v, ok := value.(float64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetRateMultiplier(v)
- return nil
- case account.FieldStatus:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetStatus(v)
- return nil
- case account.FieldErrorMessage:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetErrorMessage(v)
- return nil
- case account.FieldLastUsedAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetLastUsedAt(v)
- return nil
- case account.FieldExpiresAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetExpiresAt(v)
- return nil
- case account.FieldAutoPauseOnExpired:
- v, ok := value.(bool)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetAutoPauseOnExpired(v)
- return nil
- case account.FieldSchedulable:
- v, ok := value.(bool)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetSchedulable(v)
- return nil
- case account.FieldRateLimitedAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetRateLimitedAt(v)
- return nil
- case account.FieldRateLimitResetAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetRateLimitResetAt(v)
- return nil
- case account.FieldOverloadUntil:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetOverloadUntil(v)
- return nil
- case account.FieldTempUnschedulableUntil:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetTempUnschedulableUntil(v)
- return nil
- case account.FieldTempUnschedulableReason:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetTempUnschedulableReason(v)
- return nil
- case account.FieldSessionWindowStart:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetSessionWindowStart(v)
- return nil
- case account.FieldSessionWindowEnd:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetSessionWindowEnd(v)
- return nil
- case account.FieldSessionWindowStatus:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetSessionWindowStatus(v)
- return nil
- case account.FieldParentAccountID:
- v, ok := value.(int64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetParentAccountID(v)
- return nil
- case account.FieldQuotaDimension:
- v, ok := value.(account.QuotaDimension)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetQuotaDimension(v)
- return nil
- }
- return fmt.Errorf("unknown Account field %s", name)
- }
- // AddedFields returns all numeric fields that were incremented/decremented during
- // this mutation.
- func (m *AccountMutation) AddedFields() []string {
- var fields []string
- if m.addproxy_fallback_origin_id != nil {
- fields = append(fields, account.FieldProxyFallbackOriginID)
- }
- if m.addconcurrency != nil {
- fields = append(fields, account.FieldConcurrency)
- }
- if m.addload_factor != nil {
- fields = append(fields, account.FieldLoadFactor)
- }
- if m.addpriority != nil {
- fields = append(fields, account.FieldPriority)
- }
- if m.addrate_multiplier != nil {
- fields = append(fields, account.FieldRateMultiplier)
- }
- return fields
- }
- // AddedField returns the numeric value that was incremented/decremented on a field
- // with the given name. The second boolean return value indicates that this field
- // was not set, or was not defined in the schema.
- func (m *AccountMutation) AddedField(name string) (ent.Value, bool) {
- switch name {
- case account.FieldProxyFallbackOriginID:
- return m.AddedProxyFallbackOriginID()
- case account.FieldConcurrency:
- return m.AddedConcurrency()
- case account.FieldLoadFactor:
- return m.AddedLoadFactor()
- case account.FieldPriority:
- return m.AddedPriority()
- case account.FieldRateMultiplier:
- return m.AddedRateMultiplier()
- }
- return nil, false
- }
- // AddField adds the value to the field with the given name. It returns an error if
- // the field is not defined in the schema, or if the type mismatched the field
- // type.
- func (m *AccountMutation) AddField(name string, value ent.Value) error {
- switch name {
- case account.FieldProxyFallbackOriginID:
- v, ok := value.(int64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.AddProxyFallbackOriginID(v)
- return nil
- case account.FieldConcurrency:
- v, ok := value.(int)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.AddConcurrency(v)
- return nil
- case account.FieldLoadFactor:
- v, ok := value.(int)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.AddLoadFactor(v)
- return nil
- case account.FieldPriority:
- v, ok := value.(int)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.AddPriority(v)
- return nil
- case account.FieldRateMultiplier:
- v, ok := value.(float64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.AddRateMultiplier(v)
- return nil
- }
- return fmt.Errorf("unknown Account numeric field %s", name)
- }
- // ClearedFields returns all nullable fields that were cleared during this
- // mutation.
- func (m *AccountMutation) ClearedFields() []string {
- var fields []string
- if m.FieldCleared(account.FieldDeletedAt) {
- fields = append(fields, account.FieldDeletedAt)
- }
- if m.FieldCleared(account.FieldNotes) {
- fields = append(fields, account.FieldNotes)
- }
- if m.FieldCleared(account.FieldProxyID) {
- fields = append(fields, account.FieldProxyID)
- }
- if m.FieldCleared(account.FieldProxyFallbackOriginID) {
- fields = append(fields, account.FieldProxyFallbackOriginID)
- }
- if m.FieldCleared(account.FieldLoadFactor) {
- fields = append(fields, account.FieldLoadFactor)
- }
- if m.FieldCleared(account.FieldErrorMessage) {
- fields = append(fields, account.FieldErrorMessage)
- }
- if m.FieldCleared(account.FieldLastUsedAt) {
- fields = append(fields, account.FieldLastUsedAt)
- }
- if m.FieldCleared(account.FieldExpiresAt) {
- fields = append(fields, account.FieldExpiresAt)
- }
- if m.FieldCleared(account.FieldRateLimitedAt) {
- fields = append(fields, account.FieldRateLimitedAt)
- }
- if m.FieldCleared(account.FieldRateLimitResetAt) {
- fields = append(fields, account.FieldRateLimitResetAt)
- }
- if m.FieldCleared(account.FieldOverloadUntil) {
- fields = append(fields, account.FieldOverloadUntil)
- }
- if m.FieldCleared(account.FieldTempUnschedulableUntil) {
- fields = append(fields, account.FieldTempUnschedulableUntil)
- }
- if m.FieldCleared(account.FieldTempUnschedulableReason) {
- fields = append(fields, account.FieldTempUnschedulableReason)
- }
- if m.FieldCleared(account.FieldSessionWindowStart) {
- fields = append(fields, account.FieldSessionWindowStart)
- }
- if m.FieldCleared(account.FieldSessionWindowEnd) {
- fields = append(fields, account.FieldSessionWindowEnd)
- }
- if m.FieldCleared(account.FieldSessionWindowStatus) {
- fields = append(fields, account.FieldSessionWindowStatus)
- }
- if m.FieldCleared(account.FieldParentAccountID) {
- fields = append(fields, account.FieldParentAccountID)
- }
- return fields
- }
- // FieldCleared returns a boolean indicating if a field with the given name was
- // cleared in this mutation.
- func (m *AccountMutation) FieldCleared(name string) bool {
- _, ok := m.clearedFields[name]
- return ok
- }
- // ClearField clears the value of the field with the given name. It returns an
- // error if the field is not defined in the schema.
- func (m *AccountMutation) ClearField(name string) error {
- switch name {
- case account.FieldDeletedAt:
- m.ClearDeletedAt()
- return nil
- case account.FieldNotes:
- m.ClearNotes()
- return nil
- case account.FieldProxyID:
- m.ClearProxyID()
- return nil
- case account.FieldProxyFallbackOriginID:
- m.ClearProxyFallbackOriginID()
- return nil
- case account.FieldLoadFactor:
- m.ClearLoadFactor()
- return nil
- case account.FieldErrorMessage:
- m.ClearErrorMessage()
- return nil
- case account.FieldLastUsedAt:
- m.ClearLastUsedAt()
- return nil
- case account.FieldExpiresAt:
- m.ClearExpiresAt()
- return nil
- case account.FieldRateLimitedAt:
- m.ClearRateLimitedAt()
- return nil
- case account.FieldRateLimitResetAt:
- m.ClearRateLimitResetAt()
- return nil
- case account.FieldOverloadUntil:
- m.ClearOverloadUntil()
- return nil
- case account.FieldTempUnschedulableUntil:
- m.ClearTempUnschedulableUntil()
- return nil
- case account.FieldTempUnschedulableReason:
- m.ClearTempUnschedulableReason()
- return nil
- case account.FieldSessionWindowStart:
- m.ClearSessionWindowStart()
- return nil
- case account.FieldSessionWindowEnd:
- m.ClearSessionWindowEnd()
- return nil
- case account.FieldSessionWindowStatus:
- m.ClearSessionWindowStatus()
- return nil
- case account.FieldParentAccountID:
- m.ClearParentAccountID()
- return nil
- }
- return fmt.Errorf("unknown Account nullable field %s", name)
- }
- // ResetField resets all changes in the mutation for the field with the given name.
- // It returns an error if the field is not defined in the schema.
- func (m *AccountMutation) ResetField(name string) error {
- switch name {
- case account.FieldCreatedAt:
- m.ResetCreatedAt()
- return nil
- case account.FieldUpdatedAt:
- m.ResetUpdatedAt()
- return nil
- case account.FieldDeletedAt:
- m.ResetDeletedAt()
- return nil
- case account.FieldName:
- m.ResetName()
- return nil
- case account.FieldNotes:
- m.ResetNotes()
- return nil
- case account.FieldPlatform:
- m.ResetPlatform()
- return nil
- case account.FieldType:
- m.ResetType()
- return nil
- case account.FieldCredentials:
- m.ResetCredentials()
- return nil
- case account.FieldExtra:
- m.ResetExtra()
- return nil
- case account.FieldProxyID:
- m.ResetProxyID()
- return nil
- case account.FieldProxyFallbackOriginID:
- m.ResetProxyFallbackOriginID()
- return nil
- case account.FieldConcurrency:
- m.ResetConcurrency()
- return nil
- case account.FieldLoadFactor:
- m.ResetLoadFactor()
- return nil
- case account.FieldPriority:
- m.ResetPriority()
- return nil
- case account.FieldRateMultiplier:
- m.ResetRateMultiplier()
- return nil
- case account.FieldStatus:
- m.ResetStatus()
- return nil
- case account.FieldErrorMessage:
- m.ResetErrorMessage()
- return nil
- case account.FieldLastUsedAt:
- m.ResetLastUsedAt()
- return nil
- case account.FieldExpiresAt:
- m.ResetExpiresAt()
- return nil
- case account.FieldAutoPauseOnExpired:
- m.ResetAutoPauseOnExpired()
- return nil
- case account.FieldSchedulable:
- m.ResetSchedulable()
- return nil
- case account.FieldRateLimitedAt:
- m.ResetRateLimitedAt()
- return nil
- case account.FieldRateLimitResetAt:
- m.ResetRateLimitResetAt()
- return nil
- case account.FieldOverloadUntil:
- m.ResetOverloadUntil()
- return nil
- case account.FieldTempUnschedulableUntil:
- m.ResetTempUnschedulableUntil()
- return nil
- case account.FieldTempUnschedulableReason:
- m.ResetTempUnschedulableReason()
- return nil
- case account.FieldSessionWindowStart:
- m.ResetSessionWindowStart()
- return nil
- case account.FieldSessionWindowEnd:
- m.ResetSessionWindowEnd()
- return nil
- case account.FieldSessionWindowStatus:
- m.ResetSessionWindowStatus()
- return nil
- case account.FieldParentAccountID:
- m.ResetParentAccountID()
- return nil
- case account.FieldQuotaDimension:
- m.ResetQuotaDimension()
- return nil
- }
- return fmt.Errorf("unknown Account field %s", name)
- }
- // AddedEdges returns all edge names that were set/added in this mutation.
- func (m *AccountMutation) AddedEdges() []string {
- edges := make([]string, 0, 5)
- if m.groups != nil {
- edges = append(edges, account.EdgeGroups)
- }
- if m.proxy != nil {
- edges = append(edges, account.EdgeProxy)
- }
- if m.parent != nil {
- edges = append(edges, account.EdgeParent)
- }
- if m.children != nil {
- edges = append(edges, account.EdgeChildren)
- }
- if m.usage_logs != nil {
- edges = append(edges, account.EdgeUsageLogs)
- }
- return edges
- }
- // AddedIDs returns all IDs (to other nodes) that were added for the given edge
- // name in this mutation.
- func (m *AccountMutation) AddedIDs(name string) []ent.Value {
- switch name {
- case account.EdgeGroups:
- ids := make([]ent.Value, 0, len(m.groups))
- for id := range m.groups {
- ids = append(ids, id)
- }
- return ids
- case account.EdgeProxy:
- if id := m.proxy; id != nil {
- return []ent.Value{*id}
- }
- case account.EdgeParent:
- if id := m.parent; id != nil {
- return []ent.Value{*id}
- }
- case account.EdgeChildren:
- ids := make([]ent.Value, 0, len(m.children))
- for id := range m.children {
- ids = append(ids, id)
- }
- return ids
- case account.EdgeUsageLogs:
- ids := make([]ent.Value, 0, len(m.usage_logs))
- for id := range m.usage_logs {
- ids = append(ids, id)
- }
- return ids
- }
- return nil
- }
- // RemovedEdges returns all edge names that were removed in this mutation.
- func (m *AccountMutation) RemovedEdges() []string {
- edges := make([]string, 0, 5)
- if m.removedgroups != nil {
- edges = append(edges, account.EdgeGroups)
- }
- if m.removedchildren != nil {
- edges = append(edges, account.EdgeChildren)
- }
- if m.removedusage_logs != nil {
- edges = append(edges, account.EdgeUsageLogs)
- }
- return edges
- }
- // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
- // the given name in this mutation.
- func (m *AccountMutation) RemovedIDs(name string) []ent.Value {
- switch name {
- case account.EdgeGroups:
- ids := make([]ent.Value, 0, len(m.removedgroups))
- for id := range m.removedgroups {
- ids = append(ids, id)
- }
- return ids
- case account.EdgeChildren:
- ids := make([]ent.Value, 0, len(m.removedchildren))
- for id := range m.removedchildren {
- ids = append(ids, id)
- }
- return ids
- case account.EdgeUsageLogs:
- ids := make([]ent.Value, 0, len(m.removedusage_logs))
- for id := range m.removedusage_logs {
- ids = append(ids, id)
- }
- return ids
- }
- return nil
- }
- // ClearedEdges returns all edge names that were cleared in this mutation.
- func (m *AccountMutation) ClearedEdges() []string {
- edges := make([]string, 0, 5)
- if m.clearedgroups {
- edges = append(edges, account.EdgeGroups)
- }
- if m.clearedproxy {
- edges = append(edges, account.EdgeProxy)
- }
- if m.clearedparent {
- edges = append(edges, account.EdgeParent)
- }
- if m.clearedchildren {
- edges = append(edges, account.EdgeChildren)
- }
- if m.clearedusage_logs {
- edges = append(edges, account.EdgeUsageLogs)
- }
- return edges
- }
- // EdgeCleared returns a boolean which indicates if the edge with the given name
- // was cleared in this mutation.
- func (m *AccountMutation) EdgeCleared(name string) bool {
- switch name {
- case account.EdgeGroups:
- return m.clearedgroups
- case account.EdgeProxy:
- return m.clearedproxy
- case account.EdgeParent:
- return m.clearedparent
- case account.EdgeChildren:
- return m.clearedchildren
- case account.EdgeUsageLogs:
- return m.clearedusage_logs
- }
- return false
- }
- // ClearEdge clears the value of the edge with the given name. It returns an error
- // if that edge is not defined in the schema.
- func (m *AccountMutation) ClearEdge(name string) error {
- switch name {
- case account.EdgeProxy:
- m.ClearProxy()
- return nil
- case account.EdgeParent:
- m.ClearParent()
- return nil
- }
- return fmt.Errorf("unknown Account unique edge %s", name)
- }
- // ResetEdge resets all changes to the edge with the given name in this mutation.
- // It returns an error if the edge is not defined in the schema.
- func (m *AccountMutation) ResetEdge(name string) error {
- switch name {
- case account.EdgeGroups:
- m.ResetGroups()
- return nil
- case account.EdgeProxy:
- m.ResetProxy()
- return nil
- case account.EdgeParent:
- m.ResetParent()
- return nil
- case account.EdgeChildren:
- m.ResetChildren()
- return nil
- case account.EdgeUsageLogs:
- m.ResetUsageLogs()
- return nil
- }
- return fmt.Errorf("unknown Account edge %s", name)
- }
- // AccountGroupMutation represents an operation that mutates the AccountGroup nodes in the graph.
- type AccountGroupMutation struct {
- config
- op Op
- typ string
- priority *int
- addpriority *int
- created_at *time.Time
- clearedFields map[string]struct{}
- account *int64
- clearedaccount bool
- group *int64
- clearedgroup bool
- done bool
- oldValue func(context.Context) (*AccountGroup, error)
- predicates []predicate.AccountGroup
- }
- var _ ent.Mutation = (*AccountGroupMutation)(nil)
- // accountgroupOption allows management of the mutation configuration using functional options.
- type accountgroupOption func(*AccountGroupMutation)
- // newAccountGroupMutation creates new mutation for the AccountGroup entity.
- func newAccountGroupMutation(c config, op Op, opts ...accountgroupOption) *AccountGroupMutation {
- m := &AccountGroupMutation{
- config: c,
- op: op,
- typ: TypeAccountGroup,
- clearedFields: make(map[string]struct{}),
- }
- for _, opt := range opts {
- opt(m)
- }
- return m
- }
- // Client returns a new `ent.Client` from the mutation. If the mutation was
- // executed in a transaction (ent.Tx), a transactional client is returned.
- func (m AccountGroupMutation) Client() *Client {
- client := &Client{config: m.config}
- client.init()
- return client
- }
- // Tx returns an `ent.Tx` for mutations that were executed in transactions;
- // it returns an error otherwise.
- func (m AccountGroupMutation) Tx() (*Tx, error) {
- if _, ok := m.driver.(*txDriver); !ok {
- return nil, errors.New("ent: mutation is not running in a transaction")
- }
- tx := &Tx{config: m.config}
- tx.init()
- return tx, nil
- }
- // SetAccountID sets the "account_id" field.
- func (m *AccountGroupMutation) SetAccountID(i int64) {
- m.account = &i
- }
- // AccountID returns the value of the "account_id" field in the mutation.
- func (m *AccountGroupMutation) AccountID() (r int64, exists bool) {
- v := m.account
- if v == nil {
- return
- }
- return *v, true
- }
- // ResetAccountID resets all changes to the "account_id" field.
- func (m *AccountGroupMutation) ResetAccountID() {
- m.account = nil
- }
- // SetGroupID sets the "group_id" field.
- func (m *AccountGroupMutation) SetGroupID(i int64) {
- m.group = &i
- }
- // GroupID returns the value of the "group_id" field in the mutation.
- func (m *AccountGroupMutation) GroupID() (r int64, exists bool) {
- v := m.group
- if v == nil {
- return
- }
- return *v, true
- }
- // ResetGroupID resets all changes to the "group_id" field.
- func (m *AccountGroupMutation) ResetGroupID() {
- m.group = nil
- }
- // SetPriority sets the "priority" field.
- func (m *AccountGroupMutation) SetPriority(i int) {
- m.priority = &i
- m.addpriority = nil
- }
- // Priority returns the value of the "priority" field in the mutation.
- func (m *AccountGroupMutation) Priority() (r int, exists bool) {
- v := m.priority
- if v == nil {
- return
- }
- return *v, true
- }
- // AddPriority adds i to the "priority" field.
- func (m *AccountGroupMutation) AddPriority(i int) {
- if m.addpriority != nil {
- *m.addpriority += i
- } else {
- m.addpriority = &i
- }
- }
- // AddedPriority returns the value that was added to the "priority" field in this mutation.
- func (m *AccountGroupMutation) AddedPriority() (r int, exists bool) {
- v := m.addpriority
- if v == nil {
- return
- }
- return *v, true
- }
- // ResetPriority resets all changes to the "priority" field.
- func (m *AccountGroupMutation) ResetPriority() {
- m.priority = nil
- m.addpriority = nil
- }
- // SetCreatedAt sets the "created_at" field.
- func (m *AccountGroupMutation) SetCreatedAt(t time.Time) {
- m.created_at = &t
- }
- // CreatedAt returns the value of the "created_at" field in the mutation.
- func (m *AccountGroupMutation) CreatedAt() (r time.Time, exists bool) {
- v := m.created_at
- if v == nil {
- return
- }
- return *v, true
- }
- // ResetCreatedAt resets all changes to the "created_at" field.
- func (m *AccountGroupMutation) ResetCreatedAt() {
- m.created_at = nil
- }
- // ClearAccount clears the "account" edge to the Account entity.
- func (m *AccountGroupMutation) ClearAccount() {
- m.clearedaccount = true
- m.clearedFields[accountgroup.FieldAccountID] = struct{}{}
- }
- // AccountCleared reports if the "account" edge to the Account entity was cleared.
- func (m *AccountGroupMutation) AccountCleared() bool {
- return m.clearedaccount
- }
- // AccountIDs returns the "account" edge IDs in the mutation.
- // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
- // AccountID instead. It exists only for internal usage by the builders.
- func (m *AccountGroupMutation) AccountIDs() (ids []int64) {
- if id := m.account; id != nil {
- ids = append(ids, *id)
- }
- return
- }
- // ResetAccount resets all changes to the "account" edge.
- func (m *AccountGroupMutation) ResetAccount() {
- m.account = nil
- m.clearedaccount = false
- }
- // ClearGroup clears the "group" edge to the Group entity.
- func (m *AccountGroupMutation) ClearGroup() {
- m.clearedgroup = true
- m.clearedFields[accountgroup.FieldGroupID] = struct{}{}
- }
- // GroupCleared reports if the "group" edge to the Group entity was cleared.
- func (m *AccountGroupMutation) GroupCleared() bool {
- return m.clearedgroup
- }
- // GroupIDs returns the "group" edge IDs in the mutation.
- // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
- // GroupID instead. It exists only for internal usage by the builders.
- func (m *AccountGroupMutation) GroupIDs() (ids []int64) {
- if id := m.group; id != nil {
- ids = append(ids, *id)
- }
- return
- }
- // ResetGroup resets all changes to the "group" edge.
- func (m *AccountGroupMutation) ResetGroup() {
- m.group = nil
- m.clearedgroup = false
- }
- // Where appends a list predicates to the AccountGroupMutation builder.
- func (m *AccountGroupMutation) Where(ps ...predicate.AccountGroup) {
- m.predicates = append(m.predicates, ps...)
- }
- // WhereP appends storage-level predicates to the AccountGroupMutation builder. Using this method,
- // users can use type-assertion to append predicates that do not depend on any generated package.
- func (m *AccountGroupMutation) WhereP(ps ...func(*sql.Selector)) {
- p := make([]predicate.AccountGroup, len(ps))
- for i := range ps {
- p[i] = ps[i]
- }
- m.Where(p...)
- }
- // Op returns the operation name.
- func (m *AccountGroupMutation) Op() Op {
- return m.op
- }
- // SetOp allows setting the mutation operation.
- func (m *AccountGroupMutation) SetOp(op Op) {
- m.op = op
- }
- // Type returns the node type of this mutation (AccountGroup).
- func (m *AccountGroupMutation) Type() string {
- return m.typ
- }
- // Fields returns all fields that were changed during this mutation. Note that in
- // order to get all numeric fields that were incremented/decremented, call
- // AddedFields().
- func (m *AccountGroupMutation) Fields() []string {
- fields := make([]string, 0, 4)
- if m.account != nil {
- fields = append(fields, accountgroup.FieldAccountID)
- }
- if m.group != nil {
- fields = append(fields, accountgroup.FieldGroupID)
- }
- if m.priority != nil {
- fields = append(fields, accountgroup.FieldPriority)
- }
- if m.created_at != nil {
- fields = append(fields, accountgroup.FieldCreatedAt)
- }
- return fields
- }
- // Field returns the value of a field with the given name. The second boolean
- // return value indicates that this field was not set, or was not defined in the
- // schema.
- func (m *AccountGroupMutation) Field(name string) (ent.Value, bool) {
- switch name {
- case accountgroup.FieldAccountID:
- return m.AccountID()
- case accountgroup.FieldGroupID:
- return m.GroupID()
- case accountgroup.FieldPriority:
- return m.Priority()
- case accountgroup.FieldCreatedAt:
- return m.CreatedAt()
- }
- return nil, false
- }
- // OldField returns the old value of the field from the database. An error is
- // returned if the mutation operation is not UpdateOne, or the query to the
- // database failed.
- func (m *AccountGroupMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
- return nil, errors.New("edge schema AccountGroup does not support getting old values")
- }
- // SetField sets the value of a field with the given name. It returns an error if
- // the field is not defined in the schema, or if the type mismatched the field
- // type.
- func (m *AccountGroupMutation) SetField(name string, value ent.Value) error {
- switch name {
- case accountgroup.FieldAccountID:
- v, ok := value.(int64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetAccountID(v)
- return nil
- case accountgroup.FieldGroupID:
- v, ok := value.(int64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetGroupID(v)
- return nil
- case accountgroup.FieldPriority:
- v, ok := value.(int)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetPriority(v)
- return nil
- case accountgroup.FieldCreatedAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetCreatedAt(v)
- return nil
- }
- return fmt.Errorf("unknown AccountGroup field %s", name)
- }
- // AddedFields returns all numeric fields that were incremented/decremented during
- // this mutation.
- func (m *AccountGroupMutation) AddedFields() []string {
- var fields []string
- if m.addpriority != nil {
- fields = append(fields, accountgroup.FieldPriority)
- }
- return fields
- }
- // AddedField returns the numeric value that was incremented/decremented on a field
- // with the given name. The second boolean return value indicates that this field
- // was not set, or was not defined in the schema.
- func (m *AccountGroupMutation) AddedField(name string) (ent.Value, bool) {
- switch name {
- case accountgroup.FieldPriority:
- return m.AddedPriority()
- }
- return nil, false
- }
- // AddField adds the value to the field with the given name. It returns an error if
- // the field is not defined in the schema, or if the type mismatched the field
- // type.
- func (m *AccountGroupMutation) AddField(name string, value ent.Value) error {
- switch name {
- case accountgroup.FieldPriority:
- v, ok := value.(int)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.AddPriority(v)
- return nil
- }
- return fmt.Errorf("unknown AccountGroup numeric field %s", name)
- }
- // ClearedFields returns all nullable fields that were cleared during this
- // mutation.
- func (m *AccountGroupMutation) ClearedFields() []string {
- return nil
- }
- // FieldCleared returns a boolean indicating if a field with the given name was
- // cleared in this mutation.
- func (m *AccountGroupMutation) FieldCleared(name string) bool {
- _, ok := m.clearedFields[name]
- return ok
- }
- // ClearField clears the value of the field with the given name. It returns an
- // error if the field is not defined in the schema.
- func (m *AccountGroupMutation) ClearField(name string) error {
- return fmt.Errorf("unknown AccountGroup nullable field %s", name)
- }
- // ResetField resets all changes in the mutation for the field with the given name.
- // It returns an error if the field is not defined in the schema.
- func (m *AccountGroupMutation) ResetField(name string) error {
- switch name {
- case accountgroup.FieldAccountID:
- m.ResetAccountID()
- return nil
- case accountgroup.FieldGroupID:
- m.ResetGroupID()
- return nil
- case accountgroup.FieldPriority:
- m.ResetPriority()
- return nil
- case accountgroup.FieldCreatedAt:
- m.ResetCreatedAt()
- return nil
- }
- return fmt.Errorf("unknown AccountGroup field %s", name)
- }
- // AddedEdges returns all edge names that were set/added in this mutation.
- func (m *AccountGroupMutation) AddedEdges() []string {
- edges := make([]string, 0, 2)
- if m.account != nil {
- edges = append(edges, accountgroup.EdgeAccount)
- }
- if m.group != nil {
- edges = append(edges, accountgroup.EdgeGroup)
- }
- return edges
- }
- // AddedIDs returns all IDs (to other nodes) that were added for the given edge
- // name in this mutation.
- func (m *AccountGroupMutation) AddedIDs(name string) []ent.Value {
- switch name {
- case accountgroup.EdgeAccount:
- if id := m.account; id != nil {
- return []ent.Value{*id}
- }
- case accountgroup.EdgeGroup:
- if id := m.group; id != nil {
- return []ent.Value{*id}
- }
- }
- return nil
- }
- // RemovedEdges returns all edge names that were removed in this mutation.
- func (m *AccountGroupMutation) RemovedEdges() []string {
- edges := make([]string, 0, 2)
- return edges
- }
- // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
- // the given name in this mutation.
- func (m *AccountGroupMutation) RemovedIDs(name string) []ent.Value {
- return nil
- }
- // ClearedEdges returns all edge names that were cleared in this mutation.
- func (m *AccountGroupMutation) ClearedEdges() []string {
- edges := make([]string, 0, 2)
- if m.clearedaccount {
- edges = append(edges, accountgroup.EdgeAccount)
- }
- if m.clearedgroup {
- edges = append(edges, accountgroup.EdgeGroup)
- }
- return edges
- }
- // EdgeCleared returns a boolean which indicates if the edge with the given name
- // was cleared in this mutation.
- func (m *AccountGroupMutation) EdgeCleared(name string) bool {
- switch name {
- case accountgroup.EdgeAccount:
- return m.clearedaccount
- case accountgroup.EdgeGroup:
- return m.clearedgroup
- }
- return false
- }
- // ClearEdge clears the value of the edge with the given name. It returns an error
- // if that edge is not defined in the schema.
- func (m *AccountGroupMutation) ClearEdge(name string) error {
- switch name {
- case accountgroup.EdgeAccount:
- m.ClearAccount()
- return nil
- case accountgroup.EdgeGroup:
- m.ClearGroup()
- return nil
- }
- return fmt.Errorf("unknown AccountGroup unique edge %s", name)
- }
- // ResetEdge resets all changes to the edge with the given name in this mutation.
- // It returns an error if the edge is not defined in the schema.
- func (m *AccountGroupMutation) ResetEdge(name string) error {
- switch name {
- case accountgroup.EdgeAccount:
- m.ResetAccount()
- return nil
- case accountgroup.EdgeGroup:
- m.ResetGroup()
- return nil
- }
- return fmt.Errorf("unknown AccountGroup edge %s", name)
- }
- // AnnouncementMutation represents an operation that mutates the Announcement nodes in the graph.
- type AnnouncementMutation struct {
- config
- op Op
- typ string
- id *int64
- title *string
- content *string
- status *string
- notify_mode *string
- targeting *domain.AnnouncementTargeting
- starts_at *time.Time
- ends_at *time.Time
- created_by *int64
- addcreated_by *int64
- updated_by *int64
- addupdated_by *int64
- created_at *time.Time
- updated_at *time.Time
- clearedFields map[string]struct{}
- reads map[int64]struct{}
- removedreads map[int64]struct{}
- clearedreads bool
- done bool
- oldValue func(context.Context) (*Announcement, error)
- predicates []predicate.Announcement
- }
- var _ ent.Mutation = (*AnnouncementMutation)(nil)
- // announcementOption allows management of the mutation configuration using functional options.
- type announcementOption func(*AnnouncementMutation)
- // newAnnouncementMutation creates new mutation for the Announcement entity.
- func newAnnouncementMutation(c config, op Op, opts ...announcementOption) *AnnouncementMutation {
- m := &AnnouncementMutation{
- config: c,
- op: op,
- typ: TypeAnnouncement,
- clearedFields: make(map[string]struct{}),
- }
- for _, opt := range opts {
- opt(m)
- }
- return m
- }
- // withAnnouncementID sets the ID field of the mutation.
- func withAnnouncementID(id int64) announcementOption {
- return func(m *AnnouncementMutation) {
- var (
- err error
- once sync.Once
- value *Announcement
- )
- m.oldValue = func(ctx context.Context) (*Announcement, error) {
- once.Do(func() {
- if m.done {
- err = errors.New("querying old values post mutation is not allowed")
- } else {
- value, err = m.Client().Announcement.Get(ctx, id)
- }
- })
- return value, err
- }
- m.id = &id
- }
- }
- // withAnnouncement sets the old Announcement of the mutation.
- func withAnnouncement(node *Announcement) announcementOption {
- return func(m *AnnouncementMutation) {
- m.oldValue = func(context.Context) (*Announcement, error) {
- return node, nil
- }
- m.id = &node.ID
- }
- }
- // Client returns a new `ent.Client` from the mutation. If the mutation was
- // executed in a transaction (ent.Tx), a transactional client is returned.
- func (m AnnouncementMutation) Client() *Client {
- client := &Client{config: m.config}
- client.init()
- return client
- }
- // Tx returns an `ent.Tx` for mutations that were executed in transactions;
- // it returns an error otherwise.
- func (m AnnouncementMutation) Tx() (*Tx, error) {
- if _, ok := m.driver.(*txDriver); !ok {
- return nil, errors.New("ent: mutation is not running in a transaction")
- }
- tx := &Tx{config: m.config}
- tx.init()
- return tx, nil
- }
- // ID returns the ID value in the mutation. Note that the ID is only available
- // if it was provided to the builder or after it was returned from the database.
- func (m *AnnouncementMutation) ID() (id int64, exists bool) {
- if m.id == nil {
- return
- }
- return *m.id, true
- }
- // IDs queries the database and returns the entity ids that match the mutation's predicate.
- // That means, if the mutation is applied within a transaction with an isolation level such
- // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
- // or updated by the mutation.
- func (m *AnnouncementMutation) IDs(ctx context.Context) ([]int64, error) {
- switch {
- case m.op.Is(OpUpdateOne | OpDeleteOne):
- id, exists := m.ID()
- if exists {
- return []int64{id}, nil
- }
- fallthrough
- case m.op.Is(OpUpdate | OpDelete):
- return m.Client().Announcement.Query().Where(m.predicates...).IDs(ctx)
- default:
- return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
- }
- }
- // SetTitle sets the "title" field.
- func (m *AnnouncementMutation) SetTitle(s string) {
- m.title = &s
- }
- // Title returns the value of the "title" field in the mutation.
- func (m *AnnouncementMutation) Title() (r string, exists bool) {
- v := m.title
- if v == nil {
- return
- }
- return *v, true
- }
- // OldTitle returns the old "title" field's value of the Announcement entity.
- // If the Announcement object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *AnnouncementMutation) OldTitle(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldTitle is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldTitle requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldTitle: %w", err)
- }
- return oldValue.Title, nil
- }
- // ResetTitle resets all changes to the "title" field.
- func (m *AnnouncementMutation) ResetTitle() {
- m.title = nil
- }
- // SetContent sets the "content" field.
- func (m *AnnouncementMutation) SetContent(s string) {
- m.content = &s
- }
- // Content returns the value of the "content" field in the mutation.
- func (m *AnnouncementMutation) Content() (r string, exists bool) {
- v := m.content
- if v == nil {
- return
- }
- return *v, true
- }
- // OldContent returns the old "content" field's value of the Announcement entity.
- // If the Announcement object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *AnnouncementMutation) OldContent(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldContent is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldContent requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldContent: %w", err)
- }
- return oldValue.Content, nil
- }
- // ResetContent resets all changes to the "content" field.
- func (m *AnnouncementMutation) ResetContent() {
- m.content = nil
- }
- // SetStatus sets the "status" field.
- func (m *AnnouncementMutation) SetStatus(s string) {
- m.status = &s
- }
- // Status returns the value of the "status" field in the mutation.
- func (m *AnnouncementMutation) Status() (r string, exists bool) {
- v := m.status
- if v == nil {
- return
- }
- return *v, true
- }
- // OldStatus returns the old "status" field's value of the Announcement entity.
- // If the Announcement object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *AnnouncementMutation) OldStatus(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldStatus is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldStatus requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldStatus: %w", err)
- }
- return oldValue.Status, nil
- }
- // ResetStatus resets all changes to the "status" field.
- func (m *AnnouncementMutation) ResetStatus() {
- m.status = nil
- }
- // SetNotifyMode sets the "notify_mode" field.
- func (m *AnnouncementMutation) SetNotifyMode(s string) {
- m.notify_mode = &s
- }
- // NotifyMode returns the value of the "notify_mode" field in the mutation.
- func (m *AnnouncementMutation) NotifyMode() (r string, exists bool) {
- v := m.notify_mode
- if v == nil {
- return
- }
- return *v, true
- }
- // OldNotifyMode returns the old "notify_mode" field's value of the Announcement entity.
- // If the Announcement object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *AnnouncementMutation) OldNotifyMode(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldNotifyMode is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldNotifyMode requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldNotifyMode: %w", err)
- }
- return oldValue.NotifyMode, nil
- }
- // ResetNotifyMode resets all changes to the "notify_mode" field.
- func (m *AnnouncementMutation) ResetNotifyMode() {
- m.notify_mode = nil
- }
- // SetTargeting sets the "targeting" field.
- func (m *AnnouncementMutation) SetTargeting(dt domain.AnnouncementTargeting) {
- m.targeting = &dt
- }
- // Targeting returns the value of the "targeting" field in the mutation.
- func (m *AnnouncementMutation) Targeting() (r domain.AnnouncementTargeting, exists bool) {
- v := m.targeting
- if v == nil {
- return
- }
- return *v, true
- }
- // OldTargeting returns the old "targeting" field's value of the Announcement entity.
- // If the Announcement object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *AnnouncementMutation) OldTargeting(ctx context.Context) (v domain.AnnouncementTargeting, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldTargeting is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldTargeting requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldTargeting: %w", err)
- }
- return oldValue.Targeting, nil
- }
- // ClearTargeting clears the value of the "targeting" field.
- func (m *AnnouncementMutation) ClearTargeting() {
- m.targeting = nil
- m.clearedFields[announcement.FieldTargeting] = struct{}{}
- }
- // TargetingCleared returns if the "targeting" field was cleared in this mutation.
- func (m *AnnouncementMutation) TargetingCleared() bool {
- _, ok := m.clearedFields[announcement.FieldTargeting]
- return ok
- }
- // ResetTargeting resets all changes to the "targeting" field.
- func (m *AnnouncementMutation) ResetTargeting() {
- m.targeting = nil
- delete(m.clearedFields, announcement.FieldTargeting)
- }
- // SetStartsAt sets the "starts_at" field.
- func (m *AnnouncementMutation) SetStartsAt(t time.Time) {
- m.starts_at = &t
- }
- // StartsAt returns the value of the "starts_at" field in the mutation.
- func (m *AnnouncementMutation) StartsAt() (r time.Time, exists bool) {
- v := m.starts_at
- if v == nil {
- return
- }
- return *v, true
- }
- // OldStartsAt returns the old "starts_at" field's value of the Announcement entity.
- // If the Announcement object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *AnnouncementMutation) OldStartsAt(ctx context.Context) (v *time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldStartsAt is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldStartsAt requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldStartsAt: %w", err)
- }
- return oldValue.StartsAt, nil
- }
- // ClearStartsAt clears the value of the "starts_at" field.
- func (m *AnnouncementMutation) ClearStartsAt() {
- m.starts_at = nil
- m.clearedFields[announcement.FieldStartsAt] = struct{}{}
- }
- // StartsAtCleared returns if the "starts_at" field was cleared in this mutation.
- func (m *AnnouncementMutation) StartsAtCleared() bool {
- _, ok := m.clearedFields[announcement.FieldStartsAt]
- return ok
- }
- // ResetStartsAt resets all changes to the "starts_at" field.
- func (m *AnnouncementMutation) ResetStartsAt() {
- m.starts_at = nil
- delete(m.clearedFields, announcement.FieldStartsAt)
- }
- // SetEndsAt sets the "ends_at" field.
- func (m *AnnouncementMutation) SetEndsAt(t time.Time) {
- m.ends_at = &t
- }
- // EndsAt returns the value of the "ends_at" field in the mutation.
- func (m *AnnouncementMutation) EndsAt() (r time.Time, exists bool) {
- v := m.ends_at
- if v == nil {
- return
- }
- return *v, true
- }
- // OldEndsAt returns the old "ends_at" field's value of the Announcement entity.
- // If the Announcement object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *AnnouncementMutation) OldEndsAt(ctx context.Context) (v *time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldEndsAt is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldEndsAt requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldEndsAt: %w", err)
- }
- return oldValue.EndsAt, nil
- }
- // ClearEndsAt clears the value of the "ends_at" field.
- func (m *AnnouncementMutation) ClearEndsAt() {
- m.ends_at = nil
- m.clearedFields[announcement.FieldEndsAt] = struct{}{}
- }
- // EndsAtCleared returns if the "ends_at" field was cleared in this mutation.
- func (m *AnnouncementMutation) EndsAtCleared() bool {
- _, ok := m.clearedFields[announcement.FieldEndsAt]
- return ok
- }
- // ResetEndsAt resets all changes to the "ends_at" field.
- func (m *AnnouncementMutation) ResetEndsAt() {
- m.ends_at = nil
- delete(m.clearedFields, announcement.FieldEndsAt)
- }
- // SetCreatedBy sets the "created_by" field.
- func (m *AnnouncementMutation) SetCreatedBy(i int64) {
- m.created_by = &i
- m.addcreated_by = nil
- }
- // CreatedBy returns the value of the "created_by" field in the mutation.
- func (m *AnnouncementMutation) CreatedBy() (r int64, exists bool) {
- v := m.created_by
- if v == nil {
- return
- }
- return *v, true
- }
- // OldCreatedBy returns the old "created_by" field's value of the Announcement entity.
- // If the Announcement object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *AnnouncementMutation) OldCreatedBy(ctx context.Context) (v *int64, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldCreatedBy is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldCreatedBy requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldCreatedBy: %w", err)
- }
- return oldValue.CreatedBy, nil
- }
- // AddCreatedBy adds i to the "created_by" field.
- func (m *AnnouncementMutation) AddCreatedBy(i int64) {
- if m.addcreated_by != nil {
- *m.addcreated_by += i
- } else {
- m.addcreated_by = &i
- }
- }
- // AddedCreatedBy returns the value that was added to the "created_by" field in this mutation.
- func (m *AnnouncementMutation) AddedCreatedBy() (r int64, exists bool) {
- v := m.addcreated_by
- if v == nil {
- return
- }
- return *v, true
- }
- // ClearCreatedBy clears the value of the "created_by" field.
- func (m *AnnouncementMutation) ClearCreatedBy() {
- m.created_by = nil
- m.addcreated_by = nil
- m.clearedFields[announcement.FieldCreatedBy] = struct{}{}
- }
- // CreatedByCleared returns if the "created_by" field was cleared in this mutation.
- func (m *AnnouncementMutation) CreatedByCleared() bool {
- _, ok := m.clearedFields[announcement.FieldCreatedBy]
- return ok
- }
- // ResetCreatedBy resets all changes to the "created_by" field.
- func (m *AnnouncementMutation) ResetCreatedBy() {
- m.created_by = nil
- m.addcreated_by = nil
- delete(m.clearedFields, announcement.FieldCreatedBy)
- }
- // SetUpdatedBy sets the "updated_by" field.
- func (m *AnnouncementMutation) SetUpdatedBy(i int64) {
- m.updated_by = &i
- m.addupdated_by = nil
- }
- // UpdatedBy returns the value of the "updated_by" field in the mutation.
- func (m *AnnouncementMutation) UpdatedBy() (r int64, exists bool) {
- v := m.updated_by
- if v == nil {
- return
- }
- return *v, true
- }
- // OldUpdatedBy returns the old "updated_by" field's value of the Announcement entity.
- // If the Announcement object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *AnnouncementMutation) OldUpdatedBy(ctx context.Context) (v *int64, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldUpdatedBy is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldUpdatedBy requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldUpdatedBy: %w", err)
- }
- return oldValue.UpdatedBy, nil
- }
- // AddUpdatedBy adds i to the "updated_by" field.
- func (m *AnnouncementMutation) AddUpdatedBy(i int64) {
- if m.addupdated_by != nil {
- *m.addupdated_by += i
- } else {
- m.addupdated_by = &i
- }
- }
- // AddedUpdatedBy returns the value that was added to the "updated_by" field in this mutation.
- func (m *AnnouncementMutation) AddedUpdatedBy() (r int64, exists bool) {
- v := m.addupdated_by
- if v == nil {
- return
- }
- return *v, true
- }
- // ClearUpdatedBy clears the value of the "updated_by" field.
- func (m *AnnouncementMutation) ClearUpdatedBy() {
- m.updated_by = nil
- m.addupdated_by = nil
- m.clearedFields[announcement.FieldUpdatedBy] = struct{}{}
- }
- // UpdatedByCleared returns if the "updated_by" field was cleared in this mutation.
- func (m *AnnouncementMutation) UpdatedByCleared() bool {
- _, ok := m.clearedFields[announcement.FieldUpdatedBy]
- return ok
- }
- // ResetUpdatedBy resets all changes to the "updated_by" field.
- func (m *AnnouncementMutation) ResetUpdatedBy() {
- m.updated_by = nil
- m.addupdated_by = nil
- delete(m.clearedFields, announcement.FieldUpdatedBy)
- }
- // SetCreatedAt sets the "created_at" field.
- func (m *AnnouncementMutation) SetCreatedAt(t time.Time) {
- m.created_at = &t
- }
- // CreatedAt returns the value of the "created_at" field in the mutation.
- func (m *AnnouncementMutation) CreatedAt() (r time.Time, exists bool) {
- v := m.created_at
- if v == nil {
- return
- }
- return *v, true
- }
- // OldCreatedAt returns the old "created_at" field's value of the Announcement entity.
- // If the Announcement object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *AnnouncementMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldCreatedAt requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
- }
- return oldValue.CreatedAt, nil
- }
- // ResetCreatedAt resets all changes to the "created_at" field.
- func (m *AnnouncementMutation) ResetCreatedAt() {
- m.created_at = nil
- }
- // SetUpdatedAt sets the "updated_at" field.
- func (m *AnnouncementMutation) SetUpdatedAt(t time.Time) {
- m.updated_at = &t
- }
- // UpdatedAt returns the value of the "updated_at" field in the mutation.
- func (m *AnnouncementMutation) UpdatedAt() (r time.Time, exists bool) {
- v := m.updated_at
- if v == nil {
- return
- }
- return *v, true
- }
- // OldUpdatedAt returns the old "updated_at" field's value of the Announcement entity.
- // If the Announcement object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *AnnouncementMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
- }
- return oldValue.UpdatedAt, nil
- }
- // ResetUpdatedAt resets all changes to the "updated_at" field.
- func (m *AnnouncementMutation) ResetUpdatedAt() {
- m.updated_at = nil
- }
- // AddReadIDs adds the "reads" edge to the AnnouncementRead entity by ids.
- func (m *AnnouncementMutation) AddReadIDs(ids ...int64) {
- if m.reads == nil {
- m.reads = make(map[int64]struct{})
- }
- for i := range ids {
- m.reads[ids[i]] = struct{}{}
- }
- }
- // ClearReads clears the "reads" edge to the AnnouncementRead entity.
- func (m *AnnouncementMutation) ClearReads() {
- m.clearedreads = true
- }
- // ReadsCleared reports if the "reads" edge to the AnnouncementRead entity was cleared.
- func (m *AnnouncementMutation) ReadsCleared() bool {
- return m.clearedreads
- }
- // RemoveReadIDs removes the "reads" edge to the AnnouncementRead entity by IDs.
- func (m *AnnouncementMutation) RemoveReadIDs(ids ...int64) {
- if m.removedreads == nil {
- m.removedreads = make(map[int64]struct{})
- }
- for i := range ids {
- delete(m.reads, ids[i])
- m.removedreads[ids[i]] = struct{}{}
- }
- }
- // RemovedReads returns the removed IDs of the "reads" edge to the AnnouncementRead entity.
- func (m *AnnouncementMutation) RemovedReadsIDs() (ids []int64) {
- for id := range m.removedreads {
- ids = append(ids, id)
- }
- return
- }
- // ReadsIDs returns the "reads" edge IDs in the mutation.
- func (m *AnnouncementMutation) ReadsIDs() (ids []int64) {
- for id := range m.reads {
- ids = append(ids, id)
- }
- return
- }
- // ResetReads resets all changes to the "reads" edge.
- func (m *AnnouncementMutation) ResetReads() {
- m.reads = nil
- m.clearedreads = false
- m.removedreads = nil
- }
- // Where appends a list predicates to the AnnouncementMutation builder.
- func (m *AnnouncementMutation) Where(ps ...predicate.Announcement) {
- m.predicates = append(m.predicates, ps...)
- }
- // WhereP appends storage-level predicates to the AnnouncementMutation builder. Using this method,
- // users can use type-assertion to append predicates that do not depend on any generated package.
- func (m *AnnouncementMutation) WhereP(ps ...func(*sql.Selector)) {
- p := make([]predicate.Announcement, len(ps))
- for i := range ps {
- p[i] = ps[i]
- }
- m.Where(p...)
- }
- // Op returns the operation name.
- func (m *AnnouncementMutation) Op() Op {
- return m.op
- }
- // SetOp allows setting the mutation operation.
- func (m *AnnouncementMutation) SetOp(op Op) {
- m.op = op
- }
- // Type returns the node type of this mutation (Announcement).
- func (m *AnnouncementMutation) Type() string {
- return m.typ
- }
- // Fields returns all fields that were changed during this mutation. Note that in
- // order to get all numeric fields that were incremented/decremented, call
- // AddedFields().
- func (m *AnnouncementMutation) Fields() []string {
- fields := make([]string, 0, 11)
- if m.title != nil {
- fields = append(fields, announcement.FieldTitle)
- }
- if m.content != nil {
- fields = append(fields, announcement.FieldContent)
- }
- if m.status != nil {
- fields = append(fields, announcement.FieldStatus)
- }
- if m.notify_mode != nil {
- fields = append(fields, announcement.FieldNotifyMode)
- }
- if m.targeting != nil {
- fields = append(fields, announcement.FieldTargeting)
- }
- if m.starts_at != nil {
- fields = append(fields, announcement.FieldStartsAt)
- }
- if m.ends_at != nil {
- fields = append(fields, announcement.FieldEndsAt)
- }
- if m.created_by != nil {
- fields = append(fields, announcement.FieldCreatedBy)
- }
- if m.updated_by != nil {
- fields = append(fields, announcement.FieldUpdatedBy)
- }
- if m.created_at != nil {
- fields = append(fields, announcement.FieldCreatedAt)
- }
- if m.updated_at != nil {
- fields = append(fields, announcement.FieldUpdatedAt)
- }
- return fields
- }
- // Field returns the value of a field with the given name. The second boolean
- // return value indicates that this field was not set, or was not defined in the
- // schema.
- func (m *AnnouncementMutation) Field(name string) (ent.Value, bool) {
- switch name {
- case announcement.FieldTitle:
- return m.Title()
- case announcement.FieldContent:
- return m.Content()
- case announcement.FieldStatus:
- return m.Status()
- case announcement.FieldNotifyMode:
- return m.NotifyMode()
- case announcement.FieldTargeting:
- return m.Targeting()
- case announcement.FieldStartsAt:
- return m.StartsAt()
- case announcement.FieldEndsAt:
- return m.EndsAt()
- case announcement.FieldCreatedBy:
- return m.CreatedBy()
- case announcement.FieldUpdatedBy:
- return m.UpdatedBy()
- case announcement.FieldCreatedAt:
- return m.CreatedAt()
- case announcement.FieldUpdatedAt:
- return m.UpdatedAt()
- }
- return nil, false
- }
- // OldField returns the old value of the field from the database. An error is
- // returned if the mutation operation is not UpdateOne, or the query to the
- // database failed.
- func (m *AnnouncementMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
- switch name {
- case announcement.FieldTitle:
- return m.OldTitle(ctx)
- case announcement.FieldContent:
- return m.OldContent(ctx)
- case announcement.FieldStatus:
- return m.OldStatus(ctx)
- case announcement.FieldNotifyMode:
- return m.OldNotifyMode(ctx)
- case announcement.FieldTargeting:
- return m.OldTargeting(ctx)
- case announcement.FieldStartsAt:
- return m.OldStartsAt(ctx)
- case announcement.FieldEndsAt:
- return m.OldEndsAt(ctx)
- case announcement.FieldCreatedBy:
- return m.OldCreatedBy(ctx)
- case announcement.FieldUpdatedBy:
- return m.OldUpdatedBy(ctx)
- case announcement.FieldCreatedAt:
- return m.OldCreatedAt(ctx)
- case announcement.FieldUpdatedAt:
- return m.OldUpdatedAt(ctx)
- }
- return nil, fmt.Errorf("unknown Announcement field %s", name)
- }
- // SetField sets the value of a field with the given name. It returns an error if
- // the field is not defined in the schema, or if the type mismatched the field
- // type.
- func (m *AnnouncementMutation) SetField(name string, value ent.Value) error {
- switch name {
- case announcement.FieldTitle:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetTitle(v)
- return nil
- case announcement.FieldContent:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetContent(v)
- return nil
- case announcement.FieldStatus:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetStatus(v)
- return nil
- case announcement.FieldNotifyMode:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetNotifyMode(v)
- return nil
- case announcement.FieldTargeting:
- v, ok := value.(domain.AnnouncementTargeting)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetTargeting(v)
- return nil
- case announcement.FieldStartsAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetStartsAt(v)
- return nil
- case announcement.FieldEndsAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetEndsAt(v)
- return nil
- case announcement.FieldCreatedBy:
- v, ok := value.(int64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetCreatedBy(v)
- return nil
- case announcement.FieldUpdatedBy:
- v, ok := value.(int64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetUpdatedBy(v)
- return nil
- case announcement.FieldCreatedAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetCreatedAt(v)
- return nil
- case announcement.FieldUpdatedAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetUpdatedAt(v)
- return nil
- }
- return fmt.Errorf("unknown Announcement field %s", name)
- }
- // AddedFields returns all numeric fields that were incremented/decremented during
- // this mutation.
- func (m *AnnouncementMutation) AddedFields() []string {
- var fields []string
- if m.addcreated_by != nil {
- fields = append(fields, announcement.FieldCreatedBy)
- }
- if m.addupdated_by != nil {
- fields = append(fields, announcement.FieldUpdatedBy)
- }
- return fields
- }
- // AddedField returns the numeric value that was incremented/decremented on a field
- // with the given name. The second boolean return value indicates that this field
- // was not set, or was not defined in the schema.
- func (m *AnnouncementMutation) AddedField(name string) (ent.Value, bool) {
- switch name {
- case announcement.FieldCreatedBy:
- return m.AddedCreatedBy()
- case announcement.FieldUpdatedBy:
- return m.AddedUpdatedBy()
- }
- return nil, false
- }
- // AddField adds the value to the field with the given name. It returns an error if
- // the field is not defined in the schema, or if the type mismatched the field
- // type.
- func (m *AnnouncementMutation) AddField(name string, value ent.Value) error {
- switch name {
- case announcement.FieldCreatedBy:
- v, ok := value.(int64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.AddCreatedBy(v)
- return nil
- case announcement.FieldUpdatedBy:
- v, ok := value.(int64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.AddUpdatedBy(v)
- return nil
- }
- return fmt.Errorf("unknown Announcement numeric field %s", name)
- }
- // ClearedFields returns all nullable fields that were cleared during this
- // mutation.
- func (m *AnnouncementMutation) ClearedFields() []string {
- var fields []string
- if m.FieldCleared(announcement.FieldTargeting) {
- fields = append(fields, announcement.FieldTargeting)
- }
- if m.FieldCleared(announcement.FieldStartsAt) {
- fields = append(fields, announcement.FieldStartsAt)
- }
- if m.FieldCleared(announcement.FieldEndsAt) {
- fields = append(fields, announcement.FieldEndsAt)
- }
- if m.FieldCleared(announcement.FieldCreatedBy) {
- fields = append(fields, announcement.FieldCreatedBy)
- }
- if m.FieldCleared(announcement.FieldUpdatedBy) {
- fields = append(fields, announcement.FieldUpdatedBy)
- }
- return fields
- }
- // FieldCleared returns a boolean indicating if a field with the given name was
- // cleared in this mutation.
- func (m *AnnouncementMutation) FieldCleared(name string) bool {
- _, ok := m.clearedFields[name]
- return ok
- }
- // ClearField clears the value of the field with the given name. It returns an
- // error if the field is not defined in the schema.
- func (m *AnnouncementMutation) ClearField(name string) error {
- switch name {
- case announcement.FieldTargeting:
- m.ClearTargeting()
- return nil
- case announcement.FieldStartsAt:
- m.ClearStartsAt()
- return nil
- case announcement.FieldEndsAt:
- m.ClearEndsAt()
- return nil
- case announcement.FieldCreatedBy:
- m.ClearCreatedBy()
- return nil
- case announcement.FieldUpdatedBy:
- m.ClearUpdatedBy()
- return nil
- }
- return fmt.Errorf("unknown Announcement nullable field %s", name)
- }
- // ResetField resets all changes in the mutation for the field with the given name.
- // It returns an error if the field is not defined in the schema.
- func (m *AnnouncementMutation) ResetField(name string) error {
- switch name {
- case announcement.FieldTitle:
- m.ResetTitle()
- return nil
- case announcement.FieldContent:
- m.ResetContent()
- return nil
- case announcement.FieldStatus:
- m.ResetStatus()
- return nil
- case announcement.FieldNotifyMode:
- m.ResetNotifyMode()
- return nil
- case announcement.FieldTargeting:
- m.ResetTargeting()
- return nil
- case announcement.FieldStartsAt:
- m.ResetStartsAt()
- return nil
- case announcement.FieldEndsAt:
- m.ResetEndsAt()
- return nil
- case announcement.FieldCreatedBy:
- m.ResetCreatedBy()
- return nil
- case announcement.FieldUpdatedBy:
- m.ResetUpdatedBy()
- return nil
- case announcement.FieldCreatedAt:
- m.ResetCreatedAt()
- return nil
- case announcement.FieldUpdatedAt:
- m.ResetUpdatedAt()
- return nil
- }
- return fmt.Errorf("unknown Announcement field %s", name)
- }
- // AddedEdges returns all edge names that were set/added in this mutation.
- func (m *AnnouncementMutation) AddedEdges() []string {
- edges := make([]string, 0, 1)
- if m.reads != nil {
- edges = append(edges, announcement.EdgeReads)
- }
- return edges
- }
- // AddedIDs returns all IDs (to other nodes) that were added for the given edge
- // name in this mutation.
- func (m *AnnouncementMutation) AddedIDs(name string) []ent.Value {
- switch name {
- case announcement.EdgeReads:
- ids := make([]ent.Value, 0, len(m.reads))
- for id := range m.reads {
- ids = append(ids, id)
- }
- return ids
- }
- return nil
- }
- // RemovedEdges returns all edge names that were removed in this mutation.
- func (m *AnnouncementMutation) RemovedEdges() []string {
- edges := make([]string, 0, 1)
- if m.removedreads != nil {
- edges = append(edges, announcement.EdgeReads)
- }
- return edges
- }
- // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
- // the given name in this mutation.
- func (m *AnnouncementMutation) RemovedIDs(name string) []ent.Value {
- switch name {
- case announcement.EdgeReads:
- ids := make([]ent.Value, 0, len(m.removedreads))
- for id := range m.removedreads {
- ids = append(ids, id)
- }
- return ids
- }
- return nil
- }
- // ClearedEdges returns all edge names that were cleared in this mutation.
- func (m *AnnouncementMutation) ClearedEdges() []string {
- edges := make([]string, 0, 1)
- if m.clearedreads {
- edges = append(edges, announcement.EdgeReads)
- }
- return edges
- }
- // EdgeCleared returns a boolean which indicates if the edge with the given name
- // was cleared in this mutation.
- func (m *AnnouncementMutation) EdgeCleared(name string) bool {
- switch name {
- case announcement.EdgeReads:
- return m.clearedreads
- }
- return false
- }
- // ClearEdge clears the value of the edge with the given name. It returns an error
- // if that edge is not defined in the schema.
- func (m *AnnouncementMutation) ClearEdge(name string) error {
- switch name {
- }
- return fmt.Errorf("unknown Announcement unique edge %s", name)
- }
- // ResetEdge resets all changes to the edge with the given name in this mutation.
- // It returns an error if the edge is not defined in the schema.
- func (m *AnnouncementMutation) ResetEdge(name string) error {
- switch name {
- case announcement.EdgeReads:
- m.ResetReads()
- return nil
- }
- return fmt.Errorf("unknown Announcement edge %s", name)
- }
- // AnnouncementReadMutation represents an operation that mutates the AnnouncementRead nodes in the graph.
- type AnnouncementReadMutation struct {
- config
- op Op
- typ string
- id *int64
- read_at *time.Time
- created_at *time.Time
- clearedFields map[string]struct{}
- announcement *int64
- clearedannouncement bool
- user *int64
- cleareduser bool
- done bool
- oldValue func(context.Context) (*AnnouncementRead, error)
- predicates []predicate.AnnouncementRead
- }
- var _ ent.Mutation = (*AnnouncementReadMutation)(nil)
- // announcementreadOption allows management of the mutation configuration using functional options.
- type announcementreadOption func(*AnnouncementReadMutation)
- // newAnnouncementReadMutation creates new mutation for the AnnouncementRead entity.
- func newAnnouncementReadMutation(c config, op Op, opts ...announcementreadOption) *AnnouncementReadMutation {
- m := &AnnouncementReadMutation{
- config: c,
- op: op,
- typ: TypeAnnouncementRead,
- clearedFields: make(map[string]struct{}),
- }
- for _, opt := range opts {
- opt(m)
- }
- return m
- }
- // withAnnouncementReadID sets the ID field of the mutation.
- func withAnnouncementReadID(id int64) announcementreadOption {
- return func(m *AnnouncementReadMutation) {
- var (
- err error
- once sync.Once
- value *AnnouncementRead
- )
- m.oldValue = func(ctx context.Context) (*AnnouncementRead, error) {
- once.Do(func() {
- if m.done {
- err = errors.New("querying old values post mutation is not allowed")
- } else {
- value, err = m.Client().AnnouncementRead.Get(ctx, id)
- }
- })
- return value, err
- }
- m.id = &id
- }
- }
- // withAnnouncementRead sets the old AnnouncementRead of the mutation.
- func withAnnouncementRead(node *AnnouncementRead) announcementreadOption {
- return func(m *AnnouncementReadMutation) {
- m.oldValue = func(context.Context) (*AnnouncementRead, error) {
- return node, nil
- }
- m.id = &node.ID
- }
- }
- // Client returns a new `ent.Client` from the mutation. If the mutation was
- // executed in a transaction (ent.Tx), a transactional client is returned.
- func (m AnnouncementReadMutation) Client() *Client {
- client := &Client{config: m.config}
- client.init()
- return client
- }
- // Tx returns an `ent.Tx` for mutations that were executed in transactions;
- // it returns an error otherwise.
- func (m AnnouncementReadMutation) Tx() (*Tx, error) {
- if _, ok := m.driver.(*txDriver); !ok {
- return nil, errors.New("ent: mutation is not running in a transaction")
- }
- tx := &Tx{config: m.config}
- tx.init()
- return tx, nil
- }
- // ID returns the ID value in the mutation. Note that the ID is only available
- // if it was provided to the builder or after it was returned from the database.
- func (m *AnnouncementReadMutation) ID() (id int64, exists bool) {
- if m.id == nil {
- return
- }
- return *m.id, true
- }
- // IDs queries the database and returns the entity ids that match the mutation's predicate.
- // That means, if the mutation is applied within a transaction with an isolation level such
- // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
- // or updated by the mutation.
- func (m *AnnouncementReadMutation) IDs(ctx context.Context) ([]int64, error) {
- switch {
- case m.op.Is(OpUpdateOne | OpDeleteOne):
- id, exists := m.ID()
- if exists {
- return []int64{id}, nil
- }
- fallthrough
- case m.op.Is(OpUpdate | OpDelete):
- return m.Client().AnnouncementRead.Query().Where(m.predicates...).IDs(ctx)
- default:
- return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
- }
- }
- // SetAnnouncementID sets the "announcement_id" field.
- func (m *AnnouncementReadMutation) SetAnnouncementID(i int64) {
- m.announcement = &i
- }
- // AnnouncementID returns the value of the "announcement_id" field in the mutation.
- func (m *AnnouncementReadMutation) AnnouncementID() (r int64, exists bool) {
- v := m.announcement
- if v == nil {
- return
- }
- return *v, true
- }
- // OldAnnouncementID returns the old "announcement_id" field's value of the AnnouncementRead entity.
- // If the AnnouncementRead object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *AnnouncementReadMutation) OldAnnouncementID(ctx context.Context) (v int64, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldAnnouncementID is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldAnnouncementID requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldAnnouncementID: %w", err)
- }
- return oldValue.AnnouncementID, nil
- }
- // ResetAnnouncementID resets all changes to the "announcement_id" field.
- func (m *AnnouncementReadMutation) ResetAnnouncementID() {
- m.announcement = nil
- }
- // SetUserID sets the "user_id" field.
- func (m *AnnouncementReadMutation) SetUserID(i int64) {
- m.user = &i
- }
- // UserID returns the value of the "user_id" field in the mutation.
- func (m *AnnouncementReadMutation) UserID() (r int64, exists bool) {
- v := m.user
- if v == nil {
- return
- }
- return *v, true
- }
- // OldUserID returns the old "user_id" field's value of the AnnouncementRead entity.
- // If the AnnouncementRead object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *AnnouncementReadMutation) OldUserID(ctx context.Context) (v int64, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldUserID is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldUserID requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldUserID: %w", err)
- }
- return oldValue.UserID, nil
- }
- // ResetUserID resets all changes to the "user_id" field.
- func (m *AnnouncementReadMutation) ResetUserID() {
- m.user = nil
- }
- // SetReadAt sets the "read_at" field.
- func (m *AnnouncementReadMutation) SetReadAt(t time.Time) {
- m.read_at = &t
- }
- // ReadAt returns the value of the "read_at" field in the mutation.
- func (m *AnnouncementReadMutation) ReadAt() (r time.Time, exists bool) {
- v := m.read_at
- if v == nil {
- return
- }
- return *v, true
- }
- // OldReadAt returns the old "read_at" field's value of the AnnouncementRead entity.
- // If the AnnouncementRead object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *AnnouncementReadMutation) OldReadAt(ctx context.Context) (v time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldReadAt is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldReadAt requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldReadAt: %w", err)
- }
- return oldValue.ReadAt, nil
- }
- // ResetReadAt resets all changes to the "read_at" field.
- func (m *AnnouncementReadMutation) ResetReadAt() {
- m.read_at = nil
- }
- // SetCreatedAt sets the "created_at" field.
- func (m *AnnouncementReadMutation) SetCreatedAt(t time.Time) {
- m.created_at = &t
- }
- // CreatedAt returns the value of the "created_at" field in the mutation.
- func (m *AnnouncementReadMutation) CreatedAt() (r time.Time, exists bool) {
- v := m.created_at
- if v == nil {
- return
- }
- return *v, true
- }
- // OldCreatedAt returns the old "created_at" field's value of the AnnouncementRead entity.
- // If the AnnouncementRead object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *AnnouncementReadMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldCreatedAt requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
- }
- return oldValue.CreatedAt, nil
- }
- // ResetCreatedAt resets all changes to the "created_at" field.
- func (m *AnnouncementReadMutation) ResetCreatedAt() {
- m.created_at = nil
- }
- // ClearAnnouncement clears the "announcement" edge to the Announcement entity.
- func (m *AnnouncementReadMutation) ClearAnnouncement() {
- m.clearedannouncement = true
- m.clearedFields[announcementread.FieldAnnouncementID] = struct{}{}
- }
- // AnnouncementCleared reports if the "announcement" edge to the Announcement entity was cleared.
- func (m *AnnouncementReadMutation) AnnouncementCleared() bool {
- return m.clearedannouncement
- }
- // AnnouncementIDs returns the "announcement" edge IDs in the mutation.
- // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
- // AnnouncementID instead. It exists only for internal usage by the builders.
- func (m *AnnouncementReadMutation) AnnouncementIDs() (ids []int64) {
- if id := m.announcement; id != nil {
- ids = append(ids, *id)
- }
- return
- }
- // ResetAnnouncement resets all changes to the "announcement" edge.
- func (m *AnnouncementReadMutation) ResetAnnouncement() {
- m.announcement = nil
- m.clearedannouncement = false
- }
- // ClearUser clears the "user" edge to the User entity.
- func (m *AnnouncementReadMutation) ClearUser() {
- m.cleareduser = true
- m.clearedFields[announcementread.FieldUserID] = struct{}{}
- }
- // UserCleared reports if the "user" edge to the User entity was cleared.
- func (m *AnnouncementReadMutation) UserCleared() bool {
- return m.cleareduser
- }
- // UserIDs returns the "user" edge IDs in the mutation.
- // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
- // UserID instead. It exists only for internal usage by the builders.
- func (m *AnnouncementReadMutation) UserIDs() (ids []int64) {
- if id := m.user; id != nil {
- ids = append(ids, *id)
- }
- return
- }
- // ResetUser resets all changes to the "user" edge.
- func (m *AnnouncementReadMutation) ResetUser() {
- m.user = nil
- m.cleareduser = false
- }
- // Where appends a list predicates to the AnnouncementReadMutation builder.
- func (m *AnnouncementReadMutation) Where(ps ...predicate.AnnouncementRead) {
- m.predicates = append(m.predicates, ps...)
- }
- // WhereP appends storage-level predicates to the AnnouncementReadMutation builder. Using this method,
- // users can use type-assertion to append predicates that do not depend on any generated package.
- func (m *AnnouncementReadMutation) WhereP(ps ...func(*sql.Selector)) {
- p := make([]predicate.AnnouncementRead, len(ps))
- for i := range ps {
- p[i] = ps[i]
- }
- m.Where(p...)
- }
- // Op returns the operation name.
- func (m *AnnouncementReadMutation) Op() Op {
- return m.op
- }
- // SetOp allows setting the mutation operation.
- func (m *AnnouncementReadMutation) SetOp(op Op) {
- m.op = op
- }
- // Type returns the node type of this mutation (AnnouncementRead).
- func (m *AnnouncementReadMutation) Type() string {
- return m.typ
- }
- // Fields returns all fields that were changed during this mutation. Note that in
- // order to get all numeric fields that were incremented/decremented, call
- // AddedFields().
- func (m *AnnouncementReadMutation) Fields() []string {
- fields := make([]string, 0, 4)
- if m.announcement != nil {
- fields = append(fields, announcementread.FieldAnnouncementID)
- }
- if m.user != nil {
- fields = append(fields, announcementread.FieldUserID)
- }
- if m.read_at != nil {
- fields = append(fields, announcementread.FieldReadAt)
- }
- if m.created_at != nil {
- fields = append(fields, announcementread.FieldCreatedAt)
- }
- return fields
- }
- // Field returns the value of a field with the given name. The second boolean
- // return value indicates that this field was not set, or was not defined in the
- // schema.
- func (m *AnnouncementReadMutation) Field(name string) (ent.Value, bool) {
- switch name {
- case announcementread.FieldAnnouncementID:
- return m.AnnouncementID()
- case announcementread.FieldUserID:
- return m.UserID()
- case announcementread.FieldReadAt:
- return m.ReadAt()
- case announcementread.FieldCreatedAt:
- return m.CreatedAt()
- }
- return nil, false
- }
- // OldField returns the old value of the field from the database. An error is
- // returned if the mutation operation is not UpdateOne, or the query to the
- // database failed.
- func (m *AnnouncementReadMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
- switch name {
- case announcementread.FieldAnnouncementID:
- return m.OldAnnouncementID(ctx)
- case announcementread.FieldUserID:
- return m.OldUserID(ctx)
- case announcementread.FieldReadAt:
- return m.OldReadAt(ctx)
- case announcementread.FieldCreatedAt:
- return m.OldCreatedAt(ctx)
- }
- return nil, fmt.Errorf("unknown AnnouncementRead field %s", name)
- }
- // SetField sets the value of a field with the given name. It returns an error if
- // the field is not defined in the schema, or if the type mismatched the field
- // type.
- func (m *AnnouncementReadMutation) SetField(name string, value ent.Value) error {
- switch name {
- case announcementread.FieldAnnouncementID:
- v, ok := value.(int64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetAnnouncementID(v)
- return nil
- case announcementread.FieldUserID:
- v, ok := value.(int64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetUserID(v)
- return nil
- case announcementread.FieldReadAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetReadAt(v)
- return nil
- case announcementread.FieldCreatedAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetCreatedAt(v)
- return nil
- }
- return fmt.Errorf("unknown AnnouncementRead field %s", name)
- }
- // AddedFields returns all numeric fields that were incremented/decremented during
- // this mutation.
- func (m *AnnouncementReadMutation) AddedFields() []string {
- var fields []string
- return fields
- }
- // AddedField returns the numeric value that was incremented/decremented on a field
- // with the given name. The second boolean return value indicates that this field
- // was not set, or was not defined in the schema.
- func (m *AnnouncementReadMutation) AddedField(name string) (ent.Value, bool) {
- switch name {
- }
- return nil, false
- }
- // AddField adds the value to the field with the given name. It returns an error if
- // the field is not defined in the schema, or if the type mismatched the field
- // type.
- func (m *AnnouncementReadMutation) AddField(name string, value ent.Value) error {
- switch name {
- }
- return fmt.Errorf("unknown AnnouncementRead numeric field %s", name)
- }
- // ClearedFields returns all nullable fields that were cleared during this
- // mutation.
- func (m *AnnouncementReadMutation) ClearedFields() []string {
- return nil
- }
- // FieldCleared returns a boolean indicating if a field with the given name was
- // cleared in this mutation.
- func (m *AnnouncementReadMutation) FieldCleared(name string) bool {
- _, ok := m.clearedFields[name]
- return ok
- }
- // ClearField clears the value of the field with the given name. It returns an
- // error if the field is not defined in the schema.
- func (m *AnnouncementReadMutation) ClearField(name string) error {
- return fmt.Errorf("unknown AnnouncementRead nullable field %s", name)
- }
- // ResetField resets all changes in the mutation for the field with the given name.
- // It returns an error if the field is not defined in the schema.
- func (m *AnnouncementReadMutation) ResetField(name string) error {
- switch name {
- case announcementread.FieldAnnouncementID:
- m.ResetAnnouncementID()
- return nil
- case announcementread.FieldUserID:
- m.ResetUserID()
- return nil
- case announcementread.FieldReadAt:
- m.ResetReadAt()
- return nil
- case announcementread.FieldCreatedAt:
- m.ResetCreatedAt()
- return nil
- }
- return fmt.Errorf("unknown AnnouncementRead field %s", name)
- }
- // AddedEdges returns all edge names that were set/added in this mutation.
- func (m *AnnouncementReadMutation) AddedEdges() []string {
- edges := make([]string, 0, 2)
- if m.announcement != nil {
- edges = append(edges, announcementread.EdgeAnnouncement)
- }
- if m.user != nil {
- edges = append(edges, announcementread.EdgeUser)
- }
- return edges
- }
- // AddedIDs returns all IDs (to other nodes) that were added for the given edge
- // name in this mutation.
- func (m *AnnouncementReadMutation) AddedIDs(name string) []ent.Value {
- switch name {
- case announcementread.EdgeAnnouncement:
- if id := m.announcement; id != nil {
- return []ent.Value{*id}
- }
- case announcementread.EdgeUser:
- if id := m.user; id != nil {
- return []ent.Value{*id}
- }
- }
- return nil
- }
- // RemovedEdges returns all edge names that were removed in this mutation.
- func (m *AnnouncementReadMutation) RemovedEdges() []string {
- edges := make([]string, 0, 2)
- return edges
- }
- // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
- // the given name in this mutation.
- func (m *AnnouncementReadMutation) RemovedIDs(name string) []ent.Value {
- return nil
- }
- // ClearedEdges returns all edge names that were cleared in this mutation.
- func (m *AnnouncementReadMutation) ClearedEdges() []string {
- edges := make([]string, 0, 2)
- if m.clearedannouncement {
- edges = append(edges, announcementread.EdgeAnnouncement)
- }
- if m.cleareduser {
- edges = append(edges, announcementread.EdgeUser)
- }
- return edges
- }
- // EdgeCleared returns a boolean which indicates if the edge with the given name
- // was cleared in this mutation.
- func (m *AnnouncementReadMutation) EdgeCleared(name string) bool {
- switch name {
- case announcementread.EdgeAnnouncement:
- return m.clearedannouncement
- case announcementread.EdgeUser:
- return m.cleareduser
- }
- return false
- }
- // ClearEdge clears the value of the edge with the given name. It returns an error
- // if that edge is not defined in the schema.
- func (m *AnnouncementReadMutation) ClearEdge(name string) error {
- switch name {
- case announcementread.EdgeAnnouncement:
- m.ClearAnnouncement()
- return nil
- case announcementread.EdgeUser:
- m.ClearUser()
- return nil
- }
- return fmt.Errorf("unknown AnnouncementRead unique edge %s", name)
- }
- // ResetEdge resets all changes to the edge with the given name in this mutation.
- // It returns an error if the edge is not defined in the schema.
- func (m *AnnouncementReadMutation) ResetEdge(name string) error {
- switch name {
- case announcementread.EdgeAnnouncement:
- m.ResetAnnouncement()
- return nil
- case announcementread.EdgeUser:
- m.ResetUser()
- return nil
- }
- return fmt.Errorf("unknown AnnouncementRead edge %s", name)
- }
- // AuthIdentityMutation represents an operation that mutates the AuthIdentity nodes in the graph.
- type AuthIdentityMutation struct {
- config
- op Op
- typ string
- id *int64
- created_at *time.Time
- updated_at *time.Time
- provider_type *string
- provider_key *string
- provider_subject *string
- verified_at *time.Time
- issuer *string
- metadata *map[string]interface{}
- clearedFields map[string]struct{}
- user *int64
- cleareduser bool
- channels map[int64]struct{}
- removedchannels map[int64]struct{}
- clearedchannels bool
- adoption_decisions map[int64]struct{}
- removedadoption_decisions map[int64]struct{}
- clearedadoption_decisions bool
- done bool
- oldValue func(context.Context) (*AuthIdentity, error)
- predicates []predicate.AuthIdentity
- }
- var _ ent.Mutation = (*AuthIdentityMutation)(nil)
- // authidentityOption allows management of the mutation configuration using functional options.
- type authidentityOption func(*AuthIdentityMutation)
- // newAuthIdentityMutation creates new mutation for the AuthIdentity entity.
- func newAuthIdentityMutation(c config, op Op, opts ...authidentityOption) *AuthIdentityMutation {
- m := &AuthIdentityMutation{
- config: c,
- op: op,
- typ: TypeAuthIdentity,
- clearedFields: make(map[string]struct{}),
- }
- for _, opt := range opts {
- opt(m)
- }
- return m
- }
- // withAuthIdentityID sets the ID field of the mutation.
- func withAuthIdentityID(id int64) authidentityOption {
- return func(m *AuthIdentityMutation) {
- var (
- err error
- once sync.Once
- value *AuthIdentity
- )
- m.oldValue = func(ctx context.Context) (*AuthIdentity, error) {
- once.Do(func() {
- if m.done {
- err = errors.New("querying old values post mutation is not allowed")
- } else {
- value, err = m.Client().AuthIdentity.Get(ctx, id)
- }
- })
- return value, err
- }
- m.id = &id
- }
- }
- // withAuthIdentity sets the old AuthIdentity of the mutation.
- func withAuthIdentity(node *AuthIdentity) authidentityOption {
- return func(m *AuthIdentityMutation) {
- m.oldValue = func(context.Context) (*AuthIdentity, error) {
- return node, nil
- }
- m.id = &node.ID
- }
- }
- // Client returns a new `ent.Client` from the mutation. If the mutation was
- // executed in a transaction (ent.Tx), a transactional client is returned.
- func (m AuthIdentityMutation) Client() *Client {
- client := &Client{config: m.config}
- client.init()
- return client
- }
- // Tx returns an `ent.Tx` for mutations that were executed in transactions;
- // it returns an error otherwise.
- func (m AuthIdentityMutation) Tx() (*Tx, error) {
- if _, ok := m.driver.(*txDriver); !ok {
- return nil, errors.New("ent: mutation is not running in a transaction")
- }
- tx := &Tx{config: m.config}
- tx.init()
- return tx, nil
- }
- // ID returns the ID value in the mutation. Note that the ID is only available
- // if it was provided to the builder or after it was returned from the database.
- func (m *AuthIdentityMutation) ID() (id int64, exists bool) {
- if m.id == nil {
- return
- }
- return *m.id, true
- }
- // IDs queries the database and returns the entity ids that match the mutation's predicate.
- // That means, if the mutation is applied within a transaction with an isolation level such
- // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
- // or updated by the mutation.
- func (m *AuthIdentityMutation) IDs(ctx context.Context) ([]int64, error) {
- switch {
- case m.op.Is(OpUpdateOne | OpDeleteOne):
- id, exists := m.ID()
- if exists {
- return []int64{id}, nil
- }
- fallthrough
- case m.op.Is(OpUpdate | OpDelete):
- return m.Client().AuthIdentity.Query().Where(m.predicates...).IDs(ctx)
- default:
- return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
- }
- }
- // SetCreatedAt sets the "created_at" field.
- func (m *AuthIdentityMutation) SetCreatedAt(t time.Time) {
- m.created_at = &t
- }
- // CreatedAt returns the value of the "created_at" field in the mutation.
- func (m *AuthIdentityMutation) CreatedAt() (r time.Time, exists bool) {
- v := m.created_at
- if v == nil {
- return
- }
- return *v, true
- }
- // OldCreatedAt returns the old "created_at" field's value of the AuthIdentity entity.
- // If the AuthIdentity object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *AuthIdentityMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldCreatedAt requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
- }
- return oldValue.CreatedAt, nil
- }
- // ResetCreatedAt resets all changes to the "created_at" field.
- func (m *AuthIdentityMutation) ResetCreatedAt() {
- m.created_at = nil
- }
- // SetUpdatedAt sets the "updated_at" field.
- func (m *AuthIdentityMutation) SetUpdatedAt(t time.Time) {
- m.updated_at = &t
- }
- // UpdatedAt returns the value of the "updated_at" field in the mutation.
- func (m *AuthIdentityMutation) UpdatedAt() (r time.Time, exists bool) {
- v := m.updated_at
- if v == nil {
- return
- }
- return *v, true
- }
- // OldUpdatedAt returns the old "updated_at" field's value of the AuthIdentity entity.
- // If the AuthIdentity object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *AuthIdentityMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
- }
- return oldValue.UpdatedAt, nil
- }
- // ResetUpdatedAt resets all changes to the "updated_at" field.
- func (m *AuthIdentityMutation) ResetUpdatedAt() {
- m.updated_at = nil
- }
- // SetUserID sets the "user_id" field.
- func (m *AuthIdentityMutation) SetUserID(i int64) {
- m.user = &i
- }
- // UserID returns the value of the "user_id" field in the mutation.
- func (m *AuthIdentityMutation) UserID() (r int64, exists bool) {
- v := m.user
- if v == nil {
- return
- }
- return *v, true
- }
- // OldUserID returns the old "user_id" field's value of the AuthIdentity entity.
- // If the AuthIdentity object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *AuthIdentityMutation) OldUserID(ctx context.Context) (v int64, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldUserID is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldUserID requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldUserID: %w", err)
- }
- return oldValue.UserID, nil
- }
- // ResetUserID resets all changes to the "user_id" field.
- func (m *AuthIdentityMutation) ResetUserID() {
- m.user = nil
- }
- // SetProviderType sets the "provider_type" field.
- func (m *AuthIdentityMutation) SetProviderType(s string) {
- m.provider_type = &s
- }
- // ProviderType returns the value of the "provider_type" field in the mutation.
- func (m *AuthIdentityMutation) ProviderType() (r string, exists bool) {
- v := m.provider_type
- if v == nil {
- return
- }
- return *v, true
- }
- // OldProviderType returns the old "provider_type" field's value of the AuthIdentity entity.
- // If the AuthIdentity object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *AuthIdentityMutation) OldProviderType(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldProviderType is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldProviderType requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldProviderType: %w", err)
- }
- return oldValue.ProviderType, nil
- }
- // ResetProviderType resets all changes to the "provider_type" field.
- func (m *AuthIdentityMutation) ResetProviderType() {
- m.provider_type = nil
- }
- // SetProviderKey sets the "provider_key" field.
- func (m *AuthIdentityMutation) SetProviderKey(s string) {
- m.provider_key = &s
- }
- // ProviderKey returns the value of the "provider_key" field in the mutation.
- func (m *AuthIdentityMutation) ProviderKey() (r string, exists bool) {
- v := m.provider_key
- if v == nil {
- return
- }
- return *v, true
- }
- // OldProviderKey returns the old "provider_key" field's value of the AuthIdentity entity.
- // If the AuthIdentity object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *AuthIdentityMutation) OldProviderKey(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldProviderKey is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldProviderKey requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldProviderKey: %w", err)
- }
- return oldValue.ProviderKey, nil
- }
- // ResetProviderKey resets all changes to the "provider_key" field.
- func (m *AuthIdentityMutation) ResetProviderKey() {
- m.provider_key = nil
- }
- // SetProviderSubject sets the "provider_subject" field.
- func (m *AuthIdentityMutation) SetProviderSubject(s string) {
- m.provider_subject = &s
- }
- // ProviderSubject returns the value of the "provider_subject" field in the mutation.
- func (m *AuthIdentityMutation) ProviderSubject() (r string, exists bool) {
- v := m.provider_subject
- if v == nil {
- return
- }
- return *v, true
- }
- // OldProviderSubject returns the old "provider_subject" field's value of the AuthIdentity entity.
- // If the AuthIdentity object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *AuthIdentityMutation) OldProviderSubject(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldProviderSubject is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldProviderSubject requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldProviderSubject: %w", err)
- }
- return oldValue.ProviderSubject, nil
- }
- // ResetProviderSubject resets all changes to the "provider_subject" field.
- func (m *AuthIdentityMutation) ResetProviderSubject() {
- m.provider_subject = nil
- }
- // SetVerifiedAt sets the "verified_at" field.
- func (m *AuthIdentityMutation) SetVerifiedAt(t time.Time) {
- m.verified_at = &t
- }
- // VerifiedAt returns the value of the "verified_at" field in the mutation.
- func (m *AuthIdentityMutation) VerifiedAt() (r time.Time, exists bool) {
- v := m.verified_at
- if v == nil {
- return
- }
- return *v, true
- }
- // OldVerifiedAt returns the old "verified_at" field's value of the AuthIdentity entity.
- // If the AuthIdentity object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *AuthIdentityMutation) OldVerifiedAt(ctx context.Context) (v *time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldVerifiedAt is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldVerifiedAt requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldVerifiedAt: %w", err)
- }
- return oldValue.VerifiedAt, nil
- }
- // ClearVerifiedAt clears the value of the "verified_at" field.
- func (m *AuthIdentityMutation) ClearVerifiedAt() {
- m.verified_at = nil
- m.clearedFields[authidentity.FieldVerifiedAt] = struct{}{}
- }
- // VerifiedAtCleared returns if the "verified_at" field was cleared in this mutation.
- func (m *AuthIdentityMutation) VerifiedAtCleared() bool {
- _, ok := m.clearedFields[authidentity.FieldVerifiedAt]
- return ok
- }
- // ResetVerifiedAt resets all changes to the "verified_at" field.
- func (m *AuthIdentityMutation) ResetVerifiedAt() {
- m.verified_at = nil
- delete(m.clearedFields, authidentity.FieldVerifiedAt)
- }
- // SetIssuer sets the "issuer" field.
- func (m *AuthIdentityMutation) SetIssuer(s string) {
- m.issuer = &s
- }
- // Issuer returns the value of the "issuer" field in the mutation.
- func (m *AuthIdentityMutation) Issuer() (r string, exists bool) {
- v := m.issuer
- if v == nil {
- return
- }
- return *v, true
- }
- // OldIssuer returns the old "issuer" field's value of the AuthIdentity entity.
- // If the AuthIdentity object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *AuthIdentityMutation) OldIssuer(ctx context.Context) (v *string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldIssuer is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldIssuer requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldIssuer: %w", err)
- }
- return oldValue.Issuer, nil
- }
- // ClearIssuer clears the value of the "issuer" field.
- func (m *AuthIdentityMutation) ClearIssuer() {
- m.issuer = nil
- m.clearedFields[authidentity.FieldIssuer] = struct{}{}
- }
- // IssuerCleared returns if the "issuer" field was cleared in this mutation.
- func (m *AuthIdentityMutation) IssuerCleared() bool {
- _, ok := m.clearedFields[authidentity.FieldIssuer]
- return ok
- }
- // ResetIssuer resets all changes to the "issuer" field.
- func (m *AuthIdentityMutation) ResetIssuer() {
- m.issuer = nil
- delete(m.clearedFields, authidentity.FieldIssuer)
- }
- // SetMetadata sets the "metadata" field.
- func (m *AuthIdentityMutation) SetMetadata(value map[string]interface{}) {
- m.metadata = &value
- }
- // Metadata returns the value of the "metadata" field in the mutation.
- func (m *AuthIdentityMutation) Metadata() (r map[string]interface{}, exists bool) {
- v := m.metadata
- if v == nil {
- return
- }
- return *v, true
- }
- // OldMetadata returns the old "metadata" field's value of the AuthIdentity entity.
- // If the AuthIdentity object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *AuthIdentityMutation) OldMetadata(ctx context.Context) (v map[string]interface{}, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldMetadata is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldMetadata requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldMetadata: %w", err)
- }
- return oldValue.Metadata, nil
- }
- // ResetMetadata resets all changes to the "metadata" field.
- func (m *AuthIdentityMutation) ResetMetadata() {
- m.metadata = nil
- }
- // ClearUser clears the "user" edge to the User entity.
- func (m *AuthIdentityMutation) ClearUser() {
- m.cleareduser = true
- m.clearedFields[authidentity.FieldUserID] = struct{}{}
- }
- // UserCleared reports if the "user" edge to the User entity was cleared.
- func (m *AuthIdentityMutation) UserCleared() bool {
- return m.cleareduser
- }
- // UserIDs returns the "user" edge IDs in the mutation.
- // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
- // UserID instead. It exists only for internal usage by the builders.
- func (m *AuthIdentityMutation) UserIDs() (ids []int64) {
- if id := m.user; id != nil {
- ids = append(ids, *id)
- }
- return
- }
- // ResetUser resets all changes to the "user" edge.
- func (m *AuthIdentityMutation) ResetUser() {
- m.user = nil
- m.cleareduser = false
- }
- // AddChannelIDs adds the "channels" edge to the AuthIdentityChannel entity by ids.
- func (m *AuthIdentityMutation) AddChannelIDs(ids ...int64) {
- if m.channels == nil {
- m.channels = make(map[int64]struct{})
- }
- for i := range ids {
- m.channels[ids[i]] = struct{}{}
- }
- }
- // ClearChannels clears the "channels" edge to the AuthIdentityChannel entity.
- func (m *AuthIdentityMutation) ClearChannels() {
- m.clearedchannels = true
- }
- // ChannelsCleared reports if the "channels" edge to the AuthIdentityChannel entity was cleared.
- func (m *AuthIdentityMutation) ChannelsCleared() bool {
- return m.clearedchannels
- }
- // RemoveChannelIDs removes the "channels" edge to the AuthIdentityChannel entity by IDs.
- func (m *AuthIdentityMutation) RemoveChannelIDs(ids ...int64) {
- if m.removedchannels == nil {
- m.removedchannels = make(map[int64]struct{})
- }
- for i := range ids {
- delete(m.channels, ids[i])
- m.removedchannels[ids[i]] = struct{}{}
- }
- }
- // RemovedChannels returns the removed IDs of the "channels" edge to the AuthIdentityChannel entity.
- func (m *AuthIdentityMutation) RemovedChannelsIDs() (ids []int64) {
- for id := range m.removedchannels {
- ids = append(ids, id)
- }
- return
- }
- // ChannelsIDs returns the "channels" edge IDs in the mutation.
- func (m *AuthIdentityMutation) ChannelsIDs() (ids []int64) {
- for id := range m.channels {
- ids = append(ids, id)
- }
- return
- }
- // ResetChannels resets all changes to the "channels" edge.
- func (m *AuthIdentityMutation) ResetChannels() {
- m.channels = nil
- m.clearedchannels = false
- m.removedchannels = nil
- }
- // AddAdoptionDecisionIDs adds the "adoption_decisions" edge to the IdentityAdoptionDecision entity by ids.
- func (m *AuthIdentityMutation) AddAdoptionDecisionIDs(ids ...int64) {
- if m.adoption_decisions == nil {
- m.adoption_decisions = make(map[int64]struct{})
- }
- for i := range ids {
- m.adoption_decisions[ids[i]] = struct{}{}
- }
- }
- // ClearAdoptionDecisions clears the "adoption_decisions" edge to the IdentityAdoptionDecision entity.
- func (m *AuthIdentityMutation) ClearAdoptionDecisions() {
- m.clearedadoption_decisions = true
- }
- // AdoptionDecisionsCleared reports if the "adoption_decisions" edge to the IdentityAdoptionDecision entity was cleared.
- func (m *AuthIdentityMutation) AdoptionDecisionsCleared() bool {
- return m.clearedadoption_decisions
- }
- // RemoveAdoptionDecisionIDs removes the "adoption_decisions" edge to the IdentityAdoptionDecision entity by IDs.
- func (m *AuthIdentityMutation) RemoveAdoptionDecisionIDs(ids ...int64) {
- if m.removedadoption_decisions == nil {
- m.removedadoption_decisions = make(map[int64]struct{})
- }
- for i := range ids {
- delete(m.adoption_decisions, ids[i])
- m.removedadoption_decisions[ids[i]] = struct{}{}
- }
- }
- // RemovedAdoptionDecisions returns the removed IDs of the "adoption_decisions" edge to the IdentityAdoptionDecision entity.
- func (m *AuthIdentityMutation) RemovedAdoptionDecisionsIDs() (ids []int64) {
- for id := range m.removedadoption_decisions {
- ids = append(ids, id)
- }
- return
- }
- // AdoptionDecisionsIDs returns the "adoption_decisions" edge IDs in the mutation.
- func (m *AuthIdentityMutation) AdoptionDecisionsIDs() (ids []int64) {
- for id := range m.adoption_decisions {
- ids = append(ids, id)
- }
- return
- }
- // ResetAdoptionDecisions resets all changes to the "adoption_decisions" edge.
- func (m *AuthIdentityMutation) ResetAdoptionDecisions() {
- m.adoption_decisions = nil
- m.clearedadoption_decisions = false
- m.removedadoption_decisions = nil
- }
- // Where appends a list predicates to the AuthIdentityMutation builder.
- func (m *AuthIdentityMutation) Where(ps ...predicate.AuthIdentity) {
- m.predicates = append(m.predicates, ps...)
- }
- // WhereP appends storage-level predicates to the AuthIdentityMutation builder. Using this method,
- // users can use type-assertion to append predicates that do not depend on any generated package.
- func (m *AuthIdentityMutation) WhereP(ps ...func(*sql.Selector)) {
- p := make([]predicate.AuthIdentity, len(ps))
- for i := range ps {
- p[i] = ps[i]
- }
- m.Where(p...)
- }
- // Op returns the operation name.
- func (m *AuthIdentityMutation) Op() Op {
- return m.op
- }
- // SetOp allows setting the mutation operation.
- func (m *AuthIdentityMutation) SetOp(op Op) {
- m.op = op
- }
- // Type returns the node type of this mutation (AuthIdentity).
- func (m *AuthIdentityMutation) Type() string {
- return m.typ
- }
- // Fields returns all fields that were changed during this mutation. Note that in
- // order to get all numeric fields that were incremented/decremented, call
- // AddedFields().
- func (m *AuthIdentityMutation) Fields() []string {
- fields := make([]string, 0, 9)
- if m.created_at != nil {
- fields = append(fields, authidentity.FieldCreatedAt)
- }
- if m.updated_at != nil {
- fields = append(fields, authidentity.FieldUpdatedAt)
- }
- if m.user != nil {
- fields = append(fields, authidentity.FieldUserID)
- }
- if m.provider_type != nil {
- fields = append(fields, authidentity.FieldProviderType)
- }
- if m.provider_key != nil {
- fields = append(fields, authidentity.FieldProviderKey)
- }
- if m.provider_subject != nil {
- fields = append(fields, authidentity.FieldProviderSubject)
- }
- if m.verified_at != nil {
- fields = append(fields, authidentity.FieldVerifiedAt)
- }
- if m.issuer != nil {
- fields = append(fields, authidentity.FieldIssuer)
- }
- if m.metadata != nil {
- fields = append(fields, authidentity.FieldMetadata)
- }
- return fields
- }
- // Field returns the value of a field with the given name. The second boolean
- // return value indicates that this field was not set, or was not defined in the
- // schema.
- func (m *AuthIdentityMutation) Field(name string) (ent.Value, bool) {
- switch name {
- case authidentity.FieldCreatedAt:
- return m.CreatedAt()
- case authidentity.FieldUpdatedAt:
- return m.UpdatedAt()
- case authidentity.FieldUserID:
- return m.UserID()
- case authidentity.FieldProviderType:
- return m.ProviderType()
- case authidentity.FieldProviderKey:
- return m.ProviderKey()
- case authidentity.FieldProviderSubject:
- return m.ProviderSubject()
- case authidentity.FieldVerifiedAt:
- return m.VerifiedAt()
- case authidentity.FieldIssuer:
- return m.Issuer()
- case authidentity.FieldMetadata:
- return m.Metadata()
- }
- return nil, false
- }
- // OldField returns the old value of the field from the database. An error is
- // returned if the mutation operation is not UpdateOne, or the query to the
- // database failed.
- func (m *AuthIdentityMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
- switch name {
- case authidentity.FieldCreatedAt:
- return m.OldCreatedAt(ctx)
- case authidentity.FieldUpdatedAt:
- return m.OldUpdatedAt(ctx)
- case authidentity.FieldUserID:
- return m.OldUserID(ctx)
- case authidentity.FieldProviderType:
- return m.OldProviderType(ctx)
- case authidentity.FieldProviderKey:
- return m.OldProviderKey(ctx)
- case authidentity.FieldProviderSubject:
- return m.OldProviderSubject(ctx)
- case authidentity.FieldVerifiedAt:
- return m.OldVerifiedAt(ctx)
- case authidentity.FieldIssuer:
- return m.OldIssuer(ctx)
- case authidentity.FieldMetadata:
- return m.OldMetadata(ctx)
- }
- return nil, fmt.Errorf("unknown AuthIdentity field %s", name)
- }
- // SetField sets the value of a field with the given name. It returns an error if
- // the field is not defined in the schema, or if the type mismatched the field
- // type.
- func (m *AuthIdentityMutation) SetField(name string, value ent.Value) error {
- switch name {
- case authidentity.FieldCreatedAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetCreatedAt(v)
- return nil
- case authidentity.FieldUpdatedAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetUpdatedAt(v)
- return nil
- case authidentity.FieldUserID:
- v, ok := value.(int64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetUserID(v)
- return nil
- case authidentity.FieldProviderType:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetProviderType(v)
- return nil
- case authidentity.FieldProviderKey:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetProviderKey(v)
- return nil
- case authidentity.FieldProviderSubject:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetProviderSubject(v)
- return nil
- case authidentity.FieldVerifiedAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetVerifiedAt(v)
- return nil
- case authidentity.FieldIssuer:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetIssuer(v)
- return nil
- case authidentity.FieldMetadata:
- v, ok := value.(map[string]interface{})
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetMetadata(v)
- return nil
- }
- return fmt.Errorf("unknown AuthIdentity field %s", name)
- }
- // AddedFields returns all numeric fields that were incremented/decremented during
- // this mutation.
- func (m *AuthIdentityMutation) AddedFields() []string {
- var fields []string
- return fields
- }
- // AddedField returns the numeric value that was incremented/decremented on a field
- // with the given name. The second boolean return value indicates that this field
- // was not set, or was not defined in the schema.
- func (m *AuthIdentityMutation) AddedField(name string) (ent.Value, bool) {
- switch name {
- }
- return nil, false
- }
- // AddField adds the value to the field with the given name. It returns an error if
- // the field is not defined in the schema, or if the type mismatched the field
- // type.
- func (m *AuthIdentityMutation) AddField(name string, value ent.Value) error {
- switch name {
- }
- return fmt.Errorf("unknown AuthIdentity numeric field %s", name)
- }
- // ClearedFields returns all nullable fields that were cleared during this
- // mutation.
- func (m *AuthIdentityMutation) ClearedFields() []string {
- var fields []string
- if m.FieldCleared(authidentity.FieldVerifiedAt) {
- fields = append(fields, authidentity.FieldVerifiedAt)
- }
- if m.FieldCleared(authidentity.FieldIssuer) {
- fields = append(fields, authidentity.FieldIssuer)
- }
- return fields
- }
- // FieldCleared returns a boolean indicating if a field with the given name was
- // cleared in this mutation.
- func (m *AuthIdentityMutation) FieldCleared(name string) bool {
- _, ok := m.clearedFields[name]
- return ok
- }
- // ClearField clears the value of the field with the given name. It returns an
- // error if the field is not defined in the schema.
- func (m *AuthIdentityMutation) ClearField(name string) error {
- switch name {
- case authidentity.FieldVerifiedAt:
- m.ClearVerifiedAt()
- return nil
- case authidentity.FieldIssuer:
- m.ClearIssuer()
- return nil
- }
- return fmt.Errorf("unknown AuthIdentity nullable field %s", name)
- }
- // ResetField resets all changes in the mutation for the field with the given name.
- // It returns an error if the field is not defined in the schema.
- func (m *AuthIdentityMutation) ResetField(name string) error {
- switch name {
- case authidentity.FieldCreatedAt:
- m.ResetCreatedAt()
- return nil
- case authidentity.FieldUpdatedAt:
- m.ResetUpdatedAt()
- return nil
- case authidentity.FieldUserID:
- m.ResetUserID()
- return nil
- case authidentity.FieldProviderType:
- m.ResetProviderType()
- return nil
- case authidentity.FieldProviderKey:
- m.ResetProviderKey()
- return nil
- case authidentity.FieldProviderSubject:
- m.ResetProviderSubject()
- return nil
- case authidentity.FieldVerifiedAt:
- m.ResetVerifiedAt()
- return nil
- case authidentity.FieldIssuer:
- m.ResetIssuer()
- return nil
- case authidentity.FieldMetadata:
- m.ResetMetadata()
- return nil
- }
- return fmt.Errorf("unknown AuthIdentity field %s", name)
- }
- // AddedEdges returns all edge names that were set/added in this mutation.
- func (m *AuthIdentityMutation) AddedEdges() []string {
- edges := make([]string, 0, 3)
- if m.user != nil {
- edges = append(edges, authidentity.EdgeUser)
- }
- if m.channels != nil {
- edges = append(edges, authidentity.EdgeChannels)
- }
- if m.adoption_decisions != nil {
- edges = append(edges, authidentity.EdgeAdoptionDecisions)
- }
- return edges
- }
- // AddedIDs returns all IDs (to other nodes) that were added for the given edge
- // name in this mutation.
- func (m *AuthIdentityMutation) AddedIDs(name string) []ent.Value {
- switch name {
- case authidentity.EdgeUser:
- if id := m.user; id != nil {
- return []ent.Value{*id}
- }
- case authidentity.EdgeChannels:
- ids := make([]ent.Value, 0, len(m.channels))
- for id := range m.channels {
- ids = append(ids, id)
- }
- return ids
- case authidentity.EdgeAdoptionDecisions:
- ids := make([]ent.Value, 0, len(m.adoption_decisions))
- for id := range m.adoption_decisions {
- ids = append(ids, id)
- }
- return ids
- }
- return nil
- }
- // RemovedEdges returns all edge names that were removed in this mutation.
- func (m *AuthIdentityMutation) RemovedEdges() []string {
- edges := make([]string, 0, 3)
- if m.removedchannels != nil {
- edges = append(edges, authidentity.EdgeChannels)
- }
- if m.removedadoption_decisions != nil {
- edges = append(edges, authidentity.EdgeAdoptionDecisions)
- }
- return edges
- }
- // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
- // the given name in this mutation.
- func (m *AuthIdentityMutation) RemovedIDs(name string) []ent.Value {
- switch name {
- case authidentity.EdgeChannels:
- ids := make([]ent.Value, 0, len(m.removedchannels))
- for id := range m.removedchannels {
- ids = append(ids, id)
- }
- return ids
- case authidentity.EdgeAdoptionDecisions:
- ids := make([]ent.Value, 0, len(m.removedadoption_decisions))
- for id := range m.removedadoption_decisions {
- ids = append(ids, id)
- }
- return ids
- }
- return nil
- }
- // ClearedEdges returns all edge names that were cleared in this mutation.
- func (m *AuthIdentityMutation) ClearedEdges() []string {
- edges := make([]string, 0, 3)
- if m.cleareduser {
- edges = append(edges, authidentity.EdgeUser)
- }
- if m.clearedchannels {
- edges = append(edges, authidentity.EdgeChannels)
- }
- if m.clearedadoption_decisions {
- edges = append(edges, authidentity.EdgeAdoptionDecisions)
- }
- return edges
- }
- // EdgeCleared returns a boolean which indicates if the edge with the given name
- // was cleared in this mutation.
- func (m *AuthIdentityMutation) EdgeCleared(name string) bool {
- switch name {
- case authidentity.EdgeUser:
- return m.cleareduser
- case authidentity.EdgeChannels:
- return m.clearedchannels
- case authidentity.EdgeAdoptionDecisions:
- return m.clearedadoption_decisions
- }
- return false
- }
- // ClearEdge clears the value of the edge with the given name. It returns an error
- // if that edge is not defined in the schema.
- func (m *AuthIdentityMutation) ClearEdge(name string) error {
- switch name {
- case authidentity.EdgeUser:
- m.ClearUser()
- return nil
- }
- return fmt.Errorf("unknown AuthIdentity unique edge %s", name)
- }
- // ResetEdge resets all changes to the edge with the given name in this mutation.
- // It returns an error if the edge is not defined in the schema.
- func (m *AuthIdentityMutation) ResetEdge(name string) error {
- switch name {
- case authidentity.EdgeUser:
- m.ResetUser()
- return nil
- case authidentity.EdgeChannels:
- m.ResetChannels()
- return nil
- case authidentity.EdgeAdoptionDecisions:
- m.ResetAdoptionDecisions()
- return nil
- }
- return fmt.Errorf("unknown AuthIdentity edge %s", name)
- }
- // AuthIdentityChannelMutation represents an operation that mutates the AuthIdentityChannel nodes in the graph.
- type AuthIdentityChannelMutation struct {
- config
- op Op
- typ string
- id *int64
- created_at *time.Time
- updated_at *time.Time
- provider_type *string
- provider_key *string
- channel *string
- channel_app_id *string
- channel_subject *string
- metadata *map[string]interface{}
- clearedFields map[string]struct{}
- identity *int64
- clearedidentity bool
- done bool
- oldValue func(context.Context) (*AuthIdentityChannel, error)
- predicates []predicate.AuthIdentityChannel
- }
- var _ ent.Mutation = (*AuthIdentityChannelMutation)(nil)
- // authidentitychannelOption allows management of the mutation configuration using functional options.
- type authidentitychannelOption func(*AuthIdentityChannelMutation)
- // newAuthIdentityChannelMutation creates new mutation for the AuthIdentityChannel entity.
- func newAuthIdentityChannelMutation(c config, op Op, opts ...authidentitychannelOption) *AuthIdentityChannelMutation {
- m := &AuthIdentityChannelMutation{
- config: c,
- op: op,
- typ: TypeAuthIdentityChannel,
- clearedFields: make(map[string]struct{}),
- }
- for _, opt := range opts {
- opt(m)
- }
- return m
- }
- // withAuthIdentityChannelID sets the ID field of the mutation.
- func withAuthIdentityChannelID(id int64) authidentitychannelOption {
- return func(m *AuthIdentityChannelMutation) {
- var (
- err error
- once sync.Once
- value *AuthIdentityChannel
- )
- m.oldValue = func(ctx context.Context) (*AuthIdentityChannel, error) {
- once.Do(func() {
- if m.done {
- err = errors.New("querying old values post mutation is not allowed")
- } else {
- value, err = m.Client().AuthIdentityChannel.Get(ctx, id)
- }
- })
- return value, err
- }
- m.id = &id
- }
- }
- // withAuthIdentityChannel sets the old AuthIdentityChannel of the mutation.
- func withAuthIdentityChannel(node *AuthIdentityChannel) authidentitychannelOption {
- return func(m *AuthIdentityChannelMutation) {
- m.oldValue = func(context.Context) (*AuthIdentityChannel, error) {
- return node, nil
- }
- m.id = &node.ID
- }
- }
- // Client returns a new `ent.Client` from the mutation. If the mutation was
- // executed in a transaction (ent.Tx), a transactional client is returned.
- func (m AuthIdentityChannelMutation) Client() *Client {
- client := &Client{config: m.config}
- client.init()
- return client
- }
- // Tx returns an `ent.Tx` for mutations that were executed in transactions;
- // it returns an error otherwise.
- func (m AuthIdentityChannelMutation) Tx() (*Tx, error) {
- if _, ok := m.driver.(*txDriver); !ok {
- return nil, errors.New("ent: mutation is not running in a transaction")
- }
- tx := &Tx{config: m.config}
- tx.init()
- return tx, nil
- }
- // ID returns the ID value in the mutation. Note that the ID is only available
- // if it was provided to the builder or after it was returned from the database.
- func (m *AuthIdentityChannelMutation) ID() (id int64, exists bool) {
- if m.id == nil {
- return
- }
- return *m.id, true
- }
- // IDs queries the database and returns the entity ids that match the mutation's predicate.
- // That means, if the mutation is applied within a transaction with an isolation level such
- // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
- // or updated by the mutation.
- func (m *AuthIdentityChannelMutation) IDs(ctx context.Context) ([]int64, error) {
- switch {
- case m.op.Is(OpUpdateOne | OpDeleteOne):
- id, exists := m.ID()
- if exists {
- return []int64{id}, nil
- }
- fallthrough
- case m.op.Is(OpUpdate | OpDelete):
- return m.Client().AuthIdentityChannel.Query().Where(m.predicates...).IDs(ctx)
- default:
- return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
- }
- }
- // SetCreatedAt sets the "created_at" field.
- func (m *AuthIdentityChannelMutation) SetCreatedAt(t time.Time) {
- m.created_at = &t
- }
- // CreatedAt returns the value of the "created_at" field in the mutation.
- func (m *AuthIdentityChannelMutation) CreatedAt() (r time.Time, exists bool) {
- v := m.created_at
- if v == nil {
- return
- }
- return *v, true
- }
- // OldCreatedAt returns the old "created_at" field's value of the AuthIdentityChannel entity.
- // If the AuthIdentityChannel object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *AuthIdentityChannelMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldCreatedAt requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
- }
- return oldValue.CreatedAt, nil
- }
- // ResetCreatedAt resets all changes to the "created_at" field.
- func (m *AuthIdentityChannelMutation) ResetCreatedAt() {
- m.created_at = nil
- }
- // SetUpdatedAt sets the "updated_at" field.
- func (m *AuthIdentityChannelMutation) SetUpdatedAt(t time.Time) {
- m.updated_at = &t
- }
- // UpdatedAt returns the value of the "updated_at" field in the mutation.
- func (m *AuthIdentityChannelMutation) UpdatedAt() (r time.Time, exists bool) {
- v := m.updated_at
- if v == nil {
- return
- }
- return *v, true
- }
- // OldUpdatedAt returns the old "updated_at" field's value of the AuthIdentityChannel entity.
- // If the AuthIdentityChannel object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *AuthIdentityChannelMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
- }
- return oldValue.UpdatedAt, nil
- }
- // ResetUpdatedAt resets all changes to the "updated_at" field.
- func (m *AuthIdentityChannelMutation) ResetUpdatedAt() {
- m.updated_at = nil
- }
- // SetIdentityID sets the "identity_id" field.
- func (m *AuthIdentityChannelMutation) SetIdentityID(i int64) {
- m.identity = &i
- }
- // IdentityID returns the value of the "identity_id" field in the mutation.
- func (m *AuthIdentityChannelMutation) IdentityID() (r int64, exists bool) {
- v := m.identity
- if v == nil {
- return
- }
- return *v, true
- }
- // OldIdentityID returns the old "identity_id" field's value of the AuthIdentityChannel entity.
- // If the AuthIdentityChannel object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *AuthIdentityChannelMutation) OldIdentityID(ctx context.Context) (v int64, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldIdentityID is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldIdentityID requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldIdentityID: %w", err)
- }
- return oldValue.IdentityID, nil
- }
- // ResetIdentityID resets all changes to the "identity_id" field.
- func (m *AuthIdentityChannelMutation) ResetIdentityID() {
- m.identity = nil
- }
- // SetProviderType sets the "provider_type" field.
- func (m *AuthIdentityChannelMutation) SetProviderType(s string) {
- m.provider_type = &s
- }
- // ProviderType returns the value of the "provider_type" field in the mutation.
- func (m *AuthIdentityChannelMutation) ProviderType() (r string, exists bool) {
- v := m.provider_type
- if v == nil {
- return
- }
- return *v, true
- }
- // OldProviderType returns the old "provider_type" field's value of the AuthIdentityChannel entity.
- // If the AuthIdentityChannel object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *AuthIdentityChannelMutation) OldProviderType(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldProviderType is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldProviderType requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldProviderType: %w", err)
- }
- return oldValue.ProviderType, nil
- }
- // ResetProviderType resets all changes to the "provider_type" field.
- func (m *AuthIdentityChannelMutation) ResetProviderType() {
- m.provider_type = nil
- }
- // SetProviderKey sets the "provider_key" field.
- func (m *AuthIdentityChannelMutation) SetProviderKey(s string) {
- m.provider_key = &s
- }
- // ProviderKey returns the value of the "provider_key" field in the mutation.
- func (m *AuthIdentityChannelMutation) ProviderKey() (r string, exists bool) {
- v := m.provider_key
- if v == nil {
- return
- }
- return *v, true
- }
- // OldProviderKey returns the old "provider_key" field's value of the AuthIdentityChannel entity.
- // If the AuthIdentityChannel object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *AuthIdentityChannelMutation) OldProviderKey(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldProviderKey is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldProviderKey requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldProviderKey: %w", err)
- }
- return oldValue.ProviderKey, nil
- }
- // ResetProviderKey resets all changes to the "provider_key" field.
- func (m *AuthIdentityChannelMutation) ResetProviderKey() {
- m.provider_key = nil
- }
- // SetChannel sets the "channel" field.
- func (m *AuthIdentityChannelMutation) SetChannel(s string) {
- m.channel = &s
- }
- // Channel returns the value of the "channel" field in the mutation.
- func (m *AuthIdentityChannelMutation) Channel() (r string, exists bool) {
- v := m.channel
- if v == nil {
- return
- }
- return *v, true
- }
- // OldChannel returns the old "channel" field's value of the AuthIdentityChannel entity.
- // If the AuthIdentityChannel object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *AuthIdentityChannelMutation) OldChannel(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldChannel is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldChannel requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldChannel: %w", err)
- }
- return oldValue.Channel, nil
- }
- // ResetChannel resets all changes to the "channel" field.
- func (m *AuthIdentityChannelMutation) ResetChannel() {
- m.channel = nil
- }
- // SetChannelAppID sets the "channel_app_id" field.
- func (m *AuthIdentityChannelMutation) SetChannelAppID(s string) {
- m.channel_app_id = &s
- }
- // ChannelAppID returns the value of the "channel_app_id" field in the mutation.
- func (m *AuthIdentityChannelMutation) ChannelAppID() (r string, exists bool) {
- v := m.channel_app_id
- if v == nil {
- return
- }
- return *v, true
- }
- // OldChannelAppID returns the old "channel_app_id" field's value of the AuthIdentityChannel entity.
- // If the AuthIdentityChannel object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *AuthIdentityChannelMutation) OldChannelAppID(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldChannelAppID is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldChannelAppID requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldChannelAppID: %w", err)
- }
- return oldValue.ChannelAppID, nil
- }
- // ResetChannelAppID resets all changes to the "channel_app_id" field.
- func (m *AuthIdentityChannelMutation) ResetChannelAppID() {
- m.channel_app_id = nil
- }
- // SetChannelSubject sets the "channel_subject" field.
- func (m *AuthIdentityChannelMutation) SetChannelSubject(s string) {
- m.channel_subject = &s
- }
- // ChannelSubject returns the value of the "channel_subject" field in the mutation.
- func (m *AuthIdentityChannelMutation) ChannelSubject() (r string, exists bool) {
- v := m.channel_subject
- if v == nil {
- return
- }
- return *v, true
- }
- // OldChannelSubject returns the old "channel_subject" field's value of the AuthIdentityChannel entity.
- // If the AuthIdentityChannel object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *AuthIdentityChannelMutation) OldChannelSubject(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldChannelSubject is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldChannelSubject requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldChannelSubject: %w", err)
- }
- return oldValue.ChannelSubject, nil
- }
- // ResetChannelSubject resets all changes to the "channel_subject" field.
- func (m *AuthIdentityChannelMutation) ResetChannelSubject() {
- m.channel_subject = nil
- }
- // SetMetadata sets the "metadata" field.
- func (m *AuthIdentityChannelMutation) SetMetadata(value map[string]interface{}) {
- m.metadata = &value
- }
- // Metadata returns the value of the "metadata" field in the mutation.
- func (m *AuthIdentityChannelMutation) Metadata() (r map[string]interface{}, exists bool) {
- v := m.metadata
- if v == nil {
- return
- }
- return *v, true
- }
- // OldMetadata returns the old "metadata" field's value of the AuthIdentityChannel entity.
- // If the AuthIdentityChannel object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *AuthIdentityChannelMutation) OldMetadata(ctx context.Context) (v map[string]interface{}, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldMetadata is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldMetadata requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldMetadata: %w", err)
- }
- return oldValue.Metadata, nil
- }
- // ResetMetadata resets all changes to the "metadata" field.
- func (m *AuthIdentityChannelMutation) ResetMetadata() {
- m.metadata = nil
- }
- // ClearIdentity clears the "identity" edge to the AuthIdentity entity.
- func (m *AuthIdentityChannelMutation) ClearIdentity() {
- m.clearedidentity = true
- m.clearedFields[authidentitychannel.FieldIdentityID] = struct{}{}
- }
- // IdentityCleared reports if the "identity" edge to the AuthIdentity entity was cleared.
- func (m *AuthIdentityChannelMutation) IdentityCleared() bool {
- return m.clearedidentity
- }
- // IdentityIDs returns the "identity" edge IDs in the mutation.
- // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
- // IdentityID instead. It exists only for internal usage by the builders.
- func (m *AuthIdentityChannelMutation) IdentityIDs() (ids []int64) {
- if id := m.identity; id != nil {
- ids = append(ids, *id)
- }
- return
- }
- // ResetIdentity resets all changes to the "identity" edge.
- func (m *AuthIdentityChannelMutation) ResetIdentity() {
- m.identity = nil
- m.clearedidentity = false
- }
- // Where appends a list predicates to the AuthIdentityChannelMutation builder.
- func (m *AuthIdentityChannelMutation) Where(ps ...predicate.AuthIdentityChannel) {
- m.predicates = append(m.predicates, ps...)
- }
- // WhereP appends storage-level predicates to the AuthIdentityChannelMutation builder. Using this method,
- // users can use type-assertion to append predicates that do not depend on any generated package.
- func (m *AuthIdentityChannelMutation) WhereP(ps ...func(*sql.Selector)) {
- p := make([]predicate.AuthIdentityChannel, len(ps))
- for i := range ps {
- p[i] = ps[i]
- }
- m.Where(p...)
- }
- // Op returns the operation name.
- func (m *AuthIdentityChannelMutation) Op() Op {
- return m.op
- }
- // SetOp allows setting the mutation operation.
- func (m *AuthIdentityChannelMutation) SetOp(op Op) {
- m.op = op
- }
- // Type returns the node type of this mutation (AuthIdentityChannel).
- func (m *AuthIdentityChannelMutation) Type() string {
- return m.typ
- }
- // Fields returns all fields that were changed during this mutation. Note that in
- // order to get all numeric fields that were incremented/decremented, call
- // AddedFields().
- func (m *AuthIdentityChannelMutation) Fields() []string {
- fields := make([]string, 0, 9)
- if m.created_at != nil {
- fields = append(fields, authidentitychannel.FieldCreatedAt)
- }
- if m.updated_at != nil {
- fields = append(fields, authidentitychannel.FieldUpdatedAt)
- }
- if m.identity != nil {
- fields = append(fields, authidentitychannel.FieldIdentityID)
- }
- if m.provider_type != nil {
- fields = append(fields, authidentitychannel.FieldProviderType)
- }
- if m.provider_key != nil {
- fields = append(fields, authidentitychannel.FieldProviderKey)
- }
- if m.channel != nil {
- fields = append(fields, authidentitychannel.FieldChannel)
- }
- if m.channel_app_id != nil {
- fields = append(fields, authidentitychannel.FieldChannelAppID)
- }
- if m.channel_subject != nil {
- fields = append(fields, authidentitychannel.FieldChannelSubject)
- }
- if m.metadata != nil {
- fields = append(fields, authidentitychannel.FieldMetadata)
- }
- return fields
- }
- // Field returns the value of a field with the given name. The second boolean
- // return value indicates that this field was not set, or was not defined in the
- // schema.
- func (m *AuthIdentityChannelMutation) Field(name string) (ent.Value, bool) {
- switch name {
- case authidentitychannel.FieldCreatedAt:
- return m.CreatedAt()
- case authidentitychannel.FieldUpdatedAt:
- return m.UpdatedAt()
- case authidentitychannel.FieldIdentityID:
- return m.IdentityID()
- case authidentitychannel.FieldProviderType:
- return m.ProviderType()
- case authidentitychannel.FieldProviderKey:
- return m.ProviderKey()
- case authidentitychannel.FieldChannel:
- return m.Channel()
- case authidentitychannel.FieldChannelAppID:
- return m.ChannelAppID()
- case authidentitychannel.FieldChannelSubject:
- return m.ChannelSubject()
- case authidentitychannel.FieldMetadata:
- return m.Metadata()
- }
- return nil, false
- }
- // OldField returns the old value of the field from the database. An error is
- // returned if the mutation operation is not UpdateOne, or the query to the
- // database failed.
- func (m *AuthIdentityChannelMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
- switch name {
- case authidentitychannel.FieldCreatedAt:
- return m.OldCreatedAt(ctx)
- case authidentitychannel.FieldUpdatedAt:
- return m.OldUpdatedAt(ctx)
- case authidentitychannel.FieldIdentityID:
- return m.OldIdentityID(ctx)
- case authidentitychannel.FieldProviderType:
- return m.OldProviderType(ctx)
- case authidentitychannel.FieldProviderKey:
- return m.OldProviderKey(ctx)
- case authidentitychannel.FieldChannel:
- return m.OldChannel(ctx)
- case authidentitychannel.FieldChannelAppID:
- return m.OldChannelAppID(ctx)
- case authidentitychannel.FieldChannelSubject:
- return m.OldChannelSubject(ctx)
- case authidentitychannel.FieldMetadata:
- return m.OldMetadata(ctx)
- }
- return nil, fmt.Errorf("unknown AuthIdentityChannel field %s", name)
- }
- // SetField sets the value of a field with the given name. It returns an error if
- // the field is not defined in the schema, or if the type mismatched the field
- // type.
- func (m *AuthIdentityChannelMutation) SetField(name string, value ent.Value) error {
- switch name {
- case authidentitychannel.FieldCreatedAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetCreatedAt(v)
- return nil
- case authidentitychannel.FieldUpdatedAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetUpdatedAt(v)
- return nil
- case authidentitychannel.FieldIdentityID:
- v, ok := value.(int64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetIdentityID(v)
- return nil
- case authidentitychannel.FieldProviderType:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetProviderType(v)
- return nil
- case authidentitychannel.FieldProviderKey:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetProviderKey(v)
- return nil
- case authidentitychannel.FieldChannel:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetChannel(v)
- return nil
- case authidentitychannel.FieldChannelAppID:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetChannelAppID(v)
- return nil
- case authidentitychannel.FieldChannelSubject:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetChannelSubject(v)
- return nil
- case authidentitychannel.FieldMetadata:
- v, ok := value.(map[string]interface{})
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetMetadata(v)
- return nil
- }
- return fmt.Errorf("unknown AuthIdentityChannel field %s", name)
- }
- // AddedFields returns all numeric fields that were incremented/decremented during
- // this mutation.
- func (m *AuthIdentityChannelMutation) AddedFields() []string {
- var fields []string
- return fields
- }
- // AddedField returns the numeric value that was incremented/decremented on a field
- // with the given name. The second boolean return value indicates that this field
- // was not set, or was not defined in the schema.
- func (m *AuthIdentityChannelMutation) AddedField(name string) (ent.Value, bool) {
- switch name {
- }
- return nil, false
- }
- // AddField adds the value to the field with the given name. It returns an error if
- // the field is not defined in the schema, or if the type mismatched the field
- // type.
- func (m *AuthIdentityChannelMutation) AddField(name string, value ent.Value) error {
- switch name {
- }
- return fmt.Errorf("unknown AuthIdentityChannel numeric field %s", name)
- }
- // ClearedFields returns all nullable fields that were cleared during this
- // mutation.
- func (m *AuthIdentityChannelMutation) ClearedFields() []string {
- return nil
- }
- // FieldCleared returns a boolean indicating if a field with the given name was
- // cleared in this mutation.
- func (m *AuthIdentityChannelMutation) FieldCleared(name string) bool {
- _, ok := m.clearedFields[name]
- return ok
- }
- // ClearField clears the value of the field with the given name. It returns an
- // error if the field is not defined in the schema.
- func (m *AuthIdentityChannelMutation) ClearField(name string) error {
- return fmt.Errorf("unknown AuthIdentityChannel nullable field %s", name)
- }
- // ResetField resets all changes in the mutation for the field with the given name.
- // It returns an error if the field is not defined in the schema.
- func (m *AuthIdentityChannelMutation) ResetField(name string) error {
- switch name {
- case authidentitychannel.FieldCreatedAt:
- m.ResetCreatedAt()
- return nil
- case authidentitychannel.FieldUpdatedAt:
- m.ResetUpdatedAt()
- return nil
- case authidentitychannel.FieldIdentityID:
- m.ResetIdentityID()
- return nil
- case authidentitychannel.FieldProviderType:
- m.ResetProviderType()
- return nil
- case authidentitychannel.FieldProviderKey:
- m.ResetProviderKey()
- return nil
- case authidentitychannel.FieldChannel:
- m.ResetChannel()
- return nil
- case authidentitychannel.FieldChannelAppID:
- m.ResetChannelAppID()
- return nil
- case authidentitychannel.FieldChannelSubject:
- m.ResetChannelSubject()
- return nil
- case authidentitychannel.FieldMetadata:
- m.ResetMetadata()
- return nil
- }
- return fmt.Errorf("unknown AuthIdentityChannel field %s", name)
- }
- // AddedEdges returns all edge names that were set/added in this mutation.
- func (m *AuthIdentityChannelMutation) AddedEdges() []string {
- edges := make([]string, 0, 1)
- if m.identity != nil {
- edges = append(edges, authidentitychannel.EdgeIdentity)
- }
- return edges
- }
- // AddedIDs returns all IDs (to other nodes) that were added for the given edge
- // name in this mutation.
- func (m *AuthIdentityChannelMutation) AddedIDs(name string) []ent.Value {
- switch name {
- case authidentitychannel.EdgeIdentity:
- if id := m.identity; id != nil {
- return []ent.Value{*id}
- }
- }
- return nil
- }
- // RemovedEdges returns all edge names that were removed in this mutation.
- func (m *AuthIdentityChannelMutation) RemovedEdges() []string {
- edges := make([]string, 0, 1)
- return edges
- }
- // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
- // the given name in this mutation.
- func (m *AuthIdentityChannelMutation) RemovedIDs(name string) []ent.Value {
- return nil
- }
- // ClearedEdges returns all edge names that were cleared in this mutation.
- func (m *AuthIdentityChannelMutation) ClearedEdges() []string {
- edges := make([]string, 0, 1)
- if m.clearedidentity {
- edges = append(edges, authidentitychannel.EdgeIdentity)
- }
- return edges
- }
- // EdgeCleared returns a boolean which indicates if the edge with the given name
- // was cleared in this mutation.
- func (m *AuthIdentityChannelMutation) EdgeCleared(name string) bool {
- switch name {
- case authidentitychannel.EdgeIdentity:
- return m.clearedidentity
- }
- return false
- }
- // ClearEdge clears the value of the edge with the given name. It returns an error
- // if that edge is not defined in the schema.
- func (m *AuthIdentityChannelMutation) ClearEdge(name string) error {
- switch name {
- case authidentitychannel.EdgeIdentity:
- m.ClearIdentity()
- return nil
- }
- return fmt.Errorf("unknown AuthIdentityChannel unique edge %s", name)
- }
- // ResetEdge resets all changes to the edge with the given name in this mutation.
- // It returns an error if the edge is not defined in the schema.
- func (m *AuthIdentityChannelMutation) ResetEdge(name string) error {
- switch name {
- case authidentitychannel.EdgeIdentity:
- m.ResetIdentity()
- return nil
- }
- return fmt.Errorf("unknown AuthIdentityChannel edge %s", name)
- }
- // BatchImageEventMutation represents an operation that mutates the BatchImageEvent nodes in the graph.
- type BatchImageEventMutation struct {
- config
- op Op
- typ string
- id *int64
- job_id *string
- event_type *string
- payload *map[string]interface{}
- event_hash *string
- created_at *time.Time
- clearedFields map[string]struct{}
- done bool
- oldValue func(context.Context) (*BatchImageEvent, error)
- predicates []predicate.BatchImageEvent
- }
- var _ ent.Mutation = (*BatchImageEventMutation)(nil)
- // batchimageeventOption allows management of the mutation configuration using functional options.
- type batchimageeventOption func(*BatchImageEventMutation)
- // newBatchImageEventMutation creates new mutation for the BatchImageEvent entity.
- func newBatchImageEventMutation(c config, op Op, opts ...batchimageeventOption) *BatchImageEventMutation {
- m := &BatchImageEventMutation{
- config: c,
- op: op,
- typ: TypeBatchImageEvent,
- clearedFields: make(map[string]struct{}),
- }
- for _, opt := range opts {
- opt(m)
- }
- return m
- }
- // withBatchImageEventID sets the ID field of the mutation.
- func withBatchImageEventID(id int64) batchimageeventOption {
- return func(m *BatchImageEventMutation) {
- var (
- err error
- once sync.Once
- value *BatchImageEvent
- )
- m.oldValue = func(ctx context.Context) (*BatchImageEvent, error) {
- once.Do(func() {
- if m.done {
- err = errors.New("querying old values post mutation is not allowed")
- } else {
- value, err = m.Client().BatchImageEvent.Get(ctx, id)
- }
- })
- return value, err
- }
- m.id = &id
- }
- }
- // withBatchImageEvent sets the old BatchImageEvent of the mutation.
- func withBatchImageEvent(node *BatchImageEvent) batchimageeventOption {
- return func(m *BatchImageEventMutation) {
- m.oldValue = func(context.Context) (*BatchImageEvent, error) {
- return node, nil
- }
- m.id = &node.ID
- }
- }
- // Client returns a new `ent.Client` from the mutation. If the mutation was
- // executed in a transaction (ent.Tx), a transactional client is returned.
- func (m BatchImageEventMutation) Client() *Client {
- client := &Client{config: m.config}
- client.init()
- return client
- }
- // Tx returns an `ent.Tx` for mutations that were executed in transactions;
- // it returns an error otherwise.
- func (m BatchImageEventMutation) Tx() (*Tx, error) {
- if _, ok := m.driver.(*txDriver); !ok {
- return nil, errors.New("ent: mutation is not running in a transaction")
- }
- tx := &Tx{config: m.config}
- tx.init()
- return tx, nil
- }
- // ID returns the ID value in the mutation. Note that the ID is only available
- // if it was provided to the builder or after it was returned from the database.
- func (m *BatchImageEventMutation) ID() (id int64, exists bool) {
- if m.id == nil {
- return
- }
- return *m.id, true
- }
- // IDs queries the database and returns the entity ids that match the mutation's predicate.
- // That means, if the mutation is applied within a transaction with an isolation level such
- // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
- // or updated by the mutation.
- func (m *BatchImageEventMutation) IDs(ctx context.Context) ([]int64, error) {
- switch {
- case m.op.Is(OpUpdateOne | OpDeleteOne):
- id, exists := m.ID()
- if exists {
- return []int64{id}, nil
- }
- fallthrough
- case m.op.Is(OpUpdate | OpDelete):
- return m.Client().BatchImageEvent.Query().Where(m.predicates...).IDs(ctx)
- default:
- return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
- }
- }
- // SetJobID sets the "job_id" field.
- func (m *BatchImageEventMutation) SetJobID(s string) {
- m.job_id = &s
- }
- // JobID returns the value of the "job_id" field in the mutation.
- func (m *BatchImageEventMutation) JobID() (r string, exists bool) {
- v := m.job_id
- if v == nil {
- return
- }
- return *v, true
- }
- // OldJobID returns the old "job_id" field's value of the BatchImageEvent entity.
- // If the BatchImageEvent object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *BatchImageEventMutation) OldJobID(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldJobID is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldJobID requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldJobID: %w", err)
- }
- return oldValue.JobID, nil
- }
- // ResetJobID resets all changes to the "job_id" field.
- func (m *BatchImageEventMutation) ResetJobID() {
- m.job_id = nil
- }
- // SetEventType sets the "event_type" field.
- func (m *BatchImageEventMutation) SetEventType(s string) {
- m.event_type = &s
- }
- // EventType returns the value of the "event_type" field in the mutation.
- func (m *BatchImageEventMutation) EventType() (r string, exists bool) {
- v := m.event_type
- if v == nil {
- return
- }
- return *v, true
- }
- // OldEventType returns the old "event_type" field's value of the BatchImageEvent entity.
- // If the BatchImageEvent object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *BatchImageEventMutation) OldEventType(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldEventType is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldEventType requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldEventType: %w", err)
- }
- return oldValue.EventType, nil
- }
- // ResetEventType resets all changes to the "event_type" field.
- func (m *BatchImageEventMutation) ResetEventType() {
- m.event_type = nil
- }
- // SetPayload sets the "payload" field.
- func (m *BatchImageEventMutation) SetPayload(value map[string]interface{}) {
- m.payload = &value
- }
- // Payload returns the value of the "payload" field in the mutation.
- func (m *BatchImageEventMutation) Payload() (r map[string]interface{}, exists bool) {
- v := m.payload
- if v == nil {
- return
- }
- return *v, true
- }
- // OldPayload returns the old "payload" field's value of the BatchImageEvent entity.
- // If the BatchImageEvent object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *BatchImageEventMutation) OldPayload(ctx context.Context) (v map[string]interface{}, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldPayload is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldPayload requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldPayload: %w", err)
- }
- return oldValue.Payload, nil
- }
- // ClearPayload clears the value of the "payload" field.
- func (m *BatchImageEventMutation) ClearPayload() {
- m.payload = nil
- m.clearedFields[batchimageevent.FieldPayload] = struct{}{}
- }
- // PayloadCleared returns if the "payload" field was cleared in this mutation.
- func (m *BatchImageEventMutation) PayloadCleared() bool {
- _, ok := m.clearedFields[batchimageevent.FieldPayload]
- return ok
- }
- // ResetPayload resets all changes to the "payload" field.
- func (m *BatchImageEventMutation) ResetPayload() {
- m.payload = nil
- delete(m.clearedFields, batchimageevent.FieldPayload)
- }
- // SetEventHash sets the "event_hash" field.
- func (m *BatchImageEventMutation) SetEventHash(s string) {
- m.event_hash = &s
- }
- // EventHash returns the value of the "event_hash" field in the mutation.
- func (m *BatchImageEventMutation) EventHash() (r string, exists bool) {
- v := m.event_hash
- if v == nil {
- return
- }
- return *v, true
- }
- // OldEventHash returns the old "event_hash" field's value of the BatchImageEvent entity.
- // If the BatchImageEvent object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *BatchImageEventMutation) OldEventHash(ctx context.Context) (v *string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldEventHash is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldEventHash requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldEventHash: %w", err)
- }
- return oldValue.EventHash, nil
- }
- // ClearEventHash clears the value of the "event_hash" field.
- func (m *BatchImageEventMutation) ClearEventHash() {
- m.event_hash = nil
- m.clearedFields[batchimageevent.FieldEventHash] = struct{}{}
- }
- // EventHashCleared returns if the "event_hash" field was cleared in this mutation.
- func (m *BatchImageEventMutation) EventHashCleared() bool {
- _, ok := m.clearedFields[batchimageevent.FieldEventHash]
- return ok
- }
- // ResetEventHash resets all changes to the "event_hash" field.
- func (m *BatchImageEventMutation) ResetEventHash() {
- m.event_hash = nil
- delete(m.clearedFields, batchimageevent.FieldEventHash)
- }
- // SetCreatedAt sets the "created_at" field.
- func (m *BatchImageEventMutation) SetCreatedAt(t time.Time) {
- m.created_at = &t
- }
- // CreatedAt returns the value of the "created_at" field in the mutation.
- func (m *BatchImageEventMutation) CreatedAt() (r time.Time, exists bool) {
- v := m.created_at
- if v == nil {
- return
- }
- return *v, true
- }
- // OldCreatedAt returns the old "created_at" field's value of the BatchImageEvent entity.
- // If the BatchImageEvent object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *BatchImageEventMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldCreatedAt requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
- }
- return oldValue.CreatedAt, nil
- }
- // ResetCreatedAt resets all changes to the "created_at" field.
- func (m *BatchImageEventMutation) ResetCreatedAt() {
- m.created_at = nil
- }
- // Where appends a list predicates to the BatchImageEventMutation builder.
- func (m *BatchImageEventMutation) Where(ps ...predicate.BatchImageEvent) {
- m.predicates = append(m.predicates, ps...)
- }
- // WhereP appends storage-level predicates to the BatchImageEventMutation builder. Using this method,
- // users can use type-assertion to append predicates that do not depend on any generated package.
- func (m *BatchImageEventMutation) WhereP(ps ...func(*sql.Selector)) {
- p := make([]predicate.BatchImageEvent, len(ps))
- for i := range ps {
- p[i] = ps[i]
- }
- m.Where(p...)
- }
- // Op returns the operation name.
- func (m *BatchImageEventMutation) Op() Op {
- return m.op
- }
- // SetOp allows setting the mutation operation.
- func (m *BatchImageEventMutation) SetOp(op Op) {
- m.op = op
- }
- // Type returns the node type of this mutation (BatchImageEvent).
- func (m *BatchImageEventMutation) Type() string {
- return m.typ
- }
- // Fields returns all fields that were changed during this mutation. Note that in
- // order to get all numeric fields that were incremented/decremented, call
- // AddedFields().
- func (m *BatchImageEventMutation) Fields() []string {
- fields := make([]string, 0, 5)
- if m.job_id != nil {
- fields = append(fields, batchimageevent.FieldJobID)
- }
- if m.event_type != nil {
- fields = append(fields, batchimageevent.FieldEventType)
- }
- if m.payload != nil {
- fields = append(fields, batchimageevent.FieldPayload)
- }
- if m.event_hash != nil {
- fields = append(fields, batchimageevent.FieldEventHash)
- }
- if m.created_at != nil {
- fields = append(fields, batchimageevent.FieldCreatedAt)
- }
- return fields
- }
- // Field returns the value of a field with the given name. The second boolean
- // return value indicates that this field was not set, or was not defined in the
- // schema.
- func (m *BatchImageEventMutation) Field(name string) (ent.Value, bool) {
- switch name {
- case batchimageevent.FieldJobID:
- return m.JobID()
- case batchimageevent.FieldEventType:
- return m.EventType()
- case batchimageevent.FieldPayload:
- return m.Payload()
- case batchimageevent.FieldEventHash:
- return m.EventHash()
- case batchimageevent.FieldCreatedAt:
- return m.CreatedAt()
- }
- return nil, false
- }
- // OldField returns the old value of the field from the database. An error is
- // returned if the mutation operation is not UpdateOne, or the query to the
- // database failed.
- func (m *BatchImageEventMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
- switch name {
- case batchimageevent.FieldJobID:
- return m.OldJobID(ctx)
- case batchimageevent.FieldEventType:
- return m.OldEventType(ctx)
- case batchimageevent.FieldPayload:
- return m.OldPayload(ctx)
- case batchimageevent.FieldEventHash:
- return m.OldEventHash(ctx)
- case batchimageevent.FieldCreatedAt:
- return m.OldCreatedAt(ctx)
- }
- return nil, fmt.Errorf("unknown BatchImageEvent field %s", name)
- }
- // SetField sets the value of a field with the given name. It returns an error if
- // the field is not defined in the schema, or if the type mismatched the field
- // type.
- func (m *BatchImageEventMutation) SetField(name string, value ent.Value) error {
- switch name {
- case batchimageevent.FieldJobID:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetJobID(v)
- return nil
- case batchimageevent.FieldEventType:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetEventType(v)
- return nil
- case batchimageevent.FieldPayload:
- v, ok := value.(map[string]interface{})
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetPayload(v)
- return nil
- case batchimageevent.FieldEventHash:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetEventHash(v)
- return nil
- case batchimageevent.FieldCreatedAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetCreatedAt(v)
- return nil
- }
- return fmt.Errorf("unknown BatchImageEvent field %s", name)
- }
- // AddedFields returns all numeric fields that were incremented/decremented during
- // this mutation.
- func (m *BatchImageEventMutation) AddedFields() []string {
- return nil
- }
- // AddedField returns the numeric value that was incremented/decremented on a field
- // with the given name. The second boolean return value indicates that this field
- // was not set, or was not defined in the schema.
- func (m *BatchImageEventMutation) AddedField(name string) (ent.Value, bool) {
- return nil, false
- }
- // AddField adds the value to the field with the given name. It returns an error if
- // the field is not defined in the schema, or if the type mismatched the field
- // type.
- func (m *BatchImageEventMutation) AddField(name string, value ent.Value) error {
- switch name {
- }
- return fmt.Errorf("unknown BatchImageEvent numeric field %s", name)
- }
- // ClearedFields returns all nullable fields that were cleared during this
- // mutation.
- func (m *BatchImageEventMutation) ClearedFields() []string {
- var fields []string
- if m.FieldCleared(batchimageevent.FieldPayload) {
- fields = append(fields, batchimageevent.FieldPayload)
- }
- if m.FieldCleared(batchimageevent.FieldEventHash) {
- fields = append(fields, batchimageevent.FieldEventHash)
- }
- return fields
- }
- // FieldCleared returns a boolean indicating if a field with the given name was
- // cleared in this mutation.
- func (m *BatchImageEventMutation) FieldCleared(name string) bool {
- _, ok := m.clearedFields[name]
- return ok
- }
- // ClearField clears the value of the field with the given name. It returns an
- // error if the field is not defined in the schema.
- func (m *BatchImageEventMutation) ClearField(name string) error {
- switch name {
- case batchimageevent.FieldPayload:
- m.ClearPayload()
- return nil
- case batchimageevent.FieldEventHash:
- m.ClearEventHash()
- return nil
- }
- return fmt.Errorf("unknown BatchImageEvent nullable field %s", name)
- }
- // ResetField resets all changes in the mutation for the field with the given name.
- // It returns an error if the field is not defined in the schema.
- func (m *BatchImageEventMutation) ResetField(name string) error {
- switch name {
- case batchimageevent.FieldJobID:
- m.ResetJobID()
- return nil
- case batchimageevent.FieldEventType:
- m.ResetEventType()
- return nil
- case batchimageevent.FieldPayload:
- m.ResetPayload()
- return nil
- case batchimageevent.FieldEventHash:
- m.ResetEventHash()
- return nil
- case batchimageevent.FieldCreatedAt:
- m.ResetCreatedAt()
- return nil
- }
- return fmt.Errorf("unknown BatchImageEvent field %s", name)
- }
- // AddedEdges returns all edge names that were set/added in this mutation.
- func (m *BatchImageEventMutation) AddedEdges() []string {
- edges := make([]string, 0, 0)
- return edges
- }
- // AddedIDs returns all IDs (to other nodes) that were added for the given edge
- // name in this mutation.
- func (m *BatchImageEventMutation) AddedIDs(name string) []ent.Value {
- return nil
- }
- // RemovedEdges returns all edge names that were removed in this mutation.
- func (m *BatchImageEventMutation) RemovedEdges() []string {
- edges := make([]string, 0, 0)
- return edges
- }
- // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
- // the given name in this mutation.
- func (m *BatchImageEventMutation) RemovedIDs(name string) []ent.Value {
- return nil
- }
- // ClearedEdges returns all edge names that were cleared in this mutation.
- func (m *BatchImageEventMutation) ClearedEdges() []string {
- edges := make([]string, 0, 0)
- return edges
- }
- // EdgeCleared returns a boolean which indicates if the edge with the given name
- // was cleared in this mutation.
- func (m *BatchImageEventMutation) EdgeCleared(name string) bool {
- return false
- }
- // ClearEdge clears the value of the edge with the given name. It returns an error
- // if that edge is not defined in the schema.
- func (m *BatchImageEventMutation) ClearEdge(name string) error {
- return fmt.Errorf("unknown BatchImageEvent unique edge %s", name)
- }
- // ResetEdge resets all changes to the edge with the given name in this mutation.
- // It returns an error if the edge is not defined in the schema.
- func (m *BatchImageEventMutation) ResetEdge(name string) error {
- return fmt.Errorf("unknown BatchImageEvent edge %s", name)
- }
- // BatchImageItemMutation represents an operation that mutates the BatchImageItem nodes in the graph.
- type BatchImageItemMutation struct {
- config
- op Op
- typ string
- id *int64
- job_id *string
- custom_id *string
- status *string
- request_hash *string
- prompt_preview *string
- provider_source_object *string
- source_line_number *int
- addsource_line_number *int
- source_byte_offset *int64
- addsource_byte_offset *int64
- source_byte_length *int64
- addsource_byte_length *int64
- mime_type *string
- file_extension *string
- image_count *int
- addimage_count *int
- error_code *string
- error_message *string
- billed_amount *float64
- addbilled_amount *float64
- created_at *time.Time
- indexed_at *time.Time
- clearedFields map[string]struct{}
- done bool
- oldValue func(context.Context) (*BatchImageItem, error)
- predicates []predicate.BatchImageItem
- }
- var _ ent.Mutation = (*BatchImageItemMutation)(nil)
- // batchimageitemOption allows management of the mutation configuration using functional options.
- type batchimageitemOption func(*BatchImageItemMutation)
- // newBatchImageItemMutation creates new mutation for the BatchImageItem entity.
- func newBatchImageItemMutation(c config, op Op, opts ...batchimageitemOption) *BatchImageItemMutation {
- m := &BatchImageItemMutation{
- config: c,
- op: op,
- typ: TypeBatchImageItem,
- clearedFields: make(map[string]struct{}),
- }
- for _, opt := range opts {
- opt(m)
- }
- return m
- }
- // withBatchImageItemID sets the ID field of the mutation.
- func withBatchImageItemID(id int64) batchimageitemOption {
- return func(m *BatchImageItemMutation) {
- var (
- err error
- once sync.Once
- value *BatchImageItem
- )
- m.oldValue = func(ctx context.Context) (*BatchImageItem, error) {
- once.Do(func() {
- if m.done {
- err = errors.New("querying old values post mutation is not allowed")
- } else {
- value, err = m.Client().BatchImageItem.Get(ctx, id)
- }
- })
- return value, err
- }
- m.id = &id
- }
- }
- // withBatchImageItem sets the old BatchImageItem of the mutation.
- func withBatchImageItem(node *BatchImageItem) batchimageitemOption {
- return func(m *BatchImageItemMutation) {
- m.oldValue = func(context.Context) (*BatchImageItem, error) {
- return node, nil
- }
- m.id = &node.ID
- }
- }
- // Client returns a new `ent.Client` from the mutation. If the mutation was
- // executed in a transaction (ent.Tx), a transactional client is returned.
- func (m BatchImageItemMutation) Client() *Client {
- client := &Client{config: m.config}
- client.init()
- return client
- }
- // Tx returns an `ent.Tx` for mutations that were executed in transactions;
- // it returns an error otherwise.
- func (m BatchImageItemMutation) Tx() (*Tx, error) {
- if _, ok := m.driver.(*txDriver); !ok {
- return nil, errors.New("ent: mutation is not running in a transaction")
- }
- tx := &Tx{config: m.config}
- tx.init()
- return tx, nil
- }
- // ID returns the ID value in the mutation. Note that the ID is only available
- // if it was provided to the builder or after it was returned from the database.
- func (m *BatchImageItemMutation) ID() (id int64, exists bool) {
- if m.id == nil {
- return
- }
- return *m.id, true
- }
- // IDs queries the database and returns the entity ids that match the mutation's predicate.
- // That means, if the mutation is applied within a transaction with an isolation level such
- // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
- // or updated by the mutation.
- func (m *BatchImageItemMutation) IDs(ctx context.Context) ([]int64, error) {
- switch {
- case m.op.Is(OpUpdateOne | OpDeleteOne):
- id, exists := m.ID()
- if exists {
- return []int64{id}, nil
- }
- fallthrough
- case m.op.Is(OpUpdate | OpDelete):
- return m.Client().BatchImageItem.Query().Where(m.predicates...).IDs(ctx)
- default:
- return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
- }
- }
- // SetJobID sets the "job_id" field.
- func (m *BatchImageItemMutation) SetJobID(s string) {
- m.job_id = &s
- }
- // JobID returns the value of the "job_id" field in the mutation.
- func (m *BatchImageItemMutation) JobID() (r string, exists bool) {
- v := m.job_id
- if v == nil {
- return
- }
- return *v, true
- }
- // OldJobID returns the old "job_id" field's value of the BatchImageItem entity.
- // If the BatchImageItem object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *BatchImageItemMutation) OldJobID(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldJobID is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldJobID requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldJobID: %w", err)
- }
- return oldValue.JobID, nil
- }
- // ResetJobID resets all changes to the "job_id" field.
- func (m *BatchImageItemMutation) ResetJobID() {
- m.job_id = nil
- }
- // SetCustomID sets the "custom_id" field.
- func (m *BatchImageItemMutation) SetCustomID(s string) {
- m.custom_id = &s
- }
- // CustomID returns the value of the "custom_id" field in the mutation.
- func (m *BatchImageItemMutation) CustomID() (r string, exists bool) {
- v := m.custom_id
- if v == nil {
- return
- }
- return *v, true
- }
- // OldCustomID returns the old "custom_id" field's value of the BatchImageItem entity.
- // If the BatchImageItem object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *BatchImageItemMutation) OldCustomID(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldCustomID is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldCustomID requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldCustomID: %w", err)
- }
- return oldValue.CustomID, nil
- }
- // ResetCustomID resets all changes to the "custom_id" field.
- func (m *BatchImageItemMutation) ResetCustomID() {
- m.custom_id = nil
- }
- // SetStatus sets the "status" field.
- func (m *BatchImageItemMutation) SetStatus(s string) {
- m.status = &s
- }
- // Status returns the value of the "status" field in the mutation.
- func (m *BatchImageItemMutation) Status() (r string, exists bool) {
- v := m.status
- if v == nil {
- return
- }
- return *v, true
- }
- // OldStatus returns the old "status" field's value of the BatchImageItem entity.
- // If the BatchImageItem object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *BatchImageItemMutation) OldStatus(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldStatus is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldStatus requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldStatus: %w", err)
- }
- return oldValue.Status, nil
- }
- // ResetStatus resets all changes to the "status" field.
- func (m *BatchImageItemMutation) ResetStatus() {
- m.status = nil
- }
- // SetRequestHash sets the "request_hash" field.
- func (m *BatchImageItemMutation) SetRequestHash(s string) {
- m.request_hash = &s
- }
- // RequestHash returns the value of the "request_hash" field in the mutation.
- func (m *BatchImageItemMutation) RequestHash() (r string, exists bool) {
- v := m.request_hash
- if v == nil {
- return
- }
- return *v, true
- }
- // OldRequestHash returns the old "request_hash" field's value of the BatchImageItem entity.
- // If the BatchImageItem object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *BatchImageItemMutation) OldRequestHash(ctx context.Context) (v *string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldRequestHash is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldRequestHash requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldRequestHash: %w", err)
- }
- return oldValue.RequestHash, nil
- }
- // ClearRequestHash clears the value of the "request_hash" field.
- func (m *BatchImageItemMutation) ClearRequestHash() {
- m.request_hash = nil
- m.clearedFields[batchimageitem.FieldRequestHash] = struct{}{}
- }
- // RequestHashCleared returns if the "request_hash" field was cleared in this mutation.
- func (m *BatchImageItemMutation) RequestHashCleared() bool {
- _, ok := m.clearedFields[batchimageitem.FieldRequestHash]
- return ok
- }
- // ResetRequestHash resets all changes to the "request_hash" field.
- func (m *BatchImageItemMutation) ResetRequestHash() {
- m.request_hash = nil
- delete(m.clearedFields, batchimageitem.FieldRequestHash)
- }
- // SetPromptPreview sets the "prompt_preview" field.
- func (m *BatchImageItemMutation) SetPromptPreview(s string) {
- m.prompt_preview = &s
- }
- // PromptPreview returns the value of the "prompt_preview" field in the mutation.
- func (m *BatchImageItemMutation) PromptPreview() (r string, exists bool) {
- v := m.prompt_preview
- if v == nil {
- return
- }
- return *v, true
- }
- // OldPromptPreview returns the old "prompt_preview" field's value of the BatchImageItem entity.
- // If the BatchImageItem object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *BatchImageItemMutation) OldPromptPreview(ctx context.Context) (v *string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldPromptPreview is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldPromptPreview requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldPromptPreview: %w", err)
- }
- return oldValue.PromptPreview, nil
- }
- // ClearPromptPreview clears the value of the "prompt_preview" field.
- func (m *BatchImageItemMutation) ClearPromptPreview() {
- m.prompt_preview = nil
- m.clearedFields[batchimageitem.FieldPromptPreview] = struct{}{}
- }
- // PromptPreviewCleared returns if the "prompt_preview" field was cleared in this mutation.
- func (m *BatchImageItemMutation) PromptPreviewCleared() bool {
- _, ok := m.clearedFields[batchimageitem.FieldPromptPreview]
- return ok
- }
- // ResetPromptPreview resets all changes to the "prompt_preview" field.
- func (m *BatchImageItemMutation) ResetPromptPreview() {
- m.prompt_preview = nil
- delete(m.clearedFields, batchimageitem.FieldPromptPreview)
- }
- // SetProviderSourceObject sets the "provider_source_object" field.
- func (m *BatchImageItemMutation) SetProviderSourceObject(s string) {
- m.provider_source_object = &s
- }
- // ProviderSourceObject returns the value of the "provider_source_object" field in the mutation.
- func (m *BatchImageItemMutation) ProviderSourceObject() (r string, exists bool) {
- v := m.provider_source_object
- if v == nil {
- return
- }
- return *v, true
- }
- // OldProviderSourceObject returns the old "provider_source_object" field's value of the BatchImageItem entity.
- // If the BatchImageItem object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *BatchImageItemMutation) OldProviderSourceObject(ctx context.Context) (v *string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldProviderSourceObject is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldProviderSourceObject requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldProviderSourceObject: %w", err)
- }
- return oldValue.ProviderSourceObject, nil
- }
- // ClearProviderSourceObject clears the value of the "provider_source_object" field.
- func (m *BatchImageItemMutation) ClearProviderSourceObject() {
- m.provider_source_object = nil
- m.clearedFields[batchimageitem.FieldProviderSourceObject] = struct{}{}
- }
- // ProviderSourceObjectCleared returns if the "provider_source_object" field was cleared in this mutation.
- func (m *BatchImageItemMutation) ProviderSourceObjectCleared() bool {
- _, ok := m.clearedFields[batchimageitem.FieldProviderSourceObject]
- return ok
- }
- // ResetProviderSourceObject resets all changes to the "provider_source_object" field.
- func (m *BatchImageItemMutation) ResetProviderSourceObject() {
- m.provider_source_object = nil
- delete(m.clearedFields, batchimageitem.FieldProviderSourceObject)
- }
- // SetSourceLineNumber sets the "source_line_number" field.
- func (m *BatchImageItemMutation) SetSourceLineNumber(i int) {
- m.source_line_number = &i
- m.addsource_line_number = nil
- }
- // SourceLineNumber returns the value of the "source_line_number" field in the mutation.
- func (m *BatchImageItemMutation) SourceLineNumber() (r int, exists bool) {
- v := m.source_line_number
- if v == nil {
- return
- }
- return *v, true
- }
- // OldSourceLineNumber returns the old "source_line_number" field's value of the BatchImageItem entity.
- // If the BatchImageItem object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *BatchImageItemMutation) OldSourceLineNumber(ctx context.Context) (v *int, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldSourceLineNumber is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldSourceLineNumber requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldSourceLineNumber: %w", err)
- }
- return oldValue.SourceLineNumber, nil
- }
- // AddSourceLineNumber adds i to the "source_line_number" field.
- func (m *BatchImageItemMutation) AddSourceLineNumber(i int) {
- if m.addsource_line_number != nil {
- *m.addsource_line_number += i
- } else {
- m.addsource_line_number = &i
- }
- }
- // AddedSourceLineNumber returns the value that was added to the "source_line_number" field in this mutation.
- func (m *BatchImageItemMutation) AddedSourceLineNumber() (r int, exists bool) {
- v := m.addsource_line_number
- if v == nil {
- return
- }
- return *v, true
- }
- // ClearSourceLineNumber clears the value of the "source_line_number" field.
- func (m *BatchImageItemMutation) ClearSourceLineNumber() {
- m.source_line_number = nil
- m.addsource_line_number = nil
- m.clearedFields[batchimageitem.FieldSourceLineNumber] = struct{}{}
- }
- // SourceLineNumberCleared returns if the "source_line_number" field was cleared in this mutation.
- func (m *BatchImageItemMutation) SourceLineNumberCleared() bool {
- _, ok := m.clearedFields[batchimageitem.FieldSourceLineNumber]
- return ok
- }
- // ResetSourceLineNumber resets all changes to the "source_line_number" field.
- func (m *BatchImageItemMutation) ResetSourceLineNumber() {
- m.source_line_number = nil
- m.addsource_line_number = nil
- delete(m.clearedFields, batchimageitem.FieldSourceLineNumber)
- }
- // SetSourceByteOffset sets the "source_byte_offset" field.
- func (m *BatchImageItemMutation) SetSourceByteOffset(i int64) {
- m.source_byte_offset = &i
- m.addsource_byte_offset = nil
- }
- // SourceByteOffset returns the value of the "source_byte_offset" field in the mutation.
- func (m *BatchImageItemMutation) SourceByteOffset() (r int64, exists bool) {
- v := m.source_byte_offset
- if v == nil {
- return
- }
- return *v, true
- }
- // OldSourceByteOffset returns the old "source_byte_offset" field's value of the BatchImageItem entity.
- // If the BatchImageItem object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *BatchImageItemMutation) OldSourceByteOffset(ctx context.Context) (v *int64, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldSourceByteOffset is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldSourceByteOffset requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldSourceByteOffset: %w", err)
- }
- return oldValue.SourceByteOffset, nil
- }
- // AddSourceByteOffset adds i to the "source_byte_offset" field.
- func (m *BatchImageItemMutation) AddSourceByteOffset(i int64) {
- if m.addsource_byte_offset != nil {
- *m.addsource_byte_offset += i
- } else {
- m.addsource_byte_offset = &i
- }
- }
- // AddedSourceByteOffset returns the value that was added to the "source_byte_offset" field in this mutation.
- func (m *BatchImageItemMutation) AddedSourceByteOffset() (r int64, exists bool) {
- v := m.addsource_byte_offset
- if v == nil {
- return
- }
- return *v, true
- }
- // ClearSourceByteOffset clears the value of the "source_byte_offset" field.
- func (m *BatchImageItemMutation) ClearSourceByteOffset() {
- m.source_byte_offset = nil
- m.addsource_byte_offset = nil
- m.clearedFields[batchimageitem.FieldSourceByteOffset] = struct{}{}
- }
- // SourceByteOffsetCleared returns if the "source_byte_offset" field was cleared in this mutation.
- func (m *BatchImageItemMutation) SourceByteOffsetCleared() bool {
- _, ok := m.clearedFields[batchimageitem.FieldSourceByteOffset]
- return ok
- }
- // ResetSourceByteOffset resets all changes to the "source_byte_offset" field.
- func (m *BatchImageItemMutation) ResetSourceByteOffset() {
- m.source_byte_offset = nil
- m.addsource_byte_offset = nil
- delete(m.clearedFields, batchimageitem.FieldSourceByteOffset)
- }
- // SetSourceByteLength sets the "source_byte_length" field.
- func (m *BatchImageItemMutation) SetSourceByteLength(i int64) {
- m.source_byte_length = &i
- m.addsource_byte_length = nil
- }
- // SourceByteLength returns the value of the "source_byte_length" field in the mutation.
- func (m *BatchImageItemMutation) SourceByteLength() (r int64, exists bool) {
- v := m.source_byte_length
- if v == nil {
- return
- }
- return *v, true
- }
- // OldSourceByteLength returns the old "source_byte_length" field's value of the BatchImageItem entity.
- // If the BatchImageItem object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *BatchImageItemMutation) OldSourceByteLength(ctx context.Context) (v *int64, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldSourceByteLength is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldSourceByteLength requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldSourceByteLength: %w", err)
- }
- return oldValue.SourceByteLength, nil
- }
- // AddSourceByteLength adds i to the "source_byte_length" field.
- func (m *BatchImageItemMutation) AddSourceByteLength(i int64) {
- if m.addsource_byte_length != nil {
- *m.addsource_byte_length += i
- } else {
- m.addsource_byte_length = &i
- }
- }
- // AddedSourceByteLength returns the value that was added to the "source_byte_length" field in this mutation.
- func (m *BatchImageItemMutation) AddedSourceByteLength() (r int64, exists bool) {
- v := m.addsource_byte_length
- if v == nil {
- return
- }
- return *v, true
- }
- // ClearSourceByteLength clears the value of the "source_byte_length" field.
- func (m *BatchImageItemMutation) ClearSourceByteLength() {
- m.source_byte_length = nil
- m.addsource_byte_length = nil
- m.clearedFields[batchimageitem.FieldSourceByteLength] = struct{}{}
- }
- // SourceByteLengthCleared returns if the "source_byte_length" field was cleared in this mutation.
- func (m *BatchImageItemMutation) SourceByteLengthCleared() bool {
- _, ok := m.clearedFields[batchimageitem.FieldSourceByteLength]
- return ok
- }
- // ResetSourceByteLength resets all changes to the "source_byte_length" field.
- func (m *BatchImageItemMutation) ResetSourceByteLength() {
- m.source_byte_length = nil
- m.addsource_byte_length = nil
- delete(m.clearedFields, batchimageitem.FieldSourceByteLength)
- }
- // SetMimeType sets the "mime_type" field.
- func (m *BatchImageItemMutation) SetMimeType(s string) {
- m.mime_type = &s
- }
- // MimeType returns the value of the "mime_type" field in the mutation.
- func (m *BatchImageItemMutation) MimeType() (r string, exists bool) {
- v := m.mime_type
- if v == nil {
- return
- }
- return *v, true
- }
- // OldMimeType returns the old "mime_type" field's value of the BatchImageItem entity.
- // If the BatchImageItem object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *BatchImageItemMutation) OldMimeType(ctx context.Context) (v *string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldMimeType is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldMimeType requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldMimeType: %w", err)
- }
- return oldValue.MimeType, nil
- }
- // ClearMimeType clears the value of the "mime_type" field.
- func (m *BatchImageItemMutation) ClearMimeType() {
- m.mime_type = nil
- m.clearedFields[batchimageitem.FieldMimeType] = struct{}{}
- }
- // MimeTypeCleared returns if the "mime_type" field was cleared in this mutation.
- func (m *BatchImageItemMutation) MimeTypeCleared() bool {
- _, ok := m.clearedFields[batchimageitem.FieldMimeType]
- return ok
- }
- // ResetMimeType resets all changes to the "mime_type" field.
- func (m *BatchImageItemMutation) ResetMimeType() {
- m.mime_type = nil
- delete(m.clearedFields, batchimageitem.FieldMimeType)
- }
- // SetFileExtension sets the "file_extension" field.
- func (m *BatchImageItemMutation) SetFileExtension(s string) {
- m.file_extension = &s
- }
- // FileExtension returns the value of the "file_extension" field in the mutation.
- func (m *BatchImageItemMutation) FileExtension() (r string, exists bool) {
- v := m.file_extension
- if v == nil {
- return
- }
- return *v, true
- }
- // OldFileExtension returns the old "file_extension" field's value of the BatchImageItem entity.
- // If the BatchImageItem object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *BatchImageItemMutation) OldFileExtension(ctx context.Context) (v *string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldFileExtension is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldFileExtension requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldFileExtension: %w", err)
- }
- return oldValue.FileExtension, nil
- }
- // ClearFileExtension clears the value of the "file_extension" field.
- func (m *BatchImageItemMutation) ClearFileExtension() {
- m.file_extension = nil
- m.clearedFields[batchimageitem.FieldFileExtension] = struct{}{}
- }
- // FileExtensionCleared returns if the "file_extension" field was cleared in this mutation.
- func (m *BatchImageItemMutation) FileExtensionCleared() bool {
- _, ok := m.clearedFields[batchimageitem.FieldFileExtension]
- return ok
- }
- // ResetFileExtension resets all changes to the "file_extension" field.
- func (m *BatchImageItemMutation) ResetFileExtension() {
- m.file_extension = nil
- delete(m.clearedFields, batchimageitem.FieldFileExtension)
- }
- // SetImageCount sets the "image_count" field.
- func (m *BatchImageItemMutation) SetImageCount(i int) {
- m.image_count = &i
- m.addimage_count = nil
- }
- // ImageCount returns the value of the "image_count" field in the mutation.
- func (m *BatchImageItemMutation) ImageCount() (r int, exists bool) {
- v := m.image_count
- if v == nil {
- return
- }
- return *v, true
- }
- // OldImageCount returns the old "image_count" field's value of the BatchImageItem entity.
- // If the BatchImageItem object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *BatchImageItemMutation) OldImageCount(ctx context.Context) (v int, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldImageCount is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldImageCount requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldImageCount: %w", err)
- }
- return oldValue.ImageCount, nil
- }
- // AddImageCount adds i to the "image_count" field.
- func (m *BatchImageItemMutation) AddImageCount(i int) {
- if m.addimage_count != nil {
- *m.addimage_count += i
- } else {
- m.addimage_count = &i
- }
- }
- // AddedImageCount returns the value that was added to the "image_count" field in this mutation.
- func (m *BatchImageItemMutation) AddedImageCount() (r int, exists bool) {
- v := m.addimage_count
- if v == nil {
- return
- }
- return *v, true
- }
- // ResetImageCount resets all changes to the "image_count" field.
- func (m *BatchImageItemMutation) ResetImageCount() {
- m.image_count = nil
- m.addimage_count = nil
- }
- // SetErrorCode sets the "error_code" field.
- func (m *BatchImageItemMutation) SetErrorCode(s string) {
- m.error_code = &s
- }
- // ErrorCode returns the value of the "error_code" field in the mutation.
- func (m *BatchImageItemMutation) ErrorCode() (r string, exists bool) {
- v := m.error_code
- if v == nil {
- return
- }
- return *v, true
- }
- // OldErrorCode returns the old "error_code" field's value of the BatchImageItem entity.
- // If the BatchImageItem object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *BatchImageItemMutation) OldErrorCode(ctx context.Context) (v *string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldErrorCode is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldErrorCode requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldErrorCode: %w", err)
- }
- return oldValue.ErrorCode, nil
- }
- // ClearErrorCode clears the value of the "error_code" field.
- func (m *BatchImageItemMutation) ClearErrorCode() {
- m.error_code = nil
- m.clearedFields[batchimageitem.FieldErrorCode] = struct{}{}
- }
- // ErrorCodeCleared returns if the "error_code" field was cleared in this mutation.
- func (m *BatchImageItemMutation) ErrorCodeCleared() bool {
- _, ok := m.clearedFields[batchimageitem.FieldErrorCode]
- return ok
- }
- // ResetErrorCode resets all changes to the "error_code" field.
- func (m *BatchImageItemMutation) ResetErrorCode() {
- m.error_code = nil
- delete(m.clearedFields, batchimageitem.FieldErrorCode)
- }
- // SetErrorMessage sets the "error_message" field.
- func (m *BatchImageItemMutation) SetErrorMessage(s string) {
- m.error_message = &s
- }
- // ErrorMessage returns the value of the "error_message" field in the mutation.
- func (m *BatchImageItemMutation) ErrorMessage() (r string, exists bool) {
- v := m.error_message
- if v == nil {
- return
- }
- return *v, true
- }
- // OldErrorMessage returns the old "error_message" field's value of the BatchImageItem entity.
- // If the BatchImageItem object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *BatchImageItemMutation) OldErrorMessage(ctx context.Context) (v *string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldErrorMessage is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldErrorMessage requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldErrorMessage: %w", err)
- }
- return oldValue.ErrorMessage, nil
- }
- // ClearErrorMessage clears the value of the "error_message" field.
- func (m *BatchImageItemMutation) ClearErrorMessage() {
- m.error_message = nil
- m.clearedFields[batchimageitem.FieldErrorMessage] = struct{}{}
- }
- // ErrorMessageCleared returns if the "error_message" field was cleared in this mutation.
- func (m *BatchImageItemMutation) ErrorMessageCleared() bool {
- _, ok := m.clearedFields[batchimageitem.FieldErrorMessage]
- return ok
- }
- // ResetErrorMessage resets all changes to the "error_message" field.
- func (m *BatchImageItemMutation) ResetErrorMessage() {
- m.error_message = nil
- delete(m.clearedFields, batchimageitem.FieldErrorMessage)
- }
- // SetBilledAmount sets the "billed_amount" field.
- func (m *BatchImageItemMutation) SetBilledAmount(f float64) {
- m.billed_amount = &f
- m.addbilled_amount = nil
- }
- // BilledAmount returns the value of the "billed_amount" field in the mutation.
- func (m *BatchImageItemMutation) BilledAmount() (r float64, exists bool) {
- v := m.billed_amount
- if v == nil {
- return
- }
- return *v, true
- }
- // OldBilledAmount returns the old "billed_amount" field's value of the BatchImageItem entity.
- // If the BatchImageItem object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *BatchImageItemMutation) OldBilledAmount(ctx context.Context) (v *float64, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldBilledAmount is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldBilledAmount requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldBilledAmount: %w", err)
- }
- return oldValue.BilledAmount, nil
- }
- // AddBilledAmount adds f to the "billed_amount" field.
- func (m *BatchImageItemMutation) AddBilledAmount(f float64) {
- if m.addbilled_amount != nil {
- *m.addbilled_amount += f
- } else {
- m.addbilled_amount = &f
- }
- }
- // AddedBilledAmount returns the value that was added to the "billed_amount" field in this mutation.
- func (m *BatchImageItemMutation) AddedBilledAmount() (r float64, exists bool) {
- v := m.addbilled_amount
- if v == nil {
- return
- }
- return *v, true
- }
- // ClearBilledAmount clears the value of the "billed_amount" field.
- func (m *BatchImageItemMutation) ClearBilledAmount() {
- m.billed_amount = nil
- m.addbilled_amount = nil
- m.clearedFields[batchimageitem.FieldBilledAmount] = struct{}{}
- }
- // BilledAmountCleared returns if the "billed_amount" field was cleared in this mutation.
- func (m *BatchImageItemMutation) BilledAmountCleared() bool {
- _, ok := m.clearedFields[batchimageitem.FieldBilledAmount]
- return ok
- }
- // ResetBilledAmount resets all changes to the "billed_amount" field.
- func (m *BatchImageItemMutation) ResetBilledAmount() {
- m.billed_amount = nil
- m.addbilled_amount = nil
- delete(m.clearedFields, batchimageitem.FieldBilledAmount)
- }
- // SetCreatedAt sets the "created_at" field.
- func (m *BatchImageItemMutation) SetCreatedAt(t time.Time) {
- m.created_at = &t
- }
- // CreatedAt returns the value of the "created_at" field in the mutation.
- func (m *BatchImageItemMutation) CreatedAt() (r time.Time, exists bool) {
- v := m.created_at
- if v == nil {
- return
- }
- return *v, true
- }
- // OldCreatedAt returns the old "created_at" field's value of the BatchImageItem entity.
- // If the BatchImageItem object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *BatchImageItemMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldCreatedAt requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
- }
- return oldValue.CreatedAt, nil
- }
- // ResetCreatedAt resets all changes to the "created_at" field.
- func (m *BatchImageItemMutation) ResetCreatedAt() {
- m.created_at = nil
- }
- // SetIndexedAt sets the "indexed_at" field.
- func (m *BatchImageItemMutation) SetIndexedAt(t time.Time) {
- m.indexed_at = &t
- }
- // IndexedAt returns the value of the "indexed_at" field in the mutation.
- func (m *BatchImageItemMutation) IndexedAt() (r time.Time, exists bool) {
- v := m.indexed_at
- if v == nil {
- return
- }
- return *v, true
- }
- // OldIndexedAt returns the old "indexed_at" field's value of the BatchImageItem entity.
- // If the BatchImageItem object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *BatchImageItemMutation) OldIndexedAt(ctx context.Context) (v *time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldIndexedAt is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldIndexedAt requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldIndexedAt: %w", err)
- }
- return oldValue.IndexedAt, nil
- }
- // ClearIndexedAt clears the value of the "indexed_at" field.
- func (m *BatchImageItemMutation) ClearIndexedAt() {
- m.indexed_at = nil
- m.clearedFields[batchimageitem.FieldIndexedAt] = struct{}{}
- }
- // IndexedAtCleared returns if the "indexed_at" field was cleared in this mutation.
- func (m *BatchImageItemMutation) IndexedAtCleared() bool {
- _, ok := m.clearedFields[batchimageitem.FieldIndexedAt]
- return ok
- }
- // ResetIndexedAt resets all changes to the "indexed_at" field.
- func (m *BatchImageItemMutation) ResetIndexedAt() {
- m.indexed_at = nil
- delete(m.clearedFields, batchimageitem.FieldIndexedAt)
- }
- // Where appends a list predicates to the BatchImageItemMutation builder.
- func (m *BatchImageItemMutation) Where(ps ...predicate.BatchImageItem) {
- m.predicates = append(m.predicates, ps...)
- }
- // WhereP appends storage-level predicates to the BatchImageItemMutation builder. Using this method,
- // users can use type-assertion to append predicates that do not depend on any generated package.
- func (m *BatchImageItemMutation) WhereP(ps ...func(*sql.Selector)) {
- p := make([]predicate.BatchImageItem, len(ps))
- for i := range ps {
- p[i] = ps[i]
- }
- m.Where(p...)
- }
- // Op returns the operation name.
- func (m *BatchImageItemMutation) Op() Op {
- return m.op
- }
- // SetOp allows setting the mutation operation.
- func (m *BatchImageItemMutation) SetOp(op Op) {
- m.op = op
- }
- // Type returns the node type of this mutation (BatchImageItem).
- func (m *BatchImageItemMutation) Type() string {
- return m.typ
- }
- // Fields returns all fields that were changed during this mutation. Note that in
- // order to get all numeric fields that were incremented/decremented, call
- // AddedFields().
- func (m *BatchImageItemMutation) Fields() []string {
- fields := make([]string, 0, 17)
- if m.job_id != nil {
- fields = append(fields, batchimageitem.FieldJobID)
- }
- if m.custom_id != nil {
- fields = append(fields, batchimageitem.FieldCustomID)
- }
- if m.status != nil {
- fields = append(fields, batchimageitem.FieldStatus)
- }
- if m.request_hash != nil {
- fields = append(fields, batchimageitem.FieldRequestHash)
- }
- if m.prompt_preview != nil {
- fields = append(fields, batchimageitem.FieldPromptPreview)
- }
- if m.provider_source_object != nil {
- fields = append(fields, batchimageitem.FieldProviderSourceObject)
- }
- if m.source_line_number != nil {
- fields = append(fields, batchimageitem.FieldSourceLineNumber)
- }
- if m.source_byte_offset != nil {
- fields = append(fields, batchimageitem.FieldSourceByteOffset)
- }
- if m.source_byte_length != nil {
- fields = append(fields, batchimageitem.FieldSourceByteLength)
- }
- if m.mime_type != nil {
- fields = append(fields, batchimageitem.FieldMimeType)
- }
- if m.file_extension != nil {
- fields = append(fields, batchimageitem.FieldFileExtension)
- }
- if m.image_count != nil {
- fields = append(fields, batchimageitem.FieldImageCount)
- }
- if m.error_code != nil {
- fields = append(fields, batchimageitem.FieldErrorCode)
- }
- if m.error_message != nil {
- fields = append(fields, batchimageitem.FieldErrorMessage)
- }
- if m.billed_amount != nil {
- fields = append(fields, batchimageitem.FieldBilledAmount)
- }
- if m.created_at != nil {
- fields = append(fields, batchimageitem.FieldCreatedAt)
- }
- if m.indexed_at != nil {
- fields = append(fields, batchimageitem.FieldIndexedAt)
- }
- return fields
- }
- // Field returns the value of a field with the given name. The second boolean
- // return value indicates that this field was not set, or was not defined in the
- // schema.
- func (m *BatchImageItemMutation) Field(name string) (ent.Value, bool) {
- switch name {
- case batchimageitem.FieldJobID:
- return m.JobID()
- case batchimageitem.FieldCustomID:
- return m.CustomID()
- case batchimageitem.FieldStatus:
- return m.Status()
- case batchimageitem.FieldRequestHash:
- return m.RequestHash()
- case batchimageitem.FieldPromptPreview:
- return m.PromptPreview()
- case batchimageitem.FieldProviderSourceObject:
- return m.ProviderSourceObject()
- case batchimageitem.FieldSourceLineNumber:
- return m.SourceLineNumber()
- case batchimageitem.FieldSourceByteOffset:
- return m.SourceByteOffset()
- case batchimageitem.FieldSourceByteLength:
- return m.SourceByteLength()
- case batchimageitem.FieldMimeType:
- return m.MimeType()
- case batchimageitem.FieldFileExtension:
- return m.FileExtension()
- case batchimageitem.FieldImageCount:
- return m.ImageCount()
- case batchimageitem.FieldErrorCode:
- return m.ErrorCode()
- case batchimageitem.FieldErrorMessage:
- return m.ErrorMessage()
- case batchimageitem.FieldBilledAmount:
- return m.BilledAmount()
- case batchimageitem.FieldCreatedAt:
- return m.CreatedAt()
- case batchimageitem.FieldIndexedAt:
- return m.IndexedAt()
- }
- return nil, false
- }
- // OldField returns the old value of the field from the database. An error is
- // returned if the mutation operation is not UpdateOne, or the query to the
- // database failed.
- func (m *BatchImageItemMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
- switch name {
- case batchimageitem.FieldJobID:
- return m.OldJobID(ctx)
- case batchimageitem.FieldCustomID:
- return m.OldCustomID(ctx)
- case batchimageitem.FieldStatus:
- return m.OldStatus(ctx)
- case batchimageitem.FieldRequestHash:
- return m.OldRequestHash(ctx)
- case batchimageitem.FieldPromptPreview:
- return m.OldPromptPreview(ctx)
- case batchimageitem.FieldProviderSourceObject:
- return m.OldProviderSourceObject(ctx)
- case batchimageitem.FieldSourceLineNumber:
- return m.OldSourceLineNumber(ctx)
- case batchimageitem.FieldSourceByteOffset:
- return m.OldSourceByteOffset(ctx)
- case batchimageitem.FieldSourceByteLength:
- return m.OldSourceByteLength(ctx)
- case batchimageitem.FieldMimeType:
- return m.OldMimeType(ctx)
- case batchimageitem.FieldFileExtension:
- return m.OldFileExtension(ctx)
- case batchimageitem.FieldImageCount:
- return m.OldImageCount(ctx)
- case batchimageitem.FieldErrorCode:
- return m.OldErrorCode(ctx)
- case batchimageitem.FieldErrorMessage:
- return m.OldErrorMessage(ctx)
- case batchimageitem.FieldBilledAmount:
- return m.OldBilledAmount(ctx)
- case batchimageitem.FieldCreatedAt:
- return m.OldCreatedAt(ctx)
- case batchimageitem.FieldIndexedAt:
- return m.OldIndexedAt(ctx)
- }
- return nil, fmt.Errorf("unknown BatchImageItem field %s", name)
- }
- // SetField sets the value of a field with the given name. It returns an error if
- // the field is not defined in the schema, or if the type mismatched the field
- // type.
- func (m *BatchImageItemMutation) SetField(name string, value ent.Value) error {
- switch name {
- case batchimageitem.FieldJobID:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetJobID(v)
- return nil
- case batchimageitem.FieldCustomID:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetCustomID(v)
- return nil
- case batchimageitem.FieldStatus:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetStatus(v)
- return nil
- case batchimageitem.FieldRequestHash:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetRequestHash(v)
- return nil
- case batchimageitem.FieldPromptPreview:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetPromptPreview(v)
- return nil
- case batchimageitem.FieldProviderSourceObject:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetProviderSourceObject(v)
- return nil
- case batchimageitem.FieldSourceLineNumber:
- v, ok := value.(int)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetSourceLineNumber(v)
- return nil
- case batchimageitem.FieldSourceByteOffset:
- v, ok := value.(int64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetSourceByteOffset(v)
- return nil
- case batchimageitem.FieldSourceByteLength:
- v, ok := value.(int64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetSourceByteLength(v)
- return nil
- case batchimageitem.FieldMimeType:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetMimeType(v)
- return nil
- case batchimageitem.FieldFileExtension:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetFileExtension(v)
- return nil
- case batchimageitem.FieldImageCount:
- v, ok := value.(int)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetImageCount(v)
- return nil
- case batchimageitem.FieldErrorCode:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetErrorCode(v)
- return nil
- case batchimageitem.FieldErrorMessage:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetErrorMessage(v)
- return nil
- case batchimageitem.FieldBilledAmount:
- v, ok := value.(float64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetBilledAmount(v)
- return nil
- case batchimageitem.FieldCreatedAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetCreatedAt(v)
- return nil
- case batchimageitem.FieldIndexedAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetIndexedAt(v)
- return nil
- }
- return fmt.Errorf("unknown BatchImageItem field %s", name)
- }
- // AddedFields returns all numeric fields that were incremented/decremented during
- // this mutation.
- func (m *BatchImageItemMutation) AddedFields() []string {
- var fields []string
- if m.addsource_line_number != nil {
- fields = append(fields, batchimageitem.FieldSourceLineNumber)
- }
- if m.addsource_byte_offset != nil {
- fields = append(fields, batchimageitem.FieldSourceByteOffset)
- }
- if m.addsource_byte_length != nil {
- fields = append(fields, batchimageitem.FieldSourceByteLength)
- }
- if m.addimage_count != nil {
- fields = append(fields, batchimageitem.FieldImageCount)
- }
- if m.addbilled_amount != nil {
- fields = append(fields, batchimageitem.FieldBilledAmount)
- }
- return fields
- }
- // AddedField returns the numeric value that was incremented/decremented on a field
- // with the given name. The second boolean return value indicates that this field
- // was not set, or was not defined in the schema.
- func (m *BatchImageItemMutation) AddedField(name string) (ent.Value, bool) {
- switch name {
- case batchimageitem.FieldSourceLineNumber:
- return m.AddedSourceLineNumber()
- case batchimageitem.FieldSourceByteOffset:
- return m.AddedSourceByteOffset()
- case batchimageitem.FieldSourceByteLength:
- return m.AddedSourceByteLength()
- case batchimageitem.FieldImageCount:
- return m.AddedImageCount()
- case batchimageitem.FieldBilledAmount:
- return m.AddedBilledAmount()
- }
- return nil, false
- }
- // AddField adds the value to the field with the given name. It returns an error if
- // the field is not defined in the schema, or if the type mismatched the field
- // type.
- func (m *BatchImageItemMutation) AddField(name string, value ent.Value) error {
- switch name {
- case batchimageitem.FieldSourceLineNumber:
- v, ok := value.(int)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.AddSourceLineNumber(v)
- return nil
- case batchimageitem.FieldSourceByteOffset:
- v, ok := value.(int64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.AddSourceByteOffset(v)
- return nil
- case batchimageitem.FieldSourceByteLength:
- v, ok := value.(int64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.AddSourceByteLength(v)
- return nil
- case batchimageitem.FieldImageCount:
- v, ok := value.(int)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.AddImageCount(v)
- return nil
- case batchimageitem.FieldBilledAmount:
- v, ok := value.(float64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.AddBilledAmount(v)
- return nil
- }
- return fmt.Errorf("unknown BatchImageItem numeric field %s", name)
- }
- // ClearedFields returns all nullable fields that were cleared during this
- // mutation.
- func (m *BatchImageItemMutation) ClearedFields() []string {
- var fields []string
- if m.FieldCleared(batchimageitem.FieldRequestHash) {
- fields = append(fields, batchimageitem.FieldRequestHash)
- }
- if m.FieldCleared(batchimageitem.FieldPromptPreview) {
- fields = append(fields, batchimageitem.FieldPromptPreview)
- }
- if m.FieldCleared(batchimageitem.FieldProviderSourceObject) {
- fields = append(fields, batchimageitem.FieldProviderSourceObject)
- }
- if m.FieldCleared(batchimageitem.FieldSourceLineNumber) {
- fields = append(fields, batchimageitem.FieldSourceLineNumber)
- }
- if m.FieldCleared(batchimageitem.FieldSourceByteOffset) {
- fields = append(fields, batchimageitem.FieldSourceByteOffset)
- }
- if m.FieldCleared(batchimageitem.FieldSourceByteLength) {
- fields = append(fields, batchimageitem.FieldSourceByteLength)
- }
- if m.FieldCleared(batchimageitem.FieldMimeType) {
- fields = append(fields, batchimageitem.FieldMimeType)
- }
- if m.FieldCleared(batchimageitem.FieldFileExtension) {
- fields = append(fields, batchimageitem.FieldFileExtension)
- }
- if m.FieldCleared(batchimageitem.FieldErrorCode) {
- fields = append(fields, batchimageitem.FieldErrorCode)
- }
- if m.FieldCleared(batchimageitem.FieldErrorMessage) {
- fields = append(fields, batchimageitem.FieldErrorMessage)
- }
- if m.FieldCleared(batchimageitem.FieldBilledAmount) {
- fields = append(fields, batchimageitem.FieldBilledAmount)
- }
- if m.FieldCleared(batchimageitem.FieldIndexedAt) {
- fields = append(fields, batchimageitem.FieldIndexedAt)
- }
- return fields
- }
- // FieldCleared returns a boolean indicating if a field with the given name was
- // cleared in this mutation.
- func (m *BatchImageItemMutation) FieldCleared(name string) bool {
- _, ok := m.clearedFields[name]
- return ok
- }
- // ClearField clears the value of the field with the given name. It returns an
- // error if the field is not defined in the schema.
- func (m *BatchImageItemMutation) ClearField(name string) error {
- switch name {
- case batchimageitem.FieldRequestHash:
- m.ClearRequestHash()
- return nil
- case batchimageitem.FieldPromptPreview:
- m.ClearPromptPreview()
- return nil
- case batchimageitem.FieldProviderSourceObject:
- m.ClearProviderSourceObject()
- return nil
- case batchimageitem.FieldSourceLineNumber:
- m.ClearSourceLineNumber()
- return nil
- case batchimageitem.FieldSourceByteOffset:
- m.ClearSourceByteOffset()
- return nil
- case batchimageitem.FieldSourceByteLength:
- m.ClearSourceByteLength()
- return nil
- case batchimageitem.FieldMimeType:
- m.ClearMimeType()
- return nil
- case batchimageitem.FieldFileExtension:
- m.ClearFileExtension()
- return nil
- case batchimageitem.FieldErrorCode:
- m.ClearErrorCode()
- return nil
- case batchimageitem.FieldErrorMessage:
- m.ClearErrorMessage()
- return nil
- case batchimageitem.FieldBilledAmount:
- m.ClearBilledAmount()
- return nil
- case batchimageitem.FieldIndexedAt:
- m.ClearIndexedAt()
- return nil
- }
- return fmt.Errorf("unknown BatchImageItem nullable field %s", name)
- }
- // ResetField resets all changes in the mutation for the field with the given name.
- // It returns an error if the field is not defined in the schema.
- func (m *BatchImageItemMutation) ResetField(name string) error {
- switch name {
- case batchimageitem.FieldJobID:
- m.ResetJobID()
- return nil
- case batchimageitem.FieldCustomID:
- m.ResetCustomID()
- return nil
- case batchimageitem.FieldStatus:
- m.ResetStatus()
- return nil
- case batchimageitem.FieldRequestHash:
- m.ResetRequestHash()
- return nil
- case batchimageitem.FieldPromptPreview:
- m.ResetPromptPreview()
- return nil
- case batchimageitem.FieldProviderSourceObject:
- m.ResetProviderSourceObject()
- return nil
- case batchimageitem.FieldSourceLineNumber:
- m.ResetSourceLineNumber()
- return nil
- case batchimageitem.FieldSourceByteOffset:
- m.ResetSourceByteOffset()
- return nil
- case batchimageitem.FieldSourceByteLength:
- m.ResetSourceByteLength()
- return nil
- case batchimageitem.FieldMimeType:
- m.ResetMimeType()
- return nil
- case batchimageitem.FieldFileExtension:
- m.ResetFileExtension()
- return nil
- case batchimageitem.FieldImageCount:
- m.ResetImageCount()
- return nil
- case batchimageitem.FieldErrorCode:
- m.ResetErrorCode()
- return nil
- case batchimageitem.FieldErrorMessage:
- m.ResetErrorMessage()
- return nil
- case batchimageitem.FieldBilledAmount:
- m.ResetBilledAmount()
- return nil
- case batchimageitem.FieldCreatedAt:
- m.ResetCreatedAt()
- return nil
- case batchimageitem.FieldIndexedAt:
- m.ResetIndexedAt()
- return nil
- }
- return fmt.Errorf("unknown BatchImageItem field %s", name)
- }
- // AddedEdges returns all edge names that were set/added in this mutation.
- func (m *BatchImageItemMutation) AddedEdges() []string {
- edges := make([]string, 0, 0)
- return edges
- }
- // AddedIDs returns all IDs (to other nodes) that were added for the given edge
- // name in this mutation.
- func (m *BatchImageItemMutation) AddedIDs(name string) []ent.Value {
- return nil
- }
- // RemovedEdges returns all edge names that were removed in this mutation.
- func (m *BatchImageItemMutation) RemovedEdges() []string {
- edges := make([]string, 0, 0)
- return edges
- }
- // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
- // the given name in this mutation.
- func (m *BatchImageItemMutation) RemovedIDs(name string) []ent.Value {
- return nil
- }
- // ClearedEdges returns all edge names that were cleared in this mutation.
- func (m *BatchImageItemMutation) ClearedEdges() []string {
- edges := make([]string, 0, 0)
- return edges
- }
- // EdgeCleared returns a boolean which indicates if the edge with the given name
- // was cleared in this mutation.
- func (m *BatchImageItemMutation) EdgeCleared(name string) bool {
- return false
- }
- // ClearEdge clears the value of the edge with the given name. It returns an error
- // if that edge is not defined in the schema.
- func (m *BatchImageItemMutation) ClearEdge(name string) error {
- return fmt.Errorf("unknown BatchImageItem unique edge %s", name)
- }
- // ResetEdge resets all changes to the edge with the given name in this mutation.
- // It returns an error if the edge is not defined in the schema.
- func (m *BatchImageItemMutation) ResetEdge(name string) error {
- return fmt.Errorf("unknown BatchImageItem edge %s", name)
- }
- // BatchImageJobMutation represents an operation that mutates the BatchImageJob nodes in the graph.
- type BatchImageJobMutation struct {
- config
- op Op
- typ string
- id *int64
- batch_id *string
- user_id *int64
- adduser_id *int64
- api_key_id *int64
- addapi_key_id *int64
- account_id *int64
- addaccount_id *int64
- provider *string
- model *string
- task_name *string
- status *string
- provider_job_name *string
- provider_input_ref *string
- provider_output_ref *string
- gcs_input_uri *string
- gcs_output_uri *string
- item_count *int
- additem_count *int
- success_count *int
- addsuccess_count *int
- fail_count *int
- addfail_count *int
- cancelled_count *int
- addcancelled_count *int
- estimated_cost *float64
- addestimated_cost *float64
- hold_amount *float64
- addhold_amount *float64
- actual_cost *float64
- addactual_cost *float64
- currency *string
- hold_id *string
- idempotency_key *string
- request_hash *string
- manifest_hash *string
- retry_count *int
- addretry_count *int
- version *int
- addversion *int
- output_expires_at *time.Time
- input_deleted_at *time.Time
- output_deleted_at *time.Time
- downloaded_at *time.Time
- user_deleted_at *time.Time
- last_error_code *string
- last_error_message *string
- created_at *time.Time
- updated_at *time.Time
- submitted_at *time.Time
- started_at *time.Time
- finished_at *time.Time
- settled_at *time.Time
- clearedFields map[string]struct{}
- done bool
- oldValue func(context.Context) (*BatchImageJob, error)
- predicates []predicate.BatchImageJob
- }
- var _ ent.Mutation = (*BatchImageJobMutation)(nil)
- // batchimagejobOption allows management of the mutation configuration using functional options.
- type batchimagejobOption func(*BatchImageJobMutation)
- // newBatchImageJobMutation creates new mutation for the BatchImageJob entity.
- func newBatchImageJobMutation(c config, op Op, opts ...batchimagejobOption) *BatchImageJobMutation {
- m := &BatchImageJobMutation{
- config: c,
- op: op,
- typ: TypeBatchImageJob,
- clearedFields: make(map[string]struct{}),
- }
- for _, opt := range opts {
- opt(m)
- }
- return m
- }
- // withBatchImageJobID sets the ID field of the mutation.
- func withBatchImageJobID(id int64) batchimagejobOption {
- return func(m *BatchImageJobMutation) {
- var (
- err error
- once sync.Once
- value *BatchImageJob
- )
- m.oldValue = func(ctx context.Context) (*BatchImageJob, error) {
- once.Do(func() {
- if m.done {
- err = errors.New("querying old values post mutation is not allowed")
- } else {
- value, err = m.Client().BatchImageJob.Get(ctx, id)
- }
- })
- return value, err
- }
- m.id = &id
- }
- }
- // withBatchImageJob sets the old BatchImageJob of the mutation.
- func withBatchImageJob(node *BatchImageJob) batchimagejobOption {
- return func(m *BatchImageJobMutation) {
- m.oldValue = func(context.Context) (*BatchImageJob, error) {
- return node, nil
- }
- m.id = &node.ID
- }
- }
- // Client returns a new `ent.Client` from the mutation. If the mutation was
- // executed in a transaction (ent.Tx), a transactional client is returned.
- func (m BatchImageJobMutation) Client() *Client {
- client := &Client{config: m.config}
- client.init()
- return client
- }
- // Tx returns an `ent.Tx` for mutations that were executed in transactions;
- // it returns an error otherwise.
- func (m BatchImageJobMutation) Tx() (*Tx, error) {
- if _, ok := m.driver.(*txDriver); !ok {
- return nil, errors.New("ent: mutation is not running in a transaction")
- }
- tx := &Tx{config: m.config}
- tx.init()
- return tx, nil
- }
- // ID returns the ID value in the mutation. Note that the ID is only available
- // if it was provided to the builder or after it was returned from the database.
- func (m *BatchImageJobMutation) ID() (id int64, exists bool) {
- if m.id == nil {
- return
- }
- return *m.id, true
- }
- // IDs queries the database and returns the entity ids that match the mutation's predicate.
- // That means, if the mutation is applied within a transaction with an isolation level such
- // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
- // or updated by the mutation.
- func (m *BatchImageJobMutation) IDs(ctx context.Context) ([]int64, error) {
- switch {
- case m.op.Is(OpUpdateOne | OpDeleteOne):
- id, exists := m.ID()
- if exists {
- return []int64{id}, nil
- }
- fallthrough
- case m.op.Is(OpUpdate | OpDelete):
- return m.Client().BatchImageJob.Query().Where(m.predicates...).IDs(ctx)
- default:
- return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
- }
- }
- // SetBatchID sets the "batch_id" field.
- func (m *BatchImageJobMutation) SetBatchID(s string) {
- m.batch_id = &s
- }
- // BatchID returns the value of the "batch_id" field in the mutation.
- func (m *BatchImageJobMutation) BatchID() (r string, exists bool) {
- v := m.batch_id
- if v == nil {
- return
- }
- return *v, true
- }
- // OldBatchID returns the old "batch_id" field's value of the BatchImageJob entity.
- // If the BatchImageJob object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *BatchImageJobMutation) OldBatchID(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldBatchID is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldBatchID requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldBatchID: %w", err)
- }
- return oldValue.BatchID, nil
- }
- // ResetBatchID resets all changes to the "batch_id" field.
- func (m *BatchImageJobMutation) ResetBatchID() {
- m.batch_id = nil
- }
- // SetUserID sets the "user_id" field.
- func (m *BatchImageJobMutation) SetUserID(i int64) {
- m.user_id = &i
- m.adduser_id = nil
- }
- // UserID returns the value of the "user_id" field in the mutation.
- func (m *BatchImageJobMutation) UserID() (r int64, exists bool) {
- v := m.user_id
- if v == nil {
- return
- }
- return *v, true
- }
- // OldUserID returns the old "user_id" field's value of the BatchImageJob entity.
- // If the BatchImageJob object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *BatchImageJobMutation) OldUserID(ctx context.Context) (v int64, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldUserID is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldUserID requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldUserID: %w", err)
- }
- return oldValue.UserID, nil
- }
- // AddUserID adds i to the "user_id" field.
- func (m *BatchImageJobMutation) AddUserID(i int64) {
- if m.adduser_id != nil {
- *m.adduser_id += i
- } else {
- m.adduser_id = &i
- }
- }
- // AddedUserID returns the value that was added to the "user_id" field in this mutation.
- func (m *BatchImageJobMutation) AddedUserID() (r int64, exists bool) {
- v := m.adduser_id
- if v == nil {
- return
- }
- return *v, true
- }
- // ResetUserID resets all changes to the "user_id" field.
- func (m *BatchImageJobMutation) ResetUserID() {
- m.user_id = nil
- m.adduser_id = nil
- }
- // SetAPIKeyID sets the "api_key_id" field.
- func (m *BatchImageJobMutation) SetAPIKeyID(i int64) {
- m.api_key_id = &i
- m.addapi_key_id = nil
- }
- // APIKeyID returns the value of the "api_key_id" field in the mutation.
- func (m *BatchImageJobMutation) APIKeyID() (r int64, exists bool) {
- v := m.api_key_id
- if v == nil {
- return
- }
- return *v, true
- }
- // OldAPIKeyID returns the old "api_key_id" field's value of the BatchImageJob entity.
- // If the BatchImageJob object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *BatchImageJobMutation) OldAPIKeyID(ctx context.Context) (v *int64, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldAPIKeyID is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldAPIKeyID requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldAPIKeyID: %w", err)
- }
- return oldValue.APIKeyID, nil
- }
- // AddAPIKeyID adds i to the "api_key_id" field.
- func (m *BatchImageJobMutation) AddAPIKeyID(i int64) {
- if m.addapi_key_id != nil {
- *m.addapi_key_id += i
- } else {
- m.addapi_key_id = &i
- }
- }
- // AddedAPIKeyID returns the value that was added to the "api_key_id" field in this mutation.
- func (m *BatchImageJobMutation) AddedAPIKeyID() (r int64, exists bool) {
- v := m.addapi_key_id
- if v == nil {
- return
- }
- return *v, true
- }
- // ClearAPIKeyID clears the value of the "api_key_id" field.
- func (m *BatchImageJobMutation) ClearAPIKeyID() {
- m.api_key_id = nil
- m.addapi_key_id = nil
- m.clearedFields[batchimagejob.FieldAPIKeyID] = struct{}{}
- }
- // APIKeyIDCleared returns if the "api_key_id" field was cleared in this mutation.
- func (m *BatchImageJobMutation) APIKeyIDCleared() bool {
- _, ok := m.clearedFields[batchimagejob.FieldAPIKeyID]
- return ok
- }
- // ResetAPIKeyID resets all changes to the "api_key_id" field.
- func (m *BatchImageJobMutation) ResetAPIKeyID() {
- m.api_key_id = nil
- m.addapi_key_id = nil
- delete(m.clearedFields, batchimagejob.FieldAPIKeyID)
- }
- // SetAccountID sets the "account_id" field.
- func (m *BatchImageJobMutation) SetAccountID(i int64) {
- m.account_id = &i
- m.addaccount_id = nil
- }
- // AccountID returns the value of the "account_id" field in the mutation.
- func (m *BatchImageJobMutation) AccountID() (r int64, exists bool) {
- v := m.account_id
- if v == nil {
- return
- }
- return *v, true
- }
- // OldAccountID returns the old "account_id" field's value of the BatchImageJob entity.
- // If the BatchImageJob object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *BatchImageJobMutation) OldAccountID(ctx context.Context) (v *int64, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldAccountID is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldAccountID requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldAccountID: %w", err)
- }
- return oldValue.AccountID, nil
- }
- // AddAccountID adds i to the "account_id" field.
- func (m *BatchImageJobMutation) AddAccountID(i int64) {
- if m.addaccount_id != nil {
- *m.addaccount_id += i
- } else {
- m.addaccount_id = &i
- }
- }
- // AddedAccountID returns the value that was added to the "account_id" field in this mutation.
- func (m *BatchImageJobMutation) AddedAccountID() (r int64, exists bool) {
- v := m.addaccount_id
- if v == nil {
- return
- }
- return *v, true
- }
- // ClearAccountID clears the value of the "account_id" field.
- func (m *BatchImageJobMutation) ClearAccountID() {
- m.account_id = nil
- m.addaccount_id = nil
- m.clearedFields[batchimagejob.FieldAccountID] = struct{}{}
- }
- // AccountIDCleared returns if the "account_id" field was cleared in this mutation.
- func (m *BatchImageJobMutation) AccountIDCleared() bool {
- _, ok := m.clearedFields[batchimagejob.FieldAccountID]
- return ok
- }
- // ResetAccountID resets all changes to the "account_id" field.
- func (m *BatchImageJobMutation) ResetAccountID() {
- m.account_id = nil
- m.addaccount_id = nil
- delete(m.clearedFields, batchimagejob.FieldAccountID)
- }
- // SetProvider sets the "provider" field.
- func (m *BatchImageJobMutation) SetProvider(s string) {
- m.provider = &s
- }
- // Provider returns the value of the "provider" field in the mutation.
- func (m *BatchImageJobMutation) Provider() (r string, exists bool) {
- v := m.provider
- if v == nil {
- return
- }
- return *v, true
- }
- // OldProvider returns the old "provider" field's value of the BatchImageJob entity.
- // If the BatchImageJob object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *BatchImageJobMutation) OldProvider(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldProvider is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldProvider requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldProvider: %w", err)
- }
- return oldValue.Provider, nil
- }
- // ResetProvider resets all changes to the "provider" field.
- func (m *BatchImageJobMutation) ResetProvider() {
- m.provider = nil
- }
- // SetModel sets the "model" field.
- func (m *BatchImageJobMutation) SetModel(s string) {
- m.model = &s
- }
- // Model returns the value of the "model" field in the mutation.
- func (m *BatchImageJobMutation) Model() (r string, exists bool) {
- v := m.model
- if v == nil {
- return
- }
- return *v, true
- }
- // OldModel returns the old "model" field's value of the BatchImageJob entity.
- // If the BatchImageJob object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *BatchImageJobMutation) OldModel(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldModel is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldModel requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldModel: %w", err)
- }
- return oldValue.Model, nil
- }
- // ResetModel resets all changes to the "model" field.
- func (m *BatchImageJobMutation) ResetModel() {
- m.model = nil
- }
- // SetTaskName sets the "task_name" field.
- func (m *BatchImageJobMutation) SetTaskName(s string) {
- m.task_name = &s
- }
- // TaskName returns the value of the "task_name" field in the mutation.
- func (m *BatchImageJobMutation) TaskName() (r string, exists bool) {
- v := m.task_name
- if v == nil {
- return
- }
- return *v, true
- }
- // OldTaskName returns the old "task_name" field's value of the BatchImageJob entity.
- // If the BatchImageJob object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *BatchImageJobMutation) OldTaskName(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldTaskName is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldTaskName requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldTaskName: %w", err)
- }
- return oldValue.TaskName, nil
- }
- // ResetTaskName resets all changes to the "task_name" field.
- func (m *BatchImageJobMutation) ResetTaskName() {
- m.task_name = nil
- }
- // SetStatus sets the "status" field.
- func (m *BatchImageJobMutation) SetStatus(s string) {
- m.status = &s
- }
- // Status returns the value of the "status" field in the mutation.
- func (m *BatchImageJobMutation) Status() (r string, exists bool) {
- v := m.status
- if v == nil {
- return
- }
- return *v, true
- }
- // OldStatus returns the old "status" field's value of the BatchImageJob entity.
- // If the BatchImageJob object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *BatchImageJobMutation) OldStatus(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldStatus is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldStatus requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldStatus: %w", err)
- }
- return oldValue.Status, nil
- }
- // ResetStatus resets all changes to the "status" field.
- func (m *BatchImageJobMutation) ResetStatus() {
- m.status = nil
- }
- // SetProviderJobName sets the "provider_job_name" field.
- func (m *BatchImageJobMutation) SetProviderJobName(s string) {
- m.provider_job_name = &s
- }
- // ProviderJobName returns the value of the "provider_job_name" field in the mutation.
- func (m *BatchImageJobMutation) ProviderJobName() (r string, exists bool) {
- v := m.provider_job_name
- if v == nil {
- return
- }
- return *v, true
- }
- // OldProviderJobName returns the old "provider_job_name" field's value of the BatchImageJob entity.
- // If the BatchImageJob object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *BatchImageJobMutation) OldProviderJobName(ctx context.Context) (v *string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldProviderJobName is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldProviderJobName requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldProviderJobName: %w", err)
- }
- return oldValue.ProviderJobName, nil
- }
- // ClearProviderJobName clears the value of the "provider_job_name" field.
- func (m *BatchImageJobMutation) ClearProviderJobName() {
- m.provider_job_name = nil
- m.clearedFields[batchimagejob.FieldProviderJobName] = struct{}{}
- }
- // ProviderJobNameCleared returns if the "provider_job_name" field was cleared in this mutation.
- func (m *BatchImageJobMutation) ProviderJobNameCleared() bool {
- _, ok := m.clearedFields[batchimagejob.FieldProviderJobName]
- return ok
- }
- // ResetProviderJobName resets all changes to the "provider_job_name" field.
- func (m *BatchImageJobMutation) ResetProviderJobName() {
- m.provider_job_name = nil
- delete(m.clearedFields, batchimagejob.FieldProviderJobName)
- }
- // SetProviderInputRef sets the "provider_input_ref" field.
- func (m *BatchImageJobMutation) SetProviderInputRef(s string) {
- m.provider_input_ref = &s
- }
- // ProviderInputRef returns the value of the "provider_input_ref" field in the mutation.
- func (m *BatchImageJobMutation) ProviderInputRef() (r string, exists bool) {
- v := m.provider_input_ref
- if v == nil {
- return
- }
- return *v, true
- }
- // OldProviderInputRef returns the old "provider_input_ref" field's value of the BatchImageJob entity.
- // If the BatchImageJob object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *BatchImageJobMutation) OldProviderInputRef(ctx context.Context) (v *string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldProviderInputRef is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldProviderInputRef requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldProviderInputRef: %w", err)
- }
- return oldValue.ProviderInputRef, nil
- }
- // ClearProviderInputRef clears the value of the "provider_input_ref" field.
- func (m *BatchImageJobMutation) ClearProviderInputRef() {
- m.provider_input_ref = nil
- m.clearedFields[batchimagejob.FieldProviderInputRef] = struct{}{}
- }
- // ProviderInputRefCleared returns if the "provider_input_ref" field was cleared in this mutation.
- func (m *BatchImageJobMutation) ProviderInputRefCleared() bool {
- _, ok := m.clearedFields[batchimagejob.FieldProviderInputRef]
- return ok
- }
- // ResetProviderInputRef resets all changes to the "provider_input_ref" field.
- func (m *BatchImageJobMutation) ResetProviderInputRef() {
- m.provider_input_ref = nil
- delete(m.clearedFields, batchimagejob.FieldProviderInputRef)
- }
- // SetProviderOutputRef sets the "provider_output_ref" field.
- func (m *BatchImageJobMutation) SetProviderOutputRef(s string) {
- m.provider_output_ref = &s
- }
- // ProviderOutputRef returns the value of the "provider_output_ref" field in the mutation.
- func (m *BatchImageJobMutation) ProviderOutputRef() (r string, exists bool) {
- v := m.provider_output_ref
- if v == nil {
- return
- }
- return *v, true
- }
- // OldProviderOutputRef returns the old "provider_output_ref" field's value of the BatchImageJob entity.
- // If the BatchImageJob object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *BatchImageJobMutation) OldProviderOutputRef(ctx context.Context) (v *string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldProviderOutputRef is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldProviderOutputRef requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldProviderOutputRef: %w", err)
- }
- return oldValue.ProviderOutputRef, nil
- }
- // ClearProviderOutputRef clears the value of the "provider_output_ref" field.
- func (m *BatchImageJobMutation) ClearProviderOutputRef() {
- m.provider_output_ref = nil
- m.clearedFields[batchimagejob.FieldProviderOutputRef] = struct{}{}
- }
- // ProviderOutputRefCleared returns if the "provider_output_ref" field was cleared in this mutation.
- func (m *BatchImageJobMutation) ProviderOutputRefCleared() bool {
- _, ok := m.clearedFields[batchimagejob.FieldProviderOutputRef]
- return ok
- }
- // ResetProviderOutputRef resets all changes to the "provider_output_ref" field.
- func (m *BatchImageJobMutation) ResetProviderOutputRef() {
- m.provider_output_ref = nil
- delete(m.clearedFields, batchimagejob.FieldProviderOutputRef)
- }
- // SetGcsInputURI sets the "gcs_input_uri" field.
- func (m *BatchImageJobMutation) SetGcsInputURI(s string) {
- m.gcs_input_uri = &s
- }
- // GcsInputURI returns the value of the "gcs_input_uri" field in the mutation.
- func (m *BatchImageJobMutation) GcsInputURI() (r string, exists bool) {
- v := m.gcs_input_uri
- if v == nil {
- return
- }
- return *v, true
- }
- // OldGcsInputURI returns the old "gcs_input_uri" field's value of the BatchImageJob entity.
- // If the BatchImageJob object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *BatchImageJobMutation) OldGcsInputURI(ctx context.Context) (v *string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldGcsInputURI is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldGcsInputURI requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldGcsInputURI: %w", err)
- }
- return oldValue.GcsInputURI, nil
- }
- // ClearGcsInputURI clears the value of the "gcs_input_uri" field.
- func (m *BatchImageJobMutation) ClearGcsInputURI() {
- m.gcs_input_uri = nil
- m.clearedFields[batchimagejob.FieldGcsInputURI] = struct{}{}
- }
- // GcsInputURICleared returns if the "gcs_input_uri" field was cleared in this mutation.
- func (m *BatchImageJobMutation) GcsInputURICleared() bool {
- _, ok := m.clearedFields[batchimagejob.FieldGcsInputURI]
- return ok
- }
- // ResetGcsInputURI resets all changes to the "gcs_input_uri" field.
- func (m *BatchImageJobMutation) ResetGcsInputURI() {
- m.gcs_input_uri = nil
- delete(m.clearedFields, batchimagejob.FieldGcsInputURI)
- }
- // SetGcsOutputURI sets the "gcs_output_uri" field.
- func (m *BatchImageJobMutation) SetGcsOutputURI(s string) {
- m.gcs_output_uri = &s
- }
- // GcsOutputURI returns the value of the "gcs_output_uri" field in the mutation.
- func (m *BatchImageJobMutation) GcsOutputURI() (r string, exists bool) {
- v := m.gcs_output_uri
- if v == nil {
- return
- }
- return *v, true
- }
- // OldGcsOutputURI returns the old "gcs_output_uri" field's value of the BatchImageJob entity.
- // If the BatchImageJob object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *BatchImageJobMutation) OldGcsOutputURI(ctx context.Context) (v *string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldGcsOutputURI is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldGcsOutputURI requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldGcsOutputURI: %w", err)
- }
- return oldValue.GcsOutputURI, nil
- }
- // ClearGcsOutputURI clears the value of the "gcs_output_uri" field.
- func (m *BatchImageJobMutation) ClearGcsOutputURI() {
- m.gcs_output_uri = nil
- m.clearedFields[batchimagejob.FieldGcsOutputURI] = struct{}{}
- }
- // GcsOutputURICleared returns if the "gcs_output_uri" field was cleared in this mutation.
- func (m *BatchImageJobMutation) GcsOutputURICleared() bool {
- _, ok := m.clearedFields[batchimagejob.FieldGcsOutputURI]
- return ok
- }
- // ResetGcsOutputURI resets all changes to the "gcs_output_uri" field.
- func (m *BatchImageJobMutation) ResetGcsOutputURI() {
- m.gcs_output_uri = nil
- delete(m.clearedFields, batchimagejob.FieldGcsOutputURI)
- }
- // SetItemCount sets the "item_count" field.
- func (m *BatchImageJobMutation) SetItemCount(i int) {
- m.item_count = &i
- m.additem_count = nil
- }
- // ItemCount returns the value of the "item_count" field in the mutation.
- func (m *BatchImageJobMutation) ItemCount() (r int, exists bool) {
- v := m.item_count
- if v == nil {
- return
- }
- return *v, true
- }
- // OldItemCount returns the old "item_count" field's value of the BatchImageJob entity.
- // If the BatchImageJob object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *BatchImageJobMutation) OldItemCount(ctx context.Context) (v int, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldItemCount is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldItemCount requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldItemCount: %w", err)
- }
- return oldValue.ItemCount, nil
- }
- // AddItemCount adds i to the "item_count" field.
- func (m *BatchImageJobMutation) AddItemCount(i int) {
- if m.additem_count != nil {
- *m.additem_count += i
- } else {
- m.additem_count = &i
- }
- }
- // AddedItemCount returns the value that was added to the "item_count" field in this mutation.
- func (m *BatchImageJobMutation) AddedItemCount() (r int, exists bool) {
- v := m.additem_count
- if v == nil {
- return
- }
- return *v, true
- }
- // ResetItemCount resets all changes to the "item_count" field.
- func (m *BatchImageJobMutation) ResetItemCount() {
- m.item_count = nil
- m.additem_count = nil
- }
- // SetSuccessCount sets the "success_count" field.
- func (m *BatchImageJobMutation) SetSuccessCount(i int) {
- m.success_count = &i
- m.addsuccess_count = nil
- }
- // SuccessCount returns the value of the "success_count" field in the mutation.
- func (m *BatchImageJobMutation) SuccessCount() (r int, exists bool) {
- v := m.success_count
- if v == nil {
- return
- }
- return *v, true
- }
- // OldSuccessCount returns the old "success_count" field's value of the BatchImageJob entity.
- // If the BatchImageJob object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *BatchImageJobMutation) OldSuccessCount(ctx context.Context) (v int, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldSuccessCount is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldSuccessCount requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldSuccessCount: %w", err)
- }
- return oldValue.SuccessCount, nil
- }
- // AddSuccessCount adds i to the "success_count" field.
- func (m *BatchImageJobMutation) AddSuccessCount(i int) {
- if m.addsuccess_count != nil {
- *m.addsuccess_count += i
- } else {
- m.addsuccess_count = &i
- }
- }
- // AddedSuccessCount returns the value that was added to the "success_count" field in this mutation.
- func (m *BatchImageJobMutation) AddedSuccessCount() (r int, exists bool) {
- v := m.addsuccess_count
- if v == nil {
- return
- }
- return *v, true
- }
- // ResetSuccessCount resets all changes to the "success_count" field.
- func (m *BatchImageJobMutation) ResetSuccessCount() {
- m.success_count = nil
- m.addsuccess_count = nil
- }
- // SetFailCount sets the "fail_count" field.
- func (m *BatchImageJobMutation) SetFailCount(i int) {
- m.fail_count = &i
- m.addfail_count = nil
- }
- // FailCount returns the value of the "fail_count" field in the mutation.
- func (m *BatchImageJobMutation) FailCount() (r int, exists bool) {
- v := m.fail_count
- if v == nil {
- return
- }
- return *v, true
- }
- // OldFailCount returns the old "fail_count" field's value of the BatchImageJob entity.
- // If the BatchImageJob object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *BatchImageJobMutation) OldFailCount(ctx context.Context) (v int, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldFailCount is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldFailCount requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldFailCount: %w", err)
- }
- return oldValue.FailCount, nil
- }
- // AddFailCount adds i to the "fail_count" field.
- func (m *BatchImageJobMutation) AddFailCount(i int) {
- if m.addfail_count != nil {
- *m.addfail_count += i
- } else {
- m.addfail_count = &i
- }
- }
- // AddedFailCount returns the value that was added to the "fail_count" field in this mutation.
- func (m *BatchImageJobMutation) AddedFailCount() (r int, exists bool) {
- v := m.addfail_count
- if v == nil {
- return
- }
- return *v, true
- }
- // ResetFailCount resets all changes to the "fail_count" field.
- func (m *BatchImageJobMutation) ResetFailCount() {
- m.fail_count = nil
- m.addfail_count = nil
- }
- // SetCancelledCount sets the "cancelled_count" field.
- func (m *BatchImageJobMutation) SetCancelledCount(i int) {
- m.cancelled_count = &i
- m.addcancelled_count = nil
- }
- // CancelledCount returns the value of the "cancelled_count" field in the mutation.
- func (m *BatchImageJobMutation) CancelledCount() (r int, exists bool) {
- v := m.cancelled_count
- if v == nil {
- return
- }
- return *v, true
- }
- // OldCancelledCount returns the old "cancelled_count" field's value of the BatchImageJob entity.
- // If the BatchImageJob object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *BatchImageJobMutation) OldCancelledCount(ctx context.Context) (v int, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldCancelledCount is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldCancelledCount requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldCancelledCount: %w", err)
- }
- return oldValue.CancelledCount, nil
- }
- // AddCancelledCount adds i to the "cancelled_count" field.
- func (m *BatchImageJobMutation) AddCancelledCount(i int) {
- if m.addcancelled_count != nil {
- *m.addcancelled_count += i
- } else {
- m.addcancelled_count = &i
- }
- }
- // AddedCancelledCount returns the value that was added to the "cancelled_count" field in this mutation.
- func (m *BatchImageJobMutation) AddedCancelledCount() (r int, exists bool) {
- v := m.addcancelled_count
- if v == nil {
- return
- }
- return *v, true
- }
- // ResetCancelledCount resets all changes to the "cancelled_count" field.
- func (m *BatchImageJobMutation) ResetCancelledCount() {
- m.cancelled_count = nil
- m.addcancelled_count = nil
- }
- // SetEstimatedCost sets the "estimated_cost" field.
- func (m *BatchImageJobMutation) SetEstimatedCost(f float64) {
- m.estimated_cost = &f
- m.addestimated_cost = nil
- }
- // EstimatedCost returns the value of the "estimated_cost" field in the mutation.
- func (m *BatchImageJobMutation) EstimatedCost() (r float64, exists bool) {
- v := m.estimated_cost
- if v == nil {
- return
- }
- return *v, true
- }
- // OldEstimatedCost returns the old "estimated_cost" field's value of the BatchImageJob entity.
- // If the BatchImageJob object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *BatchImageJobMutation) OldEstimatedCost(ctx context.Context) (v float64, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldEstimatedCost is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldEstimatedCost requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldEstimatedCost: %w", err)
- }
- return oldValue.EstimatedCost, nil
- }
- // AddEstimatedCost adds f to the "estimated_cost" field.
- func (m *BatchImageJobMutation) AddEstimatedCost(f float64) {
- if m.addestimated_cost != nil {
- *m.addestimated_cost += f
- } else {
- m.addestimated_cost = &f
- }
- }
- // AddedEstimatedCost returns the value that was added to the "estimated_cost" field in this mutation.
- func (m *BatchImageJobMutation) AddedEstimatedCost() (r float64, exists bool) {
- v := m.addestimated_cost
- if v == nil {
- return
- }
- return *v, true
- }
- // ResetEstimatedCost resets all changes to the "estimated_cost" field.
- func (m *BatchImageJobMutation) ResetEstimatedCost() {
- m.estimated_cost = nil
- m.addestimated_cost = nil
- }
- // SetHoldAmount sets the "hold_amount" field.
- func (m *BatchImageJobMutation) SetHoldAmount(f float64) {
- m.hold_amount = &f
- m.addhold_amount = nil
- }
- // HoldAmount returns the value of the "hold_amount" field in the mutation.
- func (m *BatchImageJobMutation) HoldAmount() (r float64, exists bool) {
- v := m.hold_amount
- if v == nil {
- return
- }
- return *v, true
- }
- // OldHoldAmount returns the old "hold_amount" field's value of the BatchImageJob entity.
- // If the BatchImageJob object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *BatchImageJobMutation) OldHoldAmount(ctx context.Context) (v *float64, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldHoldAmount is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldHoldAmount requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldHoldAmount: %w", err)
- }
- return oldValue.HoldAmount, nil
- }
- // AddHoldAmount adds f to the "hold_amount" field.
- func (m *BatchImageJobMutation) AddHoldAmount(f float64) {
- if m.addhold_amount != nil {
- *m.addhold_amount += f
- } else {
- m.addhold_amount = &f
- }
- }
- // AddedHoldAmount returns the value that was added to the "hold_amount" field in this mutation.
- func (m *BatchImageJobMutation) AddedHoldAmount() (r float64, exists bool) {
- v := m.addhold_amount
- if v == nil {
- return
- }
- return *v, true
- }
- // ClearHoldAmount clears the value of the "hold_amount" field.
- func (m *BatchImageJobMutation) ClearHoldAmount() {
- m.hold_amount = nil
- m.addhold_amount = nil
- m.clearedFields[batchimagejob.FieldHoldAmount] = struct{}{}
- }
- // HoldAmountCleared returns if the "hold_amount" field was cleared in this mutation.
- func (m *BatchImageJobMutation) HoldAmountCleared() bool {
- _, ok := m.clearedFields[batchimagejob.FieldHoldAmount]
- return ok
- }
- // ResetHoldAmount resets all changes to the "hold_amount" field.
- func (m *BatchImageJobMutation) ResetHoldAmount() {
- m.hold_amount = nil
- m.addhold_amount = nil
- delete(m.clearedFields, batchimagejob.FieldHoldAmount)
- }
- // SetActualCost sets the "actual_cost" field.
- func (m *BatchImageJobMutation) SetActualCost(f float64) {
- m.actual_cost = &f
- m.addactual_cost = nil
- }
- // ActualCost returns the value of the "actual_cost" field in the mutation.
- func (m *BatchImageJobMutation) ActualCost() (r float64, exists bool) {
- v := m.actual_cost
- if v == nil {
- return
- }
- return *v, true
- }
- // OldActualCost returns the old "actual_cost" field's value of the BatchImageJob entity.
- // If the BatchImageJob object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *BatchImageJobMutation) OldActualCost(ctx context.Context) (v *float64, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldActualCost is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldActualCost requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldActualCost: %w", err)
- }
- return oldValue.ActualCost, nil
- }
- // AddActualCost adds f to the "actual_cost" field.
- func (m *BatchImageJobMutation) AddActualCost(f float64) {
- if m.addactual_cost != nil {
- *m.addactual_cost += f
- } else {
- m.addactual_cost = &f
- }
- }
- // AddedActualCost returns the value that was added to the "actual_cost" field in this mutation.
- func (m *BatchImageJobMutation) AddedActualCost() (r float64, exists bool) {
- v := m.addactual_cost
- if v == nil {
- return
- }
- return *v, true
- }
- // ClearActualCost clears the value of the "actual_cost" field.
- func (m *BatchImageJobMutation) ClearActualCost() {
- m.actual_cost = nil
- m.addactual_cost = nil
- m.clearedFields[batchimagejob.FieldActualCost] = struct{}{}
- }
- // ActualCostCleared returns if the "actual_cost" field was cleared in this mutation.
- func (m *BatchImageJobMutation) ActualCostCleared() bool {
- _, ok := m.clearedFields[batchimagejob.FieldActualCost]
- return ok
- }
- // ResetActualCost resets all changes to the "actual_cost" field.
- func (m *BatchImageJobMutation) ResetActualCost() {
- m.actual_cost = nil
- m.addactual_cost = nil
- delete(m.clearedFields, batchimagejob.FieldActualCost)
- }
- // SetCurrency sets the "currency" field.
- func (m *BatchImageJobMutation) SetCurrency(s string) {
- m.currency = &s
- }
- // Currency returns the value of the "currency" field in the mutation.
- func (m *BatchImageJobMutation) Currency() (r string, exists bool) {
- v := m.currency
- if v == nil {
- return
- }
- return *v, true
- }
- // OldCurrency returns the old "currency" field's value of the BatchImageJob entity.
- // If the BatchImageJob object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *BatchImageJobMutation) OldCurrency(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldCurrency is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldCurrency requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldCurrency: %w", err)
- }
- return oldValue.Currency, nil
- }
- // ResetCurrency resets all changes to the "currency" field.
- func (m *BatchImageJobMutation) ResetCurrency() {
- m.currency = nil
- }
- // SetHoldID sets the "hold_id" field.
- func (m *BatchImageJobMutation) SetHoldID(s string) {
- m.hold_id = &s
- }
- // HoldID returns the value of the "hold_id" field in the mutation.
- func (m *BatchImageJobMutation) HoldID() (r string, exists bool) {
- v := m.hold_id
- if v == nil {
- return
- }
- return *v, true
- }
- // OldHoldID returns the old "hold_id" field's value of the BatchImageJob entity.
- // If the BatchImageJob object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *BatchImageJobMutation) OldHoldID(ctx context.Context) (v *string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldHoldID is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldHoldID requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldHoldID: %w", err)
- }
- return oldValue.HoldID, nil
- }
- // ClearHoldID clears the value of the "hold_id" field.
- func (m *BatchImageJobMutation) ClearHoldID() {
- m.hold_id = nil
- m.clearedFields[batchimagejob.FieldHoldID] = struct{}{}
- }
- // HoldIDCleared returns if the "hold_id" field was cleared in this mutation.
- func (m *BatchImageJobMutation) HoldIDCleared() bool {
- _, ok := m.clearedFields[batchimagejob.FieldHoldID]
- return ok
- }
- // ResetHoldID resets all changes to the "hold_id" field.
- func (m *BatchImageJobMutation) ResetHoldID() {
- m.hold_id = nil
- delete(m.clearedFields, batchimagejob.FieldHoldID)
- }
- // SetIdempotencyKey sets the "idempotency_key" field.
- func (m *BatchImageJobMutation) SetIdempotencyKey(s string) {
- m.idempotency_key = &s
- }
- // IdempotencyKey returns the value of the "idempotency_key" field in the mutation.
- func (m *BatchImageJobMutation) IdempotencyKey() (r string, exists bool) {
- v := m.idempotency_key
- if v == nil {
- return
- }
- return *v, true
- }
- // OldIdempotencyKey returns the old "idempotency_key" field's value of the BatchImageJob entity.
- // If the BatchImageJob object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *BatchImageJobMutation) OldIdempotencyKey(ctx context.Context) (v *string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldIdempotencyKey is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldIdempotencyKey requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldIdempotencyKey: %w", err)
- }
- return oldValue.IdempotencyKey, nil
- }
- // ClearIdempotencyKey clears the value of the "idempotency_key" field.
- func (m *BatchImageJobMutation) ClearIdempotencyKey() {
- m.idempotency_key = nil
- m.clearedFields[batchimagejob.FieldIdempotencyKey] = struct{}{}
- }
- // IdempotencyKeyCleared returns if the "idempotency_key" field was cleared in this mutation.
- func (m *BatchImageJobMutation) IdempotencyKeyCleared() bool {
- _, ok := m.clearedFields[batchimagejob.FieldIdempotencyKey]
- return ok
- }
- // ResetIdempotencyKey resets all changes to the "idempotency_key" field.
- func (m *BatchImageJobMutation) ResetIdempotencyKey() {
- m.idempotency_key = nil
- delete(m.clearedFields, batchimagejob.FieldIdempotencyKey)
- }
- // SetRequestHash sets the "request_hash" field.
- func (m *BatchImageJobMutation) SetRequestHash(s string) {
- m.request_hash = &s
- }
- // RequestHash returns the value of the "request_hash" field in the mutation.
- func (m *BatchImageJobMutation) RequestHash() (r string, exists bool) {
- v := m.request_hash
- if v == nil {
- return
- }
- return *v, true
- }
- // OldRequestHash returns the old "request_hash" field's value of the BatchImageJob entity.
- // If the BatchImageJob object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *BatchImageJobMutation) OldRequestHash(ctx context.Context) (v *string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldRequestHash is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldRequestHash requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldRequestHash: %w", err)
- }
- return oldValue.RequestHash, nil
- }
- // ClearRequestHash clears the value of the "request_hash" field.
- func (m *BatchImageJobMutation) ClearRequestHash() {
- m.request_hash = nil
- m.clearedFields[batchimagejob.FieldRequestHash] = struct{}{}
- }
- // RequestHashCleared returns if the "request_hash" field was cleared in this mutation.
- func (m *BatchImageJobMutation) RequestHashCleared() bool {
- _, ok := m.clearedFields[batchimagejob.FieldRequestHash]
- return ok
- }
- // ResetRequestHash resets all changes to the "request_hash" field.
- func (m *BatchImageJobMutation) ResetRequestHash() {
- m.request_hash = nil
- delete(m.clearedFields, batchimagejob.FieldRequestHash)
- }
- // SetManifestHash sets the "manifest_hash" field.
- func (m *BatchImageJobMutation) SetManifestHash(s string) {
- m.manifest_hash = &s
- }
- // ManifestHash returns the value of the "manifest_hash" field in the mutation.
- func (m *BatchImageJobMutation) ManifestHash() (r string, exists bool) {
- v := m.manifest_hash
- if v == nil {
- return
- }
- return *v, true
- }
- // OldManifestHash returns the old "manifest_hash" field's value of the BatchImageJob entity.
- // If the BatchImageJob object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *BatchImageJobMutation) OldManifestHash(ctx context.Context) (v *string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldManifestHash is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldManifestHash requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldManifestHash: %w", err)
- }
- return oldValue.ManifestHash, nil
- }
- // ClearManifestHash clears the value of the "manifest_hash" field.
- func (m *BatchImageJobMutation) ClearManifestHash() {
- m.manifest_hash = nil
- m.clearedFields[batchimagejob.FieldManifestHash] = struct{}{}
- }
- // ManifestHashCleared returns if the "manifest_hash" field was cleared in this mutation.
- func (m *BatchImageJobMutation) ManifestHashCleared() bool {
- _, ok := m.clearedFields[batchimagejob.FieldManifestHash]
- return ok
- }
- // ResetManifestHash resets all changes to the "manifest_hash" field.
- func (m *BatchImageJobMutation) ResetManifestHash() {
- m.manifest_hash = nil
- delete(m.clearedFields, batchimagejob.FieldManifestHash)
- }
- // SetRetryCount sets the "retry_count" field.
- func (m *BatchImageJobMutation) SetRetryCount(i int) {
- m.retry_count = &i
- m.addretry_count = nil
- }
- // RetryCount returns the value of the "retry_count" field in the mutation.
- func (m *BatchImageJobMutation) RetryCount() (r int, exists bool) {
- v := m.retry_count
- if v == nil {
- return
- }
- return *v, true
- }
- // OldRetryCount returns the old "retry_count" field's value of the BatchImageJob entity.
- // If the BatchImageJob object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *BatchImageJobMutation) OldRetryCount(ctx context.Context) (v int, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldRetryCount is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldRetryCount requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldRetryCount: %w", err)
- }
- return oldValue.RetryCount, nil
- }
- // AddRetryCount adds i to the "retry_count" field.
- func (m *BatchImageJobMutation) AddRetryCount(i int) {
- if m.addretry_count != nil {
- *m.addretry_count += i
- } else {
- m.addretry_count = &i
- }
- }
- // AddedRetryCount returns the value that was added to the "retry_count" field in this mutation.
- func (m *BatchImageJobMutation) AddedRetryCount() (r int, exists bool) {
- v := m.addretry_count
- if v == nil {
- return
- }
- return *v, true
- }
- // ResetRetryCount resets all changes to the "retry_count" field.
- func (m *BatchImageJobMutation) ResetRetryCount() {
- m.retry_count = nil
- m.addretry_count = nil
- }
- // SetVersion sets the "version" field.
- func (m *BatchImageJobMutation) SetVersion(i int) {
- m.version = &i
- m.addversion = nil
- }
- // Version returns the value of the "version" field in the mutation.
- func (m *BatchImageJobMutation) Version() (r int, exists bool) {
- v := m.version
- if v == nil {
- return
- }
- return *v, true
- }
- // OldVersion returns the old "version" field's value of the BatchImageJob entity.
- // If the BatchImageJob object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *BatchImageJobMutation) OldVersion(ctx context.Context) (v int, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldVersion is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldVersion requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldVersion: %w", err)
- }
- return oldValue.Version, nil
- }
- // AddVersion adds i to the "version" field.
- func (m *BatchImageJobMutation) AddVersion(i int) {
- if m.addversion != nil {
- *m.addversion += i
- } else {
- m.addversion = &i
- }
- }
- // AddedVersion returns the value that was added to the "version" field in this mutation.
- func (m *BatchImageJobMutation) AddedVersion() (r int, exists bool) {
- v := m.addversion
- if v == nil {
- return
- }
- return *v, true
- }
- // ResetVersion resets all changes to the "version" field.
- func (m *BatchImageJobMutation) ResetVersion() {
- m.version = nil
- m.addversion = nil
- }
- // SetOutputExpiresAt sets the "output_expires_at" field.
- func (m *BatchImageJobMutation) SetOutputExpiresAt(t time.Time) {
- m.output_expires_at = &t
- }
- // OutputExpiresAt returns the value of the "output_expires_at" field in the mutation.
- func (m *BatchImageJobMutation) OutputExpiresAt() (r time.Time, exists bool) {
- v := m.output_expires_at
- if v == nil {
- return
- }
- return *v, true
- }
- // OldOutputExpiresAt returns the old "output_expires_at" field's value of the BatchImageJob entity.
- // If the BatchImageJob object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *BatchImageJobMutation) OldOutputExpiresAt(ctx context.Context) (v *time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldOutputExpiresAt is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldOutputExpiresAt requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldOutputExpiresAt: %w", err)
- }
- return oldValue.OutputExpiresAt, nil
- }
- // ClearOutputExpiresAt clears the value of the "output_expires_at" field.
- func (m *BatchImageJobMutation) ClearOutputExpiresAt() {
- m.output_expires_at = nil
- m.clearedFields[batchimagejob.FieldOutputExpiresAt] = struct{}{}
- }
- // OutputExpiresAtCleared returns if the "output_expires_at" field was cleared in this mutation.
- func (m *BatchImageJobMutation) OutputExpiresAtCleared() bool {
- _, ok := m.clearedFields[batchimagejob.FieldOutputExpiresAt]
- return ok
- }
- // ResetOutputExpiresAt resets all changes to the "output_expires_at" field.
- func (m *BatchImageJobMutation) ResetOutputExpiresAt() {
- m.output_expires_at = nil
- delete(m.clearedFields, batchimagejob.FieldOutputExpiresAt)
- }
- // SetInputDeletedAt sets the "input_deleted_at" field.
- func (m *BatchImageJobMutation) SetInputDeletedAt(t time.Time) {
- m.input_deleted_at = &t
- }
- // InputDeletedAt returns the value of the "input_deleted_at" field in the mutation.
- func (m *BatchImageJobMutation) InputDeletedAt() (r time.Time, exists bool) {
- v := m.input_deleted_at
- if v == nil {
- return
- }
- return *v, true
- }
- // OldInputDeletedAt returns the old "input_deleted_at" field's value of the BatchImageJob entity.
- // If the BatchImageJob object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *BatchImageJobMutation) OldInputDeletedAt(ctx context.Context) (v *time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldInputDeletedAt is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldInputDeletedAt requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldInputDeletedAt: %w", err)
- }
- return oldValue.InputDeletedAt, nil
- }
- // ClearInputDeletedAt clears the value of the "input_deleted_at" field.
- func (m *BatchImageJobMutation) ClearInputDeletedAt() {
- m.input_deleted_at = nil
- m.clearedFields[batchimagejob.FieldInputDeletedAt] = struct{}{}
- }
- // InputDeletedAtCleared returns if the "input_deleted_at" field was cleared in this mutation.
- func (m *BatchImageJobMutation) InputDeletedAtCleared() bool {
- _, ok := m.clearedFields[batchimagejob.FieldInputDeletedAt]
- return ok
- }
- // ResetInputDeletedAt resets all changes to the "input_deleted_at" field.
- func (m *BatchImageJobMutation) ResetInputDeletedAt() {
- m.input_deleted_at = nil
- delete(m.clearedFields, batchimagejob.FieldInputDeletedAt)
- }
- // SetOutputDeletedAt sets the "output_deleted_at" field.
- func (m *BatchImageJobMutation) SetOutputDeletedAt(t time.Time) {
- m.output_deleted_at = &t
- }
- // OutputDeletedAt returns the value of the "output_deleted_at" field in the mutation.
- func (m *BatchImageJobMutation) OutputDeletedAt() (r time.Time, exists bool) {
- v := m.output_deleted_at
- if v == nil {
- return
- }
- return *v, true
- }
- // OldOutputDeletedAt returns the old "output_deleted_at" field's value of the BatchImageJob entity.
- // If the BatchImageJob object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *BatchImageJobMutation) OldOutputDeletedAt(ctx context.Context) (v *time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldOutputDeletedAt is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldOutputDeletedAt requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldOutputDeletedAt: %w", err)
- }
- return oldValue.OutputDeletedAt, nil
- }
- // ClearOutputDeletedAt clears the value of the "output_deleted_at" field.
- func (m *BatchImageJobMutation) ClearOutputDeletedAt() {
- m.output_deleted_at = nil
- m.clearedFields[batchimagejob.FieldOutputDeletedAt] = struct{}{}
- }
- // OutputDeletedAtCleared returns if the "output_deleted_at" field was cleared in this mutation.
- func (m *BatchImageJobMutation) OutputDeletedAtCleared() bool {
- _, ok := m.clearedFields[batchimagejob.FieldOutputDeletedAt]
- return ok
- }
- // ResetOutputDeletedAt resets all changes to the "output_deleted_at" field.
- func (m *BatchImageJobMutation) ResetOutputDeletedAt() {
- m.output_deleted_at = nil
- delete(m.clearedFields, batchimagejob.FieldOutputDeletedAt)
- }
- // SetDownloadedAt sets the "downloaded_at" field.
- func (m *BatchImageJobMutation) SetDownloadedAt(t time.Time) {
- m.downloaded_at = &t
- }
- // DownloadedAt returns the value of the "downloaded_at" field in the mutation.
- func (m *BatchImageJobMutation) DownloadedAt() (r time.Time, exists bool) {
- v := m.downloaded_at
- if v == nil {
- return
- }
- return *v, true
- }
- // OldDownloadedAt returns the old "downloaded_at" field's value of the BatchImageJob entity.
- // If the BatchImageJob object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *BatchImageJobMutation) OldDownloadedAt(ctx context.Context) (v *time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldDownloadedAt is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldDownloadedAt requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldDownloadedAt: %w", err)
- }
- return oldValue.DownloadedAt, nil
- }
- // ClearDownloadedAt clears the value of the "downloaded_at" field.
- func (m *BatchImageJobMutation) ClearDownloadedAt() {
- m.downloaded_at = nil
- m.clearedFields[batchimagejob.FieldDownloadedAt] = struct{}{}
- }
- // DownloadedAtCleared returns if the "downloaded_at" field was cleared in this mutation.
- func (m *BatchImageJobMutation) DownloadedAtCleared() bool {
- _, ok := m.clearedFields[batchimagejob.FieldDownloadedAt]
- return ok
- }
- // ResetDownloadedAt resets all changes to the "downloaded_at" field.
- func (m *BatchImageJobMutation) ResetDownloadedAt() {
- m.downloaded_at = nil
- delete(m.clearedFields, batchimagejob.FieldDownloadedAt)
- }
- // SetUserDeletedAt sets the "user_deleted_at" field.
- func (m *BatchImageJobMutation) SetUserDeletedAt(t time.Time) {
- m.user_deleted_at = &t
- }
- // UserDeletedAt returns the value of the "user_deleted_at" field in the mutation.
- func (m *BatchImageJobMutation) UserDeletedAt() (r time.Time, exists bool) {
- v := m.user_deleted_at
- if v == nil {
- return
- }
- return *v, true
- }
- // OldUserDeletedAt returns the old "user_deleted_at" field's value of the BatchImageJob entity.
- // If the BatchImageJob object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *BatchImageJobMutation) OldUserDeletedAt(ctx context.Context) (v *time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldUserDeletedAt is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldUserDeletedAt requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldUserDeletedAt: %w", err)
- }
- return oldValue.UserDeletedAt, nil
- }
- // ClearUserDeletedAt clears the value of the "user_deleted_at" field.
- func (m *BatchImageJobMutation) ClearUserDeletedAt() {
- m.user_deleted_at = nil
- m.clearedFields[batchimagejob.FieldUserDeletedAt] = struct{}{}
- }
- // UserDeletedAtCleared returns if the "user_deleted_at" field was cleared in this mutation.
- func (m *BatchImageJobMutation) UserDeletedAtCleared() bool {
- _, ok := m.clearedFields[batchimagejob.FieldUserDeletedAt]
- return ok
- }
- // ResetUserDeletedAt resets all changes to the "user_deleted_at" field.
- func (m *BatchImageJobMutation) ResetUserDeletedAt() {
- m.user_deleted_at = nil
- delete(m.clearedFields, batchimagejob.FieldUserDeletedAt)
- }
- // SetLastErrorCode sets the "last_error_code" field.
- func (m *BatchImageJobMutation) SetLastErrorCode(s string) {
- m.last_error_code = &s
- }
- // LastErrorCode returns the value of the "last_error_code" field in the mutation.
- func (m *BatchImageJobMutation) LastErrorCode() (r string, exists bool) {
- v := m.last_error_code
- if v == nil {
- return
- }
- return *v, true
- }
- // OldLastErrorCode returns the old "last_error_code" field's value of the BatchImageJob entity.
- // If the BatchImageJob object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *BatchImageJobMutation) OldLastErrorCode(ctx context.Context) (v *string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldLastErrorCode is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldLastErrorCode requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldLastErrorCode: %w", err)
- }
- return oldValue.LastErrorCode, nil
- }
- // ClearLastErrorCode clears the value of the "last_error_code" field.
- func (m *BatchImageJobMutation) ClearLastErrorCode() {
- m.last_error_code = nil
- m.clearedFields[batchimagejob.FieldLastErrorCode] = struct{}{}
- }
- // LastErrorCodeCleared returns if the "last_error_code" field was cleared in this mutation.
- func (m *BatchImageJobMutation) LastErrorCodeCleared() bool {
- _, ok := m.clearedFields[batchimagejob.FieldLastErrorCode]
- return ok
- }
- // ResetLastErrorCode resets all changes to the "last_error_code" field.
- func (m *BatchImageJobMutation) ResetLastErrorCode() {
- m.last_error_code = nil
- delete(m.clearedFields, batchimagejob.FieldLastErrorCode)
- }
- // SetLastErrorMessage sets the "last_error_message" field.
- func (m *BatchImageJobMutation) SetLastErrorMessage(s string) {
- m.last_error_message = &s
- }
- // LastErrorMessage returns the value of the "last_error_message" field in the mutation.
- func (m *BatchImageJobMutation) LastErrorMessage() (r string, exists bool) {
- v := m.last_error_message
- if v == nil {
- return
- }
- return *v, true
- }
- // OldLastErrorMessage returns the old "last_error_message" field's value of the BatchImageJob entity.
- // If the BatchImageJob object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *BatchImageJobMutation) OldLastErrorMessage(ctx context.Context) (v *string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldLastErrorMessage is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldLastErrorMessage requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldLastErrorMessage: %w", err)
- }
- return oldValue.LastErrorMessage, nil
- }
- // ClearLastErrorMessage clears the value of the "last_error_message" field.
- func (m *BatchImageJobMutation) ClearLastErrorMessage() {
- m.last_error_message = nil
- m.clearedFields[batchimagejob.FieldLastErrorMessage] = struct{}{}
- }
- // LastErrorMessageCleared returns if the "last_error_message" field was cleared in this mutation.
- func (m *BatchImageJobMutation) LastErrorMessageCleared() bool {
- _, ok := m.clearedFields[batchimagejob.FieldLastErrorMessage]
- return ok
- }
- // ResetLastErrorMessage resets all changes to the "last_error_message" field.
- func (m *BatchImageJobMutation) ResetLastErrorMessage() {
- m.last_error_message = nil
- delete(m.clearedFields, batchimagejob.FieldLastErrorMessage)
- }
- // SetCreatedAt sets the "created_at" field.
- func (m *BatchImageJobMutation) SetCreatedAt(t time.Time) {
- m.created_at = &t
- }
- // CreatedAt returns the value of the "created_at" field in the mutation.
- func (m *BatchImageJobMutation) CreatedAt() (r time.Time, exists bool) {
- v := m.created_at
- if v == nil {
- return
- }
- return *v, true
- }
- // OldCreatedAt returns the old "created_at" field's value of the BatchImageJob entity.
- // If the BatchImageJob object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *BatchImageJobMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldCreatedAt requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
- }
- return oldValue.CreatedAt, nil
- }
- // ResetCreatedAt resets all changes to the "created_at" field.
- func (m *BatchImageJobMutation) ResetCreatedAt() {
- m.created_at = nil
- }
- // SetUpdatedAt sets the "updated_at" field.
- func (m *BatchImageJobMutation) SetUpdatedAt(t time.Time) {
- m.updated_at = &t
- }
- // UpdatedAt returns the value of the "updated_at" field in the mutation.
- func (m *BatchImageJobMutation) UpdatedAt() (r time.Time, exists bool) {
- v := m.updated_at
- if v == nil {
- return
- }
- return *v, true
- }
- // OldUpdatedAt returns the old "updated_at" field's value of the BatchImageJob entity.
- // If the BatchImageJob object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *BatchImageJobMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
- }
- return oldValue.UpdatedAt, nil
- }
- // ResetUpdatedAt resets all changes to the "updated_at" field.
- func (m *BatchImageJobMutation) ResetUpdatedAt() {
- m.updated_at = nil
- }
- // SetSubmittedAt sets the "submitted_at" field.
- func (m *BatchImageJobMutation) SetSubmittedAt(t time.Time) {
- m.submitted_at = &t
- }
- // SubmittedAt returns the value of the "submitted_at" field in the mutation.
- func (m *BatchImageJobMutation) SubmittedAt() (r time.Time, exists bool) {
- v := m.submitted_at
- if v == nil {
- return
- }
- return *v, true
- }
- // OldSubmittedAt returns the old "submitted_at" field's value of the BatchImageJob entity.
- // If the BatchImageJob object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *BatchImageJobMutation) OldSubmittedAt(ctx context.Context) (v *time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldSubmittedAt is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldSubmittedAt requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldSubmittedAt: %w", err)
- }
- return oldValue.SubmittedAt, nil
- }
- // ClearSubmittedAt clears the value of the "submitted_at" field.
- func (m *BatchImageJobMutation) ClearSubmittedAt() {
- m.submitted_at = nil
- m.clearedFields[batchimagejob.FieldSubmittedAt] = struct{}{}
- }
- // SubmittedAtCleared returns if the "submitted_at" field was cleared in this mutation.
- func (m *BatchImageJobMutation) SubmittedAtCleared() bool {
- _, ok := m.clearedFields[batchimagejob.FieldSubmittedAt]
- return ok
- }
- // ResetSubmittedAt resets all changes to the "submitted_at" field.
- func (m *BatchImageJobMutation) ResetSubmittedAt() {
- m.submitted_at = nil
- delete(m.clearedFields, batchimagejob.FieldSubmittedAt)
- }
- // SetStartedAt sets the "started_at" field.
- func (m *BatchImageJobMutation) SetStartedAt(t time.Time) {
- m.started_at = &t
- }
- // StartedAt returns the value of the "started_at" field in the mutation.
- func (m *BatchImageJobMutation) StartedAt() (r time.Time, exists bool) {
- v := m.started_at
- if v == nil {
- return
- }
- return *v, true
- }
- // OldStartedAt returns the old "started_at" field's value of the BatchImageJob entity.
- // If the BatchImageJob object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *BatchImageJobMutation) OldStartedAt(ctx context.Context) (v *time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldStartedAt is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldStartedAt requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldStartedAt: %w", err)
- }
- return oldValue.StartedAt, nil
- }
- // ClearStartedAt clears the value of the "started_at" field.
- func (m *BatchImageJobMutation) ClearStartedAt() {
- m.started_at = nil
- m.clearedFields[batchimagejob.FieldStartedAt] = struct{}{}
- }
- // StartedAtCleared returns if the "started_at" field was cleared in this mutation.
- func (m *BatchImageJobMutation) StartedAtCleared() bool {
- _, ok := m.clearedFields[batchimagejob.FieldStartedAt]
- return ok
- }
- // ResetStartedAt resets all changes to the "started_at" field.
- func (m *BatchImageJobMutation) ResetStartedAt() {
- m.started_at = nil
- delete(m.clearedFields, batchimagejob.FieldStartedAt)
- }
- // SetFinishedAt sets the "finished_at" field.
- func (m *BatchImageJobMutation) SetFinishedAt(t time.Time) {
- m.finished_at = &t
- }
- // FinishedAt returns the value of the "finished_at" field in the mutation.
- func (m *BatchImageJobMutation) FinishedAt() (r time.Time, exists bool) {
- v := m.finished_at
- if v == nil {
- return
- }
- return *v, true
- }
- // OldFinishedAt returns the old "finished_at" field's value of the BatchImageJob entity.
- // If the BatchImageJob object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *BatchImageJobMutation) OldFinishedAt(ctx context.Context) (v *time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldFinishedAt is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldFinishedAt requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldFinishedAt: %w", err)
- }
- return oldValue.FinishedAt, nil
- }
- // ClearFinishedAt clears the value of the "finished_at" field.
- func (m *BatchImageJobMutation) ClearFinishedAt() {
- m.finished_at = nil
- m.clearedFields[batchimagejob.FieldFinishedAt] = struct{}{}
- }
- // FinishedAtCleared returns if the "finished_at" field was cleared in this mutation.
- func (m *BatchImageJobMutation) FinishedAtCleared() bool {
- _, ok := m.clearedFields[batchimagejob.FieldFinishedAt]
- return ok
- }
- // ResetFinishedAt resets all changes to the "finished_at" field.
- func (m *BatchImageJobMutation) ResetFinishedAt() {
- m.finished_at = nil
- delete(m.clearedFields, batchimagejob.FieldFinishedAt)
- }
- // SetSettledAt sets the "settled_at" field.
- func (m *BatchImageJobMutation) SetSettledAt(t time.Time) {
- m.settled_at = &t
- }
- // SettledAt returns the value of the "settled_at" field in the mutation.
- func (m *BatchImageJobMutation) SettledAt() (r time.Time, exists bool) {
- v := m.settled_at
- if v == nil {
- return
- }
- return *v, true
- }
- // OldSettledAt returns the old "settled_at" field's value of the BatchImageJob entity.
- // If the BatchImageJob object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *BatchImageJobMutation) OldSettledAt(ctx context.Context) (v *time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldSettledAt is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldSettledAt requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldSettledAt: %w", err)
- }
- return oldValue.SettledAt, nil
- }
- // ClearSettledAt clears the value of the "settled_at" field.
- func (m *BatchImageJobMutation) ClearSettledAt() {
- m.settled_at = nil
- m.clearedFields[batchimagejob.FieldSettledAt] = struct{}{}
- }
- // SettledAtCleared returns if the "settled_at" field was cleared in this mutation.
- func (m *BatchImageJobMutation) SettledAtCleared() bool {
- _, ok := m.clearedFields[batchimagejob.FieldSettledAt]
- return ok
- }
- // ResetSettledAt resets all changes to the "settled_at" field.
- func (m *BatchImageJobMutation) ResetSettledAt() {
- m.settled_at = nil
- delete(m.clearedFields, batchimagejob.FieldSettledAt)
- }
- // Where appends a list predicates to the BatchImageJobMutation builder.
- func (m *BatchImageJobMutation) Where(ps ...predicate.BatchImageJob) {
- m.predicates = append(m.predicates, ps...)
- }
- // WhereP appends storage-level predicates to the BatchImageJobMutation builder. Using this method,
- // users can use type-assertion to append predicates that do not depend on any generated package.
- func (m *BatchImageJobMutation) WhereP(ps ...func(*sql.Selector)) {
- p := make([]predicate.BatchImageJob, len(ps))
- for i := range ps {
- p[i] = ps[i]
- }
- m.Where(p...)
- }
- // Op returns the operation name.
- func (m *BatchImageJobMutation) Op() Op {
- return m.op
- }
- // SetOp allows setting the mutation operation.
- func (m *BatchImageJobMutation) SetOp(op Op) {
- m.op = op
- }
- // Type returns the node type of this mutation (BatchImageJob).
- func (m *BatchImageJobMutation) Type() string {
- return m.typ
- }
- // Fields returns all fields that were changed during this mutation. Note that in
- // order to get all numeric fields that were incremented/decremented, call
- // AddedFields().
- func (m *BatchImageJobMutation) Fields() []string {
- fields := make([]string, 0, 40)
- if m.batch_id != nil {
- fields = append(fields, batchimagejob.FieldBatchID)
- }
- if m.user_id != nil {
- fields = append(fields, batchimagejob.FieldUserID)
- }
- if m.api_key_id != nil {
- fields = append(fields, batchimagejob.FieldAPIKeyID)
- }
- if m.account_id != nil {
- fields = append(fields, batchimagejob.FieldAccountID)
- }
- if m.provider != nil {
- fields = append(fields, batchimagejob.FieldProvider)
- }
- if m.model != nil {
- fields = append(fields, batchimagejob.FieldModel)
- }
- if m.task_name != nil {
- fields = append(fields, batchimagejob.FieldTaskName)
- }
- if m.status != nil {
- fields = append(fields, batchimagejob.FieldStatus)
- }
- if m.provider_job_name != nil {
- fields = append(fields, batchimagejob.FieldProviderJobName)
- }
- if m.provider_input_ref != nil {
- fields = append(fields, batchimagejob.FieldProviderInputRef)
- }
- if m.provider_output_ref != nil {
- fields = append(fields, batchimagejob.FieldProviderOutputRef)
- }
- if m.gcs_input_uri != nil {
- fields = append(fields, batchimagejob.FieldGcsInputURI)
- }
- if m.gcs_output_uri != nil {
- fields = append(fields, batchimagejob.FieldGcsOutputURI)
- }
- if m.item_count != nil {
- fields = append(fields, batchimagejob.FieldItemCount)
- }
- if m.success_count != nil {
- fields = append(fields, batchimagejob.FieldSuccessCount)
- }
- if m.fail_count != nil {
- fields = append(fields, batchimagejob.FieldFailCount)
- }
- if m.cancelled_count != nil {
- fields = append(fields, batchimagejob.FieldCancelledCount)
- }
- if m.estimated_cost != nil {
- fields = append(fields, batchimagejob.FieldEstimatedCost)
- }
- if m.hold_amount != nil {
- fields = append(fields, batchimagejob.FieldHoldAmount)
- }
- if m.actual_cost != nil {
- fields = append(fields, batchimagejob.FieldActualCost)
- }
- if m.currency != nil {
- fields = append(fields, batchimagejob.FieldCurrency)
- }
- if m.hold_id != nil {
- fields = append(fields, batchimagejob.FieldHoldID)
- }
- if m.idempotency_key != nil {
- fields = append(fields, batchimagejob.FieldIdempotencyKey)
- }
- if m.request_hash != nil {
- fields = append(fields, batchimagejob.FieldRequestHash)
- }
- if m.manifest_hash != nil {
- fields = append(fields, batchimagejob.FieldManifestHash)
- }
- if m.retry_count != nil {
- fields = append(fields, batchimagejob.FieldRetryCount)
- }
- if m.version != nil {
- fields = append(fields, batchimagejob.FieldVersion)
- }
- if m.output_expires_at != nil {
- fields = append(fields, batchimagejob.FieldOutputExpiresAt)
- }
- if m.input_deleted_at != nil {
- fields = append(fields, batchimagejob.FieldInputDeletedAt)
- }
- if m.output_deleted_at != nil {
- fields = append(fields, batchimagejob.FieldOutputDeletedAt)
- }
- if m.downloaded_at != nil {
- fields = append(fields, batchimagejob.FieldDownloadedAt)
- }
- if m.user_deleted_at != nil {
- fields = append(fields, batchimagejob.FieldUserDeletedAt)
- }
- if m.last_error_code != nil {
- fields = append(fields, batchimagejob.FieldLastErrorCode)
- }
- if m.last_error_message != nil {
- fields = append(fields, batchimagejob.FieldLastErrorMessage)
- }
- if m.created_at != nil {
- fields = append(fields, batchimagejob.FieldCreatedAt)
- }
- if m.updated_at != nil {
- fields = append(fields, batchimagejob.FieldUpdatedAt)
- }
- if m.submitted_at != nil {
- fields = append(fields, batchimagejob.FieldSubmittedAt)
- }
- if m.started_at != nil {
- fields = append(fields, batchimagejob.FieldStartedAt)
- }
- if m.finished_at != nil {
- fields = append(fields, batchimagejob.FieldFinishedAt)
- }
- if m.settled_at != nil {
- fields = append(fields, batchimagejob.FieldSettledAt)
- }
- return fields
- }
- // Field returns the value of a field with the given name. The second boolean
- // return value indicates that this field was not set, or was not defined in the
- // schema.
- func (m *BatchImageJobMutation) Field(name string) (ent.Value, bool) {
- switch name {
- case batchimagejob.FieldBatchID:
- return m.BatchID()
- case batchimagejob.FieldUserID:
- return m.UserID()
- case batchimagejob.FieldAPIKeyID:
- return m.APIKeyID()
- case batchimagejob.FieldAccountID:
- return m.AccountID()
- case batchimagejob.FieldProvider:
- return m.Provider()
- case batchimagejob.FieldModel:
- return m.Model()
- case batchimagejob.FieldTaskName:
- return m.TaskName()
- case batchimagejob.FieldStatus:
- return m.Status()
- case batchimagejob.FieldProviderJobName:
- return m.ProviderJobName()
- case batchimagejob.FieldProviderInputRef:
- return m.ProviderInputRef()
- case batchimagejob.FieldProviderOutputRef:
- return m.ProviderOutputRef()
- case batchimagejob.FieldGcsInputURI:
- return m.GcsInputURI()
- case batchimagejob.FieldGcsOutputURI:
- return m.GcsOutputURI()
- case batchimagejob.FieldItemCount:
- return m.ItemCount()
- case batchimagejob.FieldSuccessCount:
- return m.SuccessCount()
- case batchimagejob.FieldFailCount:
- return m.FailCount()
- case batchimagejob.FieldCancelledCount:
- return m.CancelledCount()
- case batchimagejob.FieldEstimatedCost:
- return m.EstimatedCost()
- case batchimagejob.FieldHoldAmount:
- return m.HoldAmount()
- case batchimagejob.FieldActualCost:
- return m.ActualCost()
- case batchimagejob.FieldCurrency:
- return m.Currency()
- case batchimagejob.FieldHoldID:
- return m.HoldID()
- case batchimagejob.FieldIdempotencyKey:
- return m.IdempotencyKey()
- case batchimagejob.FieldRequestHash:
- return m.RequestHash()
- case batchimagejob.FieldManifestHash:
- return m.ManifestHash()
- case batchimagejob.FieldRetryCount:
- return m.RetryCount()
- case batchimagejob.FieldVersion:
- return m.Version()
- case batchimagejob.FieldOutputExpiresAt:
- return m.OutputExpiresAt()
- case batchimagejob.FieldInputDeletedAt:
- return m.InputDeletedAt()
- case batchimagejob.FieldOutputDeletedAt:
- return m.OutputDeletedAt()
- case batchimagejob.FieldDownloadedAt:
- return m.DownloadedAt()
- case batchimagejob.FieldUserDeletedAt:
- return m.UserDeletedAt()
- case batchimagejob.FieldLastErrorCode:
- return m.LastErrorCode()
- case batchimagejob.FieldLastErrorMessage:
- return m.LastErrorMessage()
- case batchimagejob.FieldCreatedAt:
- return m.CreatedAt()
- case batchimagejob.FieldUpdatedAt:
- return m.UpdatedAt()
- case batchimagejob.FieldSubmittedAt:
- return m.SubmittedAt()
- case batchimagejob.FieldStartedAt:
- return m.StartedAt()
- case batchimagejob.FieldFinishedAt:
- return m.FinishedAt()
- case batchimagejob.FieldSettledAt:
- return m.SettledAt()
- }
- return nil, false
- }
- // OldField returns the old value of the field from the database. An error is
- // returned if the mutation operation is not UpdateOne, or the query to the
- // database failed.
- func (m *BatchImageJobMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
- switch name {
- case batchimagejob.FieldBatchID:
- return m.OldBatchID(ctx)
- case batchimagejob.FieldUserID:
- return m.OldUserID(ctx)
- case batchimagejob.FieldAPIKeyID:
- return m.OldAPIKeyID(ctx)
- case batchimagejob.FieldAccountID:
- return m.OldAccountID(ctx)
- case batchimagejob.FieldProvider:
- return m.OldProvider(ctx)
- case batchimagejob.FieldModel:
- return m.OldModel(ctx)
- case batchimagejob.FieldTaskName:
- return m.OldTaskName(ctx)
- case batchimagejob.FieldStatus:
- return m.OldStatus(ctx)
- case batchimagejob.FieldProviderJobName:
- return m.OldProviderJobName(ctx)
- case batchimagejob.FieldProviderInputRef:
- return m.OldProviderInputRef(ctx)
- case batchimagejob.FieldProviderOutputRef:
- return m.OldProviderOutputRef(ctx)
- case batchimagejob.FieldGcsInputURI:
- return m.OldGcsInputURI(ctx)
- case batchimagejob.FieldGcsOutputURI:
- return m.OldGcsOutputURI(ctx)
- case batchimagejob.FieldItemCount:
- return m.OldItemCount(ctx)
- case batchimagejob.FieldSuccessCount:
- return m.OldSuccessCount(ctx)
- case batchimagejob.FieldFailCount:
- return m.OldFailCount(ctx)
- case batchimagejob.FieldCancelledCount:
- return m.OldCancelledCount(ctx)
- case batchimagejob.FieldEstimatedCost:
- return m.OldEstimatedCost(ctx)
- case batchimagejob.FieldHoldAmount:
- return m.OldHoldAmount(ctx)
- case batchimagejob.FieldActualCost:
- return m.OldActualCost(ctx)
- case batchimagejob.FieldCurrency:
- return m.OldCurrency(ctx)
- case batchimagejob.FieldHoldID:
- return m.OldHoldID(ctx)
- case batchimagejob.FieldIdempotencyKey:
- return m.OldIdempotencyKey(ctx)
- case batchimagejob.FieldRequestHash:
- return m.OldRequestHash(ctx)
- case batchimagejob.FieldManifestHash:
- return m.OldManifestHash(ctx)
- case batchimagejob.FieldRetryCount:
- return m.OldRetryCount(ctx)
- case batchimagejob.FieldVersion:
- return m.OldVersion(ctx)
- case batchimagejob.FieldOutputExpiresAt:
- return m.OldOutputExpiresAt(ctx)
- case batchimagejob.FieldInputDeletedAt:
- return m.OldInputDeletedAt(ctx)
- case batchimagejob.FieldOutputDeletedAt:
- return m.OldOutputDeletedAt(ctx)
- case batchimagejob.FieldDownloadedAt:
- return m.OldDownloadedAt(ctx)
- case batchimagejob.FieldUserDeletedAt:
- return m.OldUserDeletedAt(ctx)
- case batchimagejob.FieldLastErrorCode:
- return m.OldLastErrorCode(ctx)
- case batchimagejob.FieldLastErrorMessage:
- return m.OldLastErrorMessage(ctx)
- case batchimagejob.FieldCreatedAt:
- return m.OldCreatedAt(ctx)
- case batchimagejob.FieldUpdatedAt:
- return m.OldUpdatedAt(ctx)
- case batchimagejob.FieldSubmittedAt:
- return m.OldSubmittedAt(ctx)
- case batchimagejob.FieldStartedAt:
- return m.OldStartedAt(ctx)
- case batchimagejob.FieldFinishedAt:
- return m.OldFinishedAt(ctx)
- case batchimagejob.FieldSettledAt:
- return m.OldSettledAt(ctx)
- }
- return nil, fmt.Errorf("unknown BatchImageJob field %s", name)
- }
- // SetField sets the value of a field with the given name. It returns an error if
- // the field is not defined in the schema, or if the type mismatched the field
- // type.
- func (m *BatchImageJobMutation) SetField(name string, value ent.Value) error {
- switch name {
- case batchimagejob.FieldBatchID:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetBatchID(v)
- return nil
- case batchimagejob.FieldUserID:
- v, ok := value.(int64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetUserID(v)
- return nil
- case batchimagejob.FieldAPIKeyID:
- v, ok := value.(int64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetAPIKeyID(v)
- return nil
- case batchimagejob.FieldAccountID:
- v, ok := value.(int64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetAccountID(v)
- return nil
- case batchimagejob.FieldProvider:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetProvider(v)
- return nil
- case batchimagejob.FieldModel:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetModel(v)
- return nil
- case batchimagejob.FieldTaskName:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetTaskName(v)
- return nil
- case batchimagejob.FieldStatus:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetStatus(v)
- return nil
- case batchimagejob.FieldProviderJobName:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetProviderJobName(v)
- return nil
- case batchimagejob.FieldProviderInputRef:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetProviderInputRef(v)
- return nil
- case batchimagejob.FieldProviderOutputRef:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetProviderOutputRef(v)
- return nil
- case batchimagejob.FieldGcsInputURI:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetGcsInputURI(v)
- return nil
- case batchimagejob.FieldGcsOutputURI:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetGcsOutputURI(v)
- return nil
- case batchimagejob.FieldItemCount:
- v, ok := value.(int)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetItemCount(v)
- return nil
- case batchimagejob.FieldSuccessCount:
- v, ok := value.(int)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetSuccessCount(v)
- return nil
- case batchimagejob.FieldFailCount:
- v, ok := value.(int)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetFailCount(v)
- return nil
- case batchimagejob.FieldCancelledCount:
- v, ok := value.(int)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetCancelledCount(v)
- return nil
- case batchimagejob.FieldEstimatedCost:
- v, ok := value.(float64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetEstimatedCost(v)
- return nil
- case batchimagejob.FieldHoldAmount:
- v, ok := value.(float64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetHoldAmount(v)
- return nil
- case batchimagejob.FieldActualCost:
- v, ok := value.(float64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetActualCost(v)
- return nil
- case batchimagejob.FieldCurrency:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetCurrency(v)
- return nil
- case batchimagejob.FieldHoldID:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetHoldID(v)
- return nil
- case batchimagejob.FieldIdempotencyKey:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetIdempotencyKey(v)
- return nil
- case batchimagejob.FieldRequestHash:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetRequestHash(v)
- return nil
- case batchimagejob.FieldManifestHash:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetManifestHash(v)
- return nil
- case batchimagejob.FieldRetryCount:
- v, ok := value.(int)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetRetryCount(v)
- return nil
- case batchimagejob.FieldVersion:
- v, ok := value.(int)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetVersion(v)
- return nil
- case batchimagejob.FieldOutputExpiresAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetOutputExpiresAt(v)
- return nil
- case batchimagejob.FieldInputDeletedAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetInputDeletedAt(v)
- return nil
- case batchimagejob.FieldOutputDeletedAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetOutputDeletedAt(v)
- return nil
- case batchimagejob.FieldDownloadedAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetDownloadedAt(v)
- return nil
- case batchimagejob.FieldUserDeletedAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetUserDeletedAt(v)
- return nil
- case batchimagejob.FieldLastErrorCode:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetLastErrorCode(v)
- return nil
- case batchimagejob.FieldLastErrorMessage:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetLastErrorMessage(v)
- return nil
- case batchimagejob.FieldCreatedAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetCreatedAt(v)
- return nil
- case batchimagejob.FieldUpdatedAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetUpdatedAt(v)
- return nil
- case batchimagejob.FieldSubmittedAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetSubmittedAt(v)
- return nil
- case batchimagejob.FieldStartedAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetStartedAt(v)
- return nil
- case batchimagejob.FieldFinishedAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetFinishedAt(v)
- return nil
- case batchimagejob.FieldSettledAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetSettledAt(v)
- return nil
- }
- return fmt.Errorf("unknown BatchImageJob field %s", name)
- }
- // AddedFields returns all numeric fields that were incremented/decremented during
- // this mutation.
- func (m *BatchImageJobMutation) AddedFields() []string {
- var fields []string
- if m.adduser_id != nil {
- fields = append(fields, batchimagejob.FieldUserID)
- }
- if m.addapi_key_id != nil {
- fields = append(fields, batchimagejob.FieldAPIKeyID)
- }
- if m.addaccount_id != nil {
- fields = append(fields, batchimagejob.FieldAccountID)
- }
- if m.additem_count != nil {
- fields = append(fields, batchimagejob.FieldItemCount)
- }
- if m.addsuccess_count != nil {
- fields = append(fields, batchimagejob.FieldSuccessCount)
- }
- if m.addfail_count != nil {
- fields = append(fields, batchimagejob.FieldFailCount)
- }
- if m.addcancelled_count != nil {
- fields = append(fields, batchimagejob.FieldCancelledCount)
- }
- if m.addestimated_cost != nil {
- fields = append(fields, batchimagejob.FieldEstimatedCost)
- }
- if m.addhold_amount != nil {
- fields = append(fields, batchimagejob.FieldHoldAmount)
- }
- if m.addactual_cost != nil {
- fields = append(fields, batchimagejob.FieldActualCost)
- }
- if m.addretry_count != nil {
- fields = append(fields, batchimagejob.FieldRetryCount)
- }
- if m.addversion != nil {
- fields = append(fields, batchimagejob.FieldVersion)
- }
- return fields
- }
- // AddedField returns the numeric value that was incremented/decremented on a field
- // with the given name. The second boolean return value indicates that this field
- // was not set, or was not defined in the schema.
- func (m *BatchImageJobMutation) AddedField(name string) (ent.Value, bool) {
- switch name {
- case batchimagejob.FieldUserID:
- return m.AddedUserID()
- case batchimagejob.FieldAPIKeyID:
- return m.AddedAPIKeyID()
- case batchimagejob.FieldAccountID:
- return m.AddedAccountID()
- case batchimagejob.FieldItemCount:
- return m.AddedItemCount()
- case batchimagejob.FieldSuccessCount:
- return m.AddedSuccessCount()
- case batchimagejob.FieldFailCount:
- return m.AddedFailCount()
- case batchimagejob.FieldCancelledCount:
- return m.AddedCancelledCount()
- case batchimagejob.FieldEstimatedCost:
- return m.AddedEstimatedCost()
- case batchimagejob.FieldHoldAmount:
- return m.AddedHoldAmount()
- case batchimagejob.FieldActualCost:
- return m.AddedActualCost()
- case batchimagejob.FieldRetryCount:
- return m.AddedRetryCount()
- case batchimagejob.FieldVersion:
- return m.AddedVersion()
- }
- return nil, false
- }
- // AddField adds the value to the field with the given name. It returns an error if
- // the field is not defined in the schema, or if the type mismatched the field
- // type.
- func (m *BatchImageJobMutation) AddField(name string, value ent.Value) error {
- switch name {
- case batchimagejob.FieldUserID:
- v, ok := value.(int64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.AddUserID(v)
- return nil
- case batchimagejob.FieldAPIKeyID:
- v, ok := value.(int64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.AddAPIKeyID(v)
- return nil
- case batchimagejob.FieldAccountID:
- v, ok := value.(int64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.AddAccountID(v)
- return nil
- case batchimagejob.FieldItemCount:
- v, ok := value.(int)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.AddItemCount(v)
- return nil
- case batchimagejob.FieldSuccessCount:
- v, ok := value.(int)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.AddSuccessCount(v)
- return nil
- case batchimagejob.FieldFailCount:
- v, ok := value.(int)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.AddFailCount(v)
- return nil
- case batchimagejob.FieldCancelledCount:
- v, ok := value.(int)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.AddCancelledCount(v)
- return nil
- case batchimagejob.FieldEstimatedCost:
- v, ok := value.(float64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.AddEstimatedCost(v)
- return nil
- case batchimagejob.FieldHoldAmount:
- v, ok := value.(float64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.AddHoldAmount(v)
- return nil
- case batchimagejob.FieldActualCost:
- v, ok := value.(float64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.AddActualCost(v)
- return nil
- case batchimagejob.FieldRetryCount:
- v, ok := value.(int)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.AddRetryCount(v)
- return nil
- case batchimagejob.FieldVersion:
- v, ok := value.(int)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.AddVersion(v)
- return nil
- }
- return fmt.Errorf("unknown BatchImageJob numeric field %s", name)
- }
- // ClearedFields returns all nullable fields that were cleared during this
- // mutation.
- func (m *BatchImageJobMutation) ClearedFields() []string {
- var fields []string
- if m.FieldCleared(batchimagejob.FieldAPIKeyID) {
- fields = append(fields, batchimagejob.FieldAPIKeyID)
- }
- if m.FieldCleared(batchimagejob.FieldAccountID) {
- fields = append(fields, batchimagejob.FieldAccountID)
- }
- if m.FieldCleared(batchimagejob.FieldProviderJobName) {
- fields = append(fields, batchimagejob.FieldProviderJobName)
- }
- if m.FieldCleared(batchimagejob.FieldProviderInputRef) {
- fields = append(fields, batchimagejob.FieldProviderInputRef)
- }
- if m.FieldCleared(batchimagejob.FieldProviderOutputRef) {
- fields = append(fields, batchimagejob.FieldProviderOutputRef)
- }
- if m.FieldCleared(batchimagejob.FieldGcsInputURI) {
- fields = append(fields, batchimagejob.FieldGcsInputURI)
- }
- if m.FieldCleared(batchimagejob.FieldGcsOutputURI) {
- fields = append(fields, batchimagejob.FieldGcsOutputURI)
- }
- if m.FieldCleared(batchimagejob.FieldHoldAmount) {
- fields = append(fields, batchimagejob.FieldHoldAmount)
- }
- if m.FieldCleared(batchimagejob.FieldActualCost) {
- fields = append(fields, batchimagejob.FieldActualCost)
- }
- if m.FieldCleared(batchimagejob.FieldHoldID) {
- fields = append(fields, batchimagejob.FieldHoldID)
- }
- if m.FieldCleared(batchimagejob.FieldIdempotencyKey) {
- fields = append(fields, batchimagejob.FieldIdempotencyKey)
- }
- if m.FieldCleared(batchimagejob.FieldRequestHash) {
- fields = append(fields, batchimagejob.FieldRequestHash)
- }
- if m.FieldCleared(batchimagejob.FieldManifestHash) {
- fields = append(fields, batchimagejob.FieldManifestHash)
- }
- if m.FieldCleared(batchimagejob.FieldOutputExpiresAt) {
- fields = append(fields, batchimagejob.FieldOutputExpiresAt)
- }
- if m.FieldCleared(batchimagejob.FieldInputDeletedAt) {
- fields = append(fields, batchimagejob.FieldInputDeletedAt)
- }
- if m.FieldCleared(batchimagejob.FieldOutputDeletedAt) {
- fields = append(fields, batchimagejob.FieldOutputDeletedAt)
- }
- if m.FieldCleared(batchimagejob.FieldDownloadedAt) {
- fields = append(fields, batchimagejob.FieldDownloadedAt)
- }
- if m.FieldCleared(batchimagejob.FieldUserDeletedAt) {
- fields = append(fields, batchimagejob.FieldUserDeletedAt)
- }
- if m.FieldCleared(batchimagejob.FieldLastErrorCode) {
- fields = append(fields, batchimagejob.FieldLastErrorCode)
- }
- if m.FieldCleared(batchimagejob.FieldLastErrorMessage) {
- fields = append(fields, batchimagejob.FieldLastErrorMessage)
- }
- if m.FieldCleared(batchimagejob.FieldSubmittedAt) {
- fields = append(fields, batchimagejob.FieldSubmittedAt)
- }
- if m.FieldCleared(batchimagejob.FieldStartedAt) {
- fields = append(fields, batchimagejob.FieldStartedAt)
- }
- if m.FieldCleared(batchimagejob.FieldFinishedAt) {
- fields = append(fields, batchimagejob.FieldFinishedAt)
- }
- if m.FieldCleared(batchimagejob.FieldSettledAt) {
- fields = append(fields, batchimagejob.FieldSettledAt)
- }
- return fields
- }
- // FieldCleared returns a boolean indicating if a field with the given name was
- // cleared in this mutation.
- func (m *BatchImageJobMutation) FieldCleared(name string) bool {
- _, ok := m.clearedFields[name]
- return ok
- }
- // ClearField clears the value of the field with the given name. It returns an
- // error if the field is not defined in the schema.
- func (m *BatchImageJobMutation) ClearField(name string) error {
- switch name {
- case batchimagejob.FieldAPIKeyID:
- m.ClearAPIKeyID()
- return nil
- case batchimagejob.FieldAccountID:
- m.ClearAccountID()
- return nil
- case batchimagejob.FieldProviderJobName:
- m.ClearProviderJobName()
- return nil
- case batchimagejob.FieldProviderInputRef:
- m.ClearProviderInputRef()
- return nil
- case batchimagejob.FieldProviderOutputRef:
- m.ClearProviderOutputRef()
- return nil
- case batchimagejob.FieldGcsInputURI:
- m.ClearGcsInputURI()
- return nil
- case batchimagejob.FieldGcsOutputURI:
- m.ClearGcsOutputURI()
- return nil
- case batchimagejob.FieldHoldAmount:
- m.ClearHoldAmount()
- return nil
- case batchimagejob.FieldActualCost:
- m.ClearActualCost()
- return nil
- case batchimagejob.FieldHoldID:
- m.ClearHoldID()
- return nil
- case batchimagejob.FieldIdempotencyKey:
- m.ClearIdempotencyKey()
- return nil
- case batchimagejob.FieldRequestHash:
- m.ClearRequestHash()
- return nil
- case batchimagejob.FieldManifestHash:
- m.ClearManifestHash()
- return nil
- case batchimagejob.FieldOutputExpiresAt:
- m.ClearOutputExpiresAt()
- return nil
- case batchimagejob.FieldInputDeletedAt:
- m.ClearInputDeletedAt()
- return nil
- case batchimagejob.FieldOutputDeletedAt:
- m.ClearOutputDeletedAt()
- return nil
- case batchimagejob.FieldDownloadedAt:
- m.ClearDownloadedAt()
- return nil
- case batchimagejob.FieldUserDeletedAt:
- m.ClearUserDeletedAt()
- return nil
- case batchimagejob.FieldLastErrorCode:
- m.ClearLastErrorCode()
- return nil
- case batchimagejob.FieldLastErrorMessage:
- m.ClearLastErrorMessage()
- return nil
- case batchimagejob.FieldSubmittedAt:
- m.ClearSubmittedAt()
- return nil
- case batchimagejob.FieldStartedAt:
- m.ClearStartedAt()
- return nil
- case batchimagejob.FieldFinishedAt:
- m.ClearFinishedAt()
- return nil
- case batchimagejob.FieldSettledAt:
- m.ClearSettledAt()
- return nil
- }
- return fmt.Errorf("unknown BatchImageJob nullable field %s", name)
- }
- // ResetField resets all changes in the mutation for the field with the given name.
- // It returns an error if the field is not defined in the schema.
- func (m *BatchImageJobMutation) ResetField(name string) error {
- switch name {
- case batchimagejob.FieldBatchID:
- m.ResetBatchID()
- return nil
- case batchimagejob.FieldUserID:
- m.ResetUserID()
- return nil
- case batchimagejob.FieldAPIKeyID:
- m.ResetAPIKeyID()
- return nil
- case batchimagejob.FieldAccountID:
- m.ResetAccountID()
- return nil
- case batchimagejob.FieldProvider:
- m.ResetProvider()
- return nil
- case batchimagejob.FieldModel:
- m.ResetModel()
- return nil
- case batchimagejob.FieldTaskName:
- m.ResetTaskName()
- return nil
- case batchimagejob.FieldStatus:
- m.ResetStatus()
- return nil
- case batchimagejob.FieldProviderJobName:
- m.ResetProviderJobName()
- return nil
- case batchimagejob.FieldProviderInputRef:
- m.ResetProviderInputRef()
- return nil
- case batchimagejob.FieldProviderOutputRef:
- m.ResetProviderOutputRef()
- return nil
- case batchimagejob.FieldGcsInputURI:
- m.ResetGcsInputURI()
- return nil
- case batchimagejob.FieldGcsOutputURI:
- m.ResetGcsOutputURI()
- return nil
- case batchimagejob.FieldItemCount:
- m.ResetItemCount()
- return nil
- case batchimagejob.FieldSuccessCount:
- m.ResetSuccessCount()
- return nil
- case batchimagejob.FieldFailCount:
- m.ResetFailCount()
- return nil
- case batchimagejob.FieldCancelledCount:
- m.ResetCancelledCount()
- return nil
- case batchimagejob.FieldEstimatedCost:
- m.ResetEstimatedCost()
- return nil
- case batchimagejob.FieldHoldAmount:
- m.ResetHoldAmount()
- return nil
- case batchimagejob.FieldActualCost:
- m.ResetActualCost()
- return nil
- case batchimagejob.FieldCurrency:
- m.ResetCurrency()
- return nil
- case batchimagejob.FieldHoldID:
- m.ResetHoldID()
- return nil
- case batchimagejob.FieldIdempotencyKey:
- m.ResetIdempotencyKey()
- return nil
- case batchimagejob.FieldRequestHash:
- m.ResetRequestHash()
- return nil
- case batchimagejob.FieldManifestHash:
- m.ResetManifestHash()
- return nil
- case batchimagejob.FieldRetryCount:
- m.ResetRetryCount()
- return nil
- case batchimagejob.FieldVersion:
- m.ResetVersion()
- return nil
- case batchimagejob.FieldOutputExpiresAt:
- m.ResetOutputExpiresAt()
- return nil
- case batchimagejob.FieldInputDeletedAt:
- m.ResetInputDeletedAt()
- return nil
- case batchimagejob.FieldOutputDeletedAt:
- m.ResetOutputDeletedAt()
- return nil
- case batchimagejob.FieldDownloadedAt:
- m.ResetDownloadedAt()
- return nil
- case batchimagejob.FieldUserDeletedAt:
- m.ResetUserDeletedAt()
- return nil
- case batchimagejob.FieldLastErrorCode:
- m.ResetLastErrorCode()
- return nil
- case batchimagejob.FieldLastErrorMessage:
- m.ResetLastErrorMessage()
- return nil
- case batchimagejob.FieldCreatedAt:
- m.ResetCreatedAt()
- return nil
- case batchimagejob.FieldUpdatedAt:
- m.ResetUpdatedAt()
- return nil
- case batchimagejob.FieldSubmittedAt:
- m.ResetSubmittedAt()
- return nil
- case batchimagejob.FieldStartedAt:
- m.ResetStartedAt()
- return nil
- case batchimagejob.FieldFinishedAt:
- m.ResetFinishedAt()
- return nil
- case batchimagejob.FieldSettledAt:
- m.ResetSettledAt()
- return nil
- }
- return fmt.Errorf("unknown BatchImageJob field %s", name)
- }
- // AddedEdges returns all edge names that were set/added in this mutation.
- func (m *BatchImageJobMutation) AddedEdges() []string {
- edges := make([]string, 0, 0)
- return edges
- }
- // AddedIDs returns all IDs (to other nodes) that were added for the given edge
- // name in this mutation.
- func (m *BatchImageJobMutation) AddedIDs(name string) []ent.Value {
- return nil
- }
- // RemovedEdges returns all edge names that were removed in this mutation.
- func (m *BatchImageJobMutation) RemovedEdges() []string {
- edges := make([]string, 0, 0)
- return edges
- }
- // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
- // the given name in this mutation.
- func (m *BatchImageJobMutation) RemovedIDs(name string) []ent.Value {
- return nil
- }
- // ClearedEdges returns all edge names that were cleared in this mutation.
- func (m *BatchImageJobMutation) ClearedEdges() []string {
- edges := make([]string, 0, 0)
- return edges
- }
- // EdgeCleared returns a boolean which indicates if the edge with the given name
- // was cleared in this mutation.
- func (m *BatchImageJobMutation) EdgeCleared(name string) bool {
- return false
- }
- // ClearEdge clears the value of the edge with the given name. It returns an error
- // if that edge is not defined in the schema.
- func (m *BatchImageJobMutation) ClearEdge(name string) error {
- return fmt.Errorf("unknown BatchImageJob unique edge %s", name)
- }
- // ResetEdge resets all changes to the edge with the given name in this mutation.
- // It returns an error if the edge is not defined in the schema.
- func (m *BatchImageJobMutation) ResetEdge(name string) error {
- return fmt.Errorf("unknown BatchImageJob edge %s", name)
- }
- // ChannelMonitorMutation represents an operation that mutates the ChannelMonitor nodes in the graph.
- type ChannelMonitorMutation struct {
- config
- op Op
- typ string
- id *int64
- created_at *time.Time
- updated_at *time.Time
- name *string
- provider *channelmonitor.Provider
- check_mode *string
- account_id *int64
- addaccount_id *int64
- api_mode *string
- endpoint *string
- api_key_encrypted *string
- primary_model *string
- extra_models *[]string
- appendextra_models []string
- group_name *string
- enabled *bool
- interval_seconds *int
- addinterval_seconds *int
- jitter_seconds *int
- addjitter_seconds *int
- last_checked_at *time.Time
- created_by *int64
- addcreated_by *int64
- extra_headers *map[string]string
- body_override_mode *string
- body_override *map[string]interface{}
- clearedFields map[string]struct{}
- history map[int64]struct{}
- removedhistory map[int64]struct{}
- clearedhistory bool
- daily_rollups map[int64]struct{}
- removeddaily_rollups map[int64]struct{}
- cleareddaily_rollups bool
- request_template *int64
- clearedrequest_template bool
- done bool
- oldValue func(context.Context) (*ChannelMonitor, error)
- predicates []predicate.ChannelMonitor
- }
- var _ ent.Mutation = (*ChannelMonitorMutation)(nil)
- // channelmonitorOption allows management of the mutation configuration using functional options.
- type channelmonitorOption func(*ChannelMonitorMutation)
- // newChannelMonitorMutation creates new mutation for the ChannelMonitor entity.
- func newChannelMonitorMutation(c config, op Op, opts ...channelmonitorOption) *ChannelMonitorMutation {
- m := &ChannelMonitorMutation{
- config: c,
- op: op,
- typ: TypeChannelMonitor,
- clearedFields: make(map[string]struct{}),
- }
- for _, opt := range opts {
- opt(m)
- }
- return m
- }
- // withChannelMonitorID sets the ID field of the mutation.
- func withChannelMonitorID(id int64) channelmonitorOption {
- return func(m *ChannelMonitorMutation) {
- var (
- err error
- once sync.Once
- value *ChannelMonitor
- )
- m.oldValue = func(ctx context.Context) (*ChannelMonitor, error) {
- once.Do(func() {
- if m.done {
- err = errors.New("querying old values post mutation is not allowed")
- } else {
- value, err = m.Client().ChannelMonitor.Get(ctx, id)
- }
- })
- return value, err
- }
- m.id = &id
- }
- }
- // withChannelMonitor sets the old ChannelMonitor of the mutation.
- func withChannelMonitor(node *ChannelMonitor) channelmonitorOption {
- return func(m *ChannelMonitorMutation) {
- m.oldValue = func(context.Context) (*ChannelMonitor, error) {
- return node, nil
- }
- m.id = &node.ID
- }
- }
- // Client returns a new `ent.Client` from the mutation. If the mutation was
- // executed in a transaction (ent.Tx), a transactional client is returned.
- func (m ChannelMonitorMutation) Client() *Client {
- client := &Client{config: m.config}
- client.init()
- return client
- }
- // Tx returns an `ent.Tx` for mutations that were executed in transactions;
- // it returns an error otherwise.
- func (m ChannelMonitorMutation) Tx() (*Tx, error) {
- if _, ok := m.driver.(*txDriver); !ok {
- return nil, errors.New("ent: mutation is not running in a transaction")
- }
- tx := &Tx{config: m.config}
- tx.init()
- return tx, nil
- }
- // ID returns the ID value in the mutation. Note that the ID is only available
- // if it was provided to the builder or after it was returned from the database.
- func (m *ChannelMonitorMutation) ID() (id int64, exists bool) {
- if m.id == nil {
- return
- }
- return *m.id, true
- }
- // IDs queries the database and returns the entity ids that match the mutation's predicate.
- // That means, if the mutation is applied within a transaction with an isolation level such
- // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
- // or updated by the mutation.
- func (m *ChannelMonitorMutation) IDs(ctx context.Context) ([]int64, error) {
- switch {
- case m.op.Is(OpUpdateOne | OpDeleteOne):
- id, exists := m.ID()
- if exists {
- return []int64{id}, nil
- }
- fallthrough
- case m.op.Is(OpUpdate | OpDelete):
- return m.Client().ChannelMonitor.Query().Where(m.predicates...).IDs(ctx)
- default:
- return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
- }
- }
- // SetCreatedAt sets the "created_at" field.
- func (m *ChannelMonitorMutation) SetCreatedAt(t time.Time) {
- m.created_at = &t
- }
- // CreatedAt returns the value of the "created_at" field in the mutation.
- func (m *ChannelMonitorMutation) CreatedAt() (r time.Time, exists bool) {
- v := m.created_at
- if v == nil {
- return
- }
- return *v, true
- }
- // OldCreatedAt returns the old "created_at" field's value of the ChannelMonitor entity.
- // If the ChannelMonitor object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *ChannelMonitorMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldCreatedAt requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
- }
- return oldValue.CreatedAt, nil
- }
- // ResetCreatedAt resets all changes to the "created_at" field.
- func (m *ChannelMonitorMutation) ResetCreatedAt() {
- m.created_at = nil
- }
- // SetUpdatedAt sets the "updated_at" field.
- func (m *ChannelMonitorMutation) SetUpdatedAt(t time.Time) {
- m.updated_at = &t
- }
- // UpdatedAt returns the value of the "updated_at" field in the mutation.
- func (m *ChannelMonitorMutation) UpdatedAt() (r time.Time, exists bool) {
- v := m.updated_at
- if v == nil {
- return
- }
- return *v, true
- }
- // OldUpdatedAt returns the old "updated_at" field's value of the ChannelMonitor entity.
- // If the ChannelMonitor object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *ChannelMonitorMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
- }
- return oldValue.UpdatedAt, nil
- }
- // ResetUpdatedAt resets all changes to the "updated_at" field.
- func (m *ChannelMonitorMutation) ResetUpdatedAt() {
- m.updated_at = nil
- }
- // SetName sets the "name" field.
- func (m *ChannelMonitorMutation) SetName(s string) {
- m.name = &s
- }
- // Name returns the value of the "name" field in the mutation.
- func (m *ChannelMonitorMutation) Name() (r string, exists bool) {
- v := m.name
- if v == nil {
- return
- }
- return *v, true
- }
- // OldName returns the old "name" field's value of the ChannelMonitor entity.
- // If the ChannelMonitor object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *ChannelMonitorMutation) OldName(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldName is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldName requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldName: %w", err)
- }
- return oldValue.Name, nil
- }
- // ResetName resets all changes to the "name" field.
- func (m *ChannelMonitorMutation) ResetName() {
- m.name = nil
- }
- // SetProvider sets the "provider" field.
- func (m *ChannelMonitorMutation) SetProvider(c channelmonitor.Provider) {
- m.provider = &c
- }
- // Provider returns the value of the "provider" field in the mutation.
- func (m *ChannelMonitorMutation) Provider() (r channelmonitor.Provider, exists bool) {
- v := m.provider
- if v == nil {
- return
- }
- return *v, true
- }
- // OldProvider returns the old "provider" field's value of the ChannelMonitor entity.
- // If the ChannelMonitor object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *ChannelMonitorMutation) OldProvider(ctx context.Context) (v channelmonitor.Provider, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldProvider is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldProvider requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldProvider: %w", err)
- }
- return oldValue.Provider, nil
- }
- // ResetProvider resets all changes to the "provider" field.
- func (m *ChannelMonitorMutation) ResetProvider() {
- m.provider = nil
- }
- // SetCheckMode sets the "check_mode" field.
- func (m *ChannelMonitorMutation) SetCheckMode(s string) {
- m.check_mode = &s
- }
- // CheckMode returns the value of the "check_mode" field in the mutation.
- func (m *ChannelMonitorMutation) CheckMode() (r string, exists bool) {
- v := m.check_mode
- if v == nil {
- return
- }
- return *v, true
- }
- // OldCheckMode returns the old "check_mode" field's value of the ChannelMonitor entity.
- // If the ChannelMonitor object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *ChannelMonitorMutation) OldCheckMode(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldCheckMode is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldCheckMode requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldCheckMode: %w", err)
- }
- return oldValue.CheckMode, nil
- }
- // ResetCheckMode resets all changes to the "check_mode" field.
- func (m *ChannelMonitorMutation) ResetCheckMode() {
- m.check_mode = nil
- }
- // SetAccountID sets the "account_id" field.
- func (m *ChannelMonitorMutation) SetAccountID(i int64) {
- m.account_id = &i
- m.addaccount_id = nil
- }
- // AccountID returns the value of the "account_id" field in the mutation.
- func (m *ChannelMonitorMutation) AccountID() (r int64, exists bool) {
- v := m.account_id
- if v == nil {
- return
- }
- return *v, true
- }
- // OldAccountID returns the old "account_id" field's value of the ChannelMonitor entity.
- // If the ChannelMonitor object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *ChannelMonitorMutation) OldAccountID(ctx context.Context) (v *int64, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldAccountID is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldAccountID requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldAccountID: %w", err)
- }
- return oldValue.AccountID, nil
- }
- // AddAccountID adds i to the "account_id" field.
- func (m *ChannelMonitorMutation) AddAccountID(i int64) {
- if m.addaccount_id != nil {
- *m.addaccount_id += i
- } else {
- m.addaccount_id = &i
- }
- }
- // AddedAccountID returns the value that was added to the "account_id" field in this mutation.
- func (m *ChannelMonitorMutation) AddedAccountID() (r int64, exists bool) {
- v := m.addaccount_id
- if v == nil {
- return
- }
- return *v, true
- }
- // ClearAccountID clears the value of the "account_id" field.
- func (m *ChannelMonitorMutation) ClearAccountID() {
- m.account_id = nil
- m.addaccount_id = nil
- m.clearedFields[channelmonitor.FieldAccountID] = struct{}{}
- }
- // AccountIDCleared returns if the "account_id" field was cleared in this mutation.
- func (m *ChannelMonitorMutation) AccountIDCleared() bool {
- _, ok := m.clearedFields[channelmonitor.FieldAccountID]
- return ok
- }
- // ResetAccountID resets all changes to the "account_id" field.
- func (m *ChannelMonitorMutation) ResetAccountID() {
- m.account_id = nil
- m.addaccount_id = nil
- delete(m.clearedFields, channelmonitor.FieldAccountID)
- }
- // SetAPIMode sets the "api_mode" field.
- func (m *ChannelMonitorMutation) SetAPIMode(s string) {
- m.api_mode = &s
- }
- // APIMode returns the value of the "api_mode" field in the mutation.
- func (m *ChannelMonitorMutation) APIMode() (r string, exists bool) {
- v := m.api_mode
- if v == nil {
- return
- }
- return *v, true
- }
- // OldAPIMode returns the old "api_mode" field's value of the ChannelMonitor entity.
- // If the ChannelMonitor object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *ChannelMonitorMutation) OldAPIMode(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldAPIMode is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldAPIMode requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldAPIMode: %w", err)
- }
- return oldValue.APIMode, nil
- }
- // ResetAPIMode resets all changes to the "api_mode" field.
- func (m *ChannelMonitorMutation) ResetAPIMode() {
- m.api_mode = nil
- }
- // SetEndpoint sets the "endpoint" field.
- func (m *ChannelMonitorMutation) SetEndpoint(s string) {
- m.endpoint = &s
- }
- // Endpoint returns the value of the "endpoint" field in the mutation.
- func (m *ChannelMonitorMutation) Endpoint() (r string, exists bool) {
- v := m.endpoint
- if v == nil {
- return
- }
- return *v, true
- }
- // OldEndpoint returns the old "endpoint" field's value of the ChannelMonitor entity.
- // If the ChannelMonitor object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *ChannelMonitorMutation) OldEndpoint(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldEndpoint is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldEndpoint requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldEndpoint: %w", err)
- }
- return oldValue.Endpoint, nil
- }
- // ResetEndpoint resets all changes to the "endpoint" field.
- func (m *ChannelMonitorMutation) ResetEndpoint() {
- m.endpoint = nil
- }
- // SetAPIKeyEncrypted sets the "api_key_encrypted" field.
- func (m *ChannelMonitorMutation) SetAPIKeyEncrypted(s string) {
- m.api_key_encrypted = &s
- }
- // APIKeyEncrypted returns the value of the "api_key_encrypted" field in the mutation.
- func (m *ChannelMonitorMutation) APIKeyEncrypted() (r string, exists bool) {
- v := m.api_key_encrypted
- if v == nil {
- return
- }
- return *v, true
- }
- // OldAPIKeyEncrypted returns the old "api_key_encrypted" field's value of the ChannelMonitor entity.
- // If the ChannelMonitor object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *ChannelMonitorMutation) OldAPIKeyEncrypted(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldAPIKeyEncrypted is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldAPIKeyEncrypted requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldAPIKeyEncrypted: %w", err)
- }
- return oldValue.APIKeyEncrypted, nil
- }
- // ResetAPIKeyEncrypted resets all changes to the "api_key_encrypted" field.
- func (m *ChannelMonitorMutation) ResetAPIKeyEncrypted() {
- m.api_key_encrypted = nil
- }
- // SetPrimaryModel sets the "primary_model" field.
- func (m *ChannelMonitorMutation) SetPrimaryModel(s string) {
- m.primary_model = &s
- }
- // PrimaryModel returns the value of the "primary_model" field in the mutation.
- func (m *ChannelMonitorMutation) PrimaryModel() (r string, exists bool) {
- v := m.primary_model
- if v == nil {
- return
- }
- return *v, true
- }
- // OldPrimaryModel returns the old "primary_model" field's value of the ChannelMonitor entity.
- // If the ChannelMonitor object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *ChannelMonitorMutation) OldPrimaryModel(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldPrimaryModel is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldPrimaryModel requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldPrimaryModel: %w", err)
- }
- return oldValue.PrimaryModel, nil
- }
- // ResetPrimaryModel resets all changes to the "primary_model" field.
- func (m *ChannelMonitorMutation) ResetPrimaryModel() {
- m.primary_model = nil
- }
- // SetExtraModels sets the "extra_models" field.
- func (m *ChannelMonitorMutation) SetExtraModels(s []string) {
- m.extra_models = &s
- m.appendextra_models = nil
- }
- // ExtraModels returns the value of the "extra_models" field in the mutation.
- func (m *ChannelMonitorMutation) ExtraModels() (r []string, exists bool) {
- v := m.extra_models
- if v == nil {
- return
- }
- return *v, true
- }
- // OldExtraModels returns the old "extra_models" field's value of the ChannelMonitor entity.
- // If the ChannelMonitor object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *ChannelMonitorMutation) OldExtraModels(ctx context.Context) (v []string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldExtraModels is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldExtraModels requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldExtraModels: %w", err)
- }
- return oldValue.ExtraModels, nil
- }
- // AppendExtraModels adds s to the "extra_models" field.
- func (m *ChannelMonitorMutation) AppendExtraModels(s []string) {
- m.appendextra_models = append(m.appendextra_models, s...)
- }
- // AppendedExtraModels returns the list of values that were appended to the "extra_models" field in this mutation.
- func (m *ChannelMonitorMutation) AppendedExtraModels() ([]string, bool) {
- if len(m.appendextra_models) == 0 {
- return nil, false
- }
- return m.appendextra_models, true
- }
- // ResetExtraModels resets all changes to the "extra_models" field.
- func (m *ChannelMonitorMutation) ResetExtraModels() {
- m.extra_models = nil
- m.appendextra_models = nil
- }
- // SetGroupName sets the "group_name" field.
- func (m *ChannelMonitorMutation) SetGroupName(s string) {
- m.group_name = &s
- }
- // GroupName returns the value of the "group_name" field in the mutation.
- func (m *ChannelMonitorMutation) GroupName() (r string, exists bool) {
- v := m.group_name
- if v == nil {
- return
- }
- return *v, true
- }
- // OldGroupName returns the old "group_name" field's value of the ChannelMonitor entity.
- // If the ChannelMonitor object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *ChannelMonitorMutation) OldGroupName(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldGroupName is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldGroupName requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldGroupName: %w", err)
- }
- return oldValue.GroupName, nil
- }
- // ClearGroupName clears the value of the "group_name" field.
- func (m *ChannelMonitorMutation) ClearGroupName() {
- m.group_name = nil
- m.clearedFields[channelmonitor.FieldGroupName] = struct{}{}
- }
- // GroupNameCleared returns if the "group_name" field was cleared in this mutation.
- func (m *ChannelMonitorMutation) GroupNameCleared() bool {
- _, ok := m.clearedFields[channelmonitor.FieldGroupName]
- return ok
- }
- // ResetGroupName resets all changes to the "group_name" field.
- func (m *ChannelMonitorMutation) ResetGroupName() {
- m.group_name = nil
- delete(m.clearedFields, channelmonitor.FieldGroupName)
- }
- // SetEnabled sets the "enabled" field.
- func (m *ChannelMonitorMutation) SetEnabled(b bool) {
- m.enabled = &b
- }
- // Enabled returns the value of the "enabled" field in the mutation.
- func (m *ChannelMonitorMutation) Enabled() (r bool, exists bool) {
- v := m.enabled
- if v == nil {
- return
- }
- return *v, true
- }
- // OldEnabled returns the old "enabled" field's value of the ChannelMonitor entity.
- // If the ChannelMonitor object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *ChannelMonitorMutation) OldEnabled(ctx context.Context) (v bool, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldEnabled is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldEnabled requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldEnabled: %w", err)
- }
- return oldValue.Enabled, nil
- }
- // ResetEnabled resets all changes to the "enabled" field.
- func (m *ChannelMonitorMutation) ResetEnabled() {
- m.enabled = nil
- }
- // SetIntervalSeconds sets the "interval_seconds" field.
- func (m *ChannelMonitorMutation) SetIntervalSeconds(i int) {
- m.interval_seconds = &i
- m.addinterval_seconds = nil
- }
- // IntervalSeconds returns the value of the "interval_seconds" field in the mutation.
- func (m *ChannelMonitorMutation) IntervalSeconds() (r int, exists bool) {
- v := m.interval_seconds
- if v == nil {
- return
- }
- return *v, true
- }
- // OldIntervalSeconds returns the old "interval_seconds" field's value of the ChannelMonitor entity.
- // If the ChannelMonitor object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *ChannelMonitorMutation) OldIntervalSeconds(ctx context.Context) (v int, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldIntervalSeconds is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldIntervalSeconds requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldIntervalSeconds: %w", err)
- }
- return oldValue.IntervalSeconds, nil
- }
- // AddIntervalSeconds adds i to the "interval_seconds" field.
- func (m *ChannelMonitorMutation) AddIntervalSeconds(i int) {
- if m.addinterval_seconds != nil {
- *m.addinterval_seconds += i
- } else {
- m.addinterval_seconds = &i
- }
- }
- // AddedIntervalSeconds returns the value that was added to the "interval_seconds" field in this mutation.
- func (m *ChannelMonitorMutation) AddedIntervalSeconds() (r int, exists bool) {
- v := m.addinterval_seconds
- if v == nil {
- return
- }
- return *v, true
- }
- // ResetIntervalSeconds resets all changes to the "interval_seconds" field.
- func (m *ChannelMonitorMutation) ResetIntervalSeconds() {
- m.interval_seconds = nil
- m.addinterval_seconds = nil
- }
- // SetJitterSeconds sets the "jitter_seconds" field.
- func (m *ChannelMonitorMutation) SetJitterSeconds(i int) {
- m.jitter_seconds = &i
- m.addjitter_seconds = nil
- }
- // JitterSeconds returns the value of the "jitter_seconds" field in the mutation.
- func (m *ChannelMonitorMutation) JitterSeconds() (r int, exists bool) {
- v := m.jitter_seconds
- if v == nil {
- return
- }
- return *v, true
- }
- // OldJitterSeconds returns the old "jitter_seconds" field's value of the ChannelMonitor entity.
- // If the ChannelMonitor object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *ChannelMonitorMutation) OldJitterSeconds(ctx context.Context) (v int, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldJitterSeconds is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldJitterSeconds requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldJitterSeconds: %w", err)
- }
- return oldValue.JitterSeconds, nil
- }
- // AddJitterSeconds adds i to the "jitter_seconds" field.
- func (m *ChannelMonitorMutation) AddJitterSeconds(i int) {
- if m.addjitter_seconds != nil {
- *m.addjitter_seconds += i
- } else {
- m.addjitter_seconds = &i
- }
- }
- // AddedJitterSeconds returns the value that was added to the "jitter_seconds" field in this mutation.
- func (m *ChannelMonitorMutation) AddedJitterSeconds() (r int, exists bool) {
- v := m.addjitter_seconds
- if v == nil {
- return
- }
- return *v, true
- }
- // ResetJitterSeconds resets all changes to the "jitter_seconds" field.
- func (m *ChannelMonitorMutation) ResetJitterSeconds() {
- m.jitter_seconds = nil
- m.addjitter_seconds = nil
- }
- // SetLastCheckedAt sets the "last_checked_at" field.
- func (m *ChannelMonitorMutation) SetLastCheckedAt(t time.Time) {
- m.last_checked_at = &t
- }
- // LastCheckedAt returns the value of the "last_checked_at" field in the mutation.
- func (m *ChannelMonitorMutation) LastCheckedAt() (r time.Time, exists bool) {
- v := m.last_checked_at
- if v == nil {
- return
- }
- return *v, true
- }
- // OldLastCheckedAt returns the old "last_checked_at" field's value of the ChannelMonitor entity.
- // If the ChannelMonitor object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *ChannelMonitorMutation) OldLastCheckedAt(ctx context.Context) (v *time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldLastCheckedAt is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldLastCheckedAt requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldLastCheckedAt: %w", err)
- }
- return oldValue.LastCheckedAt, nil
- }
- // ClearLastCheckedAt clears the value of the "last_checked_at" field.
- func (m *ChannelMonitorMutation) ClearLastCheckedAt() {
- m.last_checked_at = nil
- m.clearedFields[channelmonitor.FieldLastCheckedAt] = struct{}{}
- }
- // LastCheckedAtCleared returns if the "last_checked_at" field was cleared in this mutation.
- func (m *ChannelMonitorMutation) LastCheckedAtCleared() bool {
- _, ok := m.clearedFields[channelmonitor.FieldLastCheckedAt]
- return ok
- }
- // ResetLastCheckedAt resets all changes to the "last_checked_at" field.
- func (m *ChannelMonitorMutation) ResetLastCheckedAt() {
- m.last_checked_at = nil
- delete(m.clearedFields, channelmonitor.FieldLastCheckedAt)
- }
- // SetCreatedBy sets the "created_by" field.
- func (m *ChannelMonitorMutation) SetCreatedBy(i int64) {
- m.created_by = &i
- m.addcreated_by = nil
- }
- // CreatedBy returns the value of the "created_by" field in the mutation.
- func (m *ChannelMonitorMutation) CreatedBy() (r int64, exists bool) {
- v := m.created_by
- if v == nil {
- return
- }
- return *v, true
- }
- // OldCreatedBy returns the old "created_by" field's value of the ChannelMonitor entity.
- // If the ChannelMonitor object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *ChannelMonitorMutation) OldCreatedBy(ctx context.Context) (v int64, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldCreatedBy is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldCreatedBy requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldCreatedBy: %w", err)
- }
- return oldValue.CreatedBy, nil
- }
- // AddCreatedBy adds i to the "created_by" field.
- func (m *ChannelMonitorMutation) AddCreatedBy(i int64) {
- if m.addcreated_by != nil {
- *m.addcreated_by += i
- } else {
- m.addcreated_by = &i
- }
- }
- // AddedCreatedBy returns the value that was added to the "created_by" field in this mutation.
- func (m *ChannelMonitorMutation) AddedCreatedBy() (r int64, exists bool) {
- v := m.addcreated_by
- if v == nil {
- return
- }
- return *v, true
- }
- // ResetCreatedBy resets all changes to the "created_by" field.
- func (m *ChannelMonitorMutation) ResetCreatedBy() {
- m.created_by = nil
- m.addcreated_by = nil
- }
- // SetTemplateID sets the "template_id" field.
- func (m *ChannelMonitorMutation) SetTemplateID(i int64) {
- m.request_template = &i
- }
- // TemplateID returns the value of the "template_id" field in the mutation.
- func (m *ChannelMonitorMutation) TemplateID() (r int64, exists bool) {
- v := m.request_template
- if v == nil {
- return
- }
- return *v, true
- }
- // OldTemplateID returns the old "template_id" field's value of the ChannelMonitor entity.
- // If the ChannelMonitor object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *ChannelMonitorMutation) OldTemplateID(ctx context.Context) (v *int64, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldTemplateID is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldTemplateID requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldTemplateID: %w", err)
- }
- return oldValue.TemplateID, nil
- }
- // ClearTemplateID clears the value of the "template_id" field.
- func (m *ChannelMonitorMutation) ClearTemplateID() {
- m.request_template = nil
- m.clearedFields[channelmonitor.FieldTemplateID] = struct{}{}
- }
- // TemplateIDCleared returns if the "template_id" field was cleared in this mutation.
- func (m *ChannelMonitorMutation) TemplateIDCleared() bool {
- _, ok := m.clearedFields[channelmonitor.FieldTemplateID]
- return ok
- }
- // ResetTemplateID resets all changes to the "template_id" field.
- func (m *ChannelMonitorMutation) ResetTemplateID() {
- m.request_template = nil
- delete(m.clearedFields, channelmonitor.FieldTemplateID)
- }
- // SetExtraHeaders sets the "extra_headers" field.
- func (m *ChannelMonitorMutation) SetExtraHeaders(value map[string]string) {
- m.extra_headers = &value
- }
- // ExtraHeaders returns the value of the "extra_headers" field in the mutation.
- func (m *ChannelMonitorMutation) ExtraHeaders() (r map[string]string, exists bool) {
- v := m.extra_headers
- if v == nil {
- return
- }
- return *v, true
- }
- // OldExtraHeaders returns the old "extra_headers" field's value of the ChannelMonitor entity.
- // If the ChannelMonitor object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *ChannelMonitorMutation) OldExtraHeaders(ctx context.Context) (v map[string]string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldExtraHeaders is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldExtraHeaders requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldExtraHeaders: %w", err)
- }
- return oldValue.ExtraHeaders, nil
- }
- // ResetExtraHeaders resets all changes to the "extra_headers" field.
- func (m *ChannelMonitorMutation) ResetExtraHeaders() {
- m.extra_headers = nil
- }
- // SetBodyOverrideMode sets the "body_override_mode" field.
- func (m *ChannelMonitorMutation) SetBodyOverrideMode(s string) {
- m.body_override_mode = &s
- }
- // BodyOverrideMode returns the value of the "body_override_mode" field in the mutation.
- func (m *ChannelMonitorMutation) BodyOverrideMode() (r string, exists bool) {
- v := m.body_override_mode
- if v == nil {
- return
- }
- return *v, true
- }
- // OldBodyOverrideMode returns the old "body_override_mode" field's value of the ChannelMonitor entity.
- // If the ChannelMonitor object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *ChannelMonitorMutation) OldBodyOverrideMode(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldBodyOverrideMode is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldBodyOverrideMode requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldBodyOverrideMode: %w", err)
- }
- return oldValue.BodyOverrideMode, nil
- }
- // ResetBodyOverrideMode resets all changes to the "body_override_mode" field.
- func (m *ChannelMonitorMutation) ResetBodyOverrideMode() {
- m.body_override_mode = nil
- }
- // SetBodyOverride sets the "body_override" field.
- func (m *ChannelMonitorMutation) SetBodyOverride(value map[string]interface{}) {
- m.body_override = &value
- }
- // BodyOverride returns the value of the "body_override" field in the mutation.
- func (m *ChannelMonitorMutation) BodyOverride() (r map[string]interface{}, exists bool) {
- v := m.body_override
- if v == nil {
- return
- }
- return *v, true
- }
- // OldBodyOverride returns the old "body_override" field's value of the ChannelMonitor entity.
- // If the ChannelMonitor object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *ChannelMonitorMutation) OldBodyOverride(ctx context.Context) (v map[string]interface{}, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldBodyOverride is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldBodyOverride requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldBodyOverride: %w", err)
- }
- return oldValue.BodyOverride, nil
- }
- // ClearBodyOverride clears the value of the "body_override" field.
- func (m *ChannelMonitorMutation) ClearBodyOverride() {
- m.body_override = nil
- m.clearedFields[channelmonitor.FieldBodyOverride] = struct{}{}
- }
- // BodyOverrideCleared returns if the "body_override" field was cleared in this mutation.
- func (m *ChannelMonitorMutation) BodyOverrideCleared() bool {
- _, ok := m.clearedFields[channelmonitor.FieldBodyOverride]
- return ok
- }
- // ResetBodyOverride resets all changes to the "body_override" field.
- func (m *ChannelMonitorMutation) ResetBodyOverride() {
- m.body_override = nil
- delete(m.clearedFields, channelmonitor.FieldBodyOverride)
- }
- // AddHistoryIDs adds the "history" edge to the ChannelMonitorHistory entity by ids.
- func (m *ChannelMonitorMutation) AddHistoryIDs(ids ...int64) {
- if m.history == nil {
- m.history = make(map[int64]struct{})
- }
- for i := range ids {
- m.history[ids[i]] = struct{}{}
- }
- }
- // ClearHistory clears the "history" edge to the ChannelMonitorHistory entity.
- func (m *ChannelMonitorMutation) ClearHistory() {
- m.clearedhistory = true
- }
- // HistoryCleared reports if the "history" edge to the ChannelMonitorHistory entity was cleared.
- func (m *ChannelMonitorMutation) HistoryCleared() bool {
- return m.clearedhistory
- }
- // RemoveHistoryIDs removes the "history" edge to the ChannelMonitorHistory entity by IDs.
- func (m *ChannelMonitorMutation) RemoveHistoryIDs(ids ...int64) {
- if m.removedhistory == nil {
- m.removedhistory = make(map[int64]struct{})
- }
- for i := range ids {
- delete(m.history, ids[i])
- m.removedhistory[ids[i]] = struct{}{}
- }
- }
- // RemovedHistory returns the removed IDs of the "history" edge to the ChannelMonitorHistory entity.
- func (m *ChannelMonitorMutation) RemovedHistoryIDs() (ids []int64) {
- for id := range m.removedhistory {
- ids = append(ids, id)
- }
- return
- }
- // HistoryIDs returns the "history" edge IDs in the mutation.
- func (m *ChannelMonitorMutation) HistoryIDs() (ids []int64) {
- for id := range m.history {
- ids = append(ids, id)
- }
- return
- }
- // ResetHistory resets all changes to the "history" edge.
- func (m *ChannelMonitorMutation) ResetHistory() {
- m.history = nil
- m.clearedhistory = false
- m.removedhistory = nil
- }
- // AddDailyRollupIDs adds the "daily_rollups" edge to the ChannelMonitorDailyRollup entity by ids.
- func (m *ChannelMonitorMutation) AddDailyRollupIDs(ids ...int64) {
- if m.daily_rollups == nil {
- m.daily_rollups = make(map[int64]struct{})
- }
- for i := range ids {
- m.daily_rollups[ids[i]] = struct{}{}
- }
- }
- // ClearDailyRollups clears the "daily_rollups" edge to the ChannelMonitorDailyRollup entity.
- func (m *ChannelMonitorMutation) ClearDailyRollups() {
- m.cleareddaily_rollups = true
- }
- // DailyRollupsCleared reports if the "daily_rollups" edge to the ChannelMonitorDailyRollup entity was cleared.
- func (m *ChannelMonitorMutation) DailyRollupsCleared() bool {
- return m.cleareddaily_rollups
- }
- // RemoveDailyRollupIDs removes the "daily_rollups" edge to the ChannelMonitorDailyRollup entity by IDs.
- func (m *ChannelMonitorMutation) RemoveDailyRollupIDs(ids ...int64) {
- if m.removeddaily_rollups == nil {
- m.removeddaily_rollups = make(map[int64]struct{})
- }
- for i := range ids {
- delete(m.daily_rollups, ids[i])
- m.removeddaily_rollups[ids[i]] = struct{}{}
- }
- }
- // RemovedDailyRollups returns the removed IDs of the "daily_rollups" edge to the ChannelMonitorDailyRollup entity.
- func (m *ChannelMonitorMutation) RemovedDailyRollupsIDs() (ids []int64) {
- for id := range m.removeddaily_rollups {
- ids = append(ids, id)
- }
- return
- }
- // DailyRollupsIDs returns the "daily_rollups" edge IDs in the mutation.
- func (m *ChannelMonitorMutation) DailyRollupsIDs() (ids []int64) {
- for id := range m.daily_rollups {
- ids = append(ids, id)
- }
- return
- }
- // ResetDailyRollups resets all changes to the "daily_rollups" edge.
- func (m *ChannelMonitorMutation) ResetDailyRollups() {
- m.daily_rollups = nil
- m.cleareddaily_rollups = false
- m.removeddaily_rollups = nil
- }
- // SetRequestTemplateID sets the "request_template" edge to the ChannelMonitorRequestTemplate entity by id.
- func (m *ChannelMonitorMutation) SetRequestTemplateID(id int64) {
- m.request_template = &id
- }
- // ClearRequestTemplate clears the "request_template" edge to the ChannelMonitorRequestTemplate entity.
- func (m *ChannelMonitorMutation) ClearRequestTemplate() {
- m.clearedrequest_template = true
- m.clearedFields[channelmonitor.FieldTemplateID] = struct{}{}
- }
- // RequestTemplateCleared reports if the "request_template" edge to the ChannelMonitorRequestTemplate entity was cleared.
- func (m *ChannelMonitorMutation) RequestTemplateCleared() bool {
- return m.TemplateIDCleared() || m.clearedrequest_template
- }
- // RequestTemplateID returns the "request_template" edge ID in the mutation.
- func (m *ChannelMonitorMutation) RequestTemplateID() (id int64, exists bool) {
- if m.request_template != nil {
- return *m.request_template, true
- }
- return
- }
- // RequestTemplateIDs returns the "request_template" edge IDs in the mutation.
- // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
- // RequestTemplateID instead. It exists only for internal usage by the builders.
- func (m *ChannelMonitorMutation) RequestTemplateIDs() (ids []int64) {
- if id := m.request_template; id != nil {
- ids = append(ids, *id)
- }
- return
- }
- // ResetRequestTemplate resets all changes to the "request_template" edge.
- func (m *ChannelMonitorMutation) ResetRequestTemplate() {
- m.request_template = nil
- m.clearedrequest_template = false
- }
- // Where appends a list predicates to the ChannelMonitorMutation builder.
- func (m *ChannelMonitorMutation) Where(ps ...predicate.ChannelMonitor) {
- m.predicates = append(m.predicates, ps...)
- }
- // WhereP appends storage-level predicates to the ChannelMonitorMutation builder. Using this method,
- // users can use type-assertion to append predicates that do not depend on any generated package.
- func (m *ChannelMonitorMutation) WhereP(ps ...func(*sql.Selector)) {
- p := make([]predicate.ChannelMonitor, len(ps))
- for i := range ps {
- p[i] = ps[i]
- }
- m.Where(p...)
- }
- // Op returns the operation name.
- func (m *ChannelMonitorMutation) Op() Op {
- return m.op
- }
- // SetOp allows setting the mutation operation.
- func (m *ChannelMonitorMutation) SetOp(op Op) {
- m.op = op
- }
- // Type returns the node type of this mutation (ChannelMonitor).
- func (m *ChannelMonitorMutation) Type() string {
- return m.typ
- }
- // Fields returns all fields that were changed during this mutation. Note that in
- // order to get all numeric fields that were incremented/decremented, call
- // AddedFields().
- func (m *ChannelMonitorMutation) Fields() []string {
- fields := make([]string, 0, 21)
- if m.created_at != nil {
- fields = append(fields, channelmonitor.FieldCreatedAt)
- }
- if m.updated_at != nil {
- fields = append(fields, channelmonitor.FieldUpdatedAt)
- }
- if m.name != nil {
- fields = append(fields, channelmonitor.FieldName)
- }
- if m.provider != nil {
- fields = append(fields, channelmonitor.FieldProvider)
- }
- if m.check_mode != nil {
- fields = append(fields, channelmonitor.FieldCheckMode)
- }
- if m.account_id != nil {
- fields = append(fields, channelmonitor.FieldAccountID)
- }
- if m.api_mode != nil {
- fields = append(fields, channelmonitor.FieldAPIMode)
- }
- if m.endpoint != nil {
- fields = append(fields, channelmonitor.FieldEndpoint)
- }
- if m.api_key_encrypted != nil {
- fields = append(fields, channelmonitor.FieldAPIKeyEncrypted)
- }
- if m.primary_model != nil {
- fields = append(fields, channelmonitor.FieldPrimaryModel)
- }
- if m.extra_models != nil {
- fields = append(fields, channelmonitor.FieldExtraModels)
- }
- if m.group_name != nil {
- fields = append(fields, channelmonitor.FieldGroupName)
- }
- if m.enabled != nil {
- fields = append(fields, channelmonitor.FieldEnabled)
- }
- if m.interval_seconds != nil {
- fields = append(fields, channelmonitor.FieldIntervalSeconds)
- }
- if m.jitter_seconds != nil {
- fields = append(fields, channelmonitor.FieldJitterSeconds)
- }
- if m.last_checked_at != nil {
- fields = append(fields, channelmonitor.FieldLastCheckedAt)
- }
- if m.created_by != nil {
- fields = append(fields, channelmonitor.FieldCreatedBy)
- }
- if m.request_template != nil {
- fields = append(fields, channelmonitor.FieldTemplateID)
- }
- if m.extra_headers != nil {
- fields = append(fields, channelmonitor.FieldExtraHeaders)
- }
- if m.body_override_mode != nil {
- fields = append(fields, channelmonitor.FieldBodyOverrideMode)
- }
- if m.body_override != nil {
- fields = append(fields, channelmonitor.FieldBodyOverride)
- }
- return fields
- }
- // Field returns the value of a field with the given name. The second boolean
- // return value indicates that this field was not set, or was not defined in the
- // schema.
- func (m *ChannelMonitorMutation) Field(name string) (ent.Value, bool) {
- switch name {
- case channelmonitor.FieldCreatedAt:
- return m.CreatedAt()
- case channelmonitor.FieldUpdatedAt:
- return m.UpdatedAt()
- case channelmonitor.FieldName:
- return m.Name()
- case channelmonitor.FieldProvider:
- return m.Provider()
- case channelmonitor.FieldCheckMode:
- return m.CheckMode()
- case channelmonitor.FieldAccountID:
- return m.AccountID()
- case channelmonitor.FieldAPIMode:
- return m.APIMode()
- case channelmonitor.FieldEndpoint:
- return m.Endpoint()
- case channelmonitor.FieldAPIKeyEncrypted:
- return m.APIKeyEncrypted()
- case channelmonitor.FieldPrimaryModel:
- return m.PrimaryModel()
- case channelmonitor.FieldExtraModels:
- return m.ExtraModels()
- case channelmonitor.FieldGroupName:
- return m.GroupName()
- case channelmonitor.FieldEnabled:
- return m.Enabled()
- case channelmonitor.FieldIntervalSeconds:
- return m.IntervalSeconds()
- case channelmonitor.FieldJitterSeconds:
- return m.JitterSeconds()
- case channelmonitor.FieldLastCheckedAt:
- return m.LastCheckedAt()
- case channelmonitor.FieldCreatedBy:
- return m.CreatedBy()
- case channelmonitor.FieldTemplateID:
- return m.TemplateID()
- case channelmonitor.FieldExtraHeaders:
- return m.ExtraHeaders()
- case channelmonitor.FieldBodyOverrideMode:
- return m.BodyOverrideMode()
- case channelmonitor.FieldBodyOverride:
- return m.BodyOverride()
- }
- return nil, false
- }
- // OldField returns the old value of the field from the database. An error is
- // returned if the mutation operation is not UpdateOne, or the query to the
- // database failed.
- func (m *ChannelMonitorMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
- switch name {
- case channelmonitor.FieldCreatedAt:
- return m.OldCreatedAt(ctx)
- case channelmonitor.FieldUpdatedAt:
- return m.OldUpdatedAt(ctx)
- case channelmonitor.FieldName:
- return m.OldName(ctx)
- case channelmonitor.FieldProvider:
- return m.OldProvider(ctx)
- case channelmonitor.FieldCheckMode:
- return m.OldCheckMode(ctx)
- case channelmonitor.FieldAccountID:
- return m.OldAccountID(ctx)
- case channelmonitor.FieldAPIMode:
- return m.OldAPIMode(ctx)
- case channelmonitor.FieldEndpoint:
- return m.OldEndpoint(ctx)
- case channelmonitor.FieldAPIKeyEncrypted:
- return m.OldAPIKeyEncrypted(ctx)
- case channelmonitor.FieldPrimaryModel:
- return m.OldPrimaryModel(ctx)
- case channelmonitor.FieldExtraModels:
- return m.OldExtraModels(ctx)
- case channelmonitor.FieldGroupName:
- return m.OldGroupName(ctx)
- case channelmonitor.FieldEnabled:
- return m.OldEnabled(ctx)
- case channelmonitor.FieldIntervalSeconds:
- return m.OldIntervalSeconds(ctx)
- case channelmonitor.FieldJitterSeconds:
- return m.OldJitterSeconds(ctx)
- case channelmonitor.FieldLastCheckedAt:
- return m.OldLastCheckedAt(ctx)
- case channelmonitor.FieldCreatedBy:
- return m.OldCreatedBy(ctx)
- case channelmonitor.FieldTemplateID:
- return m.OldTemplateID(ctx)
- case channelmonitor.FieldExtraHeaders:
- return m.OldExtraHeaders(ctx)
- case channelmonitor.FieldBodyOverrideMode:
- return m.OldBodyOverrideMode(ctx)
- case channelmonitor.FieldBodyOverride:
- return m.OldBodyOverride(ctx)
- }
- return nil, fmt.Errorf("unknown ChannelMonitor field %s", name)
- }
- // SetField sets the value of a field with the given name. It returns an error if
- // the field is not defined in the schema, or if the type mismatched the field
- // type.
- func (m *ChannelMonitorMutation) SetField(name string, value ent.Value) error {
- switch name {
- case channelmonitor.FieldCreatedAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetCreatedAt(v)
- return nil
- case channelmonitor.FieldUpdatedAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetUpdatedAt(v)
- return nil
- case channelmonitor.FieldName:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetName(v)
- return nil
- case channelmonitor.FieldProvider:
- v, ok := value.(channelmonitor.Provider)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetProvider(v)
- return nil
- case channelmonitor.FieldCheckMode:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetCheckMode(v)
- return nil
- case channelmonitor.FieldAccountID:
- v, ok := value.(int64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetAccountID(v)
- return nil
- case channelmonitor.FieldAPIMode:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetAPIMode(v)
- return nil
- case channelmonitor.FieldEndpoint:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetEndpoint(v)
- return nil
- case channelmonitor.FieldAPIKeyEncrypted:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetAPIKeyEncrypted(v)
- return nil
- case channelmonitor.FieldPrimaryModel:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetPrimaryModel(v)
- return nil
- case channelmonitor.FieldExtraModels:
- v, ok := value.([]string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetExtraModels(v)
- return nil
- case channelmonitor.FieldGroupName:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetGroupName(v)
- return nil
- case channelmonitor.FieldEnabled:
- v, ok := value.(bool)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetEnabled(v)
- return nil
- case channelmonitor.FieldIntervalSeconds:
- v, ok := value.(int)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetIntervalSeconds(v)
- return nil
- case channelmonitor.FieldJitterSeconds:
- v, ok := value.(int)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetJitterSeconds(v)
- return nil
- case channelmonitor.FieldLastCheckedAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetLastCheckedAt(v)
- return nil
- case channelmonitor.FieldCreatedBy:
- v, ok := value.(int64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetCreatedBy(v)
- return nil
- case channelmonitor.FieldTemplateID:
- v, ok := value.(int64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetTemplateID(v)
- return nil
- case channelmonitor.FieldExtraHeaders:
- v, ok := value.(map[string]string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetExtraHeaders(v)
- return nil
- case channelmonitor.FieldBodyOverrideMode:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetBodyOverrideMode(v)
- return nil
- case channelmonitor.FieldBodyOverride:
- v, ok := value.(map[string]interface{})
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetBodyOverride(v)
- return nil
- }
- return fmt.Errorf("unknown ChannelMonitor field %s", name)
- }
- // AddedFields returns all numeric fields that were incremented/decremented during
- // this mutation.
- func (m *ChannelMonitorMutation) AddedFields() []string {
- var fields []string
- if m.addaccount_id != nil {
- fields = append(fields, channelmonitor.FieldAccountID)
- }
- if m.addinterval_seconds != nil {
- fields = append(fields, channelmonitor.FieldIntervalSeconds)
- }
- if m.addjitter_seconds != nil {
- fields = append(fields, channelmonitor.FieldJitterSeconds)
- }
- if m.addcreated_by != nil {
- fields = append(fields, channelmonitor.FieldCreatedBy)
- }
- return fields
- }
- // AddedField returns the numeric value that was incremented/decremented on a field
- // with the given name. The second boolean return value indicates that this field
- // was not set, or was not defined in the schema.
- func (m *ChannelMonitorMutation) AddedField(name string) (ent.Value, bool) {
- switch name {
- case channelmonitor.FieldAccountID:
- return m.AddedAccountID()
- case channelmonitor.FieldIntervalSeconds:
- return m.AddedIntervalSeconds()
- case channelmonitor.FieldJitterSeconds:
- return m.AddedJitterSeconds()
- case channelmonitor.FieldCreatedBy:
- return m.AddedCreatedBy()
- }
- return nil, false
- }
- // AddField adds the value to the field with the given name. It returns an error if
- // the field is not defined in the schema, or if the type mismatched the field
- // type.
- func (m *ChannelMonitorMutation) AddField(name string, value ent.Value) error {
- switch name {
- case channelmonitor.FieldAccountID:
- v, ok := value.(int64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.AddAccountID(v)
- return nil
- case channelmonitor.FieldIntervalSeconds:
- v, ok := value.(int)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.AddIntervalSeconds(v)
- return nil
- case channelmonitor.FieldJitterSeconds:
- v, ok := value.(int)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.AddJitterSeconds(v)
- return nil
- case channelmonitor.FieldCreatedBy:
- v, ok := value.(int64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.AddCreatedBy(v)
- return nil
- }
- return fmt.Errorf("unknown ChannelMonitor numeric field %s", name)
- }
- // ClearedFields returns all nullable fields that were cleared during this
- // mutation.
- func (m *ChannelMonitorMutation) ClearedFields() []string {
- var fields []string
- if m.FieldCleared(channelmonitor.FieldAccountID) {
- fields = append(fields, channelmonitor.FieldAccountID)
- }
- if m.FieldCleared(channelmonitor.FieldGroupName) {
- fields = append(fields, channelmonitor.FieldGroupName)
- }
- if m.FieldCleared(channelmonitor.FieldLastCheckedAt) {
- fields = append(fields, channelmonitor.FieldLastCheckedAt)
- }
- if m.FieldCleared(channelmonitor.FieldTemplateID) {
- fields = append(fields, channelmonitor.FieldTemplateID)
- }
- if m.FieldCleared(channelmonitor.FieldBodyOverride) {
- fields = append(fields, channelmonitor.FieldBodyOverride)
- }
- return fields
- }
- // FieldCleared returns a boolean indicating if a field with the given name was
- // cleared in this mutation.
- func (m *ChannelMonitorMutation) FieldCleared(name string) bool {
- _, ok := m.clearedFields[name]
- return ok
- }
- // ClearField clears the value of the field with the given name. It returns an
- // error if the field is not defined in the schema.
- func (m *ChannelMonitorMutation) ClearField(name string) error {
- switch name {
- case channelmonitor.FieldAccountID:
- m.ClearAccountID()
- return nil
- case channelmonitor.FieldGroupName:
- m.ClearGroupName()
- return nil
- case channelmonitor.FieldLastCheckedAt:
- m.ClearLastCheckedAt()
- return nil
- case channelmonitor.FieldTemplateID:
- m.ClearTemplateID()
- return nil
- case channelmonitor.FieldBodyOverride:
- m.ClearBodyOverride()
- return nil
- }
- return fmt.Errorf("unknown ChannelMonitor nullable field %s", name)
- }
- // ResetField resets all changes in the mutation for the field with the given name.
- // It returns an error if the field is not defined in the schema.
- func (m *ChannelMonitorMutation) ResetField(name string) error {
- switch name {
- case channelmonitor.FieldCreatedAt:
- m.ResetCreatedAt()
- return nil
- case channelmonitor.FieldUpdatedAt:
- m.ResetUpdatedAt()
- return nil
- case channelmonitor.FieldName:
- m.ResetName()
- return nil
- case channelmonitor.FieldProvider:
- m.ResetProvider()
- return nil
- case channelmonitor.FieldCheckMode:
- m.ResetCheckMode()
- return nil
- case channelmonitor.FieldAccountID:
- m.ResetAccountID()
- return nil
- case channelmonitor.FieldAPIMode:
- m.ResetAPIMode()
- return nil
- case channelmonitor.FieldEndpoint:
- m.ResetEndpoint()
- return nil
- case channelmonitor.FieldAPIKeyEncrypted:
- m.ResetAPIKeyEncrypted()
- return nil
- case channelmonitor.FieldPrimaryModel:
- m.ResetPrimaryModel()
- return nil
- case channelmonitor.FieldExtraModels:
- m.ResetExtraModels()
- return nil
- case channelmonitor.FieldGroupName:
- m.ResetGroupName()
- return nil
- case channelmonitor.FieldEnabled:
- m.ResetEnabled()
- return nil
- case channelmonitor.FieldIntervalSeconds:
- m.ResetIntervalSeconds()
- return nil
- case channelmonitor.FieldJitterSeconds:
- m.ResetJitterSeconds()
- return nil
- case channelmonitor.FieldLastCheckedAt:
- m.ResetLastCheckedAt()
- return nil
- case channelmonitor.FieldCreatedBy:
- m.ResetCreatedBy()
- return nil
- case channelmonitor.FieldTemplateID:
- m.ResetTemplateID()
- return nil
- case channelmonitor.FieldExtraHeaders:
- m.ResetExtraHeaders()
- return nil
- case channelmonitor.FieldBodyOverrideMode:
- m.ResetBodyOverrideMode()
- return nil
- case channelmonitor.FieldBodyOverride:
- m.ResetBodyOverride()
- return nil
- }
- return fmt.Errorf("unknown ChannelMonitor field %s", name)
- }
- // AddedEdges returns all edge names that were set/added in this mutation.
- func (m *ChannelMonitorMutation) AddedEdges() []string {
- edges := make([]string, 0, 3)
- if m.history != nil {
- edges = append(edges, channelmonitor.EdgeHistory)
- }
- if m.daily_rollups != nil {
- edges = append(edges, channelmonitor.EdgeDailyRollups)
- }
- if m.request_template != nil {
- edges = append(edges, channelmonitor.EdgeRequestTemplate)
- }
- return edges
- }
- // AddedIDs returns all IDs (to other nodes) that were added for the given edge
- // name in this mutation.
- func (m *ChannelMonitorMutation) AddedIDs(name string) []ent.Value {
- switch name {
- case channelmonitor.EdgeHistory:
- ids := make([]ent.Value, 0, len(m.history))
- for id := range m.history {
- ids = append(ids, id)
- }
- return ids
- case channelmonitor.EdgeDailyRollups:
- ids := make([]ent.Value, 0, len(m.daily_rollups))
- for id := range m.daily_rollups {
- ids = append(ids, id)
- }
- return ids
- case channelmonitor.EdgeRequestTemplate:
- if id := m.request_template; id != nil {
- return []ent.Value{*id}
- }
- }
- return nil
- }
- // RemovedEdges returns all edge names that were removed in this mutation.
- func (m *ChannelMonitorMutation) RemovedEdges() []string {
- edges := make([]string, 0, 3)
- if m.removedhistory != nil {
- edges = append(edges, channelmonitor.EdgeHistory)
- }
- if m.removeddaily_rollups != nil {
- edges = append(edges, channelmonitor.EdgeDailyRollups)
- }
- return edges
- }
- // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
- // the given name in this mutation.
- func (m *ChannelMonitorMutation) RemovedIDs(name string) []ent.Value {
- switch name {
- case channelmonitor.EdgeHistory:
- ids := make([]ent.Value, 0, len(m.removedhistory))
- for id := range m.removedhistory {
- ids = append(ids, id)
- }
- return ids
- case channelmonitor.EdgeDailyRollups:
- ids := make([]ent.Value, 0, len(m.removeddaily_rollups))
- for id := range m.removeddaily_rollups {
- ids = append(ids, id)
- }
- return ids
- }
- return nil
- }
- // ClearedEdges returns all edge names that were cleared in this mutation.
- func (m *ChannelMonitorMutation) ClearedEdges() []string {
- edges := make([]string, 0, 3)
- if m.clearedhistory {
- edges = append(edges, channelmonitor.EdgeHistory)
- }
- if m.cleareddaily_rollups {
- edges = append(edges, channelmonitor.EdgeDailyRollups)
- }
- if m.clearedrequest_template {
- edges = append(edges, channelmonitor.EdgeRequestTemplate)
- }
- return edges
- }
- // EdgeCleared returns a boolean which indicates if the edge with the given name
- // was cleared in this mutation.
- func (m *ChannelMonitorMutation) EdgeCleared(name string) bool {
- switch name {
- case channelmonitor.EdgeHistory:
- return m.clearedhistory
- case channelmonitor.EdgeDailyRollups:
- return m.cleareddaily_rollups
- case channelmonitor.EdgeRequestTemplate:
- return m.clearedrequest_template
- }
- return false
- }
- // ClearEdge clears the value of the edge with the given name. It returns an error
- // if that edge is not defined in the schema.
- func (m *ChannelMonitorMutation) ClearEdge(name string) error {
- switch name {
- case channelmonitor.EdgeRequestTemplate:
- m.ClearRequestTemplate()
- return nil
- }
- return fmt.Errorf("unknown ChannelMonitor unique edge %s", name)
- }
- // ResetEdge resets all changes to the edge with the given name in this mutation.
- // It returns an error if the edge is not defined in the schema.
- func (m *ChannelMonitorMutation) ResetEdge(name string) error {
- switch name {
- case channelmonitor.EdgeHistory:
- m.ResetHistory()
- return nil
- case channelmonitor.EdgeDailyRollups:
- m.ResetDailyRollups()
- return nil
- case channelmonitor.EdgeRequestTemplate:
- m.ResetRequestTemplate()
- return nil
- }
- return fmt.Errorf("unknown ChannelMonitor edge %s", name)
- }
- // ChannelMonitorDailyRollupMutation represents an operation that mutates the ChannelMonitorDailyRollup nodes in the graph.
- type ChannelMonitorDailyRollupMutation struct {
- config
- op Op
- typ string
- id *int64
- model *string
- bucket_date *time.Time
- total_checks *int
- addtotal_checks *int
- ok_count *int
- addok_count *int
- operational_count *int
- addoperational_count *int
- degraded_count *int
- adddegraded_count *int
- failed_count *int
- addfailed_count *int
- error_count *int
- adderror_count *int
- sum_latency_ms *int64
- addsum_latency_ms *int64
- count_latency *int
- addcount_latency *int
- sum_ping_latency_ms *int64
- addsum_ping_latency_ms *int64
- count_ping_latency *int
- addcount_ping_latency *int
- computed_at *time.Time
- clearedFields map[string]struct{}
- monitor *int64
- clearedmonitor bool
- done bool
- oldValue func(context.Context) (*ChannelMonitorDailyRollup, error)
- predicates []predicate.ChannelMonitorDailyRollup
- }
- var _ ent.Mutation = (*ChannelMonitorDailyRollupMutation)(nil)
- // channelmonitordailyrollupOption allows management of the mutation configuration using functional options.
- type channelmonitordailyrollupOption func(*ChannelMonitorDailyRollupMutation)
- // newChannelMonitorDailyRollupMutation creates new mutation for the ChannelMonitorDailyRollup entity.
- func newChannelMonitorDailyRollupMutation(c config, op Op, opts ...channelmonitordailyrollupOption) *ChannelMonitorDailyRollupMutation {
- m := &ChannelMonitorDailyRollupMutation{
- config: c,
- op: op,
- typ: TypeChannelMonitorDailyRollup,
- clearedFields: make(map[string]struct{}),
- }
- for _, opt := range opts {
- opt(m)
- }
- return m
- }
- // withChannelMonitorDailyRollupID sets the ID field of the mutation.
- func withChannelMonitorDailyRollupID(id int64) channelmonitordailyrollupOption {
- return func(m *ChannelMonitorDailyRollupMutation) {
- var (
- err error
- once sync.Once
- value *ChannelMonitorDailyRollup
- )
- m.oldValue = func(ctx context.Context) (*ChannelMonitorDailyRollup, error) {
- once.Do(func() {
- if m.done {
- err = errors.New("querying old values post mutation is not allowed")
- } else {
- value, err = m.Client().ChannelMonitorDailyRollup.Get(ctx, id)
- }
- })
- return value, err
- }
- m.id = &id
- }
- }
- // withChannelMonitorDailyRollup sets the old ChannelMonitorDailyRollup of the mutation.
- func withChannelMonitorDailyRollup(node *ChannelMonitorDailyRollup) channelmonitordailyrollupOption {
- return func(m *ChannelMonitorDailyRollupMutation) {
- m.oldValue = func(context.Context) (*ChannelMonitorDailyRollup, error) {
- return node, nil
- }
- m.id = &node.ID
- }
- }
- // Client returns a new `ent.Client` from the mutation. If the mutation was
- // executed in a transaction (ent.Tx), a transactional client is returned.
- func (m ChannelMonitorDailyRollupMutation) Client() *Client {
- client := &Client{config: m.config}
- client.init()
- return client
- }
- // Tx returns an `ent.Tx` for mutations that were executed in transactions;
- // it returns an error otherwise.
- func (m ChannelMonitorDailyRollupMutation) Tx() (*Tx, error) {
- if _, ok := m.driver.(*txDriver); !ok {
- return nil, errors.New("ent: mutation is not running in a transaction")
- }
- tx := &Tx{config: m.config}
- tx.init()
- return tx, nil
- }
- // ID returns the ID value in the mutation. Note that the ID is only available
- // if it was provided to the builder or after it was returned from the database.
- func (m *ChannelMonitorDailyRollupMutation) ID() (id int64, exists bool) {
- if m.id == nil {
- return
- }
- return *m.id, true
- }
- // IDs queries the database and returns the entity ids that match the mutation's predicate.
- // That means, if the mutation is applied within a transaction with an isolation level such
- // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
- // or updated by the mutation.
- func (m *ChannelMonitorDailyRollupMutation) IDs(ctx context.Context) ([]int64, error) {
- switch {
- case m.op.Is(OpUpdateOne | OpDeleteOne):
- id, exists := m.ID()
- if exists {
- return []int64{id}, nil
- }
- fallthrough
- case m.op.Is(OpUpdate | OpDelete):
- return m.Client().ChannelMonitorDailyRollup.Query().Where(m.predicates...).IDs(ctx)
- default:
- return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
- }
- }
- // SetMonitorID sets the "monitor_id" field.
- func (m *ChannelMonitorDailyRollupMutation) SetMonitorID(i int64) {
- m.monitor = &i
- }
- // MonitorID returns the value of the "monitor_id" field in the mutation.
- func (m *ChannelMonitorDailyRollupMutation) MonitorID() (r int64, exists bool) {
- v := m.monitor
- if v == nil {
- return
- }
- return *v, true
- }
- // OldMonitorID returns the old "monitor_id" field's value of the ChannelMonitorDailyRollup entity.
- // If the ChannelMonitorDailyRollup object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *ChannelMonitorDailyRollupMutation) OldMonitorID(ctx context.Context) (v int64, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldMonitorID is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldMonitorID requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldMonitorID: %w", err)
- }
- return oldValue.MonitorID, nil
- }
- // ResetMonitorID resets all changes to the "monitor_id" field.
- func (m *ChannelMonitorDailyRollupMutation) ResetMonitorID() {
- m.monitor = nil
- }
- // SetModel sets the "model" field.
- func (m *ChannelMonitorDailyRollupMutation) SetModel(s string) {
- m.model = &s
- }
- // Model returns the value of the "model" field in the mutation.
- func (m *ChannelMonitorDailyRollupMutation) Model() (r string, exists bool) {
- v := m.model
- if v == nil {
- return
- }
- return *v, true
- }
- // OldModel returns the old "model" field's value of the ChannelMonitorDailyRollup entity.
- // If the ChannelMonitorDailyRollup object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *ChannelMonitorDailyRollupMutation) OldModel(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldModel is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldModel requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldModel: %w", err)
- }
- return oldValue.Model, nil
- }
- // ResetModel resets all changes to the "model" field.
- func (m *ChannelMonitorDailyRollupMutation) ResetModel() {
- m.model = nil
- }
- // SetBucketDate sets the "bucket_date" field.
- func (m *ChannelMonitorDailyRollupMutation) SetBucketDate(t time.Time) {
- m.bucket_date = &t
- }
- // BucketDate returns the value of the "bucket_date" field in the mutation.
- func (m *ChannelMonitorDailyRollupMutation) BucketDate() (r time.Time, exists bool) {
- v := m.bucket_date
- if v == nil {
- return
- }
- return *v, true
- }
- // OldBucketDate returns the old "bucket_date" field's value of the ChannelMonitorDailyRollup entity.
- // If the ChannelMonitorDailyRollup object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *ChannelMonitorDailyRollupMutation) OldBucketDate(ctx context.Context) (v time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldBucketDate is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldBucketDate requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldBucketDate: %w", err)
- }
- return oldValue.BucketDate, nil
- }
- // ResetBucketDate resets all changes to the "bucket_date" field.
- func (m *ChannelMonitorDailyRollupMutation) ResetBucketDate() {
- m.bucket_date = nil
- }
- // SetTotalChecks sets the "total_checks" field.
- func (m *ChannelMonitorDailyRollupMutation) SetTotalChecks(i int) {
- m.total_checks = &i
- m.addtotal_checks = nil
- }
- // TotalChecks returns the value of the "total_checks" field in the mutation.
- func (m *ChannelMonitorDailyRollupMutation) TotalChecks() (r int, exists bool) {
- v := m.total_checks
- if v == nil {
- return
- }
- return *v, true
- }
- // OldTotalChecks returns the old "total_checks" field's value of the ChannelMonitorDailyRollup entity.
- // If the ChannelMonitorDailyRollup object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *ChannelMonitorDailyRollupMutation) OldTotalChecks(ctx context.Context) (v int, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldTotalChecks is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldTotalChecks requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldTotalChecks: %w", err)
- }
- return oldValue.TotalChecks, nil
- }
- // AddTotalChecks adds i to the "total_checks" field.
- func (m *ChannelMonitorDailyRollupMutation) AddTotalChecks(i int) {
- if m.addtotal_checks != nil {
- *m.addtotal_checks += i
- } else {
- m.addtotal_checks = &i
- }
- }
- // AddedTotalChecks returns the value that was added to the "total_checks" field in this mutation.
- func (m *ChannelMonitorDailyRollupMutation) AddedTotalChecks() (r int, exists bool) {
- v := m.addtotal_checks
- if v == nil {
- return
- }
- return *v, true
- }
- // ResetTotalChecks resets all changes to the "total_checks" field.
- func (m *ChannelMonitorDailyRollupMutation) ResetTotalChecks() {
- m.total_checks = nil
- m.addtotal_checks = nil
- }
- // SetOkCount sets the "ok_count" field.
- func (m *ChannelMonitorDailyRollupMutation) SetOkCount(i int) {
- m.ok_count = &i
- m.addok_count = nil
- }
- // OkCount returns the value of the "ok_count" field in the mutation.
- func (m *ChannelMonitorDailyRollupMutation) OkCount() (r int, exists bool) {
- v := m.ok_count
- if v == nil {
- return
- }
- return *v, true
- }
- // OldOkCount returns the old "ok_count" field's value of the ChannelMonitorDailyRollup entity.
- // If the ChannelMonitorDailyRollup object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *ChannelMonitorDailyRollupMutation) OldOkCount(ctx context.Context) (v int, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldOkCount is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldOkCount requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldOkCount: %w", err)
- }
- return oldValue.OkCount, nil
- }
- // AddOkCount adds i to the "ok_count" field.
- func (m *ChannelMonitorDailyRollupMutation) AddOkCount(i int) {
- if m.addok_count != nil {
- *m.addok_count += i
- } else {
- m.addok_count = &i
- }
- }
- // AddedOkCount returns the value that was added to the "ok_count" field in this mutation.
- func (m *ChannelMonitorDailyRollupMutation) AddedOkCount() (r int, exists bool) {
- v := m.addok_count
- if v == nil {
- return
- }
- return *v, true
- }
- // ResetOkCount resets all changes to the "ok_count" field.
- func (m *ChannelMonitorDailyRollupMutation) ResetOkCount() {
- m.ok_count = nil
- m.addok_count = nil
- }
- // SetOperationalCount sets the "operational_count" field.
- func (m *ChannelMonitorDailyRollupMutation) SetOperationalCount(i int) {
- m.operational_count = &i
- m.addoperational_count = nil
- }
- // OperationalCount returns the value of the "operational_count" field in the mutation.
- func (m *ChannelMonitorDailyRollupMutation) OperationalCount() (r int, exists bool) {
- v := m.operational_count
- if v == nil {
- return
- }
- return *v, true
- }
- // OldOperationalCount returns the old "operational_count" field's value of the ChannelMonitorDailyRollup entity.
- // If the ChannelMonitorDailyRollup object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *ChannelMonitorDailyRollupMutation) OldOperationalCount(ctx context.Context) (v int, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldOperationalCount is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldOperationalCount requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldOperationalCount: %w", err)
- }
- return oldValue.OperationalCount, nil
- }
- // AddOperationalCount adds i to the "operational_count" field.
- func (m *ChannelMonitorDailyRollupMutation) AddOperationalCount(i int) {
- if m.addoperational_count != nil {
- *m.addoperational_count += i
- } else {
- m.addoperational_count = &i
- }
- }
- // AddedOperationalCount returns the value that was added to the "operational_count" field in this mutation.
- func (m *ChannelMonitorDailyRollupMutation) AddedOperationalCount() (r int, exists bool) {
- v := m.addoperational_count
- if v == nil {
- return
- }
- return *v, true
- }
- // ResetOperationalCount resets all changes to the "operational_count" field.
- func (m *ChannelMonitorDailyRollupMutation) ResetOperationalCount() {
- m.operational_count = nil
- m.addoperational_count = nil
- }
- // SetDegradedCount sets the "degraded_count" field.
- func (m *ChannelMonitorDailyRollupMutation) SetDegradedCount(i int) {
- m.degraded_count = &i
- m.adddegraded_count = nil
- }
- // DegradedCount returns the value of the "degraded_count" field in the mutation.
- func (m *ChannelMonitorDailyRollupMutation) DegradedCount() (r int, exists bool) {
- v := m.degraded_count
- if v == nil {
- return
- }
- return *v, true
- }
- // OldDegradedCount returns the old "degraded_count" field's value of the ChannelMonitorDailyRollup entity.
- // If the ChannelMonitorDailyRollup object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *ChannelMonitorDailyRollupMutation) OldDegradedCount(ctx context.Context) (v int, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldDegradedCount is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldDegradedCount requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldDegradedCount: %w", err)
- }
- return oldValue.DegradedCount, nil
- }
- // AddDegradedCount adds i to the "degraded_count" field.
- func (m *ChannelMonitorDailyRollupMutation) AddDegradedCount(i int) {
- if m.adddegraded_count != nil {
- *m.adddegraded_count += i
- } else {
- m.adddegraded_count = &i
- }
- }
- // AddedDegradedCount returns the value that was added to the "degraded_count" field in this mutation.
- func (m *ChannelMonitorDailyRollupMutation) AddedDegradedCount() (r int, exists bool) {
- v := m.adddegraded_count
- if v == nil {
- return
- }
- return *v, true
- }
- // ResetDegradedCount resets all changes to the "degraded_count" field.
- func (m *ChannelMonitorDailyRollupMutation) ResetDegradedCount() {
- m.degraded_count = nil
- m.adddegraded_count = nil
- }
- // SetFailedCount sets the "failed_count" field.
- func (m *ChannelMonitorDailyRollupMutation) SetFailedCount(i int) {
- m.failed_count = &i
- m.addfailed_count = nil
- }
- // FailedCount returns the value of the "failed_count" field in the mutation.
- func (m *ChannelMonitorDailyRollupMutation) FailedCount() (r int, exists bool) {
- v := m.failed_count
- if v == nil {
- return
- }
- return *v, true
- }
- // OldFailedCount returns the old "failed_count" field's value of the ChannelMonitorDailyRollup entity.
- // If the ChannelMonitorDailyRollup object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *ChannelMonitorDailyRollupMutation) OldFailedCount(ctx context.Context) (v int, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldFailedCount is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldFailedCount requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldFailedCount: %w", err)
- }
- return oldValue.FailedCount, nil
- }
- // AddFailedCount adds i to the "failed_count" field.
- func (m *ChannelMonitorDailyRollupMutation) AddFailedCount(i int) {
- if m.addfailed_count != nil {
- *m.addfailed_count += i
- } else {
- m.addfailed_count = &i
- }
- }
- // AddedFailedCount returns the value that was added to the "failed_count" field in this mutation.
- func (m *ChannelMonitorDailyRollupMutation) AddedFailedCount() (r int, exists bool) {
- v := m.addfailed_count
- if v == nil {
- return
- }
- return *v, true
- }
- // ResetFailedCount resets all changes to the "failed_count" field.
- func (m *ChannelMonitorDailyRollupMutation) ResetFailedCount() {
- m.failed_count = nil
- m.addfailed_count = nil
- }
- // SetErrorCount sets the "error_count" field.
- func (m *ChannelMonitorDailyRollupMutation) SetErrorCount(i int) {
- m.error_count = &i
- m.adderror_count = nil
- }
- // ErrorCount returns the value of the "error_count" field in the mutation.
- func (m *ChannelMonitorDailyRollupMutation) ErrorCount() (r int, exists bool) {
- v := m.error_count
- if v == nil {
- return
- }
- return *v, true
- }
- // OldErrorCount returns the old "error_count" field's value of the ChannelMonitorDailyRollup entity.
- // If the ChannelMonitorDailyRollup object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *ChannelMonitorDailyRollupMutation) OldErrorCount(ctx context.Context) (v int, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldErrorCount is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldErrorCount requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldErrorCount: %w", err)
- }
- return oldValue.ErrorCount, nil
- }
- // AddErrorCount adds i to the "error_count" field.
- func (m *ChannelMonitorDailyRollupMutation) AddErrorCount(i int) {
- if m.adderror_count != nil {
- *m.adderror_count += i
- } else {
- m.adderror_count = &i
- }
- }
- // AddedErrorCount returns the value that was added to the "error_count" field in this mutation.
- func (m *ChannelMonitorDailyRollupMutation) AddedErrorCount() (r int, exists bool) {
- v := m.adderror_count
- if v == nil {
- return
- }
- return *v, true
- }
- // ResetErrorCount resets all changes to the "error_count" field.
- func (m *ChannelMonitorDailyRollupMutation) ResetErrorCount() {
- m.error_count = nil
- m.adderror_count = nil
- }
- // SetSumLatencyMs sets the "sum_latency_ms" field.
- func (m *ChannelMonitorDailyRollupMutation) SetSumLatencyMs(i int64) {
- m.sum_latency_ms = &i
- m.addsum_latency_ms = nil
- }
- // SumLatencyMs returns the value of the "sum_latency_ms" field in the mutation.
- func (m *ChannelMonitorDailyRollupMutation) SumLatencyMs() (r int64, exists bool) {
- v := m.sum_latency_ms
- if v == nil {
- return
- }
- return *v, true
- }
- // OldSumLatencyMs returns the old "sum_latency_ms" field's value of the ChannelMonitorDailyRollup entity.
- // If the ChannelMonitorDailyRollup object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *ChannelMonitorDailyRollupMutation) OldSumLatencyMs(ctx context.Context) (v int64, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldSumLatencyMs is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldSumLatencyMs requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldSumLatencyMs: %w", err)
- }
- return oldValue.SumLatencyMs, nil
- }
- // AddSumLatencyMs adds i to the "sum_latency_ms" field.
- func (m *ChannelMonitorDailyRollupMutation) AddSumLatencyMs(i int64) {
- if m.addsum_latency_ms != nil {
- *m.addsum_latency_ms += i
- } else {
- m.addsum_latency_ms = &i
- }
- }
- // AddedSumLatencyMs returns the value that was added to the "sum_latency_ms" field in this mutation.
- func (m *ChannelMonitorDailyRollupMutation) AddedSumLatencyMs() (r int64, exists bool) {
- v := m.addsum_latency_ms
- if v == nil {
- return
- }
- return *v, true
- }
- // ResetSumLatencyMs resets all changes to the "sum_latency_ms" field.
- func (m *ChannelMonitorDailyRollupMutation) ResetSumLatencyMs() {
- m.sum_latency_ms = nil
- m.addsum_latency_ms = nil
- }
- // SetCountLatency sets the "count_latency" field.
- func (m *ChannelMonitorDailyRollupMutation) SetCountLatency(i int) {
- m.count_latency = &i
- m.addcount_latency = nil
- }
- // CountLatency returns the value of the "count_latency" field in the mutation.
- func (m *ChannelMonitorDailyRollupMutation) CountLatency() (r int, exists bool) {
- v := m.count_latency
- if v == nil {
- return
- }
- return *v, true
- }
- // OldCountLatency returns the old "count_latency" field's value of the ChannelMonitorDailyRollup entity.
- // If the ChannelMonitorDailyRollup object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *ChannelMonitorDailyRollupMutation) OldCountLatency(ctx context.Context) (v int, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldCountLatency is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldCountLatency requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldCountLatency: %w", err)
- }
- return oldValue.CountLatency, nil
- }
- // AddCountLatency adds i to the "count_latency" field.
- func (m *ChannelMonitorDailyRollupMutation) AddCountLatency(i int) {
- if m.addcount_latency != nil {
- *m.addcount_latency += i
- } else {
- m.addcount_latency = &i
- }
- }
- // AddedCountLatency returns the value that was added to the "count_latency" field in this mutation.
- func (m *ChannelMonitorDailyRollupMutation) AddedCountLatency() (r int, exists bool) {
- v := m.addcount_latency
- if v == nil {
- return
- }
- return *v, true
- }
- // ResetCountLatency resets all changes to the "count_latency" field.
- func (m *ChannelMonitorDailyRollupMutation) ResetCountLatency() {
- m.count_latency = nil
- m.addcount_latency = nil
- }
- // SetSumPingLatencyMs sets the "sum_ping_latency_ms" field.
- func (m *ChannelMonitorDailyRollupMutation) SetSumPingLatencyMs(i int64) {
- m.sum_ping_latency_ms = &i
- m.addsum_ping_latency_ms = nil
- }
- // SumPingLatencyMs returns the value of the "sum_ping_latency_ms" field in the mutation.
- func (m *ChannelMonitorDailyRollupMutation) SumPingLatencyMs() (r int64, exists bool) {
- v := m.sum_ping_latency_ms
- if v == nil {
- return
- }
- return *v, true
- }
- // OldSumPingLatencyMs returns the old "sum_ping_latency_ms" field's value of the ChannelMonitorDailyRollup entity.
- // If the ChannelMonitorDailyRollup object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *ChannelMonitorDailyRollupMutation) OldSumPingLatencyMs(ctx context.Context) (v int64, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldSumPingLatencyMs is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldSumPingLatencyMs requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldSumPingLatencyMs: %w", err)
- }
- return oldValue.SumPingLatencyMs, nil
- }
- // AddSumPingLatencyMs adds i to the "sum_ping_latency_ms" field.
- func (m *ChannelMonitorDailyRollupMutation) AddSumPingLatencyMs(i int64) {
- if m.addsum_ping_latency_ms != nil {
- *m.addsum_ping_latency_ms += i
- } else {
- m.addsum_ping_latency_ms = &i
- }
- }
- // AddedSumPingLatencyMs returns the value that was added to the "sum_ping_latency_ms" field in this mutation.
- func (m *ChannelMonitorDailyRollupMutation) AddedSumPingLatencyMs() (r int64, exists bool) {
- v := m.addsum_ping_latency_ms
- if v == nil {
- return
- }
- return *v, true
- }
- // ResetSumPingLatencyMs resets all changes to the "sum_ping_latency_ms" field.
- func (m *ChannelMonitorDailyRollupMutation) ResetSumPingLatencyMs() {
- m.sum_ping_latency_ms = nil
- m.addsum_ping_latency_ms = nil
- }
- // SetCountPingLatency sets the "count_ping_latency" field.
- func (m *ChannelMonitorDailyRollupMutation) SetCountPingLatency(i int) {
- m.count_ping_latency = &i
- m.addcount_ping_latency = nil
- }
- // CountPingLatency returns the value of the "count_ping_latency" field in the mutation.
- func (m *ChannelMonitorDailyRollupMutation) CountPingLatency() (r int, exists bool) {
- v := m.count_ping_latency
- if v == nil {
- return
- }
- return *v, true
- }
- // OldCountPingLatency returns the old "count_ping_latency" field's value of the ChannelMonitorDailyRollup entity.
- // If the ChannelMonitorDailyRollup object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *ChannelMonitorDailyRollupMutation) OldCountPingLatency(ctx context.Context) (v int, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldCountPingLatency is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldCountPingLatency requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldCountPingLatency: %w", err)
- }
- return oldValue.CountPingLatency, nil
- }
- // AddCountPingLatency adds i to the "count_ping_latency" field.
- func (m *ChannelMonitorDailyRollupMutation) AddCountPingLatency(i int) {
- if m.addcount_ping_latency != nil {
- *m.addcount_ping_latency += i
- } else {
- m.addcount_ping_latency = &i
- }
- }
- // AddedCountPingLatency returns the value that was added to the "count_ping_latency" field in this mutation.
- func (m *ChannelMonitorDailyRollupMutation) AddedCountPingLatency() (r int, exists bool) {
- v := m.addcount_ping_latency
- if v == nil {
- return
- }
- return *v, true
- }
- // ResetCountPingLatency resets all changes to the "count_ping_latency" field.
- func (m *ChannelMonitorDailyRollupMutation) ResetCountPingLatency() {
- m.count_ping_latency = nil
- m.addcount_ping_latency = nil
- }
- // SetComputedAt sets the "computed_at" field.
- func (m *ChannelMonitorDailyRollupMutation) SetComputedAt(t time.Time) {
- m.computed_at = &t
- }
- // ComputedAt returns the value of the "computed_at" field in the mutation.
- func (m *ChannelMonitorDailyRollupMutation) ComputedAt() (r time.Time, exists bool) {
- v := m.computed_at
- if v == nil {
- return
- }
- return *v, true
- }
- // OldComputedAt returns the old "computed_at" field's value of the ChannelMonitorDailyRollup entity.
- // If the ChannelMonitorDailyRollup object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *ChannelMonitorDailyRollupMutation) OldComputedAt(ctx context.Context) (v time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldComputedAt is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldComputedAt requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldComputedAt: %w", err)
- }
- return oldValue.ComputedAt, nil
- }
- // ResetComputedAt resets all changes to the "computed_at" field.
- func (m *ChannelMonitorDailyRollupMutation) ResetComputedAt() {
- m.computed_at = nil
- }
- // ClearMonitor clears the "monitor" edge to the ChannelMonitor entity.
- func (m *ChannelMonitorDailyRollupMutation) ClearMonitor() {
- m.clearedmonitor = true
- m.clearedFields[channelmonitordailyrollup.FieldMonitorID] = struct{}{}
- }
- // MonitorCleared reports if the "monitor" edge to the ChannelMonitor entity was cleared.
- func (m *ChannelMonitorDailyRollupMutation) MonitorCleared() bool {
- return m.clearedmonitor
- }
- // MonitorIDs returns the "monitor" edge IDs in the mutation.
- // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
- // MonitorID instead. It exists only for internal usage by the builders.
- func (m *ChannelMonitorDailyRollupMutation) MonitorIDs() (ids []int64) {
- if id := m.monitor; id != nil {
- ids = append(ids, *id)
- }
- return
- }
- // ResetMonitor resets all changes to the "monitor" edge.
- func (m *ChannelMonitorDailyRollupMutation) ResetMonitor() {
- m.monitor = nil
- m.clearedmonitor = false
- }
- // Where appends a list predicates to the ChannelMonitorDailyRollupMutation builder.
- func (m *ChannelMonitorDailyRollupMutation) Where(ps ...predicate.ChannelMonitorDailyRollup) {
- m.predicates = append(m.predicates, ps...)
- }
- // WhereP appends storage-level predicates to the ChannelMonitorDailyRollupMutation builder. Using this method,
- // users can use type-assertion to append predicates that do not depend on any generated package.
- func (m *ChannelMonitorDailyRollupMutation) WhereP(ps ...func(*sql.Selector)) {
- p := make([]predicate.ChannelMonitorDailyRollup, len(ps))
- for i := range ps {
- p[i] = ps[i]
- }
- m.Where(p...)
- }
- // Op returns the operation name.
- func (m *ChannelMonitorDailyRollupMutation) Op() Op {
- return m.op
- }
- // SetOp allows setting the mutation operation.
- func (m *ChannelMonitorDailyRollupMutation) SetOp(op Op) {
- m.op = op
- }
- // Type returns the node type of this mutation (ChannelMonitorDailyRollup).
- func (m *ChannelMonitorDailyRollupMutation) Type() string {
- return m.typ
- }
- // Fields returns all fields that were changed during this mutation. Note that in
- // order to get all numeric fields that were incremented/decremented, call
- // AddedFields().
- func (m *ChannelMonitorDailyRollupMutation) Fields() []string {
- fields := make([]string, 0, 14)
- if m.monitor != nil {
- fields = append(fields, channelmonitordailyrollup.FieldMonitorID)
- }
- if m.model != nil {
- fields = append(fields, channelmonitordailyrollup.FieldModel)
- }
- if m.bucket_date != nil {
- fields = append(fields, channelmonitordailyrollup.FieldBucketDate)
- }
- if m.total_checks != nil {
- fields = append(fields, channelmonitordailyrollup.FieldTotalChecks)
- }
- if m.ok_count != nil {
- fields = append(fields, channelmonitordailyrollup.FieldOkCount)
- }
- if m.operational_count != nil {
- fields = append(fields, channelmonitordailyrollup.FieldOperationalCount)
- }
- if m.degraded_count != nil {
- fields = append(fields, channelmonitordailyrollup.FieldDegradedCount)
- }
- if m.failed_count != nil {
- fields = append(fields, channelmonitordailyrollup.FieldFailedCount)
- }
- if m.error_count != nil {
- fields = append(fields, channelmonitordailyrollup.FieldErrorCount)
- }
- if m.sum_latency_ms != nil {
- fields = append(fields, channelmonitordailyrollup.FieldSumLatencyMs)
- }
- if m.count_latency != nil {
- fields = append(fields, channelmonitordailyrollup.FieldCountLatency)
- }
- if m.sum_ping_latency_ms != nil {
- fields = append(fields, channelmonitordailyrollup.FieldSumPingLatencyMs)
- }
- if m.count_ping_latency != nil {
- fields = append(fields, channelmonitordailyrollup.FieldCountPingLatency)
- }
- if m.computed_at != nil {
- fields = append(fields, channelmonitordailyrollup.FieldComputedAt)
- }
- return fields
- }
- // Field returns the value of a field with the given name. The second boolean
- // return value indicates that this field was not set, or was not defined in the
- // schema.
- func (m *ChannelMonitorDailyRollupMutation) Field(name string) (ent.Value, bool) {
- switch name {
- case channelmonitordailyrollup.FieldMonitorID:
- return m.MonitorID()
- case channelmonitordailyrollup.FieldModel:
- return m.Model()
- case channelmonitordailyrollup.FieldBucketDate:
- return m.BucketDate()
- case channelmonitordailyrollup.FieldTotalChecks:
- return m.TotalChecks()
- case channelmonitordailyrollup.FieldOkCount:
- return m.OkCount()
- case channelmonitordailyrollup.FieldOperationalCount:
- return m.OperationalCount()
- case channelmonitordailyrollup.FieldDegradedCount:
- return m.DegradedCount()
- case channelmonitordailyrollup.FieldFailedCount:
- return m.FailedCount()
- case channelmonitordailyrollup.FieldErrorCount:
- return m.ErrorCount()
- case channelmonitordailyrollup.FieldSumLatencyMs:
- return m.SumLatencyMs()
- case channelmonitordailyrollup.FieldCountLatency:
- return m.CountLatency()
- case channelmonitordailyrollup.FieldSumPingLatencyMs:
- return m.SumPingLatencyMs()
- case channelmonitordailyrollup.FieldCountPingLatency:
- return m.CountPingLatency()
- case channelmonitordailyrollup.FieldComputedAt:
- return m.ComputedAt()
- }
- return nil, false
- }
- // OldField returns the old value of the field from the database. An error is
- // returned if the mutation operation is not UpdateOne, or the query to the
- // database failed.
- func (m *ChannelMonitorDailyRollupMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
- switch name {
- case channelmonitordailyrollup.FieldMonitorID:
- return m.OldMonitorID(ctx)
- case channelmonitordailyrollup.FieldModel:
- return m.OldModel(ctx)
- case channelmonitordailyrollup.FieldBucketDate:
- return m.OldBucketDate(ctx)
- case channelmonitordailyrollup.FieldTotalChecks:
- return m.OldTotalChecks(ctx)
- case channelmonitordailyrollup.FieldOkCount:
- return m.OldOkCount(ctx)
- case channelmonitordailyrollup.FieldOperationalCount:
- return m.OldOperationalCount(ctx)
- case channelmonitordailyrollup.FieldDegradedCount:
- return m.OldDegradedCount(ctx)
- case channelmonitordailyrollup.FieldFailedCount:
- return m.OldFailedCount(ctx)
- case channelmonitordailyrollup.FieldErrorCount:
- return m.OldErrorCount(ctx)
- case channelmonitordailyrollup.FieldSumLatencyMs:
- return m.OldSumLatencyMs(ctx)
- case channelmonitordailyrollup.FieldCountLatency:
- return m.OldCountLatency(ctx)
- case channelmonitordailyrollup.FieldSumPingLatencyMs:
- return m.OldSumPingLatencyMs(ctx)
- case channelmonitordailyrollup.FieldCountPingLatency:
- return m.OldCountPingLatency(ctx)
- case channelmonitordailyrollup.FieldComputedAt:
- return m.OldComputedAt(ctx)
- }
- return nil, fmt.Errorf("unknown ChannelMonitorDailyRollup field %s", name)
- }
- // SetField sets the value of a field with the given name. It returns an error if
- // the field is not defined in the schema, or if the type mismatched the field
- // type.
- func (m *ChannelMonitorDailyRollupMutation) SetField(name string, value ent.Value) error {
- switch name {
- case channelmonitordailyrollup.FieldMonitorID:
- v, ok := value.(int64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetMonitorID(v)
- return nil
- case channelmonitordailyrollup.FieldModel:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetModel(v)
- return nil
- case channelmonitordailyrollup.FieldBucketDate:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetBucketDate(v)
- return nil
- case channelmonitordailyrollup.FieldTotalChecks:
- v, ok := value.(int)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetTotalChecks(v)
- return nil
- case channelmonitordailyrollup.FieldOkCount:
- v, ok := value.(int)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetOkCount(v)
- return nil
- case channelmonitordailyrollup.FieldOperationalCount:
- v, ok := value.(int)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetOperationalCount(v)
- return nil
- case channelmonitordailyrollup.FieldDegradedCount:
- v, ok := value.(int)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetDegradedCount(v)
- return nil
- case channelmonitordailyrollup.FieldFailedCount:
- v, ok := value.(int)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetFailedCount(v)
- return nil
- case channelmonitordailyrollup.FieldErrorCount:
- v, ok := value.(int)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetErrorCount(v)
- return nil
- case channelmonitordailyrollup.FieldSumLatencyMs:
- v, ok := value.(int64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetSumLatencyMs(v)
- return nil
- case channelmonitordailyrollup.FieldCountLatency:
- v, ok := value.(int)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetCountLatency(v)
- return nil
- case channelmonitordailyrollup.FieldSumPingLatencyMs:
- v, ok := value.(int64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetSumPingLatencyMs(v)
- return nil
- case channelmonitordailyrollup.FieldCountPingLatency:
- v, ok := value.(int)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetCountPingLatency(v)
- return nil
- case channelmonitordailyrollup.FieldComputedAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetComputedAt(v)
- return nil
- }
- return fmt.Errorf("unknown ChannelMonitorDailyRollup field %s", name)
- }
- // AddedFields returns all numeric fields that were incremented/decremented during
- // this mutation.
- func (m *ChannelMonitorDailyRollupMutation) AddedFields() []string {
- var fields []string
- if m.addtotal_checks != nil {
- fields = append(fields, channelmonitordailyrollup.FieldTotalChecks)
- }
- if m.addok_count != nil {
- fields = append(fields, channelmonitordailyrollup.FieldOkCount)
- }
- if m.addoperational_count != nil {
- fields = append(fields, channelmonitordailyrollup.FieldOperationalCount)
- }
- if m.adddegraded_count != nil {
- fields = append(fields, channelmonitordailyrollup.FieldDegradedCount)
- }
- if m.addfailed_count != nil {
- fields = append(fields, channelmonitordailyrollup.FieldFailedCount)
- }
- if m.adderror_count != nil {
- fields = append(fields, channelmonitordailyrollup.FieldErrorCount)
- }
- if m.addsum_latency_ms != nil {
- fields = append(fields, channelmonitordailyrollup.FieldSumLatencyMs)
- }
- if m.addcount_latency != nil {
- fields = append(fields, channelmonitordailyrollup.FieldCountLatency)
- }
- if m.addsum_ping_latency_ms != nil {
- fields = append(fields, channelmonitordailyrollup.FieldSumPingLatencyMs)
- }
- if m.addcount_ping_latency != nil {
- fields = append(fields, channelmonitordailyrollup.FieldCountPingLatency)
- }
- return fields
- }
- // AddedField returns the numeric value that was incremented/decremented on a field
- // with the given name. The second boolean return value indicates that this field
- // was not set, or was not defined in the schema.
- func (m *ChannelMonitorDailyRollupMutation) AddedField(name string) (ent.Value, bool) {
- switch name {
- case channelmonitordailyrollup.FieldTotalChecks:
- return m.AddedTotalChecks()
- case channelmonitordailyrollup.FieldOkCount:
- return m.AddedOkCount()
- case channelmonitordailyrollup.FieldOperationalCount:
- return m.AddedOperationalCount()
- case channelmonitordailyrollup.FieldDegradedCount:
- return m.AddedDegradedCount()
- case channelmonitordailyrollup.FieldFailedCount:
- return m.AddedFailedCount()
- case channelmonitordailyrollup.FieldErrorCount:
- return m.AddedErrorCount()
- case channelmonitordailyrollup.FieldSumLatencyMs:
- return m.AddedSumLatencyMs()
- case channelmonitordailyrollup.FieldCountLatency:
- return m.AddedCountLatency()
- case channelmonitordailyrollup.FieldSumPingLatencyMs:
- return m.AddedSumPingLatencyMs()
- case channelmonitordailyrollup.FieldCountPingLatency:
- return m.AddedCountPingLatency()
- }
- return nil, false
- }
- // AddField adds the value to the field with the given name. It returns an error if
- // the field is not defined in the schema, or if the type mismatched the field
- // type.
- func (m *ChannelMonitorDailyRollupMutation) AddField(name string, value ent.Value) error {
- switch name {
- case channelmonitordailyrollup.FieldTotalChecks:
- v, ok := value.(int)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.AddTotalChecks(v)
- return nil
- case channelmonitordailyrollup.FieldOkCount:
- v, ok := value.(int)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.AddOkCount(v)
- return nil
- case channelmonitordailyrollup.FieldOperationalCount:
- v, ok := value.(int)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.AddOperationalCount(v)
- return nil
- case channelmonitordailyrollup.FieldDegradedCount:
- v, ok := value.(int)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.AddDegradedCount(v)
- return nil
- case channelmonitordailyrollup.FieldFailedCount:
- v, ok := value.(int)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.AddFailedCount(v)
- return nil
- case channelmonitordailyrollup.FieldErrorCount:
- v, ok := value.(int)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.AddErrorCount(v)
- return nil
- case channelmonitordailyrollup.FieldSumLatencyMs:
- v, ok := value.(int64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.AddSumLatencyMs(v)
- return nil
- case channelmonitordailyrollup.FieldCountLatency:
- v, ok := value.(int)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.AddCountLatency(v)
- return nil
- case channelmonitordailyrollup.FieldSumPingLatencyMs:
- v, ok := value.(int64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.AddSumPingLatencyMs(v)
- return nil
- case channelmonitordailyrollup.FieldCountPingLatency:
- v, ok := value.(int)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.AddCountPingLatency(v)
- return nil
- }
- return fmt.Errorf("unknown ChannelMonitorDailyRollup numeric field %s", name)
- }
- // ClearedFields returns all nullable fields that were cleared during this
- // mutation.
- func (m *ChannelMonitorDailyRollupMutation) ClearedFields() []string {
- return nil
- }
- // FieldCleared returns a boolean indicating if a field with the given name was
- // cleared in this mutation.
- func (m *ChannelMonitorDailyRollupMutation) FieldCleared(name string) bool {
- _, ok := m.clearedFields[name]
- return ok
- }
- // ClearField clears the value of the field with the given name. It returns an
- // error if the field is not defined in the schema.
- func (m *ChannelMonitorDailyRollupMutation) ClearField(name string) error {
- return fmt.Errorf("unknown ChannelMonitorDailyRollup nullable field %s", name)
- }
- // ResetField resets all changes in the mutation for the field with the given name.
- // It returns an error if the field is not defined in the schema.
- func (m *ChannelMonitorDailyRollupMutation) ResetField(name string) error {
- switch name {
- case channelmonitordailyrollup.FieldMonitorID:
- m.ResetMonitorID()
- return nil
- case channelmonitordailyrollup.FieldModel:
- m.ResetModel()
- return nil
- case channelmonitordailyrollup.FieldBucketDate:
- m.ResetBucketDate()
- return nil
- case channelmonitordailyrollup.FieldTotalChecks:
- m.ResetTotalChecks()
- return nil
- case channelmonitordailyrollup.FieldOkCount:
- m.ResetOkCount()
- return nil
- case channelmonitordailyrollup.FieldOperationalCount:
- m.ResetOperationalCount()
- return nil
- case channelmonitordailyrollup.FieldDegradedCount:
- m.ResetDegradedCount()
- return nil
- case channelmonitordailyrollup.FieldFailedCount:
- m.ResetFailedCount()
- return nil
- case channelmonitordailyrollup.FieldErrorCount:
- m.ResetErrorCount()
- return nil
- case channelmonitordailyrollup.FieldSumLatencyMs:
- m.ResetSumLatencyMs()
- return nil
- case channelmonitordailyrollup.FieldCountLatency:
- m.ResetCountLatency()
- return nil
- case channelmonitordailyrollup.FieldSumPingLatencyMs:
- m.ResetSumPingLatencyMs()
- return nil
- case channelmonitordailyrollup.FieldCountPingLatency:
- m.ResetCountPingLatency()
- return nil
- case channelmonitordailyrollup.FieldComputedAt:
- m.ResetComputedAt()
- return nil
- }
- return fmt.Errorf("unknown ChannelMonitorDailyRollup field %s", name)
- }
- // AddedEdges returns all edge names that were set/added in this mutation.
- func (m *ChannelMonitorDailyRollupMutation) AddedEdges() []string {
- edges := make([]string, 0, 1)
- if m.monitor != nil {
- edges = append(edges, channelmonitordailyrollup.EdgeMonitor)
- }
- return edges
- }
- // AddedIDs returns all IDs (to other nodes) that were added for the given edge
- // name in this mutation.
- func (m *ChannelMonitorDailyRollupMutation) AddedIDs(name string) []ent.Value {
- switch name {
- case channelmonitordailyrollup.EdgeMonitor:
- if id := m.monitor; id != nil {
- return []ent.Value{*id}
- }
- }
- return nil
- }
- // RemovedEdges returns all edge names that were removed in this mutation.
- func (m *ChannelMonitorDailyRollupMutation) RemovedEdges() []string {
- edges := make([]string, 0, 1)
- return edges
- }
- // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
- // the given name in this mutation.
- func (m *ChannelMonitorDailyRollupMutation) RemovedIDs(name string) []ent.Value {
- return nil
- }
- // ClearedEdges returns all edge names that were cleared in this mutation.
- func (m *ChannelMonitorDailyRollupMutation) ClearedEdges() []string {
- edges := make([]string, 0, 1)
- if m.clearedmonitor {
- edges = append(edges, channelmonitordailyrollup.EdgeMonitor)
- }
- return edges
- }
- // EdgeCleared returns a boolean which indicates if the edge with the given name
- // was cleared in this mutation.
- func (m *ChannelMonitorDailyRollupMutation) EdgeCleared(name string) bool {
- switch name {
- case channelmonitordailyrollup.EdgeMonitor:
- return m.clearedmonitor
- }
- return false
- }
- // ClearEdge clears the value of the edge with the given name. It returns an error
- // if that edge is not defined in the schema.
- func (m *ChannelMonitorDailyRollupMutation) ClearEdge(name string) error {
- switch name {
- case channelmonitordailyrollup.EdgeMonitor:
- m.ClearMonitor()
- return nil
- }
- return fmt.Errorf("unknown ChannelMonitorDailyRollup unique edge %s", name)
- }
- // ResetEdge resets all changes to the edge with the given name in this mutation.
- // It returns an error if the edge is not defined in the schema.
- func (m *ChannelMonitorDailyRollupMutation) ResetEdge(name string) error {
- switch name {
- case channelmonitordailyrollup.EdgeMonitor:
- m.ResetMonitor()
- return nil
- }
- return fmt.Errorf("unknown ChannelMonitorDailyRollup edge %s", name)
- }
- // ChannelMonitorHistoryMutation represents an operation that mutates the ChannelMonitorHistory nodes in the graph.
- type ChannelMonitorHistoryMutation struct {
- config
- op Op
- typ string
- id *int64
- model *string
- status *channelmonitorhistory.Status
- latency_ms *int
- addlatency_ms *int
- ping_latency_ms *int
- addping_latency_ms *int
- message *string
- quota **domain.MonitorQuotaSnapshot
- checked_at *time.Time
- clearedFields map[string]struct{}
- monitor *int64
- clearedmonitor bool
- done bool
- oldValue func(context.Context) (*ChannelMonitorHistory, error)
- predicates []predicate.ChannelMonitorHistory
- }
- var _ ent.Mutation = (*ChannelMonitorHistoryMutation)(nil)
- // channelmonitorhistoryOption allows management of the mutation configuration using functional options.
- type channelmonitorhistoryOption func(*ChannelMonitorHistoryMutation)
- // newChannelMonitorHistoryMutation creates new mutation for the ChannelMonitorHistory entity.
- func newChannelMonitorHistoryMutation(c config, op Op, opts ...channelmonitorhistoryOption) *ChannelMonitorHistoryMutation {
- m := &ChannelMonitorHistoryMutation{
- config: c,
- op: op,
- typ: TypeChannelMonitorHistory,
- clearedFields: make(map[string]struct{}),
- }
- for _, opt := range opts {
- opt(m)
- }
- return m
- }
- // withChannelMonitorHistoryID sets the ID field of the mutation.
- func withChannelMonitorHistoryID(id int64) channelmonitorhistoryOption {
- return func(m *ChannelMonitorHistoryMutation) {
- var (
- err error
- once sync.Once
- value *ChannelMonitorHistory
- )
- m.oldValue = func(ctx context.Context) (*ChannelMonitorHistory, error) {
- once.Do(func() {
- if m.done {
- err = errors.New("querying old values post mutation is not allowed")
- } else {
- value, err = m.Client().ChannelMonitorHistory.Get(ctx, id)
- }
- })
- return value, err
- }
- m.id = &id
- }
- }
- // withChannelMonitorHistory sets the old ChannelMonitorHistory of the mutation.
- func withChannelMonitorHistory(node *ChannelMonitorHistory) channelmonitorhistoryOption {
- return func(m *ChannelMonitorHistoryMutation) {
- m.oldValue = func(context.Context) (*ChannelMonitorHistory, error) {
- return node, nil
- }
- m.id = &node.ID
- }
- }
- // Client returns a new `ent.Client` from the mutation. If the mutation was
- // executed in a transaction (ent.Tx), a transactional client is returned.
- func (m ChannelMonitorHistoryMutation) Client() *Client {
- client := &Client{config: m.config}
- client.init()
- return client
- }
- // Tx returns an `ent.Tx` for mutations that were executed in transactions;
- // it returns an error otherwise.
- func (m ChannelMonitorHistoryMutation) Tx() (*Tx, error) {
- if _, ok := m.driver.(*txDriver); !ok {
- return nil, errors.New("ent: mutation is not running in a transaction")
- }
- tx := &Tx{config: m.config}
- tx.init()
- return tx, nil
- }
- // ID returns the ID value in the mutation. Note that the ID is only available
- // if it was provided to the builder or after it was returned from the database.
- func (m *ChannelMonitorHistoryMutation) ID() (id int64, exists bool) {
- if m.id == nil {
- return
- }
- return *m.id, true
- }
- // IDs queries the database and returns the entity ids that match the mutation's predicate.
- // That means, if the mutation is applied within a transaction with an isolation level such
- // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
- // or updated by the mutation.
- func (m *ChannelMonitorHistoryMutation) IDs(ctx context.Context) ([]int64, error) {
- switch {
- case m.op.Is(OpUpdateOne | OpDeleteOne):
- id, exists := m.ID()
- if exists {
- return []int64{id}, nil
- }
- fallthrough
- case m.op.Is(OpUpdate | OpDelete):
- return m.Client().ChannelMonitorHistory.Query().Where(m.predicates...).IDs(ctx)
- default:
- return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
- }
- }
- // SetMonitorID sets the "monitor_id" field.
- func (m *ChannelMonitorHistoryMutation) SetMonitorID(i int64) {
- m.monitor = &i
- }
- // MonitorID returns the value of the "monitor_id" field in the mutation.
- func (m *ChannelMonitorHistoryMutation) MonitorID() (r int64, exists bool) {
- v := m.monitor
- if v == nil {
- return
- }
- return *v, true
- }
- // OldMonitorID returns the old "monitor_id" field's value of the ChannelMonitorHistory entity.
- // If the ChannelMonitorHistory object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *ChannelMonitorHistoryMutation) OldMonitorID(ctx context.Context) (v int64, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldMonitorID is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldMonitorID requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldMonitorID: %w", err)
- }
- return oldValue.MonitorID, nil
- }
- // ResetMonitorID resets all changes to the "monitor_id" field.
- func (m *ChannelMonitorHistoryMutation) ResetMonitorID() {
- m.monitor = nil
- }
- // SetModel sets the "model" field.
- func (m *ChannelMonitorHistoryMutation) SetModel(s string) {
- m.model = &s
- }
- // Model returns the value of the "model" field in the mutation.
- func (m *ChannelMonitorHistoryMutation) Model() (r string, exists bool) {
- v := m.model
- if v == nil {
- return
- }
- return *v, true
- }
- // OldModel returns the old "model" field's value of the ChannelMonitorHistory entity.
- // If the ChannelMonitorHistory object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *ChannelMonitorHistoryMutation) OldModel(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldModel is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldModel requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldModel: %w", err)
- }
- return oldValue.Model, nil
- }
- // ResetModel resets all changes to the "model" field.
- func (m *ChannelMonitorHistoryMutation) ResetModel() {
- m.model = nil
- }
- // SetStatus sets the "status" field.
- func (m *ChannelMonitorHistoryMutation) SetStatus(c channelmonitorhistory.Status) {
- m.status = &c
- }
- // Status returns the value of the "status" field in the mutation.
- func (m *ChannelMonitorHistoryMutation) Status() (r channelmonitorhistory.Status, exists bool) {
- v := m.status
- if v == nil {
- return
- }
- return *v, true
- }
- // OldStatus returns the old "status" field's value of the ChannelMonitorHistory entity.
- // If the ChannelMonitorHistory object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *ChannelMonitorHistoryMutation) OldStatus(ctx context.Context) (v channelmonitorhistory.Status, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldStatus is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldStatus requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldStatus: %w", err)
- }
- return oldValue.Status, nil
- }
- // ResetStatus resets all changes to the "status" field.
- func (m *ChannelMonitorHistoryMutation) ResetStatus() {
- m.status = nil
- }
- // SetLatencyMs sets the "latency_ms" field.
- func (m *ChannelMonitorHistoryMutation) SetLatencyMs(i int) {
- m.latency_ms = &i
- m.addlatency_ms = nil
- }
- // LatencyMs returns the value of the "latency_ms" field in the mutation.
- func (m *ChannelMonitorHistoryMutation) LatencyMs() (r int, exists bool) {
- v := m.latency_ms
- if v == nil {
- return
- }
- return *v, true
- }
- // OldLatencyMs returns the old "latency_ms" field's value of the ChannelMonitorHistory entity.
- // If the ChannelMonitorHistory object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *ChannelMonitorHistoryMutation) OldLatencyMs(ctx context.Context) (v *int, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldLatencyMs is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldLatencyMs requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldLatencyMs: %w", err)
- }
- return oldValue.LatencyMs, nil
- }
- // AddLatencyMs adds i to the "latency_ms" field.
- func (m *ChannelMonitorHistoryMutation) AddLatencyMs(i int) {
- if m.addlatency_ms != nil {
- *m.addlatency_ms += i
- } else {
- m.addlatency_ms = &i
- }
- }
- // AddedLatencyMs returns the value that was added to the "latency_ms" field in this mutation.
- func (m *ChannelMonitorHistoryMutation) AddedLatencyMs() (r int, exists bool) {
- v := m.addlatency_ms
- if v == nil {
- return
- }
- return *v, true
- }
- // ClearLatencyMs clears the value of the "latency_ms" field.
- func (m *ChannelMonitorHistoryMutation) ClearLatencyMs() {
- m.latency_ms = nil
- m.addlatency_ms = nil
- m.clearedFields[channelmonitorhistory.FieldLatencyMs] = struct{}{}
- }
- // LatencyMsCleared returns if the "latency_ms" field was cleared in this mutation.
- func (m *ChannelMonitorHistoryMutation) LatencyMsCleared() bool {
- _, ok := m.clearedFields[channelmonitorhistory.FieldLatencyMs]
- return ok
- }
- // ResetLatencyMs resets all changes to the "latency_ms" field.
- func (m *ChannelMonitorHistoryMutation) ResetLatencyMs() {
- m.latency_ms = nil
- m.addlatency_ms = nil
- delete(m.clearedFields, channelmonitorhistory.FieldLatencyMs)
- }
- // SetPingLatencyMs sets the "ping_latency_ms" field.
- func (m *ChannelMonitorHistoryMutation) SetPingLatencyMs(i int) {
- m.ping_latency_ms = &i
- m.addping_latency_ms = nil
- }
- // PingLatencyMs returns the value of the "ping_latency_ms" field in the mutation.
- func (m *ChannelMonitorHistoryMutation) PingLatencyMs() (r int, exists bool) {
- v := m.ping_latency_ms
- if v == nil {
- return
- }
- return *v, true
- }
- // OldPingLatencyMs returns the old "ping_latency_ms" field's value of the ChannelMonitorHistory entity.
- // If the ChannelMonitorHistory object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *ChannelMonitorHistoryMutation) OldPingLatencyMs(ctx context.Context) (v *int, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldPingLatencyMs is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldPingLatencyMs requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldPingLatencyMs: %w", err)
- }
- return oldValue.PingLatencyMs, nil
- }
- // AddPingLatencyMs adds i to the "ping_latency_ms" field.
- func (m *ChannelMonitorHistoryMutation) AddPingLatencyMs(i int) {
- if m.addping_latency_ms != nil {
- *m.addping_latency_ms += i
- } else {
- m.addping_latency_ms = &i
- }
- }
- // AddedPingLatencyMs returns the value that was added to the "ping_latency_ms" field in this mutation.
- func (m *ChannelMonitorHistoryMutation) AddedPingLatencyMs() (r int, exists bool) {
- v := m.addping_latency_ms
- if v == nil {
- return
- }
- return *v, true
- }
- // ClearPingLatencyMs clears the value of the "ping_latency_ms" field.
- func (m *ChannelMonitorHistoryMutation) ClearPingLatencyMs() {
- m.ping_latency_ms = nil
- m.addping_latency_ms = nil
- m.clearedFields[channelmonitorhistory.FieldPingLatencyMs] = struct{}{}
- }
- // PingLatencyMsCleared returns if the "ping_latency_ms" field was cleared in this mutation.
- func (m *ChannelMonitorHistoryMutation) PingLatencyMsCleared() bool {
- _, ok := m.clearedFields[channelmonitorhistory.FieldPingLatencyMs]
- return ok
- }
- // ResetPingLatencyMs resets all changes to the "ping_latency_ms" field.
- func (m *ChannelMonitorHistoryMutation) ResetPingLatencyMs() {
- m.ping_latency_ms = nil
- m.addping_latency_ms = nil
- delete(m.clearedFields, channelmonitorhistory.FieldPingLatencyMs)
- }
- // SetMessage sets the "message" field.
- func (m *ChannelMonitorHistoryMutation) SetMessage(s string) {
- m.message = &s
- }
- // Message returns the value of the "message" field in the mutation.
- func (m *ChannelMonitorHistoryMutation) Message() (r string, exists bool) {
- v := m.message
- if v == nil {
- return
- }
- return *v, true
- }
- // OldMessage returns the old "message" field's value of the ChannelMonitorHistory entity.
- // If the ChannelMonitorHistory object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *ChannelMonitorHistoryMutation) OldMessage(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldMessage is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldMessage requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldMessage: %w", err)
- }
- return oldValue.Message, nil
- }
- // ClearMessage clears the value of the "message" field.
- func (m *ChannelMonitorHistoryMutation) ClearMessage() {
- m.message = nil
- m.clearedFields[channelmonitorhistory.FieldMessage] = struct{}{}
- }
- // MessageCleared returns if the "message" field was cleared in this mutation.
- func (m *ChannelMonitorHistoryMutation) MessageCleared() bool {
- _, ok := m.clearedFields[channelmonitorhistory.FieldMessage]
- return ok
- }
- // ResetMessage resets all changes to the "message" field.
- func (m *ChannelMonitorHistoryMutation) ResetMessage() {
- m.message = nil
- delete(m.clearedFields, channelmonitorhistory.FieldMessage)
- }
- // SetQuota sets the "quota" field.
- func (m *ChannelMonitorHistoryMutation) SetQuota(dqs *domain.MonitorQuotaSnapshot) {
- m.quota = &dqs
- }
- // Quota returns the value of the "quota" field in the mutation.
- func (m *ChannelMonitorHistoryMutation) Quota() (r *domain.MonitorQuotaSnapshot, exists bool) {
- v := m.quota
- if v == nil {
- return
- }
- return *v, true
- }
- // OldQuota returns the old "quota" field's value of the ChannelMonitorHistory entity.
- // If the ChannelMonitorHistory object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *ChannelMonitorHistoryMutation) OldQuota(ctx context.Context) (v *domain.MonitorQuotaSnapshot, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldQuota is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldQuota requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldQuota: %w", err)
- }
- return oldValue.Quota, nil
- }
- // ClearQuota clears the value of the "quota" field.
- func (m *ChannelMonitorHistoryMutation) ClearQuota() {
- m.quota = nil
- m.clearedFields[channelmonitorhistory.FieldQuota] = struct{}{}
- }
- // QuotaCleared returns if the "quota" field was cleared in this mutation.
- func (m *ChannelMonitorHistoryMutation) QuotaCleared() bool {
- _, ok := m.clearedFields[channelmonitorhistory.FieldQuota]
- return ok
- }
- // ResetQuota resets all changes to the "quota" field.
- func (m *ChannelMonitorHistoryMutation) ResetQuota() {
- m.quota = nil
- delete(m.clearedFields, channelmonitorhistory.FieldQuota)
- }
- // SetCheckedAt sets the "checked_at" field.
- func (m *ChannelMonitorHistoryMutation) SetCheckedAt(t time.Time) {
- m.checked_at = &t
- }
- // CheckedAt returns the value of the "checked_at" field in the mutation.
- func (m *ChannelMonitorHistoryMutation) CheckedAt() (r time.Time, exists bool) {
- v := m.checked_at
- if v == nil {
- return
- }
- return *v, true
- }
- // OldCheckedAt returns the old "checked_at" field's value of the ChannelMonitorHistory entity.
- // If the ChannelMonitorHistory object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *ChannelMonitorHistoryMutation) OldCheckedAt(ctx context.Context) (v time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldCheckedAt is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldCheckedAt requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldCheckedAt: %w", err)
- }
- return oldValue.CheckedAt, nil
- }
- // ResetCheckedAt resets all changes to the "checked_at" field.
- func (m *ChannelMonitorHistoryMutation) ResetCheckedAt() {
- m.checked_at = nil
- }
- // ClearMonitor clears the "monitor" edge to the ChannelMonitor entity.
- func (m *ChannelMonitorHistoryMutation) ClearMonitor() {
- m.clearedmonitor = true
- m.clearedFields[channelmonitorhistory.FieldMonitorID] = struct{}{}
- }
- // MonitorCleared reports if the "monitor" edge to the ChannelMonitor entity was cleared.
- func (m *ChannelMonitorHistoryMutation) MonitorCleared() bool {
- return m.clearedmonitor
- }
- // MonitorIDs returns the "monitor" edge IDs in the mutation.
- // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
- // MonitorID instead. It exists only for internal usage by the builders.
- func (m *ChannelMonitorHistoryMutation) MonitorIDs() (ids []int64) {
- if id := m.monitor; id != nil {
- ids = append(ids, *id)
- }
- return
- }
- // ResetMonitor resets all changes to the "monitor" edge.
- func (m *ChannelMonitorHistoryMutation) ResetMonitor() {
- m.monitor = nil
- m.clearedmonitor = false
- }
- // Where appends a list predicates to the ChannelMonitorHistoryMutation builder.
- func (m *ChannelMonitorHistoryMutation) Where(ps ...predicate.ChannelMonitorHistory) {
- m.predicates = append(m.predicates, ps...)
- }
- // WhereP appends storage-level predicates to the ChannelMonitorHistoryMutation builder. Using this method,
- // users can use type-assertion to append predicates that do not depend on any generated package.
- func (m *ChannelMonitorHistoryMutation) WhereP(ps ...func(*sql.Selector)) {
- p := make([]predicate.ChannelMonitorHistory, len(ps))
- for i := range ps {
- p[i] = ps[i]
- }
- m.Where(p...)
- }
- // Op returns the operation name.
- func (m *ChannelMonitorHistoryMutation) Op() Op {
- return m.op
- }
- // SetOp allows setting the mutation operation.
- func (m *ChannelMonitorHistoryMutation) SetOp(op Op) {
- m.op = op
- }
- // Type returns the node type of this mutation (ChannelMonitorHistory).
- func (m *ChannelMonitorHistoryMutation) Type() string {
- return m.typ
- }
- // Fields returns all fields that were changed during this mutation. Note that in
- // order to get all numeric fields that were incremented/decremented, call
- // AddedFields().
- func (m *ChannelMonitorHistoryMutation) Fields() []string {
- fields := make([]string, 0, 8)
- if m.monitor != nil {
- fields = append(fields, channelmonitorhistory.FieldMonitorID)
- }
- if m.model != nil {
- fields = append(fields, channelmonitorhistory.FieldModel)
- }
- if m.status != nil {
- fields = append(fields, channelmonitorhistory.FieldStatus)
- }
- if m.latency_ms != nil {
- fields = append(fields, channelmonitorhistory.FieldLatencyMs)
- }
- if m.ping_latency_ms != nil {
- fields = append(fields, channelmonitorhistory.FieldPingLatencyMs)
- }
- if m.message != nil {
- fields = append(fields, channelmonitorhistory.FieldMessage)
- }
- if m.quota != nil {
- fields = append(fields, channelmonitorhistory.FieldQuota)
- }
- if m.checked_at != nil {
- fields = append(fields, channelmonitorhistory.FieldCheckedAt)
- }
- return fields
- }
- // Field returns the value of a field with the given name. The second boolean
- // return value indicates that this field was not set, or was not defined in the
- // schema.
- func (m *ChannelMonitorHistoryMutation) Field(name string) (ent.Value, bool) {
- switch name {
- case channelmonitorhistory.FieldMonitorID:
- return m.MonitorID()
- case channelmonitorhistory.FieldModel:
- return m.Model()
- case channelmonitorhistory.FieldStatus:
- return m.Status()
- case channelmonitorhistory.FieldLatencyMs:
- return m.LatencyMs()
- case channelmonitorhistory.FieldPingLatencyMs:
- return m.PingLatencyMs()
- case channelmonitorhistory.FieldMessage:
- return m.Message()
- case channelmonitorhistory.FieldQuota:
- return m.Quota()
- case channelmonitorhistory.FieldCheckedAt:
- return m.CheckedAt()
- }
- return nil, false
- }
- // OldField returns the old value of the field from the database. An error is
- // returned if the mutation operation is not UpdateOne, or the query to the
- // database failed.
- func (m *ChannelMonitorHistoryMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
- switch name {
- case channelmonitorhistory.FieldMonitorID:
- return m.OldMonitorID(ctx)
- case channelmonitorhistory.FieldModel:
- return m.OldModel(ctx)
- case channelmonitorhistory.FieldStatus:
- return m.OldStatus(ctx)
- case channelmonitorhistory.FieldLatencyMs:
- return m.OldLatencyMs(ctx)
- case channelmonitorhistory.FieldPingLatencyMs:
- return m.OldPingLatencyMs(ctx)
- case channelmonitorhistory.FieldMessage:
- return m.OldMessage(ctx)
- case channelmonitorhistory.FieldQuota:
- return m.OldQuota(ctx)
- case channelmonitorhistory.FieldCheckedAt:
- return m.OldCheckedAt(ctx)
- }
- return nil, fmt.Errorf("unknown ChannelMonitorHistory field %s", name)
- }
- // SetField sets the value of a field with the given name. It returns an error if
- // the field is not defined in the schema, or if the type mismatched the field
- // type.
- func (m *ChannelMonitorHistoryMutation) SetField(name string, value ent.Value) error {
- switch name {
- case channelmonitorhistory.FieldMonitorID:
- v, ok := value.(int64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetMonitorID(v)
- return nil
- case channelmonitorhistory.FieldModel:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetModel(v)
- return nil
- case channelmonitorhistory.FieldStatus:
- v, ok := value.(channelmonitorhistory.Status)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetStatus(v)
- return nil
- case channelmonitorhistory.FieldLatencyMs:
- v, ok := value.(int)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetLatencyMs(v)
- return nil
- case channelmonitorhistory.FieldPingLatencyMs:
- v, ok := value.(int)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetPingLatencyMs(v)
- return nil
- case channelmonitorhistory.FieldMessage:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetMessage(v)
- return nil
- case channelmonitorhistory.FieldQuota:
- v, ok := value.(*domain.MonitorQuotaSnapshot)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetQuota(v)
- return nil
- case channelmonitorhistory.FieldCheckedAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetCheckedAt(v)
- return nil
- }
- return fmt.Errorf("unknown ChannelMonitorHistory field %s", name)
- }
- // AddedFields returns all numeric fields that were incremented/decremented during
- // this mutation.
- func (m *ChannelMonitorHistoryMutation) AddedFields() []string {
- var fields []string
- if m.addlatency_ms != nil {
- fields = append(fields, channelmonitorhistory.FieldLatencyMs)
- }
- if m.addping_latency_ms != nil {
- fields = append(fields, channelmonitorhistory.FieldPingLatencyMs)
- }
- return fields
- }
- // AddedField returns the numeric value that was incremented/decremented on a field
- // with the given name. The second boolean return value indicates that this field
- // was not set, or was not defined in the schema.
- func (m *ChannelMonitorHistoryMutation) AddedField(name string) (ent.Value, bool) {
- switch name {
- case channelmonitorhistory.FieldLatencyMs:
- return m.AddedLatencyMs()
- case channelmonitorhistory.FieldPingLatencyMs:
- return m.AddedPingLatencyMs()
- }
- return nil, false
- }
- // AddField adds the value to the field with the given name. It returns an error if
- // the field is not defined in the schema, or if the type mismatched the field
- // type.
- func (m *ChannelMonitorHistoryMutation) AddField(name string, value ent.Value) error {
- switch name {
- case channelmonitorhistory.FieldLatencyMs:
- v, ok := value.(int)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.AddLatencyMs(v)
- return nil
- case channelmonitorhistory.FieldPingLatencyMs:
- v, ok := value.(int)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.AddPingLatencyMs(v)
- return nil
- }
- return fmt.Errorf("unknown ChannelMonitorHistory numeric field %s", name)
- }
- // ClearedFields returns all nullable fields that were cleared during this
- // mutation.
- func (m *ChannelMonitorHistoryMutation) ClearedFields() []string {
- var fields []string
- if m.FieldCleared(channelmonitorhistory.FieldLatencyMs) {
- fields = append(fields, channelmonitorhistory.FieldLatencyMs)
- }
- if m.FieldCleared(channelmonitorhistory.FieldPingLatencyMs) {
- fields = append(fields, channelmonitorhistory.FieldPingLatencyMs)
- }
- if m.FieldCleared(channelmonitorhistory.FieldMessage) {
- fields = append(fields, channelmonitorhistory.FieldMessage)
- }
- if m.FieldCleared(channelmonitorhistory.FieldQuota) {
- fields = append(fields, channelmonitorhistory.FieldQuota)
- }
- return fields
- }
- // FieldCleared returns a boolean indicating if a field with the given name was
- // cleared in this mutation.
- func (m *ChannelMonitorHistoryMutation) FieldCleared(name string) bool {
- _, ok := m.clearedFields[name]
- return ok
- }
- // ClearField clears the value of the field with the given name. It returns an
- // error if the field is not defined in the schema.
- func (m *ChannelMonitorHistoryMutation) ClearField(name string) error {
- switch name {
- case channelmonitorhistory.FieldLatencyMs:
- m.ClearLatencyMs()
- return nil
- case channelmonitorhistory.FieldPingLatencyMs:
- m.ClearPingLatencyMs()
- return nil
- case channelmonitorhistory.FieldMessage:
- m.ClearMessage()
- return nil
- case channelmonitorhistory.FieldQuota:
- m.ClearQuota()
- return nil
- }
- return fmt.Errorf("unknown ChannelMonitorHistory nullable field %s", name)
- }
- // ResetField resets all changes in the mutation for the field with the given name.
- // It returns an error if the field is not defined in the schema.
- func (m *ChannelMonitorHistoryMutation) ResetField(name string) error {
- switch name {
- case channelmonitorhistory.FieldMonitorID:
- m.ResetMonitorID()
- return nil
- case channelmonitorhistory.FieldModel:
- m.ResetModel()
- return nil
- case channelmonitorhistory.FieldStatus:
- m.ResetStatus()
- return nil
- case channelmonitorhistory.FieldLatencyMs:
- m.ResetLatencyMs()
- return nil
- case channelmonitorhistory.FieldPingLatencyMs:
- m.ResetPingLatencyMs()
- return nil
- case channelmonitorhistory.FieldMessage:
- m.ResetMessage()
- return nil
- case channelmonitorhistory.FieldQuota:
- m.ResetQuota()
- return nil
- case channelmonitorhistory.FieldCheckedAt:
- m.ResetCheckedAt()
- return nil
- }
- return fmt.Errorf("unknown ChannelMonitorHistory field %s", name)
- }
- // AddedEdges returns all edge names that were set/added in this mutation.
- func (m *ChannelMonitorHistoryMutation) AddedEdges() []string {
- edges := make([]string, 0, 1)
- if m.monitor != nil {
- edges = append(edges, channelmonitorhistory.EdgeMonitor)
- }
- return edges
- }
- // AddedIDs returns all IDs (to other nodes) that were added for the given edge
- // name in this mutation.
- func (m *ChannelMonitorHistoryMutation) AddedIDs(name string) []ent.Value {
- switch name {
- case channelmonitorhistory.EdgeMonitor:
- if id := m.monitor; id != nil {
- return []ent.Value{*id}
- }
- }
- return nil
- }
- // RemovedEdges returns all edge names that were removed in this mutation.
- func (m *ChannelMonitorHistoryMutation) RemovedEdges() []string {
- edges := make([]string, 0, 1)
- return edges
- }
- // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
- // the given name in this mutation.
- func (m *ChannelMonitorHistoryMutation) RemovedIDs(name string) []ent.Value {
- return nil
- }
- // ClearedEdges returns all edge names that were cleared in this mutation.
- func (m *ChannelMonitorHistoryMutation) ClearedEdges() []string {
- edges := make([]string, 0, 1)
- if m.clearedmonitor {
- edges = append(edges, channelmonitorhistory.EdgeMonitor)
- }
- return edges
- }
- // EdgeCleared returns a boolean which indicates if the edge with the given name
- // was cleared in this mutation.
- func (m *ChannelMonitorHistoryMutation) EdgeCleared(name string) bool {
- switch name {
- case channelmonitorhistory.EdgeMonitor:
- return m.clearedmonitor
- }
- return false
- }
- // ClearEdge clears the value of the edge with the given name. It returns an error
- // if that edge is not defined in the schema.
- func (m *ChannelMonitorHistoryMutation) ClearEdge(name string) error {
- switch name {
- case channelmonitorhistory.EdgeMonitor:
- m.ClearMonitor()
- return nil
- }
- return fmt.Errorf("unknown ChannelMonitorHistory unique edge %s", name)
- }
- // ResetEdge resets all changes to the edge with the given name in this mutation.
- // It returns an error if the edge is not defined in the schema.
- func (m *ChannelMonitorHistoryMutation) ResetEdge(name string) error {
- switch name {
- case channelmonitorhistory.EdgeMonitor:
- m.ResetMonitor()
- return nil
- }
- return fmt.Errorf("unknown ChannelMonitorHistory edge %s", name)
- }
- // ChannelMonitorRequestTemplateMutation represents an operation that mutates the ChannelMonitorRequestTemplate nodes in the graph.
- type ChannelMonitorRequestTemplateMutation struct {
- config
- op Op
- typ string
- id *int64
- created_at *time.Time
- updated_at *time.Time
- name *string
- provider *channelmonitorrequesttemplate.Provider
- api_mode *string
- description *string
- extra_headers *map[string]string
- body_override_mode *string
- body_override *map[string]interface{}
- clearedFields map[string]struct{}
- monitors map[int64]struct{}
- removedmonitors map[int64]struct{}
- clearedmonitors bool
- done bool
- oldValue func(context.Context) (*ChannelMonitorRequestTemplate, error)
- predicates []predicate.ChannelMonitorRequestTemplate
- }
- var _ ent.Mutation = (*ChannelMonitorRequestTemplateMutation)(nil)
- // channelmonitorrequesttemplateOption allows management of the mutation configuration using functional options.
- type channelmonitorrequesttemplateOption func(*ChannelMonitorRequestTemplateMutation)
- // newChannelMonitorRequestTemplateMutation creates new mutation for the ChannelMonitorRequestTemplate entity.
- func newChannelMonitorRequestTemplateMutation(c config, op Op, opts ...channelmonitorrequesttemplateOption) *ChannelMonitorRequestTemplateMutation {
- m := &ChannelMonitorRequestTemplateMutation{
- config: c,
- op: op,
- typ: TypeChannelMonitorRequestTemplate,
- clearedFields: make(map[string]struct{}),
- }
- for _, opt := range opts {
- opt(m)
- }
- return m
- }
- // withChannelMonitorRequestTemplateID sets the ID field of the mutation.
- func withChannelMonitorRequestTemplateID(id int64) channelmonitorrequesttemplateOption {
- return func(m *ChannelMonitorRequestTemplateMutation) {
- var (
- err error
- once sync.Once
- value *ChannelMonitorRequestTemplate
- )
- m.oldValue = func(ctx context.Context) (*ChannelMonitorRequestTemplate, error) {
- once.Do(func() {
- if m.done {
- err = errors.New("querying old values post mutation is not allowed")
- } else {
- value, err = m.Client().ChannelMonitorRequestTemplate.Get(ctx, id)
- }
- })
- return value, err
- }
- m.id = &id
- }
- }
- // withChannelMonitorRequestTemplate sets the old ChannelMonitorRequestTemplate of the mutation.
- func withChannelMonitorRequestTemplate(node *ChannelMonitorRequestTemplate) channelmonitorrequesttemplateOption {
- return func(m *ChannelMonitorRequestTemplateMutation) {
- m.oldValue = func(context.Context) (*ChannelMonitorRequestTemplate, error) {
- return node, nil
- }
- m.id = &node.ID
- }
- }
- // Client returns a new `ent.Client` from the mutation. If the mutation was
- // executed in a transaction (ent.Tx), a transactional client is returned.
- func (m ChannelMonitorRequestTemplateMutation) Client() *Client {
- client := &Client{config: m.config}
- client.init()
- return client
- }
- // Tx returns an `ent.Tx` for mutations that were executed in transactions;
- // it returns an error otherwise.
- func (m ChannelMonitorRequestTemplateMutation) Tx() (*Tx, error) {
- if _, ok := m.driver.(*txDriver); !ok {
- return nil, errors.New("ent: mutation is not running in a transaction")
- }
- tx := &Tx{config: m.config}
- tx.init()
- return tx, nil
- }
- // ID returns the ID value in the mutation. Note that the ID is only available
- // if it was provided to the builder or after it was returned from the database.
- func (m *ChannelMonitorRequestTemplateMutation) ID() (id int64, exists bool) {
- if m.id == nil {
- return
- }
- return *m.id, true
- }
- // IDs queries the database and returns the entity ids that match the mutation's predicate.
- // That means, if the mutation is applied within a transaction with an isolation level such
- // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
- // or updated by the mutation.
- func (m *ChannelMonitorRequestTemplateMutation) IDs(ctx context.Context) ([]int64, error) {
- switch {
- case m.op.Is(OpUpdateOne | OpDeleteOne):
- id, exists := m.ID()
- if exists {
- return []int64{id}, nil
- }
- fallthrough
- case m.op.Is(OpUpdate | OpDelete):
- return m.Client().ChannelMonitorRequestTemplate.Query().Where(m.predicates...).IDs(ctx)
- default:
- return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
- }
- }
- // SetCreatedAt sets the "created_at" field.
- func (m *ChannelMonitorRequestTemplateMutation) SetCreatedAt(t time.Time) {
- m.created_at = &t
- }
- // CreatedAt returns the value of the "created_at" field in the mutation.
- func (m *ChannelMonitorRequestTemplateMutation) CreatedAt() (r time.Time, exists bool) {
- v := m.created_at
- if v == nil {
- return
- }
- return *v, true
- }
- // OldCreatedAt returns the old "created_at" field's value of the ChannelMonitorRequestTemplate entity.
- // If the ChannelMonitorRequestTemplate object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *ChannelMonitorRequestTemplateMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldCreatedAt requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
- }
- return oldValue.CreatedAt, nil
- }
- // ResetCreatedAt resets all changes to the "created_at" field.
- func (m *ChannelMonitorRequestTemplateMutation) ResetCreatedAt() {
- m.created_at = nil
- }
- // SetUpdatedAt sets the "updated_at" field.
- func (m *ChannelMonitorRequestTemplateMutation) SetUpdatedAt(t time.Time) {
- m.updated_at = &t
- }
- // UpdatedAt returns the value of the "updated_at" field in the mutation.
- func (m *ChannelMonitorRequestTemplateMutation) UpdatedAt() (r time.Time, exists bool) {
- v := m.updated_at
- if v == nil {
- return
- }
- return *v, true
- }
- // OldUpdatedAt returns the old "updated_at" field's value of the ChannelMonitorRequestTemplate entity.
- // If the ChannelMonitorRequestTemplate object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *ChannelMonitorRequestTemplateMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
- }
- return oldValue.UpdatedAt, nil
- }
- // ResetUpdatedAt resets all changes to the "updated_at" field.
- func (m *ChannelMonitorRequestTemplateMutation) ResetUpdatedAt() {
- m.updated_at = nil
- }
- // SetName sets the "name" field.
- func (m *ChannelMonitorRequestTemplateMutation) SetName(s string) {
- m.name = &s
- }
- // Name returns the value of the "name" field in the mutation.
- func (m *ChannelMonitorRequestTemplateMutation) Name() (r string, exists bool) {
- v := m.name
- if v == nil {
- return
- }
- return *v, true
- }
- // OldName returns the old "name" field's value of the ChannelMonitorRequestTemplate entity.
- // If the ChannelMonitorRequestTemplate object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *ChannelMonitorRequestTemplateMutation) OldName(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldName is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldName requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldName: %w", err)
- }
- return oldValue.Name, nil
- }
- // ResetName resets all changes to the "name" field.
- func (m *ChannelMonitorRequestTemplateMutation) ResetName() {
- m.name = nil
- }
- // SetProvider sets the "provider" field.
- func (m *ChannelMonitorRequestTemplateMutation) SetProvider(c channelmonitorrequesttemplate.Provider) {
- m.provider = &c
- }
- // Provider returns the value of the "provider" field in the mutation.
- func (m *ChannelMonitorRequestTemplateMutation) Provider() (r channelmonitorrequesttemplate.Provider, exists bool) {
- v := m.provider
- if v == nil {
- return
- }
- return *v, true
- }
- // OldProvider returns the old "provider" field's value of the ChannelMonitorRequestTemplate entity.
- // If the ChannelMonitorRequestTemplate object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *ChannelMonitorRequestTemplateMutation) OldProvider(ctx context.Context) (v channelmonitorrequesttemplate.Provider, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldProvider is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldProvider requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldProvider: %w", err)
- }
- return oldValue.Provider, nil
- }
- // ResetProvider resets all changes to the "provider" field.
- func (m *ChannelMonitorRequestTemplateMutation) ResetProvider() {
- m.provider = nil
- }
- // SetAPIMode sets the "api_mode" field.
- func (m *ChannelMonitorRequestTemplateMutation) SetAPIMode(s string) {
- m.api_mode = &s
- }
- // APIMode returns the value of the "api_mode" field in the mutation.
- func (m *ChannelMonitorRequestTemplateMutation) APIMode() (r string, exists bool) {
- v := m.api_mode
- if v == nil {
- return
- }
- return *v, true
- }
- // OldAPIMode returns the old "api_mode" field's value of the ChannelMonitorRequestTemplate entity.
- // If the ChannelMonitorRequestTemplate object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *ChannelMonitorRequestTemplateMutation) OldAPIMode(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldAPIMode is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldAPIMode requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldAPIMode: %w", err)
- }
- return oldValue.APIMode, nil
- }
- // ResetAPIMode resets all changes to the "api_mode" field.
- func (m *ChannelMonitorRequestTemplateMutation) ResetAPIMode() {
- m.api_mode = nil
- }
- // SetDescription sets the "description" field.
- func (m *ChannelMonitorRequestTemplateMutation) SetDescription(s string) {
- m.description = &s
- }
- // Description returns the value of the "description" field in the mutation.
- func (m *ChannelMonitorRequestTemplateMutation) Description() (r string, exists bool) {
- v := m.description
- if v == nil {
- return
- }
- return *v, true
- }
- // OldDescription returns the old "description" field's value of the ChannelMonitorRequestTemplate entity.
- // If the ChannelMonitorRequestTemplate object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *ChannelMonitorRequestTemplateMutation) OldDescription(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldDescription is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldDescription requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldDescription: %w", err)
- }
- return oldValue.Description, nil
- }
- // ClearDescription clears the value of the "description" field.
- func (m *ChannelMonitorRequestTemplateMutation) ClearDescription() {
- m.description = nil
- m.clearedFields[channelmonitorrequesttemplate.FieldDescription] = struct{}{}
- }
- // DescriptionCleared returns if the "description" field was cleared in this mutation.
- func (m *ChannelMonitorRequestTemplateMutation) DescriptionCleared() bool {
- _, ok := m.clearedFields[channelmonitorrequesttemplate.FieldDescription]
- return ok
- }
- // ResetDescription resets all changes to the "description" field.
- func (m *ChannelMonitorRequestTemplateMutation) ResetDescription() {
- m.description = nil
- delete(m.clearedFields, channelmonitorrequesttemplate.FieldDescription)
- }
- // SetExtraHeaders sets the "extra_headers" field.
- func (m *ChannelMonitorRequestTemplateMutation) SetExtraHeaders(value map[string]string) {
- m.extra_headers = &value
- }
- // ExtraHeaders returns the value of the "extra_headers" field in the mutation.
- func (m *ChannelMonitorRequestTemplateMutation) ExtraHeaders() (r map[string]string, exists bool) {
- v := m.extra_headers
- if v == nil {
- return
- }
- return *v, true
- }
- // OldExtraHeaders returns the old "extra_headers" field's value of the ChannelMonitorRequestTemplate entity.
- // If the ChannelMonitorRequestTemplate object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *ChannelMonitorRequestTemplateMutation) OldExtraHeaders(ctx context.Context) (v map[string]string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldExtraHeaders is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldExtraHeaders requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldExtraHeaders: %w", err)
- }
- return oldValue.ExtraHeaders, nil
- }
- // ResetExtraHeaders resets all changes to the "extra_headers" field.
- func (m *ChannelMonitorRequestTemplateMutation) ResetExtraHeaders() {
- m.extra_headers = nil
- }
- // SetBodyOverrideMode sets the "body_override_mode" field.
- func (m *ChannelMonitorRequestTemplateMutation) SetBodyOverrideMode(s string) {
- m.body_override_mode = &s
- }
- // BodyOverrideMode returns the value of the "body_override_mode" field in the mutation.
- func (m *ChannelMonitorRequestTemplateMutation) BodyOverrideMode() (r string, exists bool) {
- v := m.body_override_mode
- if v == nil {
- return
- }
- return *v, true
- }
- // OldBodyOverrideMode returns the old "body_override_mode" field's value of the ChannelMonitorRequestTemplate entity.
- // If the ChannelMonitorRequestTemplate object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *ChannelMonitorRequestTemplateMutation) OldBodyOverrideMode(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldBodyOverrideMode is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldBodyOverrideMode requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldBodyOverrideMode: %w", err)
- }
- return oldValue.BodyOverrideMode, nil
- }
- // ResetBodyOverrideMode resets all changes to the "body_override_mode" field.
- func (m *ChannelMonitorRequestTemplateMutation) ResetBodyOverrideMode() {
- m.body_override_mode = nil
- }
- // SetBodyOverride sets the "body_override" field.
- func (m *ChannelMonitorRequestTemplateMutation) SetBodyOverride(value map[string]interface{}) {
- m.body_override = &value
- }
- // BodyOverride returns the value of the "body_override" field in the mutation.
- func (m *ChannelMonitorRequestTemplateMutation) BodyOverride() (r map[string]interface{}, exists bool) {
- v := m.body_override
- if v == nil {
- return
- }
- return *v, true
- }
- // OldBodyOverride returns the old "body_override" field's value of the ChannelMonitorRequestTemplate entity.
- // If the ChannelMonitorRequestTemplate object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *ChannelMonitorRequestTemplateMutation) OldBodyOverride(ctx context.Context) (v map[string]interface{}, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldBodyOverride is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldBodyOverride requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldBodyOverride: %w", err)
- }
- return oldValue.BodyOverride, nil
- }
- // ClearBodyOverride clears the value of the "body_override" field.
- func (m *ChannelMonitorRequestTemplateMutation) ClearBodyOverride() {
- m.body_override = nil
- m.clearedFields[channelmonitorrequesttemplate.FieldBodyOverride] = struct{}{}
- }
- // BodyOverrideCleared returns if the "body_override" field was cleared in this mutation.
- func (m *ChannelMonitorRequestTemplateMutation) BodyOverrideCleared() bool {
- _, ok := m.clearedFields[channelmonitorrequesttemplate.FieldBodyOverride]
- return ok
- }
- // ResetBodyOverride resets all changes to the "body_override" field.
- func (m *ChannelMonitorRequestTemplateMutation) ResetBodyOverride() {
- m.body_override = nil
- delete(m.clearedFields, channelmonitorrequesttemplate.FieldBodyOverride)
- }
- // AddMonitorIDs adds the "monitors" edge to the ChannelMonitor entity by ids.
- func (m *ChannelMonitorRequestTemplateMutation) AddMonitorIDs(ids ...int64) {
- if m.monitors == nil {
- m.monitors = make(map[int64]struct{})
- }
- for i := range ids {
- m.monitors[ids[i]] = struct{}{}
- }
- }
- // ClearMonitors clears the "monitors" edge to the ChannelMonitor entity.
- func (m *ChannelMonitorRequestTemplateMutation) ClearMonitors() {
- m.clearedmonitors = true
- }
- // MonitorsCleared reports if the "monitors" edge to the ChannelMonitor entity was cleared.
- func (m *ChannelMonitorRequestTemplateMutation) MonitorsCleared() bool {
- return m.clearedmonitors
- }
- // RemoveMonitorIDs removes the "monitors" edge to the ChannelMonitor entity by IDs.
- func (m *ChannelMonitorRequestTemplateMutation) RemoveMonitorIDs(ids ...int64) {
- if m.removedmonitors == nil {
- m.removedmonitors = make(map[int64]struct{})
- }
- for i := range ids {
- delete(m.monitors, ids[i])
- m.removedmonitors[ids[i]] = struct{}{}
- }
- }
- // RemovedMonitors returns the removed IDs of the "monitors" edge to the ChannelMonitor entity.
- func (m *ChannelMonitorRequestTemplateMutation) RemovedMonitorsIDs() (ids []int64) {
- for id := range m.removedmonitors {
- ids = append(ids, id)
- }
- return
- }
- // MonitorsIDs returns the "monitors" edge IDs in the mutation.
- func (m *ChannelMonitorRequestTemplateMutation) MonitorsIDs() (ids []int64) {
- for id := range m.monitors {
- ids = append(ids, id)
- }
- return
- }
- // ResetMonitors resets all changes to the "monitors" edge.
- func (m *ChannelMonitorRequestTemplateMutation) ResetMonitors() {
- m.monitors = nil
- m.clearedmonitors = false
- m.removedmonitors = nil
- }
- // Where appends a list predicates to the ChannelMonitorRequestTemplateMutation builder.
- func (m *ChannelMonitorRequestTemplateMutation) Where(ps ...predicate.ChannelMonitorRequestTemplate) {
- m.predicates = append(m.predicates, ps...)
- }
- // WhereP appends storage-level predicates to the ChannelMonitorRequestTemplateMutation builder. Using this method,
- // users can use type-assertion to append predicates that do not depend on any generated package.
- func (m *ChannelMonitorRequestTemplateMutation) WhereP(ps ...func(*sql.Selector)) {
- p := make([]predicate.ChannelMonitorRequestTemplate, len(ps))
- for i := range ps {
- p[i] = ps[i]
- }
- m.Where(p...)
- }
- // Op returns the operation name.
- func (m *ChannelMonitorRequestTemplateMutation) Op() Op {
- return m.op
- }
- // SetOp allows setting the mutation operation.
- func (m *ChannelMonitorRequestTemplateMutation) SetOp(op Op) {
- m.op = op
- }
- // Type returns the node type of this mutation (ChannelMonitorRequestTemplate).
- func (m *ChannelMonitorRequestTemplateMutation) Type() string {
- return m.typ
- }
- // Fields returns all fields that were changed during this mutation. Note that in
- // order to get all numeric fields that were incremented/decremented, call
- // AddedFields().
- func (m *ChannelMonitorRequestTemplateMutation) Fields() []string {
- fields := make([]string, 0, 9)
- if m.created_at != nil {
- fields = append(fields, channelmonitorrequesttemplate.FieldCreatedAt)
- }
- if m.updated_at != nil {
- fields = append(fields, channelmonitorrequesttemplate.FieldUpdatedAt)
- }
- if m.name != nil {
- fields = append(fields, channelmonitorrequesttemplate.FieldName)
- }
- if m.provider != nil {
- fields = append(fields, channelmonitorrequesttemplate.FieldProvider)
- }
- if m.api_mode != nil {
- fields = append(fields, channelmonitorrequesttemplate.FieldAPIMode)
- }
- if m.description != nil {
- fields = append(fields, channelmonitorrequesttemplate.FieldDescription)
- }
- if m.extra_headers != nil {
- fields = append(fields, channelmonitorrequesttemplate.FieldExtraHeaders)
- }
- if m.body_override_mode != nil {
- fields = append(fields, channelmonitorrequesttemplate.FieldBodyOverrideMode)
- }
- if m.body_override != nil {
- fields = append(fields, channelmonitorrequesttemplate.FieldBodyOverride)
- }
- return fields
- }
- // Field returns the value of a field with the given name. The second boolean
- // return value indicates that this field was not set, or was not defined in the
- // schema.
- func (m *ChannelMonitorRequestTemplateMutation) Field(name string) (ent.Value, bool) {
- switch name {
- case channelmonitorrequesttemplate.FieldCreatedAt:
- return m.CreatedAt()
- case channelmonitorrequesttemplate.FieldUpdatedAt:
- return m.UpdatedAt()
- case channelmonitorrequesttemplate.FieldName:
- return m.Name()
- case channelmonitorrequesttemplate.FieldProvider:
- return m.Provider()
- case channelmonitorrequesttemplate.FieldAPIMode:
- return m.APIMode()
- case channelmonitorrequesttemplate.FieldDescription:
- return m.Description()
- case channelmonitorrequesttemplate.FieldExtraHeaders:
- return m.ExtraHeaders()
- case channelmonitorrequesttemplate.FieldBodyOverrideMode:
- return m.BodyOverrideMode()
- case channelmonitorrequesttemplate.FieldBodyOverride:
- return m.BodyOverride()
- }
- return nil, false
- }
- // OldField returns the old value of the field from the database. An error is
- // returned if the mutation operation is not UpdateOne, or the query to the
- // database failed.
- func (m *ChannelMonitorRequestTemplateMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
- switch name {
- case channelmonitorrequesttemplate.FieldCreatedAt:
- return m.OldCreatedAt(ctx)
- case channelmonitorrequesttemplate.FieldUpdatedAt:
- return m.OldUpdatedAt(ctx)
- case channelmonitorrequesttemplate.FieldName:
- return m.OldName(ctx)
- case channelmonitorrequesttemplate.FieldProvider:
- return m.OldProvider(ctx)
- case channelmonitorrequesttemplate.FieldAPIMode:
- return m.OldAPIMode(ctx)
- case channelmonitorrequesttemplate.FieldDescription:
- return m.OldDescription(ctx)
- case channelmonitorrequesttemplate.FieldExtraHeaders:
- return m.OldExtraHeaders(ctx)
- case channelmonitorrequesttemplate.FieldBodyOverrideMode:
- return m.OldBodyOverrideMode(ctx)
- case channelmonitorrequesttemplate.FieldBodyOverride:
- return m.OldBodyOverride(ctx)
- }
- return nil, fmt.Errorf("unknown ChannelMonitorRequestTemplate field %s", name)
- }
- // SetField sets the value of a field with the given name. It returns an error if
- // the field is not defined in the schema, or if the type mismatched the field
- // type.
- func (m *ChannelMonitorRequestTemplateMutation) SetField(name string, value ent.Value) error {
- switch name {
- case channelmonitorrequesttemplate.FieldCreatedAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetCreatedAt(v)
- return nil
- case channelmonitorrequesttemplate.FieldUpdatedAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetUpdatedAt(v)
- return nil
- case channelmonitorrequesttemplate.FieldName:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetName(v)
- return nil
- case channelmonitorrequesttemplate.FieldProvider:
- v, ok := value.(channelmonitorrequesttemplate.Provider)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetProvider(v)
- return nil
- case channelmonitorrequesttemplate.FieldAPIMode:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetAPIMode(v)
- return nil
- case channelmonitorrequesttemplate.FieldDescription:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetDescription(v)
- return nil
- case channelmonitorrequesttemplate.FieldExtraHeaders:
- v, ok := value.(map[string]string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetExtraHeaders(v)
- return nil
- case channelmonitorrequesttemplate.FieldBodyOverrideMode:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetBodyOverrideMode(v)
- return nil
- case channelmonitorrequesttemplate.FieldBodyOverride:
- v, ok := value.(map[string]interface{})
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetBodyOverride(v)
- return nil
- }
- return fmt.Errorf("unknown ChannelMonitorRequestTemplate field %s", name)
- }
- // AddedFields returns all numeric fields that were incremented/decremented during
- // this mutation.
- func (m *ChannelMonitorRequestTemplateMutation) AddedFields() []string {
- return nil
- }
- // AddedField returns the numeric value that was incremented/decremented on a field
- // with the given name. The second boolean return value indicates that this field
- // was not set, or was not defined in the schema.
- func (m *ChannelMonitorRequestTemplateMutation) AddedField(name string) (ent.Value, bool) {
- return nil, false
- }
- // AddField adds the value to the field with the given name. It returns an error if
- // the field is not defined in the schema, or if the type mismatched the field
- // type.
- func (m *ChannelMonitorRequestTemplateMutation) AddField(name string, value ent.Value) error {
- switch name {
- }
- return fmt.Errorf("unknown ChannelMonitorRequestTemplate numeric field %s", name)
- }
- // ClearedFields returns all nullable fields that were cleared during this
- // mutation.
- func (m *ChannelMonitorRequestTemplateMutation) ClearedFields() []string {
- var fields []string
- if m.FieldCleared(channelmonitorrequesttemplate.FieldDescription) {
- fields = append(fields, channelmonitorrequesttemplate.FieldDescription)
- }
- if m.FieldCleared(channelmonitorrequesttemplate.FieldBodyOverride) {
- fields = append(fields, channelmonitorrequesttemplate.FieldBodyOverride)
- }
- return fields
- }
- // FieldCleared returns a boolean indicating if a field with the given name was
- // cleared in this mutation.
- func (m *ChannelMonitorRequestTemplateMutation) FieldCleared(name string) bool {
- _, ok := m.clearedFields[name]
- return ok
- }
- // ClearField clears the value of the field with the given name. It returns an
- // error if the field is not defined in the schema.
- func (m *ChannelMonitorRequestTemplateMutation) ClearField(name string) error {
- switch name {
- case channelmonitorrequesttemplate.FieldDescription:
- m.ClearDescription()
- return nil
- case channelmonitorrequesttemplate.FieldBodyOverride:
- m.ClearBodyOverride()
- return nil
- }
- return fmt.Errorf("unknown ChannelMonitorRequestTemplate nullable field %s", name)
- }
- // ResetField resets all changes in the mutation for the field with the given name.
- // It returns an error if the field is not defined in the schema.
- func (m *ChannelMonitorRequestTemplateMutation) ResetField(name string) error {
- switch name {
- case channelmonitorrequesttemplate.FieldCreatedAt:
- m.ResetCreatedAt()
- return nil
- case channelmonitorrequesttemplate.FieldUpdatedAt:
- m.ResetUpdatedAt()
- return nil
- case channelmonitorrequesttemplate.FieldName:
- m.ResetName()
- return nil
- case channelmonitorrequesttemplate.FieldProvider:
- m.ResetProvider()
- return nil
- case channelmonitorrequesttemplate.FieldAPIMode:
- m.ResetAPIMode()
- return nil
- case channelmonitorrequesttemplate.FieldDescription:
- m.ResetDescription()
- return nil
- case channelmonitorrequesttemplate.FieldExtraHeaders:
- m.ResetExtraHeaders()
- return nil
- case channelmonitorrequesttemplate.FieldBodyOverrideMode:
- m.ResetBodyOverrideMode()
- return nil
- case channelmonitorrequesttemplate.FieldBodyOverride:
- m.ResetBodyOverride()
- return nil
- }
- return fmt.Errorf("unknown ChannelMonitorRequestTemplate field %s", name)
- }
- // AddedEdges returns all edge names that were set/added in this mutation.
- func (m *ChannelMonitorRequestTemplateMutation) AddedEdges() []string {
- edges := make([]string, 0, 1)
- if m.monitors != nil {
- edges = append(edges, channelmonitorrequesttemplate.EdgeMonitors)
- }
- return edges
- }
- // AddedIDs returns all IDs (to other nodes) that were added for the given edge
- // name in this mutation.
- func (m *ChannelMonitorRequestTemplateMutation) AddedIDs(name string) []ent.Value {
- switch name {
- case channelmonitorrequesttemplate.EdgeMonitors:
- ids := make([]ent.Value, 0, len(m.monitors))
- for id := range m.monitors {
- ids = append(ids, id)
- }
- return ids
- }
- return nil
- }
- // RemovedEdges returns all edge names that were removed in this mutation.
- func (m *ChannelMonitorRequestTemplateMutation) RemovedEdges() []string {
- edges := make([]string, 0, 1)
- if m.removedmonitors != nil {
- edges = append(edges, channelmonitorrequesttemplate.EdgeMonitors)
- }
- return edges
- }
- // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
- // the given name in this mutation.
- func (m *ChannelMonitorRequestTemplateMutation) RemovedIDs(name string) []ent.Value {
- switch name {
- case channelmonitorrequesttemplate.EdgeMonitors:
- ids := make([]ent.Value, 0, len(m.removedmonitors))
- for id := range m.removedmonitors {
- ids = append(ids, id)
- }
- return ids
- }
- return nil
- }
- // ClearedEdges returns all edge names that were cleared in this mutation.
- func (m *ChannelMonitorRequestTemplateMutation) ClearedEdges() []string {
- edges := make([]string, 0, 1)
- if m.clearedmonitors {
- edges = append(edges, channelmonitorrequesttemplate.EdgeMonitors)
- }
- return edges
- }
- // EdgeCleared returns a boolean which indicates if the edge with the given name
- // was cleared in this mutation.
- func (m *ChannelMonitorRequestTemplateMutation) EdgeCleared(name string) bool {
- switch name {
- case channelmonitorrequesttemplate.EdgeMonitors:
- return m.clearedmonitors
- }
- return false
- }
- // ClearEdge clears the value of the edge with the given name. It returns an error
- // if that edge is not defined in the schema.
- func (m *ChannelMonitorRequestTemplateMutation) ClearEdge(name string) error {
- switch name {
- }
- return fmt.Errorf("unknown ChannelMonitorRequestTemplate unique edge %s", name)
- }
- // ResetEdge resets all changes to the edge with the given name in this mutation.
- // It returns an error if the edge is not defined in the schema.
- func (m *ChannelMonitorRequestTemplateMutation) ResetEdge(name string) error {
- switch name {
- case channelmonitorrequesttemplate.EdgeMonitors:
- m.ResetMonitors()
- return nil
- }
- return fmt.Errorf("unknown ChannelMonitorRequestTemplate edge %s", name)
- }
- // CompositeModelRouteMutation represents an operation that mutates the CompositeModelRoute nodes in the graph.
- type CompositeModelRouteMutation struct {
- config
- op Op
- typ string
- id *int64
- created_at *time.Time
- updated_at *time.Time
- deleted_at *time.Time
- public_model *string
- match_type *string
- target_platform *string
- upstream_model *string
- endpoint *string
- priority *int
- addpriority *int
- enabled *bool
- notes *string
- clearedFields map[string]struct{}
- group *int64
- clearedgroup bool
- done bool
- oldValue func(context.Context) (*CompositeModelRoute, error)
- predicates []predicate.CompositeModelRoute
- }
- var _ ent.Mutation = (*CompositeModelRouteMutation)(nil)
- // compositemodelrouteOption allows management of the mutation configuration using functional options.
- type compositemodelrouteOption func(*CompositeModelRouteMutation)
- // newCompositeModelRouteMutation creates new mutation for the CompositeModelRoute entity.
- func newCompositeModelRouteMutation(c config, op Op, opts ...compositemodelrouteOption) *CompositeModelRouteMutation {
- m := &CompositeModelRouteMutation{
- config: c,
- op: op,
- typ: TypeCompositeModelRoute,
- clearedFields: make(map[string]struct{}),
- }
- for _, opt := range opts {
- opt(m)
- }
- return m
- }
- // withCompositeModelRouteID sets the ID field of the mutation.
- func withCompositeModelRouteID(id int64) compositemodelrouteOption {
- return func(m *CompositeModelRouteMutation) {
- var (
- err error
- once sync.Once
- value *CompositeModelRoute
- )
- m.oldValue = func(ctx context.Context) (*CompositeModelRoute, error) {
- once.Do(func() {
- if m.done {
- err = errors.New("querying old values post mutation is not allowed")
- } else {
- value, err = m.Client().CompositeModelRoute.Get(ctx, id)
- }
- })
- return value, err
- }
- m.id = &id
- }
- }
- // withCompositeModelRoute sets the old CompositeModelRoute of the mutation.
- func withCompositeModelRoute(node *CompositeModelRoute) compositemodelrouteOption {
- return func(m *CompositeModelRouteMutation) {
- m.oldValue = func(context.Context) (*CompositeModelRoute, error) {
- return node, nil
- }
- m.id = &node.ID
- }
- }
- // Client returns a new `ent.Client` from the mutation. If the mutation was
- // executed in a transaction (ent.Tx), a transactional client is returned.
- func (m CompositeModelRouteMutation) Client() *Client {
- client := &Client{config: m.config}
- client.init()
- return client
- }
- // Tx returns an `ent.Tx` for mutations that were executed in transactions;
- // it returns an error otherwise.
- func (m CompositeModelRouteMutation) Tx() (*Tx, error) {
- if _, ok := m.driver.(*txDriver); !ok {
- return nil, errors.New("ent: mutation is not running in a transaction")
- }
- tx := &Tx{config: m.config}
- tx.init()
- return tx, nil
- }
- // ID returns the ID value in the mutation. Note that the ID is only available
- // if it was provided to the builder or after it was returned from the database.
- func (m *CompositeModelRouteMutation) ID() (id int64, exists bool) {
- if m.id == nil {
- return
- }
- return *m.id, true
- }
- // IDs queries the database and returns the entity ids that match the mutation's predicate.
- // That means, if the mutation is applied within a transaction with an isolation level such
- // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
- // or updated by the mutation.
- func (m *CompositeModelRouteMutation) IDs(ctx context.Context) ([]int64, error) {
- switch {
- case m.op.Is(OpUpdateOne | OpDeleteOne):
- id, exists := m.ID()
- if exists {
- return []int64{id}, nil
- }
- fallthrough
- case m.op.Is(OpUpdate | OpDelete):
- return m.Client().CompositeModelRoute.Query().Where(m.predicates...).IDs(ctx)
- default:
- return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
- }
- }
- // SetCreatedAt sets the "created_at" field.
- func (m *CompositeModelRouteMutation) SetCreatedAt(t time.Time) {
- m.created_at = &t
- }
- // CreatedAt returns the value of the "created_at" field in the mutation.
- func (m *CompositeModelRouteMutation) CreatedAt() (r time.Time, exists bool) {
- v := m.created_at
- if v == nil {
- return
- }
- return *v, true
- }
- // OldCreatedAt returns the old "created_at" field's value of the CompositeModelRoute entity.
- // If the CompositeModelRoute object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *CompositeModelRouteMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldCreatedAt requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
- }
- return oldValue.CreatedAt, nil
- }
- // ResetCreatedAt resets all changes to the "created_at" field.
- func (m *CompositeModelRouteMutation) ResetCreatedAt() {
- m.created_at = nil
- }
- // SetUpdatedAt sets the "updated_at" field.
- func (m *CompositeModelRouteMutation) SetUpdatedAt(t time.Time) {
- m.updated_at = &t
- }
- // UpdatedAt returns the value of the "updated_at" field in the mutation.
- func (m *CompositeModelRouteMutation) UpdatedAt() (r time.Time, exists bool) {
- v := m.updated_at
- if v == nil {
- return
- }
- return *v, true
- }
- // OldUpdatedAt returns the old "updated_at" field's value of the CompositeModelRoute entity.
- // If the CompositeModelRoute object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *CompositeModelRouteMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
- }
- return oldValue.UpdatedAt, nil
- }
- // ResetUpdatedAt resets all changes to the "updated_at" field.
- func (m *CompositeModelRouteMutation) ResetUpdatedAt() {
- m.updated_at = nil
- }
- // SetDeletedAt sets the "deleted_at" field.
- func (m *CompositeModelRouteMutation) SetDeletedAt(t time.Time) {
- m.deleted_at = &t
- }
- // DeletedAt returns the value of the "deleted_at" field in the mutation.
- func (m *CompositeModelRouteMutation) DeletedAt() (r time.Time, exists bool) {
- v := m.deleted_at
- if v == nil {
- return
- }
- return *v, true
- }
- // OldDeletedAt returns the old "deleted_at" field's value of the CompositeModelRoute entity.
- // If the CompositeModelRoute object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *CompositeModelRouteMutation) OldDeletedAt(ctx context.Context) (v *time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldDeletedAt requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
- }
- return oldValue.DeletedAt, nil
- }
- // ClearDeletedAt clears the value of the "deleted_at" field.
- func (m *CompositeModelRouteMutation) ClearDeletedAt() {
- m.deleted_at = nil
- m.clearedFields[compositemodelroute.FieldDeletedAt] = struct{}{}
- }
- // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
- func (m *CompositeModelRouteMutation) DeletedAtCleared() bool {
- _, ok := m.clearedFields[compositemodelroute.FieldDeletedAt]
- return ok
- }
- // ResetDeletedAt resets all changes to the "deleted_at" field.
- func (m *CompositeModelRouteMutation) ResetDeletedAt() {
- m.deleted_at = nil
- delete(m.clearedFields, compositemodelroute.FieldDeletedAt)
- }
- // SetGroupID sets the "group_id" field.
- func (m *CompositeModelRouteMutation) SetGroupID(i int64) {
- m.group = &i
- }
- // GroupID returns the value of the "group_id" field in the mutation.
- func (m *CompositeModelRouteMutation) GroupID() (r int64, exists bool) {
- v := m.group
- if v == nil {
- return
- }
- return *v, true
- }
- // OldGroupID returns the old "group_id" field's value of the CompositeModelRoute entity.
- // If the CompositeModelRoute object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *CompositeModelRouteMutation) OldGroupID(ctx context.Context) (v int64, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldGroupID is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldGroupID requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldGroupID: %w", err)
- }
- return oldValue.GroupID, nil
- }
- // ResetGroupID resets all changes to the "group_id" field.
- func (m *CompositeModelRouteMutation) ResetGroupID() {
- m.group = nil
- }
- // SetPublicModel sets the "public_model" field.
- func (m *CompositeModelRouteMutation) SetPublicModel(s string) {
- m.public_model = &s
- }
- // PublicModel returns the value of the "public_model" field in the mutation.
- func (m *CompositeModelRouteMutation) PublicModel() (r string, exists bool) {
- v := m.public_model
- if v == nil {
- return
- }
- return *v, true
- }
- // OldPublicModel returns the old "public_model" field's value of the CompositeModelRoute entity.
- // If the CompositeModelRoute object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *CompositeModelRouteMutation) OldPublicModel(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldPublicModel is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldPublicModel requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldPublicModel: %w", err)
- }
- return oldValue.PublicModel, nil
- }
- // ResetPublicModel resets all changes to the "public_model" field.
- func (m *CompositeModelRouteMutation) ResetPublicModel() {
- m.public_model = nil
- }
- // SetMatchType sets the "match_type" field.
- func (m *CompositeModelRouteMutation) SetMatchType(s string) {
- m.match_type = &s
- }
- // MatchType returns the value of the "match_type" field in the mutation.
- func (m *CompositeModelRouteMutation) MatchType() (r string, exists bool) {
- v := m.match_type
- if v == nil {
- return
- }
- return *v, true
- }
- // OldMatchType returns the old "match_type" field's value of the CompositeModelRoute entity.
- // If the CompositeModelRoute object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *CompositeModelRouteMutation) OldMatchType(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldMatchType is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldMatchType requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldMatchType: %w", err)
- }
- return oldValue.MatchType, nil
- }
- // ResetMatchType resets all changes to the "match_type" field.
- func (m *CompositeModelRouteMutation) ResetMatchType() {
- m.match_type = nil
- }
- // SetTargetPlatform sets the "target_platform" field.
- func (m *CompositeModelRouteMutation) SetTargetPlatform(s string) {
- m.target_platform = &s
- }
- // TargetPlatform returns the value of the "target_platform" field in the mutation.
- func (m *CompositeModelRouteMutation) TargetPlatform() (r string, exists bool) {
- v := m.target_platform
- if v == nil {
- return
- }
- return *v, true
- }
- // OldTargetPlatform returns the old "target_platform" field's value of the CompositeModelRoute entity.
- // If the CompositeModelRoute object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *CompositeModelRouteMutation) OldTargetPlatform(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldTargetPlatform is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldTargetPlatform requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldTargetPlatform: %w", err)
- }
- return oldValue.TargetPlatform, nil
- }
- // ResetTargetPlatform resets all changes to the "target_platform" field.
- func (m *CompositeModelRouteMutation) ResetTargetPlatform() {
- m.target_platform = nil
- }
- // SetUpstreamModel sets the "upstream_model" field.
- func (m *CompositeModelRouteMutation) SetUpstreamModel(s string) {
- m.upstream_model = &s
- }
- // UpstreamModel returns the value of the "upstream_model" field in the mutation.
- func (m *CompositeModelRouteMutation) UpstreamModel() (r string, exists bool) {
- v := m.upstream_model
- if v == nil {
- return
- }
- return *v, true
- }
- // OldUpstreamModel returns the old "upstream_model" field's value of the CompositeModelRoute entity.
- // If the CompositeModelRoute object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *CompositeModelRouteMutation) OldUpstreamModel(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldUpstreamModel is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldUpstreamModel requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldUpstreamModel: %w", err)
- }
- return oldValue.UpstreamModel, nil
- }
- // ResetUpstreamModel resets all changes to the "upstream_model" field.
- func (m *CompositeModelRouteMutation) ResetUpstreamModel() {
- m.upstream_model = nil
- }
- // SetEndpoint sets the "endpoint" field.
- func (m *CompositeModelRouteMutation) SetEndpoint(s string) {
- m.endpoint = &s
- }
- // Endpoint returns the value of the "endpoint" field in the mutation.
- func (m *CompositeModelRouteMutation) Endpoint() (r string, exists bool) {
- v := m.endpoint
- if v == nil {
- return
- }
- return *v, true
- }
- // OldEndpoint returns the old "endpoint" field's value of the CompositeModelRoute entity.
- // If the CompositeModelRoute object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *CompositeModelRouteMutation) OldEndpoint(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldEndpoint is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldEndpoint requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldEndpoint: %w", err)
- }
- return oldValue.Endpoint, nil
- }
- // ResetEndpoint resets all changes to the "endpoint" field.
- func (m *CompositeModelRouteMutation) ResetEndpoint() {
- m.endpoint = nil
- }
- // SetPriority sets the "priority" field.
- func (m *CompositeModelRouteMutation) SetPriority(i int) {
- m.priority = &i
- m.addpriority = nil
- }
- // Priority returns the value of the "priority" field in the mutation.
- func (m *CompositeModelRouteMutation) Priority() (r int, exists bool) {
- v := m.priority
- if v == nil {
- return
- }
- return *v, true
- }
- // OldPriority returns the old "priority" field's value of the CompositeModelRoute entity.
- // If the CompositeModelRoute object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *CompositeModelRouteMutation) OldPriority(ctx context.Context) (v int, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldPriority is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldPriority requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldPriority: %w", err)
- }
- return oldValue.Priority, nil
- }
- // AddPriority adds i to the "priority" field.
- func (m *CompositeModelRouteMutation) AddPriority(i int) {
- if m.addpriority != nil {
- *m.addpriority += i
- } else {
- m.addpriority = &i
- }
- }
- // AddedPriority returns the value that was added to the "priority" field in this mutation.
- func (m *CompositeModelRouteMutation) AddedPriority() (r int, exists bool) {
- v := m.addpriority
- if v == nil {
- return
- }
- return *v, true
- }
- // ResetPriority resets all changes to the "priority" field.
- func (m *CompositeModelRouteMutation) ResetPriority() {
- m.priority = nil
- m.addpriority = nil
- }
- // SetEnabled sets the "enabled" field.
- func (m *CompositeModelRouteMutation) SetEnabled(b bool) {
- m.enabled = &b
- }
- // Enabled returns the value of the "enabled" field in the mutation.
- func (m *CompositeModelRouteMutation) Enabled() (r bool, exists bool) {
- v := m.enabled
- if v == nil {
- return
- }
- return *v, true
- }
- // OldEnabled returns the old "enabled" field's value of the CompositeModelRoute entity.
- // If the CompositeModelRoute object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *CompositeModelRouteMutation) OldEnabled(ctx context.Context) (v bool, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldEnabled is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldEnabled requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldEnabled: %w", err)
- }
- return oldValue.Enabled, nil
- }
- // ResetEnabled resets all changes to the "enabled" field.
- func (m *CompositeModelRouteMutation) ResetEnabled() {
- m.enabled = nil
- }
- // SetNotes sets the "notes" field.
- func (m *CompositeModelRouteMutation) SetNotes(s string) {
- m.notes = &s
- }
- // Notes returns the value of the "notes" field in the mutation.
- func (m *CompositeModelRouteMutation) Notes() (r string, exists bool) {
- v := m.notes
- if v == nil {
- return
- }
- return *v, true
- }
- // OldNotes returns the old "notes" field's value of the CompositeModelRoute entity.
- // If the CompositeModelRoute object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *CompositeModelRouteMutation) OldNotes(ctx context.Context) (v *string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldNotes is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldNotes requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldNotes: %w", err)
- }
- return oldValue.Notes, nil
- }
- // ClearNotes clears the value of the "notes" field.
- func (m *CompositeModelRouteMutation) ClearNotes() {
- m.notes = nil
- m.clearedFields[compositemodelroute.FieldNotes] = struct{}{}
- }
- // NotesCleared returns if the "notes" field was cleared in this mutation.
- func (m *CompositeModelRouteMutation) NotesCleared() bool {
- _, ok := m.clearedFields[compositemodelroute.FieldNotes]
- return ok
- }
- // ResetNotes resets all changes to the "notes" field.
- func (m *CompositeModelRouteMutation) ResetNotes() {
- m.notes = nil
- delete(m.clearedFields, compositemodelroute.FieldNotes)
- }
- // ClearGroup clears the "group" edge to the Group entity.
- func (m *CompositeModelRouteMutation) ClearGroup() {
- m.clearedgroup = true
- m.clearedFields[compositemodelroute.FieldGroupID] = struct{}{}
- }
- // GroupCleared reports if the "group" edge to the Group entity was cleared.
- func (m *CompositeModelRouteMutation) GroupCleared() bool {
- return m.clearedgroup
- }
- // GroupIDs returns the "group" edge IDs in the mutation.
- // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
- // GroupID instead. It exists only for internal usage by the builders.
- func (m *CompositeModelRouteMutation) GroupIDs() (ids []int64) {
- if id := m.group; id != nil {
- ids = append(ids, *id)
- }
- return
- }
- // ResetGroup resets all changes to the "group" edge.
- func (m *CompositeModelRouteMutation) ResetGroup() {
- m.group = nil
- m.clearedgroup = false
- }
- // Where appends a list predicates to the CompositeModelRouteMutation builder.
- func (m *CompositeModelRouteMutation) Where(ps ...predicate.CompositeModelRoute) {
- m.predicates = append(m.predicates, ps...)
- }
- // WhereP appends storage-level predicates to the CompositeModelRouteMutation builder. Using this method,
- // users can use type-assertion to append predicates that do not depend on any generated package.
- func (m *CompositeModelRouteMutation) WhereP(ps ...func(*sql.Selector)) {
- p := make([]predicate.CompositeModelRoute, len(ps))
- for i := range ps {
- p[i] = ps[i]
- }
- m.Where(p...)
- }
- // Op returns the operation name.
- func (m *CompositeModelRouteMutation) Op() Op {
- return m.op
- }
- // SetOp allows setting the mutation operation.
- func (m *CompositeModelRouteMutation) SetOp(op Op) {
- m.op = op
- }
- // Type returns the node type of this mutation (CompositeModelRoute).
- func (m *CompositeModelRouteMutation) Type() string {
- return m.typ
- }
- // Fields returns all fields that were changed during this mutation. Note that in
- // order to get all numeric fields that were incremented/decremented, call
- // AddedFields().
- func (m *CompositeModelRouteMutation) Fields() []string {
- fields := make([]string, 0, 12)
- if m.created_at != nil {
- fields = append(fields, compositemodelroute.FieldCreatedAt)
- }
- if m.updated_at != nil {
- fields = append(fields, compositemodelroute.FieldUpdatedAt)
- }
- if m.deleted_at != nil {
- fields = append(fields, compositemodelroute.FieldDeletedAt)
- }
- if m.group != nil {
- fields = append(fields, compositemodelroute.FieldGroupID)
- }
- if m.public_model != nil {
- fields = append(fields, compositemodelroute.FieldPublicModel)
- }
- if m.match_type != nil {
- fields = append(fields, compositemodelroute.FieldMatchType)
- }
- if m.target_platform != nil {
- fields = append(fields, compositemodelroute.FieldTargetPlatform)
- }
- if m.upstream_model != nil {
- fields = append(fields, compositemodelroute.FieldUpstreamModel)
- }
- if m.endpoint != nil {
- fields = append(fields, compositemodelroute.FieldEndpoint)
- }
- if m.priority != nil {
- fields = append(fields, compositemodelroute.FieldPriority)
- }
- if m.enabled != nil {
- fields = append(fields, compositemodelroute.FieldEnabled)
- }
- if m.notes != nil {
- fields = append(fields, compositemodelroute.FieldNotes)
- }
- return fields
- }
- // Field returns the value of a field with the given name. The second boolean
- // return value indicates that this field was not set, or was not defined in the
- // schema.
- func (m *CompositeModelRouteMutation) Field(name string) (ent.Value, bool) {
- switch name {
- case compositemodelroute.FieldCreatedAt:
- return m.CreatedAt()
- case compositemodelroute.FieldUpdatedAt:
- return m.UpdatedAt()
- case compositemodelroute.FieldDeletedAt:
- return m.DeletedAt()
- case compositemodelroute.FieldGroupID:
- return m.GroupID()
- case compositemodelroute.FieldPublicModel:
- return m.PublicModel()
- case compositemodelroute.FieldMatchType:
- return m.MatchType()
- case compositemodelroute.FieldTargetPlatform:
- return m.TargetPlatform()
- case compositemodelroute.FieldUpstreamModel:
- return m.UpstreamModel()
- case compositemodelroute.FieldEndpoint:
- return m.Endpoint()
- case compositemodelroute.FieldPriority:
- return m.Priority()
- case compositemodelroute.FieldEnabled:
- return m.Enabled()
- case compositemodelroute.FieldNotes:
- return m.Notes()
- }
- return nil, false
- }
- // OldField returns the old value of the field from the database. An error is
- // returned if the mutation operation is not UpdateOne, or the query to the
- // database failed.
- func (m *CompositeModelRouteMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
- switch name {
- case compositemodelroute.FieldCreatedAt:
- return m.OldCreatedAt(ctx)
- case compositemodelroute.FieldUpdatedAt:
- return m.OldUpdatedAt(ctx)
- case compositemodelroute.FieldDeletedAt:
- return m.OldDeletedAt(ctx)
- case compositemodelroute.FieldGroupID:
- return m.OldGroupID(ctx)
- case compositemodelroute.FieldPublicModel:
- return m.OldPublicModel(ctx)
- case compositemodelroute.FieldMatchType:
- return m.OldMatchType(ctx)
- case compositemodelroute.FieldTargetPlatform:
- return m.OldTargetPlatform(ctx)
- case compositemodelroute.FieldUpstreamModel:
- return m.OldUpstreamModel(ctx)
- case compositemodelroute.FieldEndpoint:
- return m.OldEndpoint(ctx)
- case compositemodelroute.FieldPriority:
- return m.OldPriority(ctx)
- case compositemodelroute.FieldEnabled:
- return m.OldEnabled(ctx)
- case compositemodelroute.FieldNotes:
- return m.OldNotes(ctx)
- }
- return nil, fmt.Errorf("unknown CompositeModelRoute field %s", name)
- }
- // SetField sets the value of a field with the given name. It returns an error if
- // the field is not defined in the schema, or if the type mismatched the field
- // type.
- func (m *CompositeModelRouteMutation) SetField(name string, value ent.Value) error {
- switch name {
- case compositemodelroute.FieldCreatedAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetCreatedAt(v)
- return nil
- case compositemodelroute.FieldUpdatedAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetUpdatedAt(v)
- return nil
- case compositemodelroute.FieldDeletedAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetDeletedAt(v)
- return nil
- case compositemodelroute.FieldGroupID:
- v, ok := value.(int64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetGroupID(v)
- return nil
- case compositemodelroute.FieldPublicModel:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetPublicModel(v)
- return nil
- case compositemodelroute.FieldMatchType:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetMatchType(v)
- return nil
- case compositemodelroute.FieldTargetPlatform:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetTargetPlatform(v)
- return nil
- case compositemodelroute.FieldUpstreamModel:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetUpstreamModel(v)
- return nil
- case compositemodelroute.FieldEndpoint:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetEndpoint(v)
- return nil
- case compositemodelroute.FieldPriority:
- v, ok := value.(int)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetPriority(v)
- return nil
- case compositemodelroute.FieldEnabled:
- v, ok := value.(bool)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetEnabled(v)
- return nil
- case compositemodelroute.FieldNotes:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetNotes(v)
- return nil
- }
- return fmt.Errorf("unknown CompositeModelRoute field %s", name)
- }
- // AddedFields returns all numeric fields that were incremented/decremented during
- // this mutation.
- func (m *CompositeModelRouteMutation) AddedFields() []string {
- var fields []string
- if m.addpriority != nil {
- fields = append(fields, compositemodelroute.FieldPriority)
- }
- return fields
- }
- // AddedField returns the numeric value that was incremented/decremented on a field
- // with the given name. The second boolean return value indicates that this field
- // was not set, or was not defined in the schema.
- func (m *CompositeModelRouteMutation) AddedField(name string) (ent.Value, bool) {
- switch name {
- case compositemodelroute.FieldPriority:
- return m.AddedPriority()
- }
- return nil, false
- }
- // AddField adds the value to the field with the given name. It returns an error if
- // the field is not defined in the schema, or if the type mismatched the field
- // type.
- func (m *CompositeModelRouteMutation) AddField(name string, value ent.Value) error {
- switch name {
- case compositemodelroute.FieldPriority:
- v, ok := value.(int)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.AddPriority(v)
- return nil
- }
- return fmt.Errorf("unknown CompositeModelRoute numeric field %s", name)
- }
- // ClearedFields returns all nullable fields that were cleared during this
- // mutation.
- func (m *CompositeModelRouteMutation) ClearedFields() []string {
- var fields []string
- if m.FieldCleared(compositemodelroute.FieldDeletedAt) {
- fields = append(fields, compositemodelroute.FieldDeletedAt)
- }
- if m.FieldCleared(compositemodelroute.FieldNotes) {
- fields = append(fields, compositemodelroute.FieldNotes)
- }
- return fields
- }
- // FieldCleared returns a boolean indicating if a field with the given name was
- // cleared in this mutation.
- func (m *CompositeModelRouteMutation) FieldCleared(name string) bool {
- _, ok := m.clearedFields[name]
- return ok
- }
- // ClearField clears the value of the field with the given name. It returns an
- // error if the field is not defined in the schema.
- func (m *CompositeModelRouteMutation) ClearField(name string) error {
- switch name {
- case compositemodelroute.FieldDeletedAt:
- m.ClearDeletedAt()
- return nil
- case compositemodelroute.FieldNotes:
- m.ClearNotes()
- return nil
- }
- return fmt.Errorf("unknown CompositeModelRoute nullable field %s", name)
- }
- // ResetField resets all changes in the mutation for the field with the given name.
- // It returns an error if the field is not defined in the schema.
- func (m *CompositeModelRouteMutation) ResetField(name string) error {
- switch name {
- case compositemodelroute.FieldCreatedAt:
- m.ResetCreatedAt()
- return nil
- case compositemodelroute.FieldUpdatedAt:
- m.ResetUpdatedAt()
- return nil
- case compositemodelroute.FieldDeletedAt:
- m.ResetDeletedAt()
- return nil
- case compositemodelroute.FieldGroupID:
- m.ResetGroupID()
- return nil
- case compositemodelroute.FieldPublicModel:
- m.ResetPublicModel()
- return nil
- case compositemodelroute.FieldMatchType:
- m.ResetMatchType()
- return nil
- case compositemodelroute.FieldTargetPlatform:
- m.ResetTargetPlatform()
- return nil
- case compositemodelroute.FieldUpstreamModel:
- m.ResetUpstreamModel()
- return nil
- case compositemodelroute.FieldEndpoint:
- m.ResetEndpoint()
- return nil
- case compositemodelroute.FieldPriority:
- m.ResetPriority()
- return nil
- case compositemodelroute.FieldEnabled:
- m.ResetEnabled()
- return nil
- case compositemodelroute.FieldNotes:
- m.ResetNotes()
- return nil
- }
- return fmt.Errorf("unknown CompositeModelRoute field %s", name)
- }
- // AddedEdges returns all edge names that were set/added in this mutation.
- func (m *CompositeModelRouteMutation) AddedEdges() []string {
- edges := make([]string, 0, 1)
- if m.group != nil {
- edges = append(edges, compositemodelroute.EdgeGroup)
- }
- return edges
- }
- // AddedIDs returns all IDs (to other nodes) that were added for the given edge
- // name in this mutation.
- func (m *CompositeModelRouteMutation) AddedIDs(name string) []ent.Value {
- switch name {
- case compositemodelroute.EdgeGroup:
- if id := m.group; id != nil {
- return []ent.Value{*id}
- }
- }
- return nil
- }
- // RemovedEdges returns all edge names that were removed in this mutation.
- func (m *CompositeModelRouteMutation) RemovedEdges() []string {
- edges := make([]string, 0, 1)
- return edges
- }
- // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
- // the given name in this mutation.
- func (m *CompositeModelRouteMutation) RemovedIDs(name string) []ent.Value {
- return nil
- }
- // ClearedEdges returns all edge names that were cleared in this mutation.
- func (m *CompositeModelRouteMutation) ClearedEdges() []string {
- edges := make([]string, 0, 1)
- if m.clearedgroup {
- edges = append(edges, compositemodelroute.EdgeGroup)
- }
- return edges
- }
- // EdgeCleared returns a boolean which indicates if the edge with the given name
- // was cleared in this mutation.
- func (m *CompositeModelRouteMutation) EdgeCleared(name string) bool {
- switch name {
- case compositemodelroute.EdgeGroup:
- return m.clearedgroup
- }
- return false
- }
- // ClearEdge clears the value of the edge with the given name. It returns an error
- // if that edge is not defined in the schema.
- func (m *CompositeModelRouteMutation) ClearEdge(name string) error {
- switch name {
- case compositemodelroute.EdgeGroup:
- m.ClearGroup()
- return nil
- }
- return fmt.Errorf("unknown CompositeModelRoute unique edge %s", name)
- }
- // ResetEdge resets all changes to the edge with the given name in this mutation.
- // It returns an error if the edge is not defined in the schema.
- func (m *CompositeModelRouteMutation) ResetEdge(name string) error {
- switch name {
- case compositemodelroute.EdgeGroup:
- m.ResetGroup()
- return nil
- }
- return fmt.Errorf("unknown CompositeModelRoute edge %s", name)
- }
- // ErrorPassthroughRuleMutation represents an operation that mutates the ErrorPassthroughRule nodes in the graph.
- type ErrorPassthroughRuleMutation struct {
- config
- op Op
- typ string
- id *int64
- created_at *time.Time
- updated_at *time.Time
- name *string
- enabled *bool
- priority *int
- addpriority *int
- error_codes *[]int
- appenderror_codes []int
- keywords *[]string
- appendkeywords []string
- match_mode *string
- platforms *[]string
- appendplatforms []string
- passthrough_code *bool
- response_code *int
- addresponse_code *int
- passthrough_body *bool
- custom_message *string
- skip_monitoring *bool
- description *string
- clearedFields map[string]struct{}
- done bool
- oldValue func(context.Context) (*ErrorPassthroughRule, error)
- predicates []predicate.ErrorPassthroughRule
- }
- var _ ent.Mutation = (*ErrorPassthroughRuleMutation)(nil)
- // errorpassthroughruleOption allows management of the mutation configuration using functional options.
- type errorpassthroughruleOption func(*ErrorPassthroughRuleMutation)
- // newErrorPassthroughRuleMutation creates new mutation for the ErrorPassthroughRule entity.
- func newErrorPassthroughRuleMutation(c config, op Op, opts ...errorpassthroughruleOption) *ErrorPassthroughRuleMutation {
- m := &ErrorPassthroughRuleMutation{
- config: c,
- op: op,
- typ: TypeErrorPassthroughRule,
- clearedFields: make(map[string]struct{}),
- }
- for _, opt := range opts {
- opt(m)
- }
- return m
- }
- // withErrorPassthroughRuleID sets the ID field of the mutation.
- func withErrorPassthroughRuleID(id int64) errorpassthroughruleOption {
- return func(m *ErrorPassthroughRuleMutation) {
- var (
- err error
- once sync.Once
- value *ErrorPassthroughRule
- )
- m.oldValue = func(ctx context.Context) (*ErrorPassthroughRule, error) {
- once.Do(func() {
- if m.done {
- err = errors.New("querying old values post mutation is not allowed")
- } else {
- value, err = m.Client().ErrorPassthroughRule.Get(ctx, id)
- }
- })
- return value, err
- }
- m.id = &id
- }
- }
- // withErrorPassthroughRule sets the old ErrorPassthroughRule of the mutation.
- func withErrorPassthroughRule(node *ErrorPassthroughRule) errorpassthroughruleOption {
- return func(m *ErrorPassthroughRuleMutation) {
- m.oldValue = func(context.Context) (*ErrorPassthroughRule, error) {
- return node, nil
- }
- m.id = &node.ID
- }
- }
- // Client returns a new `ent.Client` from the mutation. If the mutation was
- // executed in a transaction (ent.Tx), a transactional client is returned.
- func (m ErrorPassthroughRuleMutation) Client() *Client {
- client := &Client{config: m.config}
- client.init()
- return client
- }
- // Tx returns an `ent.Tx` for mutations that were executed in transactions;
- // it returns an error otherwise.
- func (m ErrorPassthroughRuleMutation) Tx() (*Tx, error) {
- if _, ok := m.driver.(*txDriver); !ok {
- return nil, errors.New("ent: mutation is not running in a transaction")
- }
- tx := &Tx{config: m.config}
- tx.init()
- return tx, nil
- }
- // ID returns the ID value in the mutation. Note that the ID is only available
- // if it was provided to the builder or after it was returned from the database.
- func (m *ErrorPassthroughRuleMutation) ID() (id int64, exists bool) {
- if m.id == nil {
- return
- }
- return *m.id, true
- }
- // IDs queries the database and returns the entity ids that match the mutation's predicate.
- // That means, if the mutation is applied within a transaction with an isolation level such
- // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
- // or updated by the mutation.
- func (m *ErrorPassthroughRuleMutation) IDs(ctx context.Context) ([]int64, error) {
- switch {
- case m.op.Is(OpUpdateOne | OpDeleteOne):
- id, exists := m.ID()
- if exists {
- return []int64{id}, nil
- }
- fallthrough
- case m.op.Is(OpUpdate | OpDelete):
- return m.Client().ErrorPassthroughRule.Query().Where(m.predicates...).IDs(ctx)
- default:
- return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
- }
- }
- // SetCreatedAt sets the "created_at" field.
- func (m *ErrorPassthroughRuleMutation) SetCreatedAt(t time.Time) {
- m.created_at = &t
- }
- // CreatedAt returns the value of the "created_at" field in the mutation.
- func (m *ErrorPassthroughRuleMutation) CreatedAt() (r time.Time, exists bool) {
- v := m.created_at
- if v == nil {
- return
- }
- return *v, true
- }
- // OldCreatedAt returns the old "created_at" field's value of the ErrorPassthroughRule entity.
- // If the ErrorPassthroughRule object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *ErrorPassthroughRuleMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldCreatedAt requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
- }
- return oldValue.CreatedAt, nil
- }
- // ResetCreatedAt resets all changes to the "created_at" field.
- func (m *ErrorPassthroughRuleMutation) ResetCreatedAt() {
- m.created_at = nil
- }
- // SetUpdatedAt sets the "updated_at" field.
- func (m *ErrorPassthroughRuleMutation) SetUpdatedAt(t time.Time) {
- m.updated_at = &t
- }
- // UpdatedAt returns the value of the "updated_at" field in the mutation.
- func (m *ErrorPassthroughRuleMutation) UpdatedAt() (r time.Time, exists bool) {
- v := m.updated_at
- if v == nil {
- return
- }
- return *v, true
- }
- // OldUpdatedAt returns the old "updated_at" field's value of the ErrorPassthroughRule entity.
- // If the ErrorPassthroughRule object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *ErrorPassthroughRuleMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
- }
- return oldValue.UpdatedAt, nil
- }
- // ResetUpdatedAt resets all changes to the "updated_at" field.
- func (m *ErrorPassthroughRuleMutation) ResetUpdatedAt() {
- m.updated_at = nil
- }
- // SetName sets the "name" field.
- func (m *ErrorPassthroughRuleMutation) SetName(s string) {
- m.name = &s
- }
- // Name returns the value of the "name" field in the mutation.
- func (m *ErrorPassthroughRuleMutation) Name() (r string, exists bool) {
- v := m.name
- if v == nil {
- return
- }
- return *v, true
- }
- // OldName returns the old "name" field's value of the ErrorPassthroughRule entity.
- // If the ErrorPassthroughRule object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *ErrorPassthroughRuleMutation) OldName(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldName is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldName requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldName: %w", err)
- }
- return oldValue.Name, nil
- }
- // ResetName resets all changes to the "name" field.
- func (m *ErrorPassthroughRuleMutation) ResetName() {
- m.name = nil
- }
- // SetEnabled sets the "enabled" field.
- func (m *ErrorPassthroughRuleMutation) SetEnabled(b bool) {
- m.enabled = &b
- }
- // Enabled returns the value of the "enabled" field in the mutation.
- func (m *ErrorPassthroughRuleMutation) Enabled() (r bool, exists bool) {
- v := m.enabled
- if v == nil {
- return
- }
- return *v, true
- }
- // OldEnabled returns the old "enabled" field's value of the ErrorPassthroughRule entity.
- // If the ErrorPassthroughRule object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *ErrorPassthroughRuleMutation) OldEnabled(ctx context.Context) (v bool, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldEnabled is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldEnabled requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldEnabled: %w", err)
- }
- return oldValue.Enabled, nil
- }
- // ResetEnabled resets all changes to the "enabled" field.
- func (m *ErrorPassthroughRuleMutation) ResetEnabled() {
- m.enabled = nil
- }
- // SetPriority sets the "priority" field.
- func (m *ErrorPassthroughRuleMutation) SetPriority(i int) {
- m.priority = &i
- m.addpriority = nil
- }
- // Priority returns the value of the "priority" field in the mutation.
- func (m *ErrorPassthroughRuleMutation) Priority() (r int, exists bool) {
- v := m.priority
- if v == nil {
- return
- }
- return *v, true
- }
- // OldPriority returns the old "priority" field's value of the ErrorPassthroughRule entity.
- // If the ErrorPassthroughRule object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *ErrorPassthroughRuleMutation) OldPriority(ctx context.Context) (v int, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldPriority is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldPriority requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldPriority: %w", err)
- }
- return oldValue.Priority, nil
- }
- // AddPriority adds i to the "priority" field.
- func (m *ErrorPassthroughRuleMutation) AddPriority(i int) {
- if m.addpriority != nil {
- *m.addpriority += i
- } else {
- m.addpriority = &i
- }
- }
- // AddedPriority returns the value that was added to the "priority" field in this mutation.
- func (m *ErrorPassthroughRuleMutation) AddedPriority() (r int, exists bool) {
- v := m.addpriority
- if v == nil {
- return
- }
- return *v, true
- }
- // ResetPriority resets all changes to the "priority" field.
- func (m *ErrorPassthroughRuleMutation) ResetPriority() {
- m.priority = nil
- m.addpriority = nil
- }
- // SetErrorCodes sets the "error_codes" field.
- func (m *ErrorPassthroughRuleMutation) SetErrorCodes(i []int) {
- m.error_codes = &i
- m.appenderror_codes = nil
- }
- // ErrorCodes returns the value of the "error_codes" field in the mutation.
- func (m *ErrorPassthroughRuleMutation) ErrorCodes() (r []int, exists bool) {
- v := m.error_codes
- if v == nil {
- return
- }
- return *v, true
- }
- // OldErrorCodes returns the old "error_codes" field's value of the ErrorPassthroughRule entity.
- // If the ErrorPassthroughRule object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *ErrorPassthroughRuleMutation) OldErrorCodes(ctx context.Context) (v []int, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldErrorCodes is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldErrorCodes requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldErrorCodes: %w", err)
- }
- return oldValue.ErrorCodes, nil
- }
- // AppendErrorCodes adds i to the "error_codes" field.
- func (m *ErrorPassthroughRuleMutation) AppendErrorCodes(i []int) {
- m.appenderror_codes = append(m.appenderror_codes, i...)
- }
- // AppendedErrorCodes returns the list of values that were appended to the "error_codes" field in this mutation.
- func (m *ErrorPassthroughRuleMutation) AppendedErrorCodes() ([]int, bool) {
- if len(m.appenderror_codes) == 0 {
- return nil, false
- }
- return m.appenderror_codes, true
- }
- // ClearErrorCodes clears the value of the "error_codes" field.
- func (m *ErrorPassthroughRuleMutation) ClearErrorCodes() {
- m.error_codes = nil
- m.appenderror_codes = nil
- m.clearedFields[errorpassthroughrule.FieldErrorCodes] = struct{}{}
- }
- // ErrorCodesCleared returns if the "error_codes" field was cleared in this mutation.
- func (m *ErrorPassthroughRuleMutation) ErrorCodesCleared() bool {
- _, ok := m.clearedFields[errorpassthroughrule.FieldErrorCodes]
- return ok
- }
- // ResetErrorCodes resets all changes to the "error_codes" field.
- func (m *ErrorPassthroughRuleMutation) ResetErrorCodes() {
- m.error_codes = nil
- m.appenderror_codes = nil
- delete(m.clearedFields, errorpassthroughrule.FieldErrorCodes)
- }
- // SetKeywords sets the "keywords" field.
- func (m *ErrorPassthroughRuleMutation) SetKeywords(s []string) {
- m.keywords = &s
- m.appendkeywords = nil
- }
- // Keywords returns the value of the "keywords" field in the mutation.
- func (m *ErrorPassthroughRuleMutation) Keywords() (r []string, exists bool) {
- v := m.keywords
- if v == nil {
- return
- }
- return *v, true
- }
- // OldKeywords returns the old "keywords" field's value of the ErrorPassthroughRule entity.
- // If the ErrorPassthroughRule object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *ErrorPassthroughRuleMutation) OldKeywords(ctx context.Context) (v []string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldKeywords is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldKeywords requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldKeywords: %w", err)
- }
- return oldValue.Keywords, nil
- }
- // AppendKeywords adds s to the "keywords" field.
- func (m *ErrorPassthroughRuleMutation) AppendKeywords(s []string) {
- m.appendkeywords = append(m.appendkeywords, s...)
- }
- // AppendedKeywords returns the list of values that were appended to the "keywords" field in this mutation.
- func (m *ErrorPassthroughRuleMutation) AppendedKeywords() ([]string, bool) {
- if len(m.appendkeywords) == 0 {
- return nil, false
- }
- return m.appendkeywords, true
- }
- // ClearKeywords clears the value of the "keywords" field.
- func (m *ErrorPassthroughRuleMutation) ClearKeywords() {
- m.keywords = nil
- m.appendkeywords = nil
- m.clearedFields[errorpassthroughrule.FieldKeywords] = struct{}{}
- }
- // KeywordsCleared returns if the "keywords" field was cleared in this mutation.
- func (m *ErrorPassthroughRuleMutation) KeywordsCleared() bool {
- _, ok := m.clearedFields[errorpassthroughrule.FieldKeywords]
- return ok
- }
- // ResetKeywords resets all changes to the "keywords" field.
- func (m *ErrorPassthroughRuleMutation) ResetKeywords() {
- m.keywords = nil
- m.appendkeywords = nil
- delete(m.clearedFields, errorpassthroughrule.FieldKeywords)
- }
- // SetMatchMode sets the "match_mode" field.
- func (m *ErrorPassthroughRuleMutation) SetMatchMode(s string) {
- m.match_mode = &s
- }
- // MatchMode returns the value of the "match_mode" field in the mutation.
- func (m *ErrorPassthroughRuleMutation) MatchMode() (r string, exists bool) {
- v := m.match_mode
- if v == nil {
- return
- }
- return *v, true
- }
- // OldMatchMode returns the old "match_mode" field's value of the ErrorPassthroughRule entity.
- // If the ErrorPassthroughRule object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *ErrorPassthroughRuleMutation) OldMatchMode(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldMatchMode is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldMatchMode requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldMatchMode: %w", err)
- }
- return oldValue.MatchMode, nil
- }
- // ResetMatchMode resets all changes to the "match_mode" field.
- func (m *ErrorPassthroughRuleMutation) ResetMatchMode() {
- m.match_mode = nil
- }
- // SetPlatforms sets the "platforms" field.
- func (m *ErrorPassthroughRuleMutation) SetPlatforms(s []string) {
- m.platforms = &s
- m.appendplatforms = nil
- }
- // Platforms returns the value of the "platforms" field in the mutation.
- func (m *ErrorPassthroughRuleMutation) Platforms() (r []string, exists bool) {
- v := m.platforms
- if v == nil {
- return
- }
- return *v, true
- }
- // OldPlatforms returns the old "platforms" field's value of the ErrorPassthroughRule entity.
- // If the ErrorPassthroughRule object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *ErrorPassthroughRuleMutation) OldPlatforms(ctx context.Context) (v []string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldPlatforms is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldPlatforms requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldPlatforms: %w", err)
- }
- return oldValue.Platforms, nil
- }
- // AppendPlatforms adds s to the "platforms" field.
- func (m *ErrorPassthroughRuleMutation) AppendPlatforms(s []string) {
- m.appendplatforms = append(m.appendplatforms, s...)
- }
- // AppendedPlatforms returns the list of values that were appended to the "platforms" field in this mutation.
- func (m *ErrorPassthroughRuleMutation) AppendedPlatforms() ([]string, bool) {
- if len(m.appendplatforms) == 0 {
- return nil, false
- }
- return m.appendplatforms, true
- }
- // ClearPlatforms clears the value of the "platforms" field.
- func (m *ErrorPassthroughRuleMutation) ClearPlatforms() {
- m.platforms = nil
- m.appendplatforms = nil
- m.clearedFields[errorpassthroughrule.FieldPlatforms] = struct{}{}
- }
- // PlatformsCleared returns if the "platforms" field was cleared in this mutation.
- func (m *ErrorPassthroughRuleMutation) PlatformsCleared() bool {
- _, ok := m.clearedFields[errorpassthroughrule.FieldPlatforms]
- return ok
- }
- // ResetPlatforms resets all changes to the "platforms" field.
- func (m *ErrorPassthroughRuleMutation) ResetPlatforms() {
- m.platforms = nil
- m.appendplatforms = nil
- delete(m.clearedFields, errorpassthroughrule.FieldPlatforms)
- }
- // SetPassthroughCode sets the "passthrough_code" field.
- func (m *ErrorPassthroughRuleMutation) SetPassthroughCode(b bool) {
- m.passthrough_code = &b
- }
- // PassthroughCode returns the value of the "passthrough_code" field in the mutation.
- func (m *ErrorPassthroughRuleMutation) PassthroughCode() (r bool, exists bool) {
- v := m.passthrough_code
- if v == nil {
- return
- }
- return *v, true
- }
- // OldPassthroughCode returns the old "passthrough_code" field's value of the ErrorPassthroughRule entity.
- // If the ErrorPassthroughRule object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *ErrorPassthroughRuleMutation) OldPassthroughCode(ctx context.Context) (v bool, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldPassthroughCode is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldPassthroughCode requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldPassthroughCode: %w", err)
- }
- return oldValue.PassthroughCode, nil
- }
- // ResetPassthroughCode resets all changes to the "passthrough_code" field.
- func (m *ErrorPassthroughRuleMutation) ResetPassthroughCode() {
- m.passthrough_code = nil
- }
- // SetResponseCode sets the "response_code" field.
- func (m *ErrorPassthroughRuleMutation) SetResponseCode(i int) {
- m.response_code = &i
- m.addresponse_code = nil
- }
- // ResponseCode returns the value of the "response_code" field in the mutation.
- func (m *ErrorPassthroughRuleMutation) ResponseCode() (r int, exists bool) {
- v := m.response_code
- if v == nil {
- return
- }
- return *v, true
- }
- // OldResponseCode returns the old "response_code" field's value of the ErrorPassthroughRule entity.
- // If the ErrorPassthroughRule object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *ErrorPassthroughRuleMutation) OldResponseCode(ctx context.Context) (v *int, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldResponseCode is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldResponseCode requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldResponseCode: %w", err)
- }
- return oldValue.ResponseCode, nil
- }
- // AddResponseCode adds i to the "response_code" field.
- func (m *ErrorPassthroughRuleMutation) AddResponseCode(i int) {
- if m.addresponse_code != nil {
- *m.addresponse_code += i
- } else {
- m.addresponse_code = &i
- }
- }
- // AddedResponseCode returns the value that was added to the "response_code" field in this mutation.
- func (m *ErrorPassthroughRuleMutation) AddedResponseCode() (r int, exists bool) {
- v := m.addresponse_code
- if v == nil {
- return
- }
- return *v, true
- }
- // ClearResponseCode clears the value of the "response_code" field.
- func (m *ErrorPassthroughRuleMutation) ClearResponseCode() {
- m.response_code = nil
- m.addresponse_code = nil
- m.clearedFields[errorpassthroughrule.FieldResponseCode] = struct{}{}
- }
- // ResponseCodeCleared returns if the "response_code" field was cleared in this mutation.
- func (m *ErrorPassthroughRuleMutation) ResponseCodeCleared() bool {
- _, ok := m.clearedFields[errorpassthroughrule.FieldResponseCode]
- return ok
- }
- // ResetResponseCode resets all changes to the "response_code" field.
- func (m *ErrorPassthroughRuleMutation) ResetResponseCode() {
- m.response_code = nil
- m.addresponse_code = nil
- delete(m.clearedFields, errorpassthroughrule.FieldResponseCode)
- }
- // SetPassthroughBody sets the "passthrough_body" field.
- func (m *ErrorPassthroughRuleMutation) SetPassthroughBody(b bool) {
- m.passthrough_body = &b
- }
- // PassthroughBody returns the value of the "passthrough_body" field in the mutation.
- func (m *ErrorPassthroughRuleMutation) PassthroughBody() (r bool, exists bool) {
- v := m.passthrough_body
- if v == nil {
- return
- }
- return *v, true
- }
- // OldPassthroughBody returns the old "passthrough_body" field's value of the ErrorPassthroughRule entity.
- // If the ErrorPassthroughRule object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *ErrorPassthroughRuleMutation) OldPassthroughBody(ctx context.Context) (v bool, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldPassthroughBody is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldPassthroughBody requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldPassthroughBody: %w", err)
- }
- return oldValue.PassthroughBody, nil
- }
- // ResetPassthroughBody resets all changes to the "passthrough_body" field.
- func (m *ErrorPassthroughRuleMutation) ResetPassthroughBody() {
- m.passthrough_body = nil
- }
- // SetCustomMessage sets the "custom_message" field.
- func (m *ErrorPassthroughRuleMutation) SetCustomMessage(s string) {
- m.custom_message = &s
- }
- // CustomMessage returns the value of the "custom_message" field in the mutation.
- func (m *ErrorPassthroughRuleMutation) CustomMessage() (r string, exists bool) {
- v := m.custom_message
- if v == nil {
- return
- }
- return *v, true
- }
- // OldCustomMessage returns the old "custom_message" field's value of the ErrorPassthroughRule entity.
- // If the ErrorPassthroughRule object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *ErrorPassthroughRuleMutation) OldCustomMessage(ctx context.Context) (v *string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldCustomMessage is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldCustomMessage requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldCustomMessage: %w", err)
- }
- return oldValue.CustomMessage, nil
- }
- // ClearCustomMessage clears the value of the "custom_message" field.
- func (m *ErrorPassthroughRuleMutation) ClearCustomMessage() {
- m.custom_message = nil
- m.clearedFields[errorpassthroughrule.FieldCustomMessage] = struct{}{}
- }
- // CustomMessageCleared returns if the "custom_message" field was cleared in this mutation.
- func (m *ErrorPassthroughRuleMutation) CustomMessageCleared() bool {
- _, ok := m.clearedFields[errorpassthroughrule.FieldCustomMessage]
- return ok
- }
- // ResetCustomMessage resets all changes to the "custom_message" field.
- func (m *ErrorPassthroughRuleMutation) ResetCustomMessage() {
- m.custom_message = nil
- delete(m.clearedFields, errorpassthroughrule.FieldCustomMessage)
- }
- // SetSkipMonitoring sets the "skip_monitoring" field.
- func (m *ErrorPassthroughRuleMutation) SetSkipMonitoring(b bool) {
- m.skip_monitoring = &b
- }
- // SkipMonitoring returns the value of the "skip_monitoring" field in the mutation.
- func (m *ErrorPassthroughRuleMutation) SkipMonitoring() (r bool, exists bool) {
- v := m.skip_monitoring
- if v == nil {
- return
- }
- return *v, true
- }
- // OldSkipMonitoring returns the old "skip_monitoring" field's value of the ErrorPassthroughRule entity.
- // If the ErrorPassthroughRule object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *ErrorPassthroughRuleMutation) OldSkipMonitoring(ctx context.Context) (v bool, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldSkipMonitoring is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldSkipMonitoring requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldSkipMonitoring: %w", err)
- }
- return oldValue.SkipMonitoring, nil
- }
- // ResetSkipMonitoring resets all changes to the "skip_monitoring" field.
- func (m *ErrorPassthroughRuleMutation) ResetSkipMonitoring() {
- m.skip_monitoring = nil
- }
- // SetDescription sets the "description" field.
- func (m *ErrorPassthroughRuleMutation) SetDescription(s string) {
- m.description = &s
- }
- // Description returns the value of the "description" field in the mutation.
- func (m *ErrorPassthroughRuleMutation) Description() (r string, exists bool) {
- v := m.description
- if v == nil {
- return
- }
- return *v, true
- }
- // OldDescription returns the old "description" field's value of the ErrorPassthroughRule entity.
- // If the ErrorPassthroughRule object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *ErrorPassthroughRuleMutation) OldDescription(ctx context.Context) (v *string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldDescription is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldDescription requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldDescription: %w", err)
- }
- return oldValue.Description, nil
- }
- // ClearDescription clears the value of the "description" field.
- func (m *ErrorPassthroughRuleMutation) ClearDescription() {
- m.description = nil
- m.clearedFields[errorpassthroughrule.FieldDescription] = struct{}{}
- }
- // DescriptionCleared returns if the "description" field was cleared in this mutation.
- func (m *ErrorPassthroughRuleMutation) DescriptionCleared() bool {
- _, ok := m.clearedFields[errorpassthroughrule.FieldDescription]
- return ok
- }
- // ResetDescription resets all changes to the "description" field.
- func (m *ErrorPassthroughRuleMutation) ResetDescription() {
- m.description = nil
- delete(m.clearedFields, errorpassthroughrule.FieldDescription)
- }
- // Where appends a list predicates to the ErrorPassthroughRuleMutation builder.
- func (m *ErrorPassthroughRuleMutation) Where(ps ...predicate.ErrorPassthroughRule) {
- m.predicates = append(m.predicates, ps...)
- }
- // WhereP appends storage-level predicates to the ErrorPassthroughRuleMutation builder. Using this method,
- // users can use type-assertion to append predicates that do not depend on any generated package.
- func (m *ErrorPassthroughRuleMutation) WhereP(ps ...func(*sql.Selector)) {
- p := make([]predicate.ErrorPassthroughRule, len(ps))
- for i := range ps {
- p[i] = ps[i]
- }
- m.Where(p...)
- }
- // Op returns the operation name.
- func (m *ErrorPassthroughRuleMutation) Op() Op {
- return m.op
- }
- // SetOp allows setting the mutation operation.
- func (m *ErrorPassthroughRuleMutation) SetOp(op Op) {
- m.op = op
- }
- // Type returns the node type of this mutation (ErrorPassthroughRule).
- func (m *ErrorPassthroughRuleMutation) Type() string {
- return m.typ
- }
- // Fields returns all fields that were changed during this mutation. Note that in
- // order to get all numeric fields that were incremented/decremented, call
- // AddedFields().
- func (m *ErrorPassthroughRuleMutation) Fields() []string {
- fields := make([]string, 0, 15)
- if m.created_at != nil {
- fields = append(fields, errorpassthroughrule.FieldCreatedAt)
- }
- if m.updated_at != nil {
- fields = append(fields, errorpassthroughrule.FieldUpdatedAt)
- }
- if m.name != nil {
- fields = append(fields, errorpassthroughrule.FieldName)
- }
- if m.enabled != nil {
- fields = append(fields, errorpassthroughrule.FieldEnabled)
- }
- if m.priority != nil {
- fields = append(fields, errorpassthroughrule.FieldPriority)
- }
- if m.error_codes != nil {
- fields = append(fields, errorpassthroughrule.FieldErrorCodes)
- }
- if m.keywords != nil {
- fields = append(fields, errorpassthroughrule.FieldKeywords)
- }
- if m.match_mode != nil {
- fields = append(fields, errorpassthroughrule.FieldMatchMode)
- }
- if m.platforms != nil {
- fields = append(fields, errorpassthroughrule.FieldPlatforms)
- }
- if m.passthrough_code != nil {
- fields = append(fields, errorpassthroughrule.FieldPassthroughCode)
- }
- if m.response_code != nil {
- fields = append(fields, errorpassthroughrule.FieldResponseCode)
- }
- if m.passthrough_body != nil {
- fields = append(fields, errorpassthroughrule.FieldPassthroughBody)
- }
- if m.custom_message != nil {
- fields = append(fields, errorpassthroughrule.FieldCustomMessage)
- }
- if m.skip_monitoring != nil {
- fields = append(fields, errorpassthroughrule.FieldSkipMonitoring)
- }
- if m.description != nil {
- fields = append(fields, errorpassthroughrule.FieldDescription)
- }
- return fields
- }
- // Field returns the value of a field with the given name. The second boolean
- // return value indicates that this field was not set, or was not defined in the
- // schema.
- func (m *ErrorPassthroughRuleMutation) Field(name string) (ent.Value, bool) {
- switch name {
- case errorpassthroughrule.FieldCreatedAt:
- return m.CreatedAt()
- case errorpassthroughrule.FieldUpdatedAt:
- return m.UpdatedAt()
- case errorpassthroughrule.FieldName:
- return m.Name()
- case errorpassthroughrule.FieldEnabled:
- return m.Enabled()
- case errorpassthroughrule.FieldPriority:
- return m.Priority()
- case errorpassthroughrule.FieldErrorCodes:
- return m.ErrorCodes()
- case errorpassthroughrule.FieldKeywords:
- return m.Keywords()
- case errorpassthroughrule.FieldMatchMode:
- return m.MatchMode()
- case errorpassthroughrule.FieldPlatforms:
- return m.Platforms()
- case errorpassthroughrule.FieldPassthroughCode:
- return m.PassthroughCode()
- case errorpassthroughrule.FieldResponseCode:
- return m.ResponseCode()
- case errorpassthroughrule.FieldPassthroughBody:
- return m.PassthroughBody()
- case errorpassthroughrule.FieldCustomMessage:
- return m.CustomMessage()
- case errorpassthroughrule.FieldSkipMonitoring:
- return m.SkipMonitoring()
- case errorpassthroughrule.FieldDescription:
- return m.Description()
- }
- return nil, false
- }
- // OldField returns the old value of the field from the database. An error is
- // returned if the mutation operation is not UpdateOne, or the query to the
- // database failed.
- func (m *ErrorPassthroughRuleMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
- switch name {
- case errorpassthroughrule.FieldCreatedAt:
- return m.OldCreatedAt(ctx)
- case errorpassthroughrule.FieldUpdatedAt:
- return m.OldUpdatedAt(ctx)
- case errorpassthroughrule.FieldName:
- return m.OldName(ctx)
- case errorpassthroughrule.FieldEnabled:
- return m.OldEnabled(ctx)
- case errorpassthroughrule.FieldPriority:
- return m.OldPriority(ctx)
- case errorpassthroughrule.FieldErrorCodes:
- return m.OldErrorCodes(ctx)
- case errorpassthroughrule.FieldKeywords:
- return m.OldKeywords(ctx)
- case errorpassthroughrule.FieldMatchMode:
- return m.OldMatchMode(ctx)
- case errorpassthroughrule.FieldPlatforms:
- return m.OldPlatforms(ctx)
- case errorpassthroughrule.FieldPassthroughCode:
- return m.OldPassthroughCode(ctx)
- case errorpassthroughrule.FieldResponseCode:
- return m.OldResponseCode(ctx)
- case errorpassthroughrule.FieldPassthroughBody:
- return m.OldPassthroughBody(ctx)
- case errorpassthroughrule.FieldCustomMessage:
- return m.OldCustomMessage(ctx)
- case errorpassthroughrule.FieldSkipMonitoring:
- return m.OldSkipMonitoring(ctx)
- case errorpassthroughrule.FieldDescription:
- return m.OldDescription(ctx)
- }
- return nil, fmt.Errorf("unknown ErrorPassthroughRule field %s", name)
- }
- // SetField sets the value of a field with the given name. It returns an error if
- // the field is not defined in the schema, or if the type mismatched the field
- // type.
- func (m *ErrorPassthroughRuleMutation) SetField(name string, value ent.Value) error {
- switch name {
- case errorpassthroughrule.FieldCreatedAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetCreatedAt(v)
- return nil
- case errorpassthroughrule.FieldUpdatedAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetUpdatedAt(v)
- return nil
- case errorpassthroughrule.FieldName:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetName(v)
- return nil
- case errorpassthroughrule.FieldEnabled:
- v, ok := value.(bool)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetEnabled(v)
- return nil
- case errorpassthroughrule.FieldPriority:
- v, ok := value.(int)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetPriority(v)
- return nil
- case errorpassthroughrule.FieldErrorCodes:
- v, ok := value.([]int)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetErrorCodes(v)
- return nil
- case errorpassthroughrule.FieldKeywords:
- v, ok := value.([]string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetKeywords(v)
- return nil
- case errorpassthroughrule.FieldMatchMode:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetMatchMode(v)
- return nil
- case errorpassthroughrule.FieldPlatforms:
- v, ok := value.([]string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetPlatforms(v)
- return nil
- case errorpassthroughrule.FieldPassthroughCode:
- v, ok := value.(bool)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetPassthroughCode(v)
- return nil
- case errorpassthroughrule.FieldResponseCode:
- v, ok := value.(int)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetResponseCode(v)
- return nil
- case errorpassthroughrule.FieldPassthroughBody:
- v, ok := value.(bool)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetPassthroughBody(v)
- return nil
- case errorpassthroughrule.FieldCustomMessage:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetCustomMessage(v)
- return nil
- case errorpassthroughrule.FieldSkipMonitoring:
- v, ok := value.(bool)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetSkipMonitoring(v)
- return nil
- case errorpassthroughrule.FieldDescription:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetDescription(v)
- return nil
- }
- return fmt.Errorf("unknown ErrorPassthroughRule field %s", name)
- }
- // AddedFields returns all numeric fields that were incremented/decremented during
- // this mutation.
- func (m *ErrorPassthroughRuleMutation) AddedFields() []string {
- var fields []string
- if m.addpriority != nil {
- fields = append(fields, errorpassthroughrule.FieldPriority)
- }
- if m.addresponse_code != nil {
- fields = append(fields, errorpassthroughrule.FieldResponseCode)
- }
- return fields
- }
- // AddedField returns the numeric value that was incremented/decremented on a field
- // with the given name. The second boolean return value indicates that this field
- // was not set, or was not defined in the schema.
- func (m *ErrorPassthroughRuleMutation) AddedField(name string) (ent.Value, bool) {
- switch name {
- case errorpassthroughrule.FieldPriority:
- return m.AddedPriority()
- case errorpassthroughrule.FieldResponseCode:
- return m.AddedResponseCode()
- }
- return nil, false
- }
- // AddField adds the value to the field with the given name. It returns an error if
- // the field is not defined in the schema, or if the type mismatched the field
- // type.
- func (m *ErrorPassthroughRuleMutation) AddField(name string, value ent.Value) error {
- switch name {
- case errorpassthroughrule.FieldPriority:
- v, ok := value.(int)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.AddPriority(v)
- return nil
- case errorpassthroughrule.FieldResponseCode:
- v, ok := value.(int)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.AddResponseCode(v)
- return nil
- }
- return fmt.Errorf("unknown ErrorPassthroughRule numeric field %s", name)
- }
- // ClearedFields returns all nullable fields that were cleared during this
- // mutation.
- func (m *ErrorPassthroughRuleMutation) ClearedFields() []string {
- var fields []string
- if m.FieldCleared(errorpassthroughrule.FieldErrorCodes) {
- fields = append(fields, errorpassthroughrule.FieldErrorCodes)
- }
- if m.FieldCleared(errorpassthroughrule.FieldKeywords) {
- fields = append(fields, errorpassthroughrule.FieldKeywords)
- }
- if m.FieldCleared(errorpassthroughrule.FieldPlatforms) {
- fields = append(fields, errorpassthroughrule.FieldPlatforms)
- }
- if m.FieldCleared(errorpassthroughrule.FieldResponseCode) {
- fields = append(fields, errorpassthroughrule.FieldResponseCode)
- }
- if m.FieldCleared(errorpassthroughrule.FieldCustomMessage) {
- fields = append(fields, errorpassthroughrule.FieldCustomMessage)
- }
- if m.FieldCleared(errorpassthroughrule.FieldDescription) {
- fields = append(fields, errorpassthroughrule.FieldDescription)
- }
- return fields
- }
- // FieldCleared returns a boolean indicating if a field with the given name was
- // cleared in this mutation.
- func (m *ErrorPassthroughRuleMutation) FieldCleared(name string) bool {
- _, ok := m.clearedFields[name]
- return ok
- }
- // ClearField clears the value of the field with the given name. It returns an
- // error if the field is not defined in the schema.
- func (m *ErrorPassthroughRuleMutation) ClearField(name string) error {
- switch name {
- case errorpassthroughrule.FieldErrorCodes:
- m.ClearErrorCodes()
- return nil
- case errorpassthroughrule.FieldKeywords:
- m.ClearKeywords()
- return nil
- case errorpassthroughrule.FieldPlatforms:
- m.ClearPlatforms()
- return nil
- case errorpassthroughrule.FieldResponseCode:
- m.ClearResponseCode()
- return nil
- case errorpassthroughrule.FieldCustomMessage:
- m.ClearCustomMessage()
- return nil
- case errorpassthroughrule.FieldDescription:
- m.ClearDescription()
- return nil
- }
- return fmt.Errorf("unknown ErrorPassthroughRule nullable field %s", name)
- }
- // ResetField resets all changes in the mutation for the field with the given name.
- // It returns an error if the field is not defined in the schema.
- func (m *ErrorPassthroughRuleMutation) ResetField(name string) error {
- switch name {
- case errorpassthroughrule.FieldCreatedAt:
- m.ResetCreatedAt()
- return nil
- case errorpassthroughrule.FieldUpdatedAt:
- m.ResetUpdatedAt()
- return nil
- case errorpassthroughrule.FieldName:
- m.ResetName()
- return nil
- case errorpassthroughrule.FieldEnabled:
- m.ResetEnabled()
- return nil
- case errorpassthroughrule.FieldPriority:
- m.ResetPriority()
- return nil
- case errorpassthroughrule.FieldErrorCodes:
- m.ResetErrorCodes()
- return nil
- case errorpassthroughrule.FieldKeywords:
- m.ResetKeywords()
- return nil
- case errorpassthroughrule.FieldMatchMode:
- m.ResetMatchMode()
- return nil
- case errorpassthroughrule.FieldPlatforms:
- m.ResetPlatforms()
- return nil
- case errorpassthroughrule.FieldPassthroughCode:
- m.ResetPassthroughCode()
- return nil
- case errorpassthroughrule.FieldResponseCode:
- m.ResetResponseCode()
- return nil
- case errorpassthroughrule.FieldPassthroughBody:
- m.ResetPassthroughBody()
- return nil
- case errorpassthroughrule.FieldCustomMessage:
- m.ResetCustomMessage()
- return nil
- case errorpassthroughrule.FieldSkipMonitoring:
- m.ResetSkipMonitoring()
- return nil
- case errorpassthroughrule.FieldDescription:
- m.ResetDescription()
- return nil
- }
- return fmt.Errorf("unknown ErrorPassthroughRule field %s", name)
- }
- // AddedEdges returns all edge names that were set/added in this mutation.
- func (m *ErrorPassthroughRuleMutation) AddedEdges() []string {
- edges := make([]string, 0, 0)
- return edges
- }
- // AddedIDs returns all IDs (to other nodes) that were added for the given edge
- // name in this mutation.
- func (m *ErrorPassthroughRuleMutation) AddedIDs(name string) []ent.Value {
- return nil
- }
- // RemovedEdges returns all edge names that were removed in this mutation.
- func (m *ErrorPassthroughRuleMutation) RemovedEdges() []string {
- edges := make([]string, 0, 0)
- return edges
- }
- // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
- // the given name in this mutation.
- func (m *ErrorPassthroughRuleMutation) RemovedIDs(name string) []ent.Value {
- return nil
- }
- // ClearedEdges returns all edge names that were cleared in this mutation.
- func (m *ErrorPassthroughRuleMutation) ClearedEdges() []string {
- edges := make([]string, 0, 0)
- return edges
- }
- // EdgeCleared returns a boolean which indicates if the edge with the given name
- // was cleared in this mutation.
- func (m *ErrorPassthroughRuleMutation) EdgeCleared(name string) bool {
- return false
- }
- // ClearEdge clears the value of the edge with the given name. It returns an error
- // if that edge is not defined in the schema.
- func (m *ErrorPassthroughRuleMutation) ClearEdge(name string) error {
- return fmt.Errorf("unknown ErrorPassthroughRule unique edge %s", name)
- }
- // ResetEdge resets all changes to the edge with the given name in this mutation.
- // It returns an error if the edge is not defined in the schema.
- func (m *ErrorPassthroughRuleMutation) ResetEdge(name string) error {
- return fmt.Errorf("unknown ErrorPassthroughRule edge %s", name)
- }
- // GroupMutation represents an operation that mutates the Group nodes in the graph.
- type GroupMutation struct {
- config
- op Op
- typ string
- id *int64
- created_at *time.Time
- updated_at *time.Time
- deleted_at *time.Time
- name *string
- description *string
- rate_multiplier *float64
- addrate_multiplier *float64
- peak_rate_enabled *bool
- peak_start *string
- peak_end *string
- peak_rate_multiplier *float64
- addpeak_rate_multiplier *float64
- is_exclusive *bool
- security_policy_enabled *bool
- security_policy_mode *string
- security_policy_email_enabled *bool
- status *string
- duplicate_operation_id *string
- platform *string
- subscription_type *string
- daily_limit_usd *float64
- adddaily_limit_usd *float64
- weekly_limit_usd *float64
- addweekly_limit_usd *float64
- monthly_limit_usd *float64
- addmonthly_limit_usd *float64
- default_validity_days *int
- adddefault_validity_days *int
- allow_image_generation *bool
- allow_batch_image_generation *bool
- image_rate_independent *bool
- image_rate_multiplier *float64
- addimage_rate_multiplier *float64
- image_price_1k *float64
- addimage_price_1k *float64
- image_price_2k *float64
- addimage_price_2k *float64
- image_price_4k *float64
- addimage_price_4k *float64
- batch_image_discount_multiplier *float64
- addbatch_image_discount_multiplier *float64
- batch_image_hold_multiplier *float64
- addbatch_image_hold_multiplier *float64
- video_rate_independent *bool
- video_rate_multiplier *float64
- addvideo_rate_multiplier *float64
- video_price_480p *float64
- addvideo_price_480p *float64
- video_price_720p *float64
- addvideo_price_720p *float64
- video_price_1080p *float64
- addvideo_price_1080p *float64
- video_model_prices *map[string]map[string]float64
- web_search_price_per_call *float64
- addweb_search_price_per_call *float64
- search_price_per_1k *float64
- addsearch_price_per_1k *float64
- audio_realtime_price_per_min *float64
- addaudio_realtime_price_per_min *float64
- audio_tts_price_per_million_chars *float64
- addaudio_tts_price_per_million_chars *float64
- audio_stt_price_per_hour *float64
- addaudio_stt_price_per_hour *float64
- long_context_pricing_enabled *bool
- model_pricing *jsontext.Value
- appendmodel_pricing jsontext.Value
- claude_code_only *bool
- fallback_group_id *int64
- addfallback_group_id *int64
- fallback_group_id_on_invalid_request *int64
- addfallback_group_id_on_invalid_request *int64
- model_routing *map[string][]int64
- model_routing_enabled *bool
- mcp_xml_inject *bool
- supported_model_scopes *[]string
- appendsupported_model_scopes []string
- sort_order *int
- addsort_order *int
- allow_messages_dispatch *bool
- allow_live *bool
- force_openai_fast *bool
- free_openai_fast *bool
- require_oauth_only *bool
- require_privacy_set *bool
- default_mapped_model *string
- messages_dispatch_model_config *domain.OpenAIMessagesDispatchModelConfig
- model_allowlist *domain.GroupModelAllowlist
- codex_models_manifest_config *domain.GroupCodexModelsManifestConfig
- rpm_limit *int
- addrpm_limit *int
- max_reasoning_effort *string
- max_reasoning_effort_over_limit *string
- reasoning_effort_mappings *[]domain.ReasoningEffortMapping
- appendreasoning_effort_mappings []domain.ReasoningEffortMapping
- profit_control_enabled *bool
- profit_min_margin *float64
- addprofit_min_margin *float64
- profit_safety_buffer *float64
- addprofit_safety_buffer *float64
- clearedFields map[string]struct{}
- api_keys map[int64]struct{}
- removedapi_keys map[int64]struct{}
- clearedapi_keys bool
- redeem_codes map[int64]struct{}
- removedredeem_codes map[int64]struct{}
- clearedredeem_codes bool
- subscriptions map[int64]struct{}
- removedsubscriptions map[int64]struct{}
- clearedsubscriptions bool
- usage_logs map[int64]struct{}
- removedusage_logs map[int64]struct{}
- clearedusage_logs bool
- accounts map[int64]struct{}
- removedaccounts map[int64]struct{}
- clearedaccounts bool
- allowed_users map[int64]struct{}
- removedallowed_users map[int64]struct{}
- clearedallowed_users bool
- done bool
- oldValue func(context.Context) (*Group, error)
- predicates []predicate.Group
- }
- var _ ent.Mutation = (*GroupMutation)(nil)
- // groupOption allows management of the mutation configuration using functional options.
- type groupOption func(*GroupMutation)
- // newGroupMutation creates new mutation for the Group entity.
- func newGroupMutation(c config, op Op, opts ...groupOption) *GroupMutation {
- m := &GroupMutation{
- config: c,
- op: op,
- typ: TypeGroup,
- clearedFields: make(map[string]struct{}),
- }
- for _, opt := range opts {
- opt(m)
- }
- return m
- }
- // withGroupID sets the ID field of the mutation.
- func withGroupID(id int64) groupOption {
- return func(m *GroupMutation) {
- var (
- err error
- once sync.Once
- value *Group
- )
- m.oldValue = func(ctx context.Context) (*Group, error) {
- once.Do(func() {
- if m.done {
- err = errors.New("querying old values post mutation is not allowed")
- } else {
- value, err = m.Client().Group.Get(ctx, id)
- }
- })
- return value, err
- }
- m.id = &id
- }
- }
- // withGroup sets the old Group of the mutation.
- func withGroup(node *Group) groupOption {
- return func(m *GroupMutation) {
- m.oldValue = func(context.Context) (*Group, error) {
- return node, nil
- }
- m.id = &node.ID
- }
- }
- // Client returns a new `ent.Client` from the mutation. If the mutation was
- // executed in a transaction (ent.Tx), a transactional client is returned.
- func (m GroupMutation) Client() *Client {
- client := &Client{config: m.config}
- client.init()
- return client
- }
- // Tx returns an `ent.Tx` for mutations that were executed in transactions;
- // it returns an error otherwise.
- func (m GroupMutation) Tx() (*Tx, error) {
- if _, ok := m.driver.(*txDriver); !ok {
- return nil, errors.New("ent: mutation is not running in a transaction")
- }
- tx := &Tx{config: m.config}
- tx.init()
- return tx, nil
- }
- // ID returns the ID value in the mutation. Note that the ID is only available
- // if it was provided to the builder or after it was returned from the database.
- func (m *GroupMutation) ID() (id int64, exists bool) {
- if m.id == nil {
- return
- }
- return *m.id, true
- }
- // IDs queries the database and returns the entity ids that match the mutation's predicate.
- // That means, if the mutation is applied within a transaction with an isolation level such
- // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
- // or updated by the mutation.
- func (m *GroupMutation) IDs(ctx context.Context) ([]int64, error) {
- switch {
- case m.op.Is(OpUpdateOne | OpDeleteOne):
- id, exists := m.ID()
- if exists {
- return []int64{id}, nil
- }
- fallthrough
- case m.op.Is(OpUpdate | OpDelete):
- return m.Client().Group.Query().Where(m.predicates...).IDs(ctx)
- default:
- return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
- }
- }
- // SetCreatedAt sets the "created_at" field.
- func (m *GroupMutation) SetCreatedAt(t time.Time) {
- m.created_at = &t
- }
- // CreatedAt returns the value of the "created_at" field in the mutation.
- func (m *GroupMutation) CreatedAt() (r time.Time, exists bool) {
- v := m.created_at
- if v == nil {
- return
- }
- return *v, true
- }
- // OldCreatedAt returns the old "created_at" field's value of the Group entity.
- // If the Group object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *GroupMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldCreatedAt requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
- }
- return oldValue.CreatedAt, nil
- }
- // ResetCreatedAt resets all changes to the "created_at" field.
- func (m *GroupMutation) ResetCreatedAt() {
- m.created_at = nil
- }
- // SetUpdatedAt sets the "updated_at" field.
- func (m *GroupMutation) SetUpdatedAt(t time.Time) {
- m.updated_at = &t
- }
- // UpdatedAt returns the value of the "updated_at" field in the mutation.
- func (m *GroupMutation) UpdatedAt() (r time.Time, exists bool) {
- v := m.updated_at
- if v == nil {
- return
- }
- return *v, true
- }
- // OldUpdatedAt returns the old "updated_at" field's value of the Group entity.
- // If the Group object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *GroupMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
- }
- return oldValue.UpdatedAt, nil
- }
- // ResetUpdatedAt resets all changes to the "updated_at" field.
- func (m *GroupMutation) ResetUpdatedAt() {
- m.updated_at = nil
- }
- // SetDeletedAt sets the "deleted_at" field.
- func (m *GroupMutation) SetDeletedAt(t time.Time) {
- m.deleted_at = &t
- }
- // DeletedAt returns the value of the "deleted_at" field in the mutation.
- func (m *GroupMutation) DeletedAt() (r time.Time, exists bool) {
- v := m.deleted_at
- if v == nil {
- return
- }
- return *v, true
- }
- // OldDeletedAt returns the old "deleted_at" field's value of the Group entity.
- // If the Group object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *GroupMutation) OldDeletedAt(ctx context.Context) (v *time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldDeletedAt requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
- }
- return oldValue.DeletedAt, nil
- }
- // ClearDeletedAt clears the value of the "deleted_at" field.
- func (m *GroupMutation) ClearDeletedAt() {
- m.deleted_at = nil
- m.clearedFields[group.FieldDeletedAt] = struct{}{}
- }
- // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
- func (m *GroupMutation) DeletedAtCleared() bool {
- _, ok := m.clearedFields[group.FieldDeletedAt]
- return ok
- }
- // ResetDeletedAt resets all changes to the "deleted_at" field.
- func (m *GroupMutation) ResetDeletedAt() {
- m.deleted_at = nil
- delete(m.clearedFields, group.FieldDeletedAt)
- }
- // SetName sets the "name" field.
- func (m *GroupMutation) SetName(s string) {
- m.name = &s
- }
- // Name returns the value of the "name" field in the mutation.
- func (m *GroupMutation) Name() (r string, exists bool) {
- v := m.name
- if v == nil {
- return
- }
- return *v, true
- }
- // OldName returns the old "name" field's value of the Group entity.
- // If the Group object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *GroupMutation) OldName(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldName is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldName requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldName: %w", err)
- }
- return oldValue.Name, nil
- }
- // ResetName resets all changes to the "name" field.
- func (m *GroupMutation) ResetName() {
- m.name = nil
- }
- // SetDescription sets the "description" field.
- func (m *GroupMutation) SetDescription(s string) {
- m.description = &s
- }
- // Description returns the value of the "description" field in the mutation.
- func (m *GroupMutation) Description() (r string, exists bool) {
- v := m.description
- if v == nil {
- return
- }
- return *v, true
- }
- // OldDescription returns the old "description" field's value of the Group entity.
- // If the Group object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *GroupMutation) OldDescription(ctx context.Context) (v *string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldDescription is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldDescription requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldDescription: %w", err)
- }
- return oldValue.Description, nil
- }
- // ClearDescription clears the value of the "description" field.
- func (m *GroupMutation) ClearDescription() {
- m.description = nil
- m.clearedFields[group.FieldDescription] = struct{}{}
- }
- // DescriptionCleared returns if the "description" field was cleared in this mutation.
- func (m *GroupMutation) DescriptionCleared() bool {
- _, ok := m.clearedFields[group.FieldDescription]
- return ok
- }
- // ResetDescription resets all changes to the "description" field.
- func (m *GroupMutation) ResetDescription() {
- m.description = nil
- delete(m.clearedFields, group.FieldDescription)
- }
- // SetRateMultiplier sets the "rate_multiplier" field.
- func (m *GroupMutation) SetRateMultiplier(f float64) {
- m.rate_multiplier = &f
- m.addrate_multiplier = nil
- }
- // RateMultiplier returns the value of the "rate_multiplier" field in the mutation.
- func (m *GroupMutation) RateMultiplier() (r float64, exists bool) {
- v := m.rate_multiplier
- if v == nil {
- return
- }
- return *v, true
- }
- // OldRateMultiplier returns the old "rate_multiplier" field's value of the Group entity.
- // If the Group object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *GroupMutation) OldRateMultiplier(ctx context.Context) (v float64, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldRateMultiplier is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldRateMultiplier requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldRateMultiplier: %w", err)
- }
- return oldValue.RateMultiplier, nil
- }
- // AddRateMultiplier adds f to the "rate_multiplier" field.
- func (m *GroupMutation) AddRateMultiplier(f float64) {
- if m.addrate_multiplier != nil {
- *m.addrate_multiplier += f
- } else {
- m.addrate_multiplier = &f
- }
- }
- // AddedRateMultiplier returns the value that was added to the "rate_multiplier" field in this mutation.
- func (m *GroupMutation) AddedRateMultiplier() (r float64, exists bool) {
- v := m.addrate_multiplier
- if v == nil {
- return
- }
- return *v, true
- }
- // ResetRateMultiplier resets all changes to the "rate_multiplier" field.
- func (m *GroupMutation) ResetRateMultiplier() {
- m.rate_multiplier = nil
- m.addrate_multiplier = nil
- }
- // SetPeakRateEnabled sets the "peak_rate_enabled" field.
- func (m *GroupMutation) SetPeakRateEnabled(b bool) {
- m.peak_rate_enabled = &b
- }
- // PeakRateEnabled returns the value of the "peak_rate_enabled" field in the mutation.
- func (m *GroupMutation) PeakRateEnabled() (r bool, exists bool) {
- v := m.peak_rate_enabled
- if v == nil {
- return
- }
- return *v, true
- }
- // OldPeakRateEnabled returns the old "peak_rate_enabled" field's value of the Group entity.
- // If the Group object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *GroupMutation) OldPeakRateEnabled(ctx context.Context) (v bool, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldPeakRateEnabled is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldPeakRateEnabled requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldPeakRateEnabled: %w", err)
- }
- return oldValue.PeakRateEnabled, nil
- }
- // ResetPeakRateEnabled resets all changes to the "peak_rate_enabled" field.
- func (m *GroupMutation) ResetPeakRateEnabled() {
- m.peak_rate_enabled = nil
- }
- // SetPeakStart sets the "peak_start" field.
- func (m *GroupMutation) SetPeakStart(s string) {
- m.peak_start = &s
- }
- // PeakStart returns the value of the "peak_start" field in the mutation.
- func (m *GroupMutation) PeakStart() (r string, exists bool) {
- v := m.peak_start
- if v == nil {
- return
- }
- return *v, true
- }
- // OldPeakStart returns the old "peak_start" field's value of the Group entity.
- // If the Group object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *GroupMutation) OldPeakStart(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldPeakStart is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldPeakStart requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldPeakStart: %w", err)
- }
- return oldValue.PeakStart, nil
- }
- // ResetPeakStart resets all changes to the "peak_start" field.
- func (m *GroupMutation) ResetPeakStart() {
- m.peak_start = nil
- }
- // SetPeakEnd sets the "peak_end" field.
- func (m *GroupMutation) SetPeakEnd(s string) {
- m.peak_end = &s
- }
- // PeakEnd returns the value of the "peak_end" field in the mutation.
- func (m *GroupMutation) PeakEnd() (r string, exists bool) {
- v := m.peak_end
- if v == nil {
- return
- }
- return *v, true
- }
- // OldPeakEnd returns the old "peak_end" field's value of the Group entity.
- // If the Group object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *GroupMutation) OldPeakEnd(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldPeakEnd is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldPeakEnd requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldPeakEnd: %w", err)
- }
- return oldValue.PeakEnd, nil
- }
- // ResetPeakEnd resets all changes to the "peak_end" field.
- func (m *GroupMutation) ResetPeakEnd() {
- m.peak_end = nil
- }
- // SetPeakRateMultiplier sets the "peak_rate_multiplier" field.
- func (m *GroupMutation) SetPeakRateMultiplier(f float64) {
- m.peak_rate_multiplier = &f
- m.addpeak_rate_multiplier = nil
- }
- // PeakRateMultiplier returns the value of the "peak_rate_multiplier" field in the mutation.
- func (m *GroupMutation) PeakRateMultiplier() (r float64, exists bool) {
- v := m.peak_rate_multiplier
- if v == nil {
- return
- }
- return *v, true
- }
- // OldPeakRateMultiplier returns the old "peak_rate_multiplier" field's value of the Group entity.
- // If the Group object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *GroupMutation) OldPeakRateMultiplier(ctx context.Context) (v float64, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldPeakRateMultiplier is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldPeakRateMultiplier requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldPeakRateMultiplier: %w", err)
- }
- return oldValue.PeakRateMultiplier, nil
- }
- // AddPeakRateMultiplier adds f to the "peak_rate_multiplier" field.
- func (m *GroupMutation) AddPeakRateMultiplier(f float64) {
- if m.addpeak_rate_multiplier != nil {
- *m.addpeak_rate_multiplier += f
- } else {
- m.addpeak_rate_multiplier = &f
- }
- }
- // AddedPeakRateMultiplier returns the value that was added to the "peak_rate_multiplier" field in this mutation.
- func (m *GroupMutation) AddedPeakRateMultiplier() (r float64, exists bool) {
- v := m.addpeak_rate_multiplier
- if v == nil {
- return
- }
- return *v, true
- }
- // ResetPeakRateMultiplier resets all changes to the "peak_rate_multiplier" field.
- func (m *GroupMutation) ResetPeakRateMultiplier() {
- m.peak_rate_multiplier = nil
- m.addpeak_rate_multiplier = nil
- }
- // SetIsExclusive sets the "is_exclusive" field.
- func (m *GroupMutation) SetIsExclusive(b bool) {
- m.is_exclusive = &b
- }
- // IsExclusive returns the value of the "is_exclusive" field in the mutation.
- func (m *GroupMutation) IsExclusive() (r bool, exists bool) {
- v := m.is_exclusive
- if v == nil {
- return
- }
- return *v, true
- }
- // OldIsExclusive returns the old "is_exclusive" field's value of the Group entity.
- // If the Group object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *GroupMutation) OldIsExclusive(ctx context.Context) (v bool, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldIsExclusive is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldIsExclusive requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldIsExclusive: %w", err)
- }
- return oldValue.IsExclusive, nil
- }
- // ResetIsExclusive resets all changes to the "is_exclusive" field.
- func (m *GroupMutation) ResetIsExclusive() {
- m.is_exclusive = nil
- }
- // SetSecurityPolicyEnabled sets the "security_policy_enabled" field.
- func (m *GroupMutation) SetSecurityPolicyEnabled(b bool) {
- m.security_policy_enabled = &b
- }
- // SecurityPolicyEnabled returns the value of the "security_policy_enabled" field in the mutation.
- func (m *GroupMutation) SecurityPolicyEnabled() (r bool, exists bool) {
- v := m.security_policy_enabled
- if v == nil {
- return
- }
- return *v, true
- }
- // OldSecurityPolicyEnabled returns the old "security_policy_enabled" field's value of the Group entity.
- // If the Group object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *GroupMutation) OldSecurityPolicyEnabled(ctx context.Context) (v bool, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldSecurityPolicyEnabled is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldSecurityPolicyEnabled requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldSecurityPolicyEnabled: %w", err)
- }
- return oldValue.SecurityPolicyEnabled, nil
- }
- // ResetSecurityPolicyEnabled resets all changes to the "security_policy_enabled" field.
- func (m *GroupMutation) ResetSecurityPolicyEnabled() {
- m.security_policy_enabled = nil
- }
- // SetSecurityPolicyMode sets the "security_policy_mode" field.
- func (m *GroupMutation) SetSecurityPolicyMode(s string) {
- m.security_policy_mode = &s
- }
- // SecurityPolicyMode returns the value of the "security_policy_mode" field in the mutation.
- func (m *GroupMutation) SecurityPolicyMode() (r string, exists bool) {
- v := m.security_policy_mode
- if v == nil {
- return
- }
- return *v, true
- }
- // OldSecurityPolicyMode returns the old "security_policy_mode" field's value of the Group entity.
- // If the Group object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *GroupMutation) OldSecurityPolicyMode(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldSecurityPolicyMode is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldSecurityPolicyMode requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldSecurityPolicyMode: %w", err)
- }
- return oldValue.SecurityPolicyMode, nil
- }
- // ResetSecurityPolicyMode resets all changes to the "security_policy_mode" field.
- func (m *GroupMutation) ResetSecurityPolicyMode() {
- m.security_policy_mode = nil
- }
- // SetSecurityPolicyEmailEnabled sets the "security_policy_email_enabled" field.
- func (m *GroupMutation) SetSecurityPolicyEmailEnabled(b bool) {
- m.security_policy_email_enabled = &b
- }
- // SecurityPolicyEmailEnabled returns the value of the "security_policy_email_enabled" field in the mutation.
- func (m *GroupMutation) SecurityPolicyEmailEnabled() (r bool, exists bool) {
- v := m.security_policy_email_enabled
- if v == nil {
- return
- }
- return *v, true
- }
- // OldSecurityPolicyEmailEnabled returns the old "security_policy_email_enabled" field's value of the Group entity.
- // If the Group object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *GroupMutation) OldSecurityPolicyEmailEnabled(ctx context.Context) (v bool, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldSecurityPolicyEmailEnabled is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldSecurityPolicyEmailEnabled requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldSecurityPolicyEmailEnabled: %w", err)
- }
- return oldValue.SecurityPolicyEmailEnabled, nil
- }
- // ResetSecurityPolicyEmailEnabled resets all changes to the "security_policy_email_enabled" field.
- func (m *GroupMutation) ResetSecurityPolicyEmailEnabled() {
- m.security_policy_email_enabled = nil
- }
- // SetStatus sets the "status" field.
- func (m *GroupMutation) SetStatus(s string) {
- m.status = &s
- }
- // Status returns the value of the "status" field in the mutation.
- func (m *GroupMutation) Status() (r string, exists bool) {
- v := m.status
- if v == nil {
- return
- }
- return *v, true
- }
- // OldStatus returns the old "status" field's value of the Group entity.
- // If the Group object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *GroupMutation) OldStatus(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldStatus is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldStatus requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldStatus: %w", err)
- }
- return oldValue.Status, nil
- }
- // ResetStatus resets all changes to the "status" field.
- func (m *GroupMutation) ResetStatus() {
- m.status = nil
- }
- // SetDuplicateOperationID sets the "duplicate_operation_id" field.
- func (m *GroupMutation) SetDuplicateOperationID(s string) {
- m.duplicate_operation_id = &s
- }
- // DuplicateOperationID returns the value of the "duplicate_operation_id" field in the mutation.
- func (m *GroupMutation) DuplicateOperationID() (r string, exists bool) {
- v := m.duplicate_operation_id
- if v == nil {
- return
- }
- return *v, true
- }
- // OldDuplicateOperationID returns the old "duplicate_operation_id" field's value of the Group entity.
- // If the Group object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *GroupMutation) OldDuplicateOperationID(ctx context.Context) (v *string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldDuplicateOperationID is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldDuplicateOperationID requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldDuplicateOperationID: %w", err)
- }
- return oldValue.DuplicateOperationID, nil
- }
- // ClearDuplicateOperationID clears the value of the "duplicate_operation_id" field.
- func (m *GroupMutation) ClearDuplicateOperationID() {
- m.duplicate_operation_id = nil
- m.clearedFields[group.FieldDuplicateOperationID] = struct{}{}
- }
- // DuplicateOperationIDCleared returns if the "duplicate_operation_id" field was cleared in this mutation.
- func (m *GroupMutation) DuplicateOperationIDCleared() bool {
- _, ok := m.clearedFields[group.FieldDuplicateOperationID]
- return ok
- }
- // ResetDuplicateOperationID resets all changes to the "duplicate_operation_id" field.
- func (m *GroupMutation) ResetDuplicateOperationID() {
- m.duplicate_operation_id = nil
- delete(m.clearedFields, group.FieldDuplicateOperationID)
- }
- // SetPlatform sets the "platform" field.
- func (m *GroupMutation) SetPlatform(s string) {
- m.platform = &s
- }
- // Platform returns the value of the "platform" field in the mutation.
- func (m *GroupMutation) Platform() (r string, exists bool) {
- v := m.platform
- if v == nil {
- return
- }
- return *v, true
- }
- // OldPlatform returns the old "platform" field's value of the Group entity.
- // If the Group object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *GroupMutation) OldPlatform(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldPlatform is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldPlatform requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldPlatform: %w", err)
- }
- return oldValue.Platform, nil
- }
- // ResetPlatform resets all changes to the "platform" field.
- func (m *GroupMutation) ResetPlatform() {
- m.platform = nil
- }
- // SetSubscriptionType sets the "subscription_type" field.
- func (m *GroupMutation) SetSubscriptionType(s string) {
- m.subscription_type = &s
- }
- // SubscriptionType returns the value of the "subscription_type" field in the mutation.
- func (m *GroupMutation) SubscriptionType() (r string, exists bool) {
- v := m.subscription_type
- if v == nil {
- return
- }
- return *v, true
- }
- // OldSubscriptionType returns the old "subscription_type" field's value of the Group entity.
- // If the Group object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *GroupMutation) OldSubscriptionType(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldSubscriptionType is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldSubscriptionType requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldSubscriptionType: %w", err)
- }
- return oldValue.SubscriptionType, nil
- }
- // ResetSubscriptionType resets all changes to the "subscription_type" field.
- func (m *GroupMutation) ResetSubscriptionType() {
- m.subscription_type = nil
- }
- // SetDailyLimitUsd sets the "daily_limit_usd" field.
- func (m *GroupMutation) SetDailyLimitUsd(f float64) {
- m.daily_limit_usd = &f
- m.adddaily_limit_usd = nil
- }
- // DailyLimitUsd returns the value of the "daily_limit_usd" field in the mutation.
- func (m *GroupMutation) DailyLimitUsd() (r float64, exists bool) {
- v := m.daily_limit_usd
- if v == nil {
- return
- }
- return *v, true
- }
- // OldDailyLimitUsd returns the old "daily_limit_usd" field's value of the Group entity.
- // If the Group object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *GroupMutation) OldDailyLimitUsd(ctx context.Context) (v *float64, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldDailyLimitUsd is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldDailyLimitUsd requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldDailyLimitUsd: %w", err)
- }
- return oldValue.DailyLimitUsd, nil
- }
- // AddDailyLimitUsd adds f to the "daily_limit_usd" field.
- func (m *GroupMutation) AddDailyLimitUsd(f float64) {
- if m.adddaily_limit_usd != nil {
- *m.adddaily_limit_usd += f
- } else {
- m.adddaily_limit_usd = &f
- }
- }
- // AddedDailyLimitUsd returns the value that was added to the "daily_limit_usd" field in this mutation.
- func (m *GroupMutation) AddedDailyLimitUsd() (r float64, exists bool) {
- v := m.adddaily_limit_usd
- if v == nil {
- return
- }
- return *v, true
- }
- // ClearDailyLimitUsd clears the value of the "daily_limit_usd" field.
- func (m *GroupMutation) ClearDailyLimitUsd() {
- m.daily_limit_usd = nil
- m.adddaily_limit_usd = nil
- m.clearedFields[group.FieldDailyLimitUsd] = struct{}{}
- }
- // DailyLimitUsdCleared returns if the "daily_limit_usd" field was cleared in this mutation.
- func (m *GroupMutation) DailyLimitUsdCleared() bool {
- _, ok := m.clearedFields[group.FieldDailyLimitUsd]
- return ok
- }
- // ResetDailyLimitUsd resets all changes to the "daily_limit_usd" field.
- func (m *GroupMutation) ResetDailyLimitUsd() {
- m.daily_limit_usd = nil
- m.adddaily_limit_usd = nil
- delete(m.clearedFields, group.FieldDailyLimitUsd)
- }
- // SetWeeklyLimitUsd sets the "weekly_limit_usd" field.
- func (m *GroupMutation) SetWeeklyLimitUsd(f float64) {
- m.weekly_limit_usd = &f
- m.addweekly_limit_usd = nil
- }
- // WeeklyLimitUsd returns the value of the "weekly_limit_usd" field in the mutation.
- func (m *GroupMutation) WeeklyLimitUsd() (r float64, exists bool) {
- v := m.weekly_limit_usd
- if v == nil {
- return
- }
- return *v, true
- }
- // OldWeeklyLimitUsd returns the old "weekly_limit_usd" field's value of the Group entity.
- // If the Group object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *GroupMutation) OldWeeklyLimitUsd(ctx context.Context) (v *float64, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldWeeklyLimitUsd is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldWeeklyLimitUsd requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldWeeklyLimitUsd: %w", err)
- }
- return oldValue.WeeklyLimitUsd, nil
- }
- // AddWeeklyLimitUsd adds f to the "weekly_limit_usd" field.
- func (m *GroupMutation) AddWeeklyLimitUsd(f float64) {
- if m.addweekly_limit_usd != nil {
- *m.addweekly_limit_usd += f
- } else {
- m.addweekly_limit_usd = &f
- }
- }
- // AddedWeeklyLimitUsd returns the value that was added to the "weekly_limit_usd" field in this mutation.
- func (m *GroupMutation) AddedWeeklyLimitUsd() (r float64, exists bool) {
- v := m.addweekly_limit_usd
- if v == nil {
- return
- }
- return *v, true
- }
- // ClearWeeklyLimitUsd clears the value of the "weekly_limit_usd" field.
- func (m *GroupMutation) ClearWeeklyLimitUsd() {
- m.weekly_limit_usd = nil
- m.addweekly_limit_usd = nil
- m.clearedFields[group.FieldWeeklyLimitUsd] = struct{}{}
- }
- // WeeklyLimitUsdCleared returns if the "weekly_limit_usd" field was cleared in this mutation.
- func (m *GroupMutation) WeeklyLimitUsdCleared() bool {
- _, ok := m.clearedFields[group.FieldWeeklyLimitUsd]
- return ok
- }
- // ResetWeeklyLimitUsd resets all changes to the "weekly_limit_usd" field.
- func (m *GroupMutation) ResetWeeklyLimitUsd() {
- m.weekly_limit_usd = nil
- m.addweekly_limit_usd = nil
- delete(m.clearedFields, group.FieldWeeklyLimitUsd)
- }
- // SetMonthlyLimitUsd sets the "monthly_limit_usd" field.
- func (m *GroupMutation) SetMonthlyLimitUsd(f float64) {
- m.monthly_limit_usd = &f
- m.addmonthly_limit_usd = nil
- }
- // MonthlyLimitUsd returns the value of the "monthly_limit_usd" field in the mutation.
- func (m *GroupMutation) MonthlyLimitUsd() (r float64, exists bool) {
- v := m.monthly_limit_usd
- if v == nil {
- return
- }
- return *v, true
- }
- // OldMonthlyLimitUsd returns the old "monthly_limit_usd" field's value of the Group entity.
- // If the Group object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *GroupMutation) OldMonthlyLimitUsd(ctx context.Context) (v *float64, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldMonthlyLimitUsd is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldMonthlyLimitUsd requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldMonthlyLimitUsd: %w", err)
- }
- return oldValue.MonthlyLimitUsd, nil
- }
- // AddMonthlyLimitUsd adds f to the "monthly_limit_usd" field.
- func (m *GroupMutation) AddMonthlyLimitUsd(f float64) {
- if m.addmonthly_limit_usd != nil {
- *m.addmonthly_limit_usd += f
- } else {
- m.addmonthly_limit_usd = &f
- }
- }
- // AddedMonthlyLimitUsd returns the value that was added to the "monthly_limit_usd" field in this mutation.
- func (m *GroupMutation) AddedMonthlyLimitUsd() (r float64, exists bool) {
- v := m.addmonthly_limit_usd
- if v == nil {
- return
- }
- return *v, true
- }
- // ClearMonthlyLimitUsd clears the value of the "monthly_limit_usd" field.
- func (m *GroupMutation) ClearMonthlyLimitUsd() {
- m.monthly_limit_usd = nil
- m.addmonthly_limit_usd = nil
- m.clearedFields[group.FieldMonthlyLimitUsd] = struct{}{}
- }
- // MonthlyLimitUsdCleared returns if the "monthly_limit_usd" field was cleared in this mutation.
- func (m *GroupMutation) MonthlyLimitUsdCleared() bool {
- _, ok := m.clearedFields[group.FieldMonthlyLimitUsd]
- return ok
- }
- // ResetMonthlyLimitUsd resets all changes to the "monthly_limit_usd" field.
- func (m *GroupMutation) ResetMonthlyLimitUsd() {
- m.monthly_limit_usd = nil
- m.addmonthly_limit_usd = nil
- delete(m.clearedFields, group.FieldMonthlyLimitUsd)
- }
- // SetDefaultValidityDays sets the "default_validity_days" field.
- func (m *GroupMutation) SetDefaultValidityDays(i int) {
- m.default_validity_days = &i
- m.adddefault_validity_days = nil
- }
- // DefaultValidityDays returns the value of the "default_validity_days" field in the mutation.
- func (m *GroupMutation) DefaultValidityDays() (r int, exists bool) {
- v := m.default_validity_days
- if v == nil {
- return
- }
- return *v, true
- }
- // OldDefaultValidityDays returns the old "default_validity_days" field's value of the Group entity.
- // If the Group object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *GroupMutation) OldDefaultValidityDays(ctx context.Context) (v int, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldDefaultValidityDays is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldDefaultValidityDays requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldDefaultValidityDays: %w", err)
- }
- return oldValue.DefaultValidityDays, nil
- }
- // AddDefaultValidityDays adds i to the "default_validity_days" field.
- func (m *GroupMutation) AddDefaultValidityDays(i int) {
- if m.adddefault_validity_days != nil {
- *m.adddefault_validity_days += i
- } else {
- m.adddefault_validity_days = &i
- }
- }
- // AddedDefaultValidityDays returns the value that was added to the "default_validity_days" field in this mutation.
- func (m *GroupMutation) AddedDefaultValidityDays() (r int, exists bool) {
- v := m.adddefault_validity_days
- if v == nil {
- return
- }
- return *v, true
- }
- // ResetDefaultValidityDays resets all changes to the "default_validity_days" field.
- func (m *GroupMutation) ResetDefaultValidityDays() {
- m.default_validity_days = nil
- m.adddefault_validity_days = nil
- }
- // SetAllowImageGeneration sets the "allow_image_generation" field.
- func (m *GroupMutation) SetAllowImageGeneration(b bool) {
- m.allow_image_generation = &b
- }
- // AllowImageGeneration returns the value of the "allow_image_generation" field in the mutation.
- func (m *GroupMutation) AllowImageGeneration() (r bool, exists bool) {
- v := m.allow_image_generation
- if v == nil {
- return
- }
- return *v, true
- }
- // OldAllowImageGeneration returns the old "allow_image_generation" field's value of the Group entity.
- // If the Group object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *GroupMutation) OldAllowImageGeneration(ctx context.Context) (v bool, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldAllowImageGeneration is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldAllowImageGeneration requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldAllowImageGeneration: %w", err)
- }
- return oldValue.AllowImageGeneration, nil
- }
- // ResetAllowImageGeneration resets all changes to the "allow_image_generation" field.
- func (m *GroupMutation) ResetAllowImageGeneration() {
- m.allow_image_generation = nil
- }
- // SetAllowBatchImageGeneration sets the "allow_batch_image_generation" field.
- func (m *GroupMutation) SetAllowBatchImageGeneration(b bool) {
- m.allow_batch_image_generation = &b
- }
- // AllowBatchImageGeneration returns the value of the "allow_batch_image_generation" field in the mutation.
- func (m *GroupMutation) AllowBatchImageGeneration() (r bool, exists bool) {
- v := m.allow_batch_image_generation
- if v == nil {
- return
- }
- return *v, true
- }
- // OldAllowBatchImageGeneration returns the old "allow_batch_image_generation" field's value of the Group entity.
- // If the Group object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *GroupMutation) OldAllowBatchImageGeneration(ctx context.Context) (v bool, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldAllowBatchImageGeneration is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldAllowBatchImageGeneration requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldAllowBatchImageGeneration: %w", err)
- }
- return oldValue.AllowBatchImageGeneration, nil
- }
- // ResetAllowBatchImageGeneration resets all changes to the "allow_batch_image_generation" field.
- func (m *GroupMutation) ResetAllowBatchImageGeneration() {
- m.allow_batch_image_generation = nil
- }
- // SetImageRateIndependent sets the "image_rate_independent" field.
- func (m *GroupMutation) SetImageRateIndependent(b bool) {
- m.image_rate_independent = &b
- }
- // ImageRateIndependent returns the value of the "image_rate_independent" field in the mutation.
- func (m *GroupMutation) ImageRateIndependent() (r bool, exists bool) {
- v := m.image_rate_independent
- if v == nil {
- return
- }
- return *v, true
- }
- // OldImageRateIndependent returns the old "image_rate_independent" field's value of the Group entity.
- // If the Group object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *GroupMutation) OldImageRateIndependent(ctx context.Context) (v bool, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldImageRateIndependent is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldImageRateIndependent requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldImageRateIndependent: %w", err)
- }
- return oldValue.ImageRateIndependent, nil
- }
- // ResetImageRateIndependent resets all changes to the "image_rate_independent" field.
- func (m *GroupMutation) ResetImageRateIndependent() {
- m.image_rate_independent = nil
- }
- // SetImageRateMultiplier sets the "image_rate_multiplier" field.
- func (m *GroupMutation) SetImageRateMultiplier(f float64) {
- m.image_rate_multiplier = &f
- m.addimage_rate_multiplier = nil
- }
- // ImageRateMultiplier returns the value of the "image_rate_multiplier" field in the mutation.
- func (m *GroupMutation) ImageRateMultiplier() (r float64, exists bool) {
- v := m.image_rate_multiplier
- if v == nil {
- return
- }
- return *v, true
- }
- // OldImageRateMultiplier returns the old "image_rate_multiplier" field's value of the Group entity.
- // If the Group object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *GroupMutation) OldImageRateMultiplier(ctx context.Context) (v float64, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldImageRateMultiplier is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldImageRateMultiplier requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldImageRateMultiplier: %w", err)
- }
- return oldValue.ImageRateMultiplier, nil
- }
- // AddImageRateMultiplier adds f to the "image_rate_multiplier" field.
- func (m *GroupMutation) AddImageRateMultiplier(f float64) {
- if m.addimage_rate_multiplier != nil {
- *m.addimage_rate_multiplier += f
- } else {
- m.addimage_rate_multiplier = &f
- }
- }
- // AddedImageRateMultiplier returns the value that was added to the "image_rate_multiplier" field in this mutation.
- func (m *GroupMutation) AddedImageRateMultiplier() (r float64, exists bool) {
- v := m.addimage_rate_multiplier
- if v == nil {
- return
- }
- return *v, true
- }
- // ResetImageRateMultiplier resets all changes to the "image_rate_multiplier" field.
- func (m *GroupMutation) ResetImageRateMultiplier() {
- m.image_rate_multiplier = nil
- m.addimage_rate_multiplier = nil
- }
- // SetImagePrice1k sets the "image_price_1k" field.
- func (m *GroupMutation) SetImagePrice1k(f float64) {
- m.image_price_1k = &f
- m.addimage_price_1k = nil
- }
- // ImagePrice1k returns the value of the "image_price_1k" field in the mutation.
- func (m *GroupMutation) ImagePrice1k() (r float64, exists bool) {
- v := m.image_price_1k
- if v == nil {
- return
- }
- return *v, true
- }
- // OldImagePrice1k returns the old "image_price_1k" field's value of the Group entity.
- // If the Group object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *GroupMutation) OldImagePrice1k(ctx context.Context) (v *float64, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldImagePrice1k is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldImagePrice1k requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldImagePrice1k: %w", err)
- }
- return oldValue.ImagePrice1k, nil
- }
- // AddImagePrice1k adds f to the "image_price_1k" field.
- func (m *GroupMutation) AddImagePrice1k(f float64) {
- if m.addimage_price_1k != nil {
- *m.addimage_price_1k += f
- } else {
- m.addimage_price_1k = &f
- }
- }
- // AddedImagePrice1k returns the value that was added to the "image_price_1k" field in this mutation.
- func (m *GroupMutation) AddedImagePrice1k() (r float64, exists bool) {
- v := m.addimage_price_1k
- if v == nil {
- return
- }
- return *v, true
- }
- // ClearImagePrice1k clears the value of the "image_price_1k" field.
- func (m *GroupMutation) ClearImagePrice1k() {
- m.image_price_1k = nil
- m.addimage_price_1k = nil
- m.clearedFields[group.FieldImagePrice1k] = struct{}{}
- }
- // ImagePrice1kCleared returns if the "image_price_1k" field was cleared in this mutation.
- func (m *GroupMutation) ImagePrice1kCleared() bool {
- _, ok := m.clearedFields[group.FieldImagePrice1k]
- return ok
- }
- // ResetImagePrice1k resets all changes to the "image_price_1k" field.
- func (m *GroupMutation) ResetImagePrice1k() {
- m.image_price_1k = nil
- m.addimage_price_1k = nil
- delete(m.clearedFields, group.FieldImagePrice1k)
- }
- // SetImagePrice2k sets the "image_price_2k" field.
- func (m *GroupMutation) SetImagePrice2k(f float64) {
- m.image_price_2k = &f
- m.addimage_price_2k = nil
- }
- // ImagePrice2k returns the value of the "image_price_2k" field in the mutation.
- func (m *GroupMutation) ImagePrice2k() (r float64, exists bool) {
- v := m.image_price_2k
- if v == nil {
- return
- }
- return *v, true
- }
- // OldImagePrice2k returns the old "image_price_2k" field's value of the Group entity.
- // If the Group object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *GroupMutation) OldImagePrice2k(ctx context.Context) (v *float64, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldImagePrice2k is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldImagePrice2k requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldImagePrice2k: %w", err)
- }
- return oldValue.ImagePrice2k, nil
- }
- // AddImagePrice2k adds f to the "image_price_2k" field.
- func (m *GroupMutation) AddImagePrice2k(f float64) {
- if m.addimage_price_2k != nil {
- *m.addimage_price_2k += f
- } else {
- m.addimage_price_2k = &f
- }
- }
- // AddedImagePrice2k returns the value that was added to the "image_price_2k" field in this mutation.
- func (m *GroupMutation) AddedImagePrice2k() (r float64, exists bool) {
- v := m.addimage_price_2k
- if v == nil {
- return
- }
- return *v, true
- }
- // ClearImagePrice2k clears the value of the "image_price_2k" field.
- func (m *GroupMutation) ClearImagePrice2k() {
- m.image_price_2k = nil
- m.addimage_price_2k = nil
- m.clearedFields[group.FieldImagePrice2k] = struct{}{}
- }
- // ImagePrice2kCleared returns if the "image_price_2k" field was cleared in this mutation.
- func (m *GroupMutation) ImagePrice2kCleared() bool {
- _, ok := m.clearedFields[group.FieldImagePrice2k]
- return ok
- }
- // ResetImagePrice2k resets all changes to the "image_price_2k" field.
- func (m *GroupMutation) ResetImagePrice2k() {
- m.image_price_2k = nil
- m.addimage_price_2k = nil
- delete(m.clearedFields, group.FieldImagePrice2k)
- }
- // SetImagePrice4k sets the "image_price_4k" field.
- func (m *GroupMutation) SetImagePrice4k(f float64) {
- m.image_price_4k = &f
- m.addimage_price_4k = nil
- }
- // ImagePrice4k returns the value of the "image_price_4k" field in the mutation.
- func (m *GroupMutation) ImagePrice4k() (r float64, exists bool) {
- v := m.image_price_4k
- if v == nil {
- return
- }
- return *v, true
- }
- // OldImagePrice4k returns the old "image_price_4k" field's value of the Group entity.
- // If the Group object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *GroupMutation) OldImagePrice4k(ctx context.Context) (v *float64, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldImagePrice4k is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldImagePrice4k requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldImagePrice4k: %w", err)
- }
- return oldValue.ImagePrice4k, nil
- }
- // AddImagePrice4k adds f to the "image_price_4k" field.
- func (m *GroupMutation) AddImagePrice4k(f float64) {
- if m.addimage_price_4k != nil {
- *m.addimage_price_4k += f
- } else {
- m.addimage_price_4k = &f
- }
- }
- // AddedImagePrice4k returns the value that was added to the "image_price_4k" field in this mutation.
- func (m *GroupMutation) AddedImagePrice4k() (r float64, exists bool) {
- v := m.addimage_price_4k
- if v == nil {
- return
- }
- return *v, true
- }
- // ClearImagePrice4k clears the value of the "image_price_4k" field.
- func (m *GroupMutation) ClearImagePrice4k() {
- m.image_price_4k = nil
- m.addimage_price_4k = nil
- m.clearedFields[group.FieldImagePrice4k] = struct{}{}
- }
- // ImagePrice4kCleared returns if the "image_price_4k" field was cleared in this mutation.
- func (m *GroupMutation) ImagePrice4kCleared() bool {
- _, ok := m.clearedFields[group.FieldImagePrice4k]
- return ok
- }
- // ResetImagePrice4k resets all changes to the "image_price_4k" field.
- func (m *GroupMutation) ResetImagePrice4k() {
- m.image_price_4k = nil
- m.addimage_price_4k = nil
- delete(m.clearedFields, group.FieldImagePrice4k)
- }
- // SetBatchImageDiscountMultiplier sets the "batch_image_discount_multiplier" field.
- func (m *GroupMutation) SetBatchImageDiscountMultiplier(f float64) {
- m.batch_image_discount_multiplier = &f
- m.addbatch_image_discount_multiplier = nil
- }
- // BatchImageDiscountMultiplier returns the value of the "batch_image_discount_multiplier" field in the mutation.
- func (m *GroupMutation) BatchImageDiscountMultiplier() (r float64, exists bool) {
- v := m.batch_image_discount_multiplier
- if v == nil {
- return
- }
- return *v, true
- }
- // OldBatchImageDiscountMultiplier returns the old "batch_image_discount_multiplier" field's value of the Group entity.
- // If the Group object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *GroupMutation) OldBatchImageDiscountMultiplier(ctx context.Context) (v float64, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldBatchImageDiscountMultiplier is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldBatchImageDiscountMultiplier requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldBatchImageDiscountMultiplier: %w", err)
- }
- return oldValue.BatchImageDiscountMultiplier, nil
- }
- // AddBatchImageDiscountMultiplier adds f to the "batch_image_discount_multiplier" field.
- func (m *GroupMutation) AddBatchImageDiscountMultiplier(f float64) {
- if m.addbatch_image_discount_multiplier != nil {
- *m.addbatch_image_discount_multiplier += f
- } else {
- m.addbatch_image_discount_multiplier = &f
- }
- }
- // AddedBatchImageDiscountMultiplier returns the value that was added to the "batch_image_discount_multiplier" field in this mutation.
- func (m *GroupMutation) AddedBatchImageDiscountMultiplier() (r float64, exists bool) {
- v := m.addbatch_image_discount_multiplier
- if v == nil {
- return
- }
- return *v, true
- }
- // ResetBatchImageDiscountMultiplier resets all changes to the "batch_image_discount_multiplier" field.
- func (m *GroupMutation) ResetBatchImageDiscountMultiplier() {
- m.batch_image_discount_multiplier = nil
- m.addbatch_image_discount_multiplier = nil
- }
- // SetBatchImageHoldMultiplier sets the "batch_image_hold_multiplier" field.
- func (m *GroupMutation) SetBatchImageHoldMultiplier(f float64) {
- m.batch_image_hold_multiplier = &f
- m.addbatch_image_hold_multiplier = nil
- }
- // BatchImageHoldMultiplier returns the value of the "batch_image_hold_multiplier" field in the mutation.
- func (m *GroupMutation) BatchImageHoldMultiplier() (r float64, exists bool) {
- v := m.batch_image_hold_multiplier
- if v == nil {
- return
- }
- return *v, true
- }
- // OldBatchImageHoldMultiplier returns the old "batch_image_hold_multiplier" field's value of the Group entity.
- // If the Group object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *GroupMutation) OldBatchImageHoldMultiplier(ctx context.Context) (v float64, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldBatchImageHoldMultiplier is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldBatchImageHoldMultiplier requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldBatchImageHoldMultiplier: %w", err)
- }
- return oldValue.BatchImageHoldMultiplier, nil
- }
- // AddBatchImageHoldMultiplier adds f to the "batch_image_hold_multiplier" field.
- func (m *GroupMutation) AddBatchImageHoldMultiplier(f float64) {
- if m.addbatch_image_hold_multiplier != nil {
- *m.addbatch_image_hold_multiplier += f
- } else {
- m.addbatch_image_hold_multiplier = &f
- }
- }
- // AddedBatchImageHoldMultiplier returns the value that was added to the "batch_image_hold_multiplier" field in this mutation.
- func (m *GroupMutation) AddedBatchImageHoldMultiplier() (r float64, exists bool) {
- v := m.addbatch_image_hold_multiplier
- if v == nil {
- return
- }
- return *v, true
- }
- // ResetBatchImageHoldMultiplier resets all changes to the "batch_image_hold_multiplier" field.
- func (m *GroupMutation) ResetBatchImageHoldMultiplier() {
- m.batch_image_hold_multiplier = nil
- m.addbatch_image_hold_multiplier = nil
- }
- // SetVideoRateIndependent sets the "video_rate_independent" field.
- func (m *GroupMutation) SetVideoRateIndependent(b bool) {
- m.video_rate_independent = &b
- }
- // VideoRateIndependent returns the value of the "video_rate_independent" field in the mutation.
- func (m *GroupMutation) VideoRateIndependent() (r bool, exists bool) {
- v := m.video_rate_independent
- if v == nil {
- return
- }
- return *v, true
- }
- // OldVideoRateIndependent returns the old "video_rate_independent" field's value of the Group entity.
- // If the Group object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *GroupMutation) OldVideoRateIndependent(ctx context.Context) (v bool, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldVideoRateIndependent is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldVideoRateIndependent requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldVideoRateIndependent: %w", err)
- }
- return oldValue.VideoRateIndependent, nil
- }
- // ResetVideoRateIndependent resets all changes to the "video_rate_independent" field.
- func (m *GroupMutation) ResetVideoRateIndependent() {
- m.video_rate_independent = nil
- }
- // SetVideoRateMultiplier sets the "video_rate_multiplier" field.
- func (m *GroupMutation) SetVideoRateMultiplier(f float64) {
- m.video_rate_multiplier = &f
- m.addvideo_rate_multiplier = nil
- }
- // VideoRateMultiplier returns the value of the "video_rate_multiplier" field in the mutation.
- func (m *GroupMutation) VideoRateMultiplier() (r float64, exists bool) {
- v := m.video_rate_multiplier
- if v == nil {
- return
- }
- return *v, true
- }
- // OldVideoRateMultiplier returns the old "video_rate_multiplier" field's value of the Group entity.
- // If the Group object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *GroupMutation) OldVideoRateMultiplier(ctx context.Context) (v float64, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldVideoRateMultiplier is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldVideoRateMultiplier requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldVideoRateMultiplier: %w", err)
- }
- return oldValue.VideoRateMultiplier, nil
- }
- // AddVideoRateMultiplier adds f to the "video_rate_multiplier" field.
- func (m *GroupMutation) AddVideoRateMultiplier(f float64) {
- if m.addvideo_rate_multiplier != nil {
- *m.addvideo_rate_multiplier += f
- } else {
- m.addvideo_rate_multiplier = &f
- }
- }
- // AddedVideoRateMultiplier returns the value that was added to the "video_rate_multiplier" field in this mutation.
- func (m *GroupMutation) AddedVideoRateMultiplier() (r float64, exists bool) {
- v := m.addvideo_rate_multiplier
- if v == nil {
- return
- }
- return *v, true
- }
- // ResetVideoRateMultiplier resets all changes to the "video_rate_multiplier" field.
- func (m *GroupMutation) ResetVideoRateMultiplier() {
- m.video_rate_multiplier = nil
- m.addvideo_rate_multiplier = nil
- }
- // SetVideoPrice480p sets the "video_price_480p" field.
- func (m *GroupMutation) SetVideoPrice480p(f float64) {
- m.video_price_480p = &f
- m.addvideo_price_480p = nil
- }
- // VideoPrice480p returns the value of the "video_price_480p" field in the mutation.
- func (m *GroupMutation) VideoPrice480p() (r float64, exists bool) {
- v := m.video_price_480p
- if v == nil {
- return
- }
- return *v, true
- }
- // OldVideoPrice480p returns the old "video_price_480p" field's value of the Group entity.
- // If the Group object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *GroupMutation) OldVideoPrice480p(ctx context.Context) (v *float64, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldVideoPrice480p is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldVideoPrice480p requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldVideoPrice480p: %w", err)
- }
- return oldValue.VideoPrice480p, nil
- }
- // AddVideoPrice480p adds f to the "video_price_480p" field.
- func (m *GroupMutation) AddVideoPrice480p(f float64) {
- if m.addvideo_price_480p != nil {
- *m.addvideo_price_480p += f
- } else {
- m.addvideo_price_480p = &f
- }
- }
- // AddedVideoPrice480p returns the value that was added to the "video_price_480p" field in this mutation.
- func (m *GroupMutation) AddedVideoPrice480p() (r float64, exists bool) {
- v := m.addvideo_price_480p
- if v == nil {
- return
- }
- return *v, true
- }
- // ClearVideoPrice480p clears the value of the "video_price_480p" field.
- func (m *GroupMutation) ClearVideoPrice480p() {
- m.video_price_480p = nil
- m.addvideo_price_480p = nil
- m.clearedFields[group.FieldVideoPrice480p] = struct{}{}
- }
- // VideoPrice480pCleared returns if the "video_price_480p" field was cleared in this mutation.
- func (m *GroupMutation) VideoPrice480pCleared() bool {
- _, ok := m.clearedFields[group.FieldVideoPrice480p]
- return ok
- }
- // ResetVideoPrice480p resets all changes to the "video_price_480p" field.
- func (m *GroupMutation) ResetVideoPrice480p() {
- m.video_price_480p = nil
- m.addvideo_price_480p = nil
- delete(m.clearedFields, group.FieldVideoPrice480p)
- }
- // SetVideoPrice720p sets the "video_price_720p" field.
- func (m *GroupMutation) SetVideoPrice720p(f float64) {
- m.video_price_720p = &f
- m.addvideo_price_720p = nil
- }
- // VideoPrice720p returns the value of the "video_price_720p" field in the mutation.
- func (m *GroupMutation) VideoPrice720p() (r float64, exists bool) {
- v := m.video_price_720p
- if v == nil {
- return
- }
- return *v, true
- }
- // OldVideoPrice720p returns the old "video_price_720p" field's value of the Group entity.
- // If the Group object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *GroupMutation) OldVideoPrice720p(ctx context.Context) (v *float64, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldVideoPrice720p is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldVideoPrice720p requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldVideoPrice720p: %w", err)
- }
- return oldValue.VideoPrice720p, nil
- }
- // AddVideoPrice720p adds f to the "video_price_720p" field.
- func (m *GroupMutation) AddVideoPrice720p(f float64) {
- if m.addvideo_price_720p != nil {
- *m.addvideo_price_720p += f
- } else {
- m.addvideo_price_720p = &f
- }
- }
- // AddedVideoPrice720p returns the value that was added to the "video_price_720p" field in this mutation.
- func (m *GroupMutation) AddedVideoPrice720p() (r float64, exists bool) {
- v := m.addvideo_price_720p
- if v == nil {
- return
- }
- return *v, true
- }
- // ClearVideoPrice720p clears the value of the "video_price_720p" field.
- func (m *GroupMutation) ClearVideoPrice720p() {
- m.video_price_720p = nil
- m.addvideo_price_720p = nil
- m.clearedFields[group.FieldVideoPrice720p] = struct{}{}
- }
- // VideoPrice720pCleared returns if the "video_price_720p" field was cleared in this mutation.
- func (m *GroupMutation) VideoPrice720pCleared() bool {
- _, ok := m.clearedFields[group.FieldVideoPrice720p]
- return ok
- }
- // ResetVideoPrice720p resets all changes to the "video_price_720p" field.
- func (m *GroupMutation) ResetVideoPrice720p() {
- m.video_price_720p = nil
- m.addvideo_price_720p = nil
- delete(m.clearedFields, group.FieldVideoPrice720p)
- }
- // SetVideoPrice1080p sets the "video_price_1080p" field.
- func (m *GroupMutation) SetVideoPrice1080p(f float64) {
- m.video_price_1080p = &f
- m.addvideo_price_1080p = nil
- }
- // VideoPrice1080p returns the value of the "video_price_1080p" field in the mutation.
- func (m *GroupMutation) VideoPrice1080p() (r float64, exists bool) {
- v := m.video_price_1080p
- if v == nil {
- return
- }
- return *v, true
- }
- // OldVideoPrice1080p returns the old "video_price_1080p" field's value of the Group entity.
- // If the Group object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *GroupMutation) OldVideoPrice1080p(ctx context.Context) (v *float64, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldVideoPrice1080p is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldVideoPrice1080p requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldVideoPrice1080p: %w", err)
- }
- return oldValue.VideoPrice1080p, nil
- }
- // AddVideoPrice1080p adds f to the "video_price_1080p" field.
- func (m *GroupMutation) AddVideoPrice1080p(f float64) {
- if m.addvideo_price_1080p != nil {
- *m.addvideo_price_1080p += f
- } else {
- m.addvideo_price_1080p = &f
- }
- }
- // AddedVideoPrice1080p returns the value that was added to the "video_price_1080p" field in this mutation.
- func (m *GroupMutation) AddedVideoPrice1080p() (r float64, exists bool) {
- v := m.addvideo_price_1080p
- if v == nil {
- return
- }
- return *v, true
- }
- // ClearVideoPrice1080p clears the value of the "video_price_1080p" field.
- func (m *GroupMutation) ClearVideoPrice1080p() {
- m.video_price_1080p = nil
- m.addvideo_price_1080p = nil
- m.clearedFields[group.FieldVideoPrice1080p] = struct{}{}
- }
- // VideoPrice1080pCleared returns if the "video_price_1080p" field was cleared in this mutation.
- func (m *GroupMutation) VideoPrice1080pCleared() bool {
- _, ok := m.clearedFields[group.FieldVideoPrice1080p]
- return ok
- }
- // ResetVideoPrice1080p resets all changes to the "video_price_1080p" field.
- func (m *GroupMutation) ResetVideoPrice1080p() {
- m.video_price_1080p = nil
- m.addvideo_price_1080p = nil
- delete(m.clearedFields, group.FieldVideoPrice1080p)
- }
- // SetVideoModelPrices sets the "video_model_prices" field.
- func (m *GroupMutation) SetVideoModelPrices(value map[string]map[string]float64) {
- m.video_model_prices = &value
- }
- // VideoModelPrices returns the value of the "video_model_prices" field in the mutation.
- func (m *GroupMutation) VideoModelPrices() (r map[string]map[string]float64, exists bool) {
- v := m.video_model_prices
- if v == nil {
- return
- }
- return *v, true
- }
- // OldVideoModelPrices returns the old "video_model_prices" field's value of the Group entity.
- // If the Group object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *GroupMutation) OldVideoModelPrices(ctx context.Context) (v map[string]map[string]float64, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldVideoModelPrices is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldVideoModelPrices requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldVideoModelPrices: %w", err)
- }
- return oldValue.VideoModelPrices, nil
- }
- // ClearVideoModelPrices clears the value of the "video_model_prices" field.
- func (m *GroupMutation) ClearVideoModelPrices() {
- m.video_model_prices = nil
- m.clearedFields[group.FieldVideoModelPrices] = struct{}{}
- }
- // VideoModelPricesCleared returns if the "video_model_prices" field was cleared in this mutation.
- func (m *GroupMutation) VideoModelPricesCleared() bool {
- _, ok := m.clearedFields[group.FieldVideoModelPrices]
- return ok
- }
- // ResetVideoModelPrices resets all changes to the "video_model_prices" field.
- func (m *GroupMutation) ResetVideoModelPrices() {
- m.video_model_prices = nil
- delete(m.clearedFields, group.FieldVideoModelPrices)
- }
- // SetWebSearchPricePerCall sets the "web_search_price_per_call" field.
- func (m *GroupMutation) SetWebSearchPricePerCall(f float64) {
- m.web_search_price_per_call = &f
- m.addweb_search_price_per_call = nil
- }
- // WebSearchPricePerCall returns the value of the "web_search_price_per_call" field in the mutation.
- func (m *GroupMutation) WebSearchPricePerCall() (r float64, exists bool) {
- v := m.web_search_price_per_call
- if v == nil {
- return
- }
- return *v, true
- }
- // OldWebSearchPricePerCall returns the old "web_search_price_per_call" field's value of the Group entity.
- // If the Group object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *GroupMutation) OldWebSearchPricePerCall(ctx context.Context) (v *float64, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldWebSearchPricePerCall is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldWebSearchPricePerCall requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldWebSearchPricePerCall: %w", err)
- }
- return oldValue.WebSearchPricePerCall, nil
- }
- // AddWebSearchPricePerCall adds f to the "web_search_price_per_call" field.
- func (m *GroupMutation) AddWebSearchPricePerCall(f float64) {
- if m.addweb_search_price_per_call != nil {
- *m.addweb_search_price_per_call += f
- } else {
- m.addweb_search_price_per_call = &f
- }
- }
- // AddedWebSearchPricePerCall returns the value that was added to the "web_search_price_per_call" field in this mutation.
- func (m *GroupMutation) AddedWebSearchPricePerCall() (r float64, exists bool) {
- v := m.addweb_search_price_per_call
- if v == nil {
- return
- }
- return *v, true
- }
- // ClearWebSearchPricePerCall clears the value of the "web_search_price_per_call" field.
- func (m *GroupMutation) ClearWebSearchPricePerCall() {
- m.web_search_price_per_call = nil
- m.addweb_search_price_per_call = nil
- m.clearedFields[group.FieldWebSearchPricePerCall] = struct{}{}
- }
- // WebSearchPricePerCallCleared returns if the "web_search_price_per_call" field was cleared in this mutation.
- func (m *GroupMutation) WebSearchPricePerCallCleared() bool {
- _, ok := m.clearedFields[group.FieldWebSearchPricePerCall]
- return ok
- }
- // ResetWebSearchPricePerCall resets all changes to the "web_search_price_per_call" field.
- func (m *GroupMutation) ResetWebSearchPricePerCall() {
- m.web_search_price_per_call = nil
- m.addweb_search_price_per_call = nil
- delete(m.clearedFields, group.FieldWebSearchPricePerCall)
- }
- // SetSearchPricePer1k sets the "search_price_per_1k" field.
- func (m *GroupMutation) SetSearchPricePer1k(f float64) {
- m.search_price_per_1k = &f
- m.addsearch_price_per_1k = nil
- }
- // SearchPricePer1k returns the value of the "search_price_per_1k" field in the mutation.
- func (m *GroupMutation) SearchPricePer1k() (r float64, exists bool) {
- v := m.search_price_per_1k
- if v == nil {
- return
- }
- return *v, true
- }
- // OldSearchPricePer1k returns the old "search_price_per_1k" field's value of the Group entity.
- // If the Group object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *GroupMutation) OldSearchPricePer1k(ctx context.Context) (v *float64, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldSearchPricePer1k is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldSearchPricePer1k requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldSearchPricePer1k: %w", err)
- }
- return oldValue.SearchPricePer1k, nil
- }
- // AddSearchPricePer1k adds f to the "search_price_per_1k" field.
- func (m *GroupMutation) AddSearchPricePer1k(f float64) {
- if m.addsearch_price_per_1k != nil {
- *m.addsearch_price_per_1k += f
- } else {
- m.addsearch_price_per_1k = &f
- }
- }
- // AddedSearchPricePer1k returns the value that was added to the "search_price_per_1k" field in this mutation.
- func (m *GroupMutation) AddedSearchPricePer1k() (r float64, exists bool) {
- v := m.addsearch_price_per_1k
- if v == nil {
- return
- }
- return *v, true
- }
- // ClearSearchPricePer1k clears the value of the "search_price_per_1k" field.
- func (m *GroupMutation) ClearSearchPricePer1k() {
- m.search_price_per_1k = nil
- m.addsearch_price_per_1k = nil
- m.clearedFields[group.FieldSearchPricePer1k] = struct{}{}
- }
- // SearchPricePer1kCleared returns if the "search_price_per_1k" field was cleared in this mutation.
- func (m *GroupMutation) SearchPricePer1kCleared() bool {
- _, ok := m.clearedFields[group.FieldSearchPricePer1k]
- return ok
- }
- // ResetSearchPricePer1k resets all changes to the "search_price_per_1k" field.
- func (m *GroupMutation) ResetSearchPricePer1k() {
- m.search_price_per_1k = nil
- m.addsearch_price_per_1k = nil
- delete(m.clearedFields, group.FieldSearchPricePer1k)
- }
- // SetAudioRealtimePricePerMin sets the "audio_realtime_price_per_min" field.
- func (m *GroupMutation) SetAudioRealtimePricePerMin(f float64) {
- m.audio_realtime_price_per_min = &f
- m.addaudio_realtime_price_per_min = nil
- }
- // AudioRealtimePricePerMin returns the value of the "audio_realtime_price_per_min" field in the mutation.
- func (m *GroupMutation) AudioRealtimePricePerMin() (r float64, exists bool) {
- v := m.audio_realtime_price_per_min
- if v == nil {
- return
- }
- return *v, true
- }
- // OldAudioRealtimePricePerMin returns the old "audio_realtime_price_per_min" field's value of the Group entity.
- // If the Group object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *GroupMutation) OldAudioRealtimePricePerMin(ctx context.Context) (v *float64, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldAudioRealtimePricePerMin is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldAudioRealtimePricePerMin requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldAudioRealtimePricePerMin: %w", err)
- }
- return oldValue.AudioRealtimePricePerMin, nil
- }
- // AddAudioRealtimePricePerMin adds f to the "audio_realtime_price_per_min" field.
- func (m *GroupMutation) AddAudioRealtimePricePerMin(f float64) {
- if m.addaudio_realtime_price_per_min != nil {
- *m.addaudio_realtime_price_per_min += f
- } else {
- m.addaudio_realtime_price_per_min = &f
- }
- }
- // AddedAudioRealtimePricePerMin returns the value that was added to the "audio_realtime_price_per_min" field in this mutation.
- func (m *GroupMutation) AddedAudioRealtimePricePerMin() (r float64, exists bool) {
- v := m.addaudio_realtime_price_per_min
- if v == nil {
- return
- }
- return *v, true
- }
- // ClearAudioRealtimePricePerMin clears the value of the "audio_realtime_price_per_min" field.
- func (m *GroupMutation) ClearAudioRealtimePricePerMin() {
- m.audio_realtime_price_per_min = nil
- m.addaudio_realtime_price_per_min = nil
- m.clearedFields[group.FieldAudioRealtimePricePerMin] = struct{}{}
- }
- // AudioRealtimePricePerMinCleared returns if the "audio_realtime_price_per_min" field was cleared in this mutation.
- func (m *GroupMutation) AudioRealtimePricePerMinCleared() bool {
- _, ok := m.clearedFields[group.FieldAudioRealtimePricePerMin]
- return ok
- }
- // ResetAudioRealtimePricePerMin resets all changes to the "audio_realtime_price_per_min" field.
- func (m *GroupMutation) ResetAudioRealtimePricePerMin() {
- m.audio_realtime_price_per_min = nil
- m.addaudio_realtime_price_per_min = nil
- delete(m.clearedFields, group.FieldAudioRealtimePricePerMin)
- }
- // SetAudioTtsPricePerMillionChars sets the "audio_tts_price_per_million_chars" field.
- func (m *GroupMutation) SetAudioTtsPricePerMillionChars(f float64) {
- m.audio_tts_price_per_million_chars = &f
- m.addaudio_tts_price_per_million_chars = nil
- }
- // AudioTtsPricePerMillionChars returns the value of the "audio_tts_price_per_million_chars" field in the mutation.
- func (m *GroupMutation) AudioTtsPricePerMillionChars() (r float64, exists bool) {
- v := m.audio_tts_price_per_million_chars
- if v == nil {
- return
- }
- return *v, true
- }
- // OldAudioTtsPricePerMillionChars returns the old "audio_tts_price_per_million_chars" field's value of the Group entity.
- // If the Group object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *GroupMutation) OldAudioTtsPricePerMillionChars(ctx context.Context) (v *float64, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldAudioTtsPricePerMillionChars is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldAudioTtsPricePerMillionChars requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldAudioTtsPricePerMillionChars: %w", err)
- }
- return oldValue.AudioTtsPricePerMillionChars, nil
- }
- // AddAudioTtsPricePerMillionChars adds f to the "audio_tts_price_per_million_chars" field.
- func (m *GroupMutation) AddAudioTtsPricePerMillionChars(f float64) {
- if m.addaudio_tts_price_per_million_chars != nil {
- *m.addaudio_tts_price_per_million_chars += f
- } else {
- m.addaudio_tts_price_per_million_chars = &f
- }
- }
- // AddedAudioTtsPricePerMillionChars returns the value that was added to the "audio_tts_price_per_million_chars" field in this mutation.
- func (m *GroupMutation) AddedAudioTtsPricePerMillionChars() (r float64, exists bool) {
- v := m.addaudio_tts_price_per_million_chars
- if v == nil {
- return
- }
- return *v, true
- }
- // ClearAudioTtsPricePerMillionChars clears the value of the "audio_tts_price_per_million_chars" field.
- func (m *GroupMutation) ClearAudioTtsPricePerMillionChars() {
- m.audio_tts_price_per_million_chars = nil
- m.addaudio_tts_price_per_million_chars = nil
- m.clearedFields[group.FieldAudioTtsPricePerMillionChars] = struct{}{}
- }
- // AudioTtsPricePerMillionCharsCleared returns if the "audio_tts_price_per_million_chars" field was cleared in this mutation.
- func (m *GroupMutation) AudioTtsPricePerMillionCharsCleared() bool {
- _, ok := m.clearedFields[group.FieldAudioTtsPricePerMillionChars]
- return ok
- }
- // ResetAudioTtsPricePerMillionChars resets all changes to the "audio_tts_price_per_million_chars" field.
- func (m *GroupMutation) ResetAudioTtsPricePerMillionChars() {
- m.audio_tts_price_per_million_chars = nil
- m.addaudio_tts_price_per_million_chars = nil
- delete(m.clearedFields, group.FieldAudioTtsPricePerMillionChars)
- }
- // SetAudioSttPricePerHour sets the "audio_stt_price_per_hour" field.
- func (m *GroupMutation) SetAudioSttPricePerHour(f float64) {
- m.audio_stt_price_per_hour = &f
- m.addaudio_stt_price_per_hour = nil
- }
- // AudioSttPricePerHour returns the value of the "audio_stt_price_per_hour" field in the mutation.
- func (m *GroupMutation) AudioSttPricePerHour() (r float64, exists bool) {
- v := m.audio_stt_price_per_hour
- if v == nil {
- return
- }
- return *v, true
- }
- // OldAudioSttPricePerHour returns the old "audio_stt_price_per_hour" field's value of the Group entity.
- // If the Group object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *GroupMutation) OldAudioSttPricePerHour(ctx context.Context) (v *float64, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldAudioSttPricePerHour is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldAudioSttPricePerHour requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldAudioSttPricePerHour: %w", err)
- }
- return oldValue.AudioSttPricePerHour, nil
- }
- // AddAudioSttPricePerHour adds f to the "audio_stt_price_per_hour" field.
- func (m *GroupMutation) AddAudioSttPricePerHour(f float64) {
- if m.addaudio_stt_price_per_hour != nil {
- *m.addaudio_stt_price_per_hour += f
- } else {
- m.addaudio_stt_price_per_hour = &f
- }
- }
- // AddedAudioSttPricePerHour returns the value that was added to the "audio_stt_price_per_hour" field in this mutation.
- func (m *GroupMutation) AddedAudioSttPricePerHour() (r float64, exists bool) {
- v := m.addaudio_stt_price_per_hour
- if v == nil {
- return
- }
- return *v, true
- }
- // ClearAudioSttPricePerHour clears the value of the "audio_stt_price_per_hour" field.
- func (m *GroupMutation) ClearAudioSttPricePerHour() {
- m.audio_stt_price_per_hour = nil
- m.addaudio_stt_price_per_hour = nil
- m.clearedFields[group.FieldAudioSttPricePerHour] = struct{}{}
- }
- // AudioSttPricePerHourCleared returns if the "audio_stt_price_per_hour" field was cleared in this mutation.
- func (m *GroupMutation) AudioSttPricePerHourCleared() bool {
- _, ok := m.clearedFields[group.FieldAudioSttPricePerHour]
- return ok
- }
- // ResetAudioSttPricePerHour resets all changes to the "audio_stt_price_per_hour" field.
- func (m *GroupMutation) ResetAudioSttPricePerHour() {
- m.audio_stt_price_per_hour = nil
- m.addaudio_stt_price_per_hour = nil
- delete(m.clearedFields, group.FieldAudioSttPricePerHour)
- }
- // SetLongContextPricingEnabled sets the "long_context_pricing_enabled" field.
- func (m *GroupMutation) SetLongContextPricingEnabled(b bool) {
- m.long_context_pricing_enabled = &b
- }
- // LongContextPricingEnabled returns the value of the "long_context_pricing_enabled" field in the mutation.
- func (m *GroupMutation) LongContextPricingEnabled() (r bool, exists bool) {
- v := m.long_context_pricing_enabled
- if v == nil {
- return
- }
- return *v, true
- }
- // OldLongContextPricingEnabled returns the old "long_context_pricing_enabled" field's value of the Group entity.
- // If the Group object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *GroupMutation) OldLongContextPricingEnabled(ctx context.Context) (v bool, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldLongContextPricingEnabled is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldLongContextPricingEnabled requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldLongContextPricingEnabled: %w", err)
- }
- return oldValue.LongContextPricingEnabled, nil
- }
- // ResetLongContextPricingEnabled resets all changes to the "long_context_pricing_enabled" field.
- func (m *GroupMutation) ResetLongContextPricingEnabled() {
- m.long_context_pricing_enabled = nil
- }
- // SetModelPricing sets the "model_pricing" field.
- func (m *GroupMutation) SetModelPricing(j jsontext.Value) {
- m.model_pricing = &j
- m.appendmodel_pricing = nil
- }
- // ModelPricing returns the value of the "model_pricing" field in the mutation.
- func (m *GroupMutation) ModelPricing() (r jsontext.Value, exists bool) {
- v := m.model_pricing
- if v == nil {
- return
- }
- return *v, true
- }
- // OldModelPricing returns the old "model_pricing" field's value of the Group entity.
- // If the Group object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *GroupMutation) OldModelPricing(ctx context.Context) (v jsontext.Value, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldModelPricing is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldModelPricing requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldModelPricing: %w", err)
- }
- return oldValue.ModelPricing, nil
- }
- // AppendModelPricing adds j to the "model_pricing" field.
- func (m *GroupMutation) AppendModelPricing(j jsontext.Value) {
- m.appendmodel_pricing = append(m.appendmodel_pricing, j...)
- }
- // AppendedModelPricing returns the list of values that were appended to the "model_pricing" field in this mutation.
- func (m *GroupMutation) AppendedModelPricing() (jsontext.Value, bool) {
- if len(m.appendmodel_pricing) == 0 {
- return nil, false
- }
- return m.appendmodel_pricing, true
- }
- // ClearModelPricing clears the value of the "model_pricing" field.
- func (m *GroupMutation) ClearModelPricing() {
- m.model_pricing = nil
- m.appendmodel_pricing = nil
- m.clearedFields[group.FieldModelPricing] = struct{}{}
- }
- // ModelPricingCleared returns if the "model_pricing" field was cleared in this mutation.
- func (m *GroupMutation) ModelPricingCleared() bool {
- _, ok := m.clearedFields[group.FieldModelPricing]
- return ok
- }
- // ResetModelPricing resets all changes to the "model_pricing" field.
- func (m *GroupMutation) ResetModelPricing() {
- m.model_pricing = nil
- m.appendmodel_pricing = nil
- delete(m.clearedFields, group.FieldModelPricing)
- }
- // SetClaudeCodeOnly sets the "claude_code_only" field.
- func (m *GroupMutation) SetClaudeCodeOnly(b bool) {
- m.claude_code_only = &b
- }
- // ClaudeCodeOnly returns the value of the "claude_code_only" field in the mutation.
- func (m *GroupMutation) ClaudeCodeOnly() (r bool, exists bool) {
- v := m.claude_code_only
- if v == nil {
- return
- }
- return *v, true
- }
- // OldClaudeCodeOnly returns the old "claude_code_only" field's value of the Group entity.
- // If the Group object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *GroupMutation) OldClaudeCodeOnly(ctx context.Context) (v bool, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldClaudeCodeOnly is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldClaudeCodeOnly requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldClaudeCodeOnly: %w", err)
- }
- return oldValue.ClaudeCodeOnly, nil
- }
- // ResetClaudeCodeOnly resets all changes to the "claude_code_only" field.
- func (m *GroupMutation) ResetClaudeCodeOnly() {
- m.claude_code_only = nil
- }
- // SetFallbackGroupID sets the "fallback_group_id" field.
- func (m *GroupMutation) SetFallbackGroupID(i int64) {
- m.fallback_group_id = &i
- m.addfallback_group_id = nil
- }
- // FallbackGroupID returns the value of the "fallback_group_id" field in the mutation.
- func (m *GroupMutation) FallbackGroupID() (r int64, exists bool) {
- v := m.fallback_group_id
- if v == nil {
- return
- }
- return *v, true
- }
- // OldFallbackGroupID returns the old "fallback_group_id" field's value of the Group entity.
- // If the Group object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *GroupMutation) OldFallbackGroupID(ctx context.Context) (v *int64, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldFallbackGroupID is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldFallbackGroupID requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldFallbackGroupID: %w", err)
- }
- return oldValue.FallbackGroupID, nil
- }
- // AddFallbackGroupID adds i to the "fallback_group_id" field.
- func (m *GroupMutation) AddFallbackGroupID(i int64) {
- if m.addfallback_group_id != nil {
- *m.addfallback_group_id += i
- } else {
- m.addfallback_group_id = &i
- }
- }
- // AddedFallbackGroupID returns the value that was added to the "fallback_group_id" field in this mutation.
- func (m *GroupMutation) AddedFallbackGroupID() (r int64, exists bool) {
- v := m.addfallback_group_id
- if v == nil {
- return
- }
- return *v, true
- }
- // ClearFallbackGroupID clears the value of the "fallback_group_id" field.
- func (m *GroupMutation) ClearFallbackGroupID() {
- m.fallback_group_id = nil
- m.addfallback_group_id = nil
- m.clearedFields[group.FieldFallbackGroupID] = struct{}{}
- }
- // FallbackGroupIDCleared returns if the "fallback_group_id" field was cleared in this mutation.
- func (m *GroupMutation) FallbackGroupIDCleared() bool {
- _, ok := m.clearedFields[group.FieldFallbackGroupID]
- return ok
- }
- // ResetFallbackGroupID resets all changes to the "fallback_group_id" field.
- func (m *GroupMutation) ResetFallbackGroupID() {
- m.fallback_group_id = nil
- m.addfallback_group_id = nil
- delete(m.clearedFields, group.FieldFallbackGroupID)
- }
- // SetFallbackGroupIDOnInvalidRequest sets the "fallback_group_id_on_invalid_request" field.
- func (m *GroupMutation) SetFallbackGroupIDOnInvalidRequest(i int64) {
- m.fallback_group_id_on_invalid_request = &i
- m.addfallback_group_id_on_invalid_request = nil
- }
- // FallbackGroupIDOnInvalidRequest returns the value of the "fallback_group_id_on_invalid_request" field in the mutation.
- func (m *GroupMutation) FallbackGroupIDOnInvalidRequest() (r int64, exists bool) {
- v := m.fallback_group_id_on_invalid_request
- if v == nil {
- return
- }
- return *v, true
- }
- // OldFallbackGroupIDOnInvalidRequest returns the old "fallback_group_id_on_invalid_request" field's value of the Group entity.
- // If the Group object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *GroupMutation) OldFallbackGroupIDOnInvalidRequest(ctx context.Context) (v *int64, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldFallbackGroupIDOnInvalidRequest is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldFallbackGroupIDOnInvalidRequest requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldFallbackGroupIDOnInvalidRequest: %w", err)
- }
- return oldValue.FallbackGroupIDOnInvalidRequest, nil
- }
- // AddFallbackGroupIDOnInvalidRequest adds i to the "fallback_group_id_on_invalid_request" field.
- func (m *GroupMutation) AddFallbackGroupIDOnInvalidRequest(i int64) {
- if m.addfallback_group_id_on_invalid_request != nil {
- *m.addfallback_group_id_on_invalid_request += i
- } else {
- m.addfallback_group_id_on_invalid_request = &i
- }
- }
- // AddedFallbackGroupIDOnInvalidRequest returns the value that was added to the "fallback_group_id_on_invalid_request" field in this mutation.
- func (m *GroupMutation) AddedFallbackGroupIDOnInvalidRequest() (r int64, exists bool) {
- v := m.addfallback_group_id_on_invalid_request
- if v == nil {
- return
- }
- return *v, true
- }
- // ClearFallbackGroupIDOnInvalidRequest clears the value of the "fallback_group_id_on_invalid_request" field.
- func (m *GroupMutation) ClearFallbackGroupIDOnInvalidRequest() {
- m.fallback_group_id_on_invalid_request = nil
- m.addfallback_group_id_on_invalid_request = nil
- m.clearedFields[group.FieldFallbackGroupIDOnInvalidRequest] = struct{}{}
- }
- // FallbackGroupIDOnInvalidRequestCleared returns if the "fallback_group_id_on_invalid_request" field was cleared in this mutation.
- func (m *GroupMutation) FallbackGroupIDOnInvalidRequestCleared() bool {
- _, ok := m.clearedFields[group.FieldFallbackGroupIDOnInvalidRequest]
- return ok
- }
- // ResetFallbackGroupIDOnInvalidRequest resets all changes to the "fallback_group_id_on_invalid_request" field.
- func (m *GroupMutation) ResetFallbackGroupIDOnInvalidRequest() {
- m.fallback_group_id_on_invalid_request = nil
- m.addfallback_group_id_on_invalid_request = nil
- delete(m.clearedFields, group.FieldFallbackGroupIDOnInvalidRequest)
- }
- // SetModelRouting sets the "model_routing" field.
- func (m *GroupMutation) SetModelRouting(value map[string][]int64) {
- m.model_routing = &value
- }
- // ModelRouting returns the value of the "model_routing" field in the mutation.
- func (m *GroupMutation) ModelRouting() (r map[string][]int64, exists bool) {
- v := m.model_routing
- if v == nil {
- return
- }
- return *v, true
- }
- // OldModelRouting returns the old "model_routing" field's value of the Group entity.
- // If the Group object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *GroupMutation) OldModelRouting(ctx context.Context) (v map[string][]int64, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldModelRouting is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldModelRouting requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldModelRouting: %w", err)
- }
- return oldValue.ModelRouting, nil
- }
- // ClearModelRouting clears the value of the "model_routing" field.
- func (m *GroupMutation) ClearModelRouting() {
- m.model_routing = nil
- m.clearedFields[group.FieldModelRouting] = struct{}{}
- }
- // ModelRoutingCleared returns if the "model_routing" field was cleared in this mutation.
- func (m *GroupMutation) ModelRoutingCleared() bool {
- _, ok := m.clearedFields[group.FieldModelRouting]
- return ok
- }
- // ResetModelRouting resets all changes to the "model_routing" field.
- func (m *GroupMutation) ResetModelRouting() {
- m.model_routing = nil
- delete(m.clearedFields, group.FieldModelRouting)
- }
- // SetModelRoutingEnabled sets the "model_routing_enabled" field.
- func (m *GroupMutation) SetModelRoutingEnabled(b bool) {
- m.model_routing_enabled = &b
- }
- // ModelRoutingEnabled returns the value of the "model_routing_enabled" field in the mutation.
- func (m *GroupMutation) ModelRoutingEnabled() (r bool, exists bool) {
- v := m.model_routing_enabled
- if v == nil {
- return
- }
- return *v, true
- }
- // OldModelRoutingEnabled returns the old "model_routing_enabled" field's value of the Group entity.
- // If the Group object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *GroupMutation) OldModelRoutingEnabled(ctx context.Context) (v bool, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldModelRoutingEnabled is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldModelRoutingEnabled requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldModelRoutingEnabled: %w", err)
- }
- return oldValue.ModelRoutingEnabled, nil
- }
- // ResetModelRoutingEnabled resets all changes to the "model_routing_enabled" field.
- func (m *GroupMutation) ResetModelRoutingEnabled() {
- m.model_routing_enabled = nil
- }
- // SetMcpXMLInject sets the "mcp_xml_inject" field.
- func (m *GroupMutation) SetMcpXMLInject(b bool) {
- m.mcp_xml_inject = &b
- }
- // McpXMLInject returns the value of the "mcp_xml_inject" field in the mutation.
- func (m *GroupMutation) McpXMLInject() (r bool, exists bool) {
- v := m.mcp_xml_inject
- if v == nil {
- return
- }
- return *v, true
- }
- // OldMcpXMLInject returns the old "mcp_xml_inject" field's value of the Group entity.
- // If the Group object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *GroupMutation) OldMcpXMLInject(ctx context.Context) (v bool, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldMcpXMLInject is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldMcpXMLInject requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldMcpXMLInject: %w", err)
- }
- return oldValue.McpXMLInject, nil
- }
- // ResetMcpXMLInject resets all changes to the "mcp_xml_inject" field.
- func (m *GroupMutation) ResetMcpXMLInject() {
- m.mcp_xml_inject = nil
- }
- // SetSupportedModelScopes sets the "supported_model_scopes" field.
- func (m *GroupMutation) SetSupportedModelScopes(s []string) {
- m.supported_model_scopes = &s
- m.appendsupported_model_scopes = nil
- }
- // SupportedModelScopes returns the value of the "supported_model_scopes" field in the mutation.
- func (m *GroupMutation) SupportedModelScopes() (r []string, exists bool) {
- v := m.supported_model_scopes
- if v == nil {
- return
- }
- return *v, true
- }
- // OldSupportedModelScopes returns the old "supported_model_scopes" field's value of the Group entity.
- // If the Group object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *GroupMutation) OldSupportedModelScopes(ctx context.Context) (v []string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldSupportedModelScopes is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldSupportedModelScopes requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldSupportedModelScopes: %w", err)
- }
- return oldValue.SupportedModelScopes, nil
- }
- // AppendSupportedModelScopes adds s to the "supported_model_scopes" field.
- func (m *GroupMutation) AppendSupportedModelScopes(s []string) {
- m.appendsupported_model_scopes = append(m.appendsupported_model_scopes, s...)
- }
- // AppendedSupportedModelScopes returns the list of values that were appended to the "supported_model_scopes" field in this mutation.
- func (m *GroupMutation) AppendedSupportedModelScopes() ([]string, bool) {
- if len(m.appendsupported_model_scopes) == 0 {
- return nil, false
- }
- return m.appendsupported_model_scopes, true
- }
- // ResetSupportedModelScopes resets all changes to the "supported_model_scopes" field.
- func (m *GroupMutation) ResetSupportedModelScopes() {
- m.supported_model_scopes = nil
- m.appendsupported_model_scopes = nil
- }
- // SetSortOrder sets the "sort_order" field.
- func (m *GroupMutation) SetSortOrder(i int) {
- m.sort_order = &i
- m.addsort_order = nil
- }
- // SortOrder returns the value of the "sort_order" field in the mutation.
- func (m *GroupMutation) SortOrder() (r int, exists bool) {
- v := m.sort_order
- if v == nil {
- return
- }
- return *v, true
- }
- // OldSortOrder returns the old "sort_order" field's value of the Group entity.
- // If the Group object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *GroupMutation) OldSortOrder(ctx context.Context) (v int, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldSortOrder is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldSortOrder requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldSortOrder: %w", err)
- }
- return oldValue.SortOrder, nil
- }
- // AddSortOrder adds i to the "sort_order" field.
- func (m *GroupMutation) AddSortOrder(i int) {
- if m.addsort_order != nil {
- *m.addsort_order += i
- } else {
- m.addsort_order = &i
- }
- }
- // AddedSortOrder returns the value that was added to the "sort_order" field in this mutation.
- func (m *GroupMutation) AddedSortOrder() (r int, exists bool) {
- v := m.addsort_order
- if v == nil {
- return
- }
- return *v, true
- }
- // ResetSortOrder resets all changes to the "sort_order" field.
- func (m *GroupMutation) ResetSortOrder() {
- m.sort_order = nil
- m.addsort_order = nil
- }
- // SetAllowMessagesDispatch sets the "allow_messages_dispatch" field.
- func (m *GroupMutation) SetAllowMessagesDispatch(b bool) {
- m.allow_messages_dispatch = &b
- }
- // AllowMessagesDispatch returns the value of the "allow_messages_dispatch" field in the mutation.
- func (m *GroupMutation) AllowMessagesDispatch() (r bool, exists bool) {
- v := m.allow_messages_dispatch
- if v == nil {
- return
- }
- return *v, true
- }
- // OldAllowMessagesDispatch returns the old "allow_messages_dispatch" field's value of the Group entity.
- // If the Group object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *GroupMutation) OldAllowMessagesDispatch(ctx context.Context) (v bool, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldAllowMessagesDispatch is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldAllowMessagesDispatch requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldAllowMessagesDispatch: %w", err)
- }
- return oldValue.AllowMessagesDispatch, nil
- }
- // ResetAllowMessagesDispatch resets all changes to the "allow_messages_dispatch" field.
- func (m *GroupMutation) ResetAllowMessagesDispatch() {
- m.allow_messages_dispatch = nil
- }
- // SetAllowLive sets the "allow_live" field.
- func (m *GroupMutation) SetAllowLive(b bool) {
- m.allow_live = &b
- }
- // AllowLive returns the value of the "allow_live" field in the mutation.
- func (m *GroupMutation) AllowLive() (r bool, exists bool) {
- v := m.allow_live
- if v == nil {
- return
- }
- return *v, true
- }
- // OldAllowLive returns the old "allow_live" field's value of the Group entity.
- // If the Group object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *GroupMutation) OldAllowLive(ctx context.Context) (v bool, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldAllowLive is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldAllowLive requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldAllowLive: %w", err)
- }
- return oldValue.AllowLive, nil
- }
- // ResetAllowLive resets all changes to the "allow_live" field.
- func (m *GroupMutation) ResetAllowLive() {
- m.allow_live = nil
- }
- // SetForceOpenaiFast sets the "force_openai_fast" field.
- func (m *GroupMutation) SetForceOpenaiFast(b bool) {
- m.force_openai_fast = &b
- }
- // ForceOpenaiFast returns the value of the "force_openai_fast" field in the mutation.
- func (m *GroupMutation) ForceOpenaiFast() (r bool, exists bool) {
- v := m.force_openai_fast
- if v == nil {
- return
- }
- return *v, true
- }
- // OldForceOpenaiFast returns the old "force_openai_fast" field's value of the Group entity.
- // If the Group object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *GroupMutation) OldForceOpenaiFast(ctx context.Context) (v bool, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldForceOpenaiFast is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldForceOpenaiFast requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldForceOpenaiFast: %w", err)
- }
- return oldValue.ForceOpenaiFast, nil
- }
- // ResetForceOpenaiFast resets all changes to the "force_openai_fast" field.
- func (m *GroupMutation) ResetForceOpenaiFast() {
- m.force_openai_fast = nil
- }
- // SetFreeOpenaiFast sets the "free_openai_fast" field.
- func (m *GroupMutation) SetFreeOpenaiFast(b bool) {
- m.free_openai_fast = &b
- }
- // FreeOpenaiFast returns the value of the "free_openai_fast" field in the mutation.
- func (m *GroupMutation) FreeOpenaiFast() (r bool, exists bool) {
- v := m.free_openai_fast
- if v == nil {
- return
- }
- return *v, true
- }
- // OldFreeOpenaiFast returns the old "free_openai_fast" field's value of the Group entity.
- // If the Group object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *GroupMutation) OldFreeOpenaiFast(ctx context.Context) (v bool, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldFreeOpenaiFast is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldFreeOpenaiFast requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldFreeOpenaiFast: %w", err)
- }
- return oldValue.FreeOpenaiFast, nil
- }
- // ResetFreeOpenaiFast resets all changes to the "free_openai_fast" field.
- func (m *GroupMutation) ResetFreeOpenaiFast() {
- m.free_openai_fast = nil
- }
- // SetRequireOauthOnly sets the "require_oauth_only" field.
- func (m *GroupMutation) SetRequireOauthOnly(b bool) {
- m.require_oauth_only = &b
- }
- // RequireOauthOnly returns the value of the "require_oauth_only" field in the mutation.
- func (m *GroupMutation) RequireOauthOnly() (r bool, exists bool) {
- v := m.require_oauth_only
- if v == nil {
- return
- }
- return *v, true
- }
- // OldRequireOauthOnly returns the old "require_oauth_only" field's value of the Group entity.
- // If the Group object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *GroupMutation) OldRequireOauthOnly(ctx context.Context) (v bool, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldRequireOauthOnly is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldRequireOauthOnly requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldRequireOauthOnly: %w", err)
- }
- return oldValue.RequireOauthOnly, nil
- }
- // ResetRequireOauthOnly resets all changes to the "require_oauth_only" field.
- func (m *GroupMutation) ResetRequireOauthOnly() {
- m.require_oauth_only = nil
- }
- // SetRequirePrivacySet sets the "require_privacy_set" field.
- func (m *GroupMutation) SetRequirePrivacySet(b bool) {
- m.require_privacy_set = &b
- }
- // RequirePrivacySet returns the value of the "require_privacy_set" field in the mutation.
- func (m *GroupMutation) RequirePrivacySet() (r bool, exists bool) {
- v := m.require_privacy_set
- if v == nil {
- return
- }
- return *v, true
- }
- // OldRequirePrivacySet returns the old "require_privacy_set" field's value of the Group entity.
- // If the Group object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *GroupMutation) OldRequirePrivacySet(ctx context.Context) (v bool, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldRequirePrivacySet is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldRequirePrivacySet requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldRequirePrivacySet: %w", err)
- }
- return oldValue.RequirePrivacySet, nil
- }
- // ResetRequirePrivacySet resets all changes to the "require_privacy_set" field.
- func (m *GroupMutation) ResetRequirePrivacySet() {
- m.require_privacy_set = nil
- }
- // SetDefaultMappedModel sets the "default_mapped_model" field.
- func (m *GroupMutation) SetDefaultMappedModel(s string) {
- m.default_mapped_model = &s
- }
- // DefaultMappedModel returns the value of the "default_mapped_model" field in the mutation.
- func (m *GroupMutation) DefaultMappedModel() (r string, exists bool) {
- v := m.default_mapped_model
- if v == nil {
- return
- }
- return *v, true
- }
- // OldDefaultMappedModel returns the old "default_mapped_model" field's value of the Group entity.
- // If the Group object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *GroupMutation) OldDefaultMappedModel(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldDefaultMappedModel is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldDefaultMappedModel requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldDefaultMappedModel: %w", err)
- }
- return oldValue.DefaultMappedModel, nil
- }
- // ResetDefaultMappedModel resets all changes to the "default_mapped_model" field.
- func (m *GroupMutation) ResetDefaultMappedModel() {
- m.default_mapped_model = nil
- }
- // SetMessagesDispatchModelConfig sets the "messages_dispatch_model_config" field.
- func (m *GroupMutation) SetMessagesDispatchModelConfig(damdmc domain.OpenAIMessagesDispatchModelConfig) {
- m.messages_dispatch_model_config = &damdmc
- }
- // MessagesDispatchModelConfig returns the value of the "messages_dispatch_model_config" field in the mutation.
- func (m *GroupMutation) MessagesDispatchModelConfig() (r domain.OpenAIMessagesDispatchModelConfig, exists bool) {
- v := m.messages_dispatch_model_config
- if v == nil {
- return
- }
- return *v, true
- }
- // OldMessagesDispatchModelConfig returns the old "messages_dispatch_model_config" field's value of the Group entity.
- // If the Group object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *GroupMutation) OldMessagesDispatchModelConfig(ctx context.Context) (v domain.OpenAIMessagesDispatchModelConfig, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldMessagesDispatchModelConfig is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldMessagesDispatchModelConfig requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldMessagesDispatchModelConfig: %w", err)
- }
- return oldValue.MessagesDispatchModelConfig, nil
- }
- // ResetMessagesDispatchModelConfig resets all changes to the "messages_dispatch_model_config" field.
- func (m *GroupMutation) ResetMessagesDispatchModelConfig() {
- m.messages_dispatch_model_config = nil
- }
- // SetModelAllowlist sets the "model_allowlist" field.
- func (m *GroupMutation) SetModelAllowlist(dma domain.GroupModelAllowlist) {
- m.model_allowlist = &dma
- }
- // ModelAllowlist returns the value of the "model_allowlist" field in the mutation.
- func (m *GroupMutation) ModelAllowlist() (r domain.GroupModelAllowlist, exists bool) {
- v := m.model_allowlist
- if v == nil {
- return
- }
- return *v, true
- }
- // OldModelAllowlist returns the old "model_allowlist" field's value of the Group entity.
- // If the Group object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *GroupMutation) OldModelAllowlist(ctx context.Context) (v domain.GroupModelAllowlist, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldModelAllowlist is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldModelAllowlist requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldModelAllowlist: %w", err)
- }
- return oldValue.ModelAllowlist, nil
- }
- // ResetModelAllowlist resets all changes to the "model_allowlist" field.
- func (m *GroupMutation) ResetModelAllowlist() {
- m.model_allowlist = nil
- }
- // SetCodexModelsManifestConfig sets the "codex_models_manifest_config" field.
- func (m *GroupMutation) SetCodexModelsManifestConfig(dcmmc domain.GroupCodexModelsManifestConfig) {
- m.codex_models_manifest_config = &dcmmc
- }
- // CodexModelsManifestConfig returns the value of the "codex_models_manifest_config" field in the mutation.
- func (m *GroupMutation) CodexModelsManifestConfig() (r domain.GroupCodexModelsManifestConfig, exists bool) {
- v := m.codex_models_manifest_config
- if v == nil {
- return
- }
- return *v, true
- }
- // OldCodexModelsManifestConfig returns the old "codex_models_manifest_config" field's value of the Group entity.
- // If the Group object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *GroupMutation) OldCodexModelsManifestConfig(ctx context.Context) (v domain.GroupCodexModelsManifestConfig, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldCodexModelsManifestConfig is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldCodexModelsManifestConfig requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldCodexModelsManifestConfig: %w", err)
- }
- return oldValue.CodexModelsManifestConfig, nil
- }
- // ResetCodexModelsManifestConfig resets all changes to the "codex_models_manifest_config" field.
- func (m *GroupMutation) ResetCodexModelsManifestConfig() {
- m.codex_models_manifest_config = nil
- }
- // SetRpmLimit sets the "rpm_limit" field.
- func (m *GroupMutation) SetRpmLimit(i int) {
- m.rpm_limit = &i
- m.addrpm_limit = nil
- }
- // RpmLimit returns the value of the "rpm_limit" field in the mutation.
- func (m *GroupMutation) RpmLimit() (r int, exists bool) {
- v := m.rpm_limit
- if v == nil {
- return
- }
- return *v, true
- }
- // OldRpmLimit returns the old "rpm_limit" field's value of the Group entity.
- // If the Group object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *GroupMutation) OldRpmLimit(ctx context.Context) (v int, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldRpmLimit is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldRpmLimit requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldRpmLimit: %w", err)
- }
- return oldValue.RpmLimit, nil
- }
- // AddRpmLimit adds i to the "rpm_limit" field.
- func (m *GroupMutation) AddRpmLimit(i int) {
- if m.addrpm_limit != nil {
- *m.addrpm_limit += i
- } else {
- m.addrpm_limit = &i
- }
- }
- // AddedRpmLimit returns the value that was added to the "rpm_limit" field in this mutation.
- func (m *GroupMutation) AddedRpmLimit() (r int, exists bool) {
- v := m.addrpm_limit
- if v == nil {
- return
- }
- return *v, true
- }
- // ResetRpmLimit resets all changes to the "rpm_limit" field.
- func (m *GroupMutation) ResetRpmLimit() {
- m.rpm_limit = nil
- m.addrpm_limit = nil
- }
- // SetMaxReasoningEffort sets the "max_reasoning_effort" field.
- func (m *GroupMutation) SetMaxReasoningEffort(s string) {
- m.max_reasoning_effort = &s
- }
- // MaxReasoningEffort returns the value of the "max_reasoning_effort" field in the mutation.
- func (m *GroupMutation) MaxReasoningEffort() (r string, exists bool) {
- v := m.max_reasoning_effort
- if v == nil {
- return
- }
- return *v, true
- }
- // OldMaxReasoningEffort returns the old "max_reasoning_effort" field's value of the Group entity.
- // If the Group object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *GroupMutation) OldMaxReasoningEffort(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldMaxReasoningEffort is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldMaxReasoningEffort requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldMaxReasoningEffort: %w", err)
- }
- return oldValue.MaxReasoningEffort, nil
- }
- // ResetMaxReasoningEffort resets all changes to the "max_reasoning_effort" field.
- func (m *GroupMutation) ResetMaxReasoningEffort() {
- m.max_reasoning_effort = nil
- }
- // SetMaxReasoningEffortOverLimit sets the "max_reasoning_effort_over_limit" field.
- func (m *GroupMutation) SetMaxReasoningEffortOverLimit(s string) {
- m.max_reasoning_effort_over_limit = &s
- }
- // MaxReasoningEffortOverLimit returns the value of the "max_reasoning_effort_over_limit" field in the mutation.
- func (m *GroupMutation) MaxReasoningEffortOverLimit() (r string, exists bool) {
- v := m.max_reasoning_effort_over_limit
- if v == nil {
- return
- }
- return *v, true
- }
- // OldMaxReasoningEffortOverLimit returns the old "max_reasoning_effort_over_limit" field's value of the Group entity.
- // If the Group object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *GroupMutation) OldMaxReasoningEffortOverLimit(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldMaxReasoningEffortOverLimit is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldMaxReasoningEffortOverLimit requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldMaxReasoningEffortOverLimit: %w", err)
- }
- return oldValue.MaxReasoningEffortOverLimit, nil
- }
- // ResetMaxReasoningEffortOverLimit resets all changes to the "max_reasoning_effort_over_limit" field.
- func (m *GroupMutation) ResetMaxReasoningEffortOverLimit() {
- m.max_reasoning_effort_over_limit = nil
- }
- // SetReasoningEffortMappings sets the "reasoning_effort_mappings" field.
- func (m *GroupMutation) SetReasoningEffortMappings(dem []domain.ReasoningEffortMapping) {
- m.reasoning_effort_mappings = &dem
- m.appendreasoning_effort_mappings = nil
- }
- // ReasoningEffortMappings returns the value of the "reasoning_effort_mappings" field in the mutation.
- func (m *GroupMutation) ReasoningEffortMappings() (r []domain.ReasoningEffortMapping, exists bool) {
- v := m.reasoning_effort_mappings
- if v == nil {
- return
- }
- return *v, true
- }
- // OldReasoningEffortMappings returns the old "reasoning_effort_mappings" field's value of the Group entity.
- // If the Group object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *GroupMutation) OldReasoningEffortMappings(ctx context.Context) (v []domain.ReasoningEffortMapping, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldReasoningEffortMappings is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldReasoningEffortMappings requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldReasoningEffortMappings: %w", err)
- }
- return oldValue.ReasoningEffortMappings, nil
- }
- // AppendReasoningEffortMappings adds dem to the "reasoning_effort_mappings" field.
- func (m *GroupMutation) AppendReasoningEffortMappings(dem []domain.ReasoningEffortMapping) {
- m.appendreasoning_effort_mappings = append(m.appendreasoning_effort_mappings, dem...)
- }
- // AppendedReasoningEffortMappings returns the list of values that were appended to the "reasoning_effort_mappings" field in this mutation.
- func (m *GroupMutation) AppendedReasoningEffortMappings() ([]domain.ReasoningEffortMapping, bool) {
- if len(m.appendreasoning_effort_mappings) == 0 {
- return nil, false
- }
- return m.appendreasoning_effort_mappings, true
- }
- // ResetReasoningEffortMappings resets all changes to the "reasoning_effort_mappings" field.
- func (m *GroupMutation) ResetReasoningEffortMappings() {
- m.reasoning_effort_mappings = nil
- m.appendreasoning_effort_mappings = nil
- }
- // SetProfitControlEnabled sets the "profit_control_enabled" field.
- func (m *GroupMutation) SetProfitControlEnabled(b bool) {
- m.profit_control_enabled = &b
- }
- // ProfitControlEnabled returns the value of the "profit_control_enabled" field in the mutation.
- func (m *GroupMutation) ProfitControlEnabled() (r bool, exists bool) {
- v := m.profit_control_enabled
- if v == nil {
- return
- }
- return *v, true
- }
- // OldProfitControlEnabled returns the old "profit_control_enabled" field's value of the Group entity.
- // If the Group object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *GroupMutation) OldProfitControlEnabled(ctx context.Context) (v bool, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldProfitControlEnabled is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldProfitControlEnabled requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldProfitControlEnabled: %w", err)
- }
- return oldValue.ProfitControlEnabled, nil
- }
- // ResetProfitControlEnabled resets all changes to the "profit_control_enabled" field.
- func (m *GroupMutation) ResetProfitControlEnabled() {
- m.profit_control_enabled = nil
- }
- // SetProfitMinMargin sets the "profit_min_margin" field.
- func (m *GroupMutation) SetProfitMinMargin(f float64) {
- m.profit_min_margin = &f
- m.addprofit_min_margin = nil
- }
- // ProfitMinMargin returns the value of the "profit_min_margin" field in the mutation.
- func (m *GroupMutation) ProfitMinMargin() (r float64, exists bool) {
- v := m.profit_min_margin
- if v == nil {
- return
- }
- return *v, true
- }
- // OldProfitMinMargin returns the old "profit_min_margin" field's value of the Group entity.
- // If the Group object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *GroupMutation) OldProfitMinMargin(ctx context.Context) (v float64, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldProfitMinMargin is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldProfitMinMargin requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldProfitMinMargin: %w", err)
- }
- return oldValue.ProfitMinMargin, nil
- }
- // AddProfitMinMargin adds f to the "profit_min_margin" field.
- func (m *GroupMutation) AddProfitMinMargin(f float64) {
- if m.addprofit_min_margin != nil {
- *m.addprofit_min_margin += f
- } else {
- m.addprofit_min_margin = &f
- }
- }
- // AddedProfitMinMargin returns the value that was added to the "profit_min_margin" field in this mutation.
- func (m *GroupMutation) AddedProfitMinMargin() (r float64, exists bool) {
- v := m.addprofit_min_margin
- if v == nil {
- return
- }
- return *v, true
- }
- // ResetProfitMinMargin resets all changes to the "profit_min_margin" field.
- func (m *GroupMutation) ResetProfitMinMargin() {
- m.profit_min_margin = nil
- m.addprofit_min_margin = nil
- }
- // SetProfitSafetyBuffer sets the "profit_safety_buffer" field.
- func (m *GroupMutation) SetProfitSafetyBuffer(f float64) {
- m.profit_safety_buffer = &f
- m.addprofit_safety_buffer = nil
- }
- // ProfitSafetyBuffer returns the value of the "profit_safety_buffer" field in the mutation.
- func (m *GroupMutation) ProfitSafetyBuffer() (r float64, exists bool) {
- v := m.profit_safety_buffer
- if v == nil {
- return
- }
- return *v, true
- }
- // OldProfitSafetyBuffer returns the old "profit_safety_buffer" field's value of the Group entity.
- // If the Group object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *GroupMutation) OldProfitSafetyBuffer(ctx context.Context) (v float64, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldProfitSafetyBuffer is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldProfitSafetyBuffer requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldProfitSafetyBuffer: %w", err)
- }
- return oldValue.ProfitSafetyBuffer, nil
- }
- // AddProfitSafetyBuffer adds f to the "profit_safety_buffer" field.
- func (m *GroupMutation) AddProfitSafetyBuffer(f float64) {
- if m.addprofit_safety_buffer != nil {
- *m.addprofit_safety_buffer += f
- } else {
- m.addprofit_safety_buffer = &f
- }
- }
- // AddedProfitSafetyBuffer returns the value that was added to the "profit_safety_buffer" field in this mutation.
- func (m *GroupMutation) AddedProfitSafetyBuffer() (r float64, exists bool) {
- v := m.addprofit_safety_buffer
- if v == nil {
- return
- }
- return *v, true
- }
- // ResetProfitSafetyBuffer resets all changes to the "profit_safety_buffer" field.
- func (m *GroupMutation) ResetProfitSafetyBuffer() {
- m.profit_safety_buffer = nil
- m.addprofit_safety_buffer = nil
- }
- // AddAPIKeyIDs adds the "api_keys" edge to the APIKey entity by ids.
- func (m *GroupMutation) AddAPIKeyIDs(ids ...int64) {
- if m.api_keys == nil {
- m.api_keys = make(map[int64]struct{})
- }
- for i := range ids {
- m.api_keys[ids[i]] = struct{}{}
- }
- }
- // ClearAPIKeys clears the "api_keys" edge to the APIKey entity.
- func (m *GroupMutation) ClearAPIKeys() {
- m.clearedapi_keys = true
- }
- // APIKeysCleared reports if the "api_keys" edge to the APIKey entity was cleared.
- func (m *GroupMutation) APIKeysCleared() bool {
- return m.clearedapi_keys
- }
- // RemoveAPIKeyIDs removes the "api_keys" edge to the APIKey entity by IDs.
- func (m *GroupMutation) RemoveAPIKeyIDs(ids ...int64) {
- if m.removedapi_keys == nil {
- m.removedapi_keys = make(map[int64]struct{})
- }
- for i := range ids {
- delete(m.api_keys, ids[i])
- m.removedapi_keys[ids[i]] = struct{}{}
- }
- }
- // RemovedAPIKeys returns the removed IDs of the "api_keys" edge to the APIKey entity.
- func (m *GroupMutation) RemovedAPIKeysIDs() (ids []int64) {
- for id := range m.removedapi_keys {
- ids = append(ids, id)
- }
- return
- }
- // APIKeysIDs returns the "api_keys" edge IDs in the mutation.
- func (m *GroupMutation) APIKeysIDs() (ids []int64) {
- for id := range m.api_keys {
- ids = append(ids, id)
- }
- return
- }
- // ResetAPIKeys resets all changes to the "api_keys" edge.
- func (m *GroupMutation) ResetAPIKeys() {
- m.api_keys = nil
- m.clearedapi_keys = false
- m.removedapi_keys = nil
- }
- // AddRedeemCodeIDs adds the "redeem_codes" edge to the RedeemCode entity by ids.
- func (m *GroupMutation) AddRedeemCodeIDs(ids ...int64) {
- if m.redeem_codes == nil {
- m.redeem_codes = make(map[int64]struct{})
- }
- for i := range ids {
- m.redeem_codes[ids[i]] = struct{}{}
- }
- }
- // ClearRedeemCodes clears the "redeem_codes" edge to the RedeemCode entity.
- func (m *GroupMutation) ClearRedeemCodes() {
- m.clearedredeem_codes = true
- }
- // RedeemCodesCleared reports if the "redeem_codes" edge to the RedeemCode entity was cleared.
- func (m *GroupMutation) RedeemCodesCleared() bool {
- return m.clearedredeem_codes
- }
- // RemoveRedeemCodeIDs removes the "redeem_codes" edge to the RedeemCode entity by IDs.
- func (m *GroupMutation) RemoveRedeemCodeIDs(ids ...int64) {
- if m.removedredeem_codes == nil {
- m.removedredeem_codes = make(map[int64]struct{})
- }
- for i := range ids {
- delete(m.redeem_codes, ids[i])
- m.removedredeem_codes[ids[i]] = struct{}{}
- }
- }
- // RemovedRedeemCodes returns the removed IDs of the "redeem_codes" edge to the RedeemCode entity.
- func (m *GroupMutation) RemovedRedeemCodesIDs() (ids []int64) {
- for id := range m.removedredeem_codes {
- ids = append(ids, id)
- }
- return
- }
- // RedeemCodesIDs returns the "redeem_codes" edge IDs in the mutation.
- func (m *GroupMutation) RedeemCodesIDs() (ids []int64) {
- for id := range m.redeem_codes {
- ids = append(ids, id)
- }
- return
- }
- // ResetRedeemCodes resets all changes to the "redeem_codes" edge.
- func (m *GroupMutation) ResetRedeemCodes() {
- m.redeem_codes = nil
- m.clearedredeem_codes = false
- m.removedredeem_codes = nil
- }
- // AddSubscriptionIDs adds the "subscriptions" edge to the UserSubscription entity by ids.
- func (m *GroupMutation) AddSubscriptionIDs(ids ...int64) {
- if m.subscriptions == nil {
- m.subscriptions = make(map[int64]struct{})
- }
- for i := range ids {
- m.subscriptions[ids[i]] = struct{}{}
- }
- }
- // ClearSubscriptions clears the "subscriptions" edge to the UserSubscription entity.
- func (m *GroupMutation) ClearSubscriptions() {
- m.clearedsubscriptions = true
- }
- // SubscriptionsCleared reports if the "subscriptions" edge to the UserSubscription entity was cleared.
- func (m *GroupMutation) SubscriptionsCleared() bool {
- return m.clearedsubscriptions
- }
- // RemoveSubscriptionIDs removes the "subscriptions" edge to the UserSubscription entity by IDs.
- func (m *GroupMutation) RemoveSubscriptionIDs(ids ...int64) {
- if m.removedsubscriptions == nil {
- m.removedsubscriptions = make(map[int64]struct{})
- }
- for i := range ids {
- delete(m.subscriptions, ids[i])
- m.removedsubscriptions[ids[i]] = struct{}{}
- }
- }
- // RemovedSubscriptions returns the removed IDs of the "subscriptions" edge to the UserSubscription entity.
- func (m *GroupMutation) RemovedSubscriptionsIDs() (ids []int64) {
- for id := range m.removedsubscriptions {
- ids = append(ids, id)
- }
- return
- }
- // SubscriptionsIDs returns the "subscriptions" edge IDs in the mutation.
- func (m *GroupMutation) SubscriptionsIDs() (ids []int64) {
- for id := range m.subscriptions {
- ids = append(ids, id)
- }
- return
- }
- // ResetSubscriptions resets all changes to the "subscriptions" edge.
- func (m *GroupMutation) ResetSubscriptions() {
- m.subscriptions = nil
- m.clearedsubscriptions = false
- m.removedsubscriptions = nil
- }
- // AddUsageLogIDs adds the "usage_logs" edge to the UsageLog entity by ids.
- func (m *GroupMutation) AddUsageLogIDs(ids ...int64) {
- if m.usage_logs == nil {
- m.usage_logs = make(map[int64]struct{})
- }
- for i := range ids {
- m.usage_logs[ids[i]] = struct{}{}
- }
- }
- // ClearUsageLogs clears the "usage_logs" edge to the UsageLog entity.
- func (m *GroupMutation) ClearUsageLogs() {
- m.clearedusage_logs = true
- }
- // UsageLogsCleared reports if the "usage_logs" edge to the UsageLog entity was cleared.
- func (m *GroupMutation) UsageLogsCleared() bool {
- return m.clearedusage_logs
- }
- // RemoveUsageLogIDs removes the "usage_logs" edge to the UsageLog entity by IDs.
- func (m *GroupMutation) RemoveUsageLogIDs(ids ...int64) {
- if m.removedusage_logs == nil {
- m.removedusage_logs = make(map[int64]struct{})
- }
- for i := range ids {
- delete(m.usage_logs, ids[i])
- m.removedusage_logs[ids[i]] = struct{}{}
- }
- }
- // RemovedUsageLogs returns the removed IDs of the "usage_logs" edge to the UsageLog entity.
- func (m *GroupMutation) RemovedUsageLogsIDs() (ids []int64) {
- for id := range m.removedusage_logs {
- ids = append(ids, id)
- }
- return
- }
- // UsageLogsIDs returns the "usage_logs" edge IDs in the mutation.
- func (m *GroupMutation) UsageLogsIDs() (ids []int64) {
- for id := range m.usage_logs {
- ids = append(ids, id)
- }
- return
- }
- // ResetUsageLogs resets all changes to the "usage_logs" edge.
- func (m *GroupMutation) ResetUsageLogs() {
- m.usage_logs = nil
- m.clearedusage_logs = false
- m.removedusage_logs = nil
- }
- // AddAccountIDs adds the "accounts" edge to the Account entity by ids.
- func (m *GroupMutation) AddAccountIDs(ids ...int64) {
- if m.accounts == nil {
- m.accounts = make(map[int64]struct{})
- }
- for i := range ids {
- m.accounts[ids[i]] = struct{}{}
- }
- }
- // ClearAccounts clears the "accounts" edge to the Account entity.
- func (m *GroupMutation) ClearAccounts() {
- m.clearedaccounts = true
- }
- // AccountsCleared reports if the "accounts" edge to the Account entity was cleared.
- func (m *GroupMutation) AccountsCleared() bool {
- return m.clearedaccounts
- }
- // RemoveAccountIDs removes the "accounts" edge to the Account entity by IDs.
- func (m *GroupMutation) RemoveAccountIDs(ids ...int64) {
- if m.removedaccounts == nil {
- m.removedaccounts = make(map[int64]struct{})
- }
- for i := range ids {
- delete(m.accounts, ids[i])
- m.removedaccounts[ids[i]] = struct{}{}
- }
- }
- // RemovedAccounts returns the removed IDs of the "accounts" edge to the Account entity.
- func (m *GroupMutation) RemovedAccountsIDs() (ids []int64) {
- for id := range m.removedaccounts {
- ids = append(ids, id)
- }
- return
- }
- // AccountsIDs returns the "accounts" edge IDs in the mutation.
- func (m *GroupMutation) AccountsIDs() (ids []int64) {
- for id := range m.accounts {
- ids = append(ids, id)
- }
- return
- }
- // ResetAccounts resets all changes to the "accounts" edge.
- func (m *GroupMutation) ResetAccounts() {
- m.accounts = nil
- m.clearedaccounts = false
- m.removedaccounts = nil
- }
- // AddAllowedUserIDs adds the "allowed_users" edge to the User entity by ids.
- func (m *GroupMutation) AddAllowedUserIDs(ids ...int64) {
- if m.allowed_users == nil {
- m.allowed_users = make(map[int64]struct{})
- }
- for i := range ids {
- m.allowed_users[ids[i]] = struct{}{}
- }
- }
- // ClearAllowedUsers clears the "allowed_users" edge to the User entity.
- func (m *GroupMutation) ClearAllowedUsers() {
- m.clearedallowed_users = true
- }
- // AllowedUsersCleared reports if the "allowed_users" edge to the User entity was cleared.
- func (m *GroupMutation) AllowedUsersCleared() bool {
- return m.clearedallowed_users
- }
- // RemoveAllowedUserIDs removes the "allowed_users" edge to the User entity by IDs.
- func (m *GroupMutation) RemoveAllowedUserIDs(ids ...int64) {
- if m.removedallowed_users == nil {
- m.removedallowed_users = make(map[int64]struct{})
- }
- for i := range ids {
- delete(m.allowed_users, ids[i])
- m.removedallowed_users[ids[i]] = struct{}{}
- }
- }
- // RemovedAllowedUsers returns the removed IDs of the "allowed_users" edge to the User entity.
- func (m *GroupMutation) RemovedAllowedUsersIDs() (ids []int64) {
- for id := range m.removedallowed_users {
- ids = append(ids, id)
- }
- return
- }
- // AllowedUsersIDs returns the "allowed_users" edge IDs in the mutation.
- func (m *GroupMutation) AllowedUsersIDs() (ids []int64) {
- for id := range m.allowed_users {
- ids = append(ids, id)
- }
- return
- }
- // ResetAllowedUsers resets all changes to the "allowed_users" edge.
- func (m *GroupMutation) ResetAllowedUsers() {
- m.allowed_users = nil
- m.clearedallowed_users = false
- m.removedallowed_users = nil
- }
- // Where appends a list predicates to the GroupMutation builder.
- func (m *GroupMutation) Where(ps ...predicate.Group) {
- m.predicates = append(m.predicates, ps...)
- }
- // WhereP appends storage-level predicates to the GroupMutation builder. Using this method,
- // users can use type-assertion to append predicates that do not depend on any generated package.
- func (m *GroupMutation) WhereP(ps ...func(*sql.Selector)) {
- p := make([]predicate.Group, len(ps))
- for i := range ps {
- p[i] = ps[i]
- }
- m.Where(p...)
- }
- // Op returns the operation name.
- func (m *GroupMutation) Op() Op {
- return m.op
- }
- // SetOp allows setting the mutation operation.
- func (m *GroupMutation) SetOp(op Op) {
- m.op = op
- }
- // Type returns the node type of this mutation (Group).
- func (m *GroupMutation) Type() string {
- return m.typ
- }
- // Fields returns all fields that were changed during this mutation. Note that in
- // order to get all numeric fields that were incremented/decremented, call
- // AddedFields().
- func (m *GroupMutation) Fields() []string {
- fields := make([]string, 0, 69)
- if m.created_at != nil {
- fields = append(fields, group.FieldCreatedAt)
- }
- if m.updated_at != nil {
- fields = append(fields, group.FieldUpdatedAt)
- }
- if m.deleted_at != nil {
- fields = append(fields, group.FieldDeletedAt)
- }
- if m.name != nil {
- fields = append(fields, group.FieldName)
- }
- if m.description != nil {
- fields = append(fields, group.FieldDescription)
- }
- if m.rate_multiplier != nil {
- fields = append(fields, group.FieldRateMultiplier)
- }
- if m.peak_rate_enabled != nil {
- fields = append(fields, group.FieldPeakRateEnabled)
- }
- if m.peak_start != nil {
- fields = append(fields, group.FieldPeakStart)
- }
- if m.peak_end != nil {
- fields = append(fields, group.FieldPeakEnd)
- }
- if m.peak_rate_multiplier != nil {
- fields = append(fields, group.FieldPeakRateMultiplier)
- }
- if m.is_exclusive != nil {
- fields = append(fields, group.FieldIsExclusive)
- }
- if m.security_policy_enabled != nil {
- fields = append(fields, group.FieldSecurityPolicyEnabled)
- }
- if m.security_policy_mode != nil {
- fields = append(fields, group.FieldSecurityPolicyMode)
- }
- if m.security_policy_email_enabled != nil {
- fields = append(fields, group.FieldSecurityPolicyEmailEnabled)
- }
- if m.status != nil {
- fields = append(fields, group.FieldStatus)
- }
- if m.duplicate_operation_id != nil {
- fields = append(fields, group.FieldDuplicateOperationID)
- }
- if m.platform != nil {
- fields = append(fields, group.FieldPlatform)
- }
- if m.subscription_type != nil {
- fields = append(fields, group.FieldSubscriptionType)
- }
- if m.daily_limit_usd != nil {
- fields = append(fields, group.FieldDailyLimitUsd)
- }
- if m.weekly_limit_usd != nil {
- fields = append(fields, group.FieldWeeklyLimitUsd)
- }
- if m.monthly_limit_usd != nil {
- fields = append(fields, group.FieldMonthlyLimitUsd)
- }
- if m.default_validity_days != nil {
- fields = append(fields, group.FieldDefaultValidityDays)
- }
- if m.allow_image_generation != nil {
- fields = append(fields, group.FieldAllowImageGeneration)
- }
- if m.allow_batch_image_generation != nil {
- fields = append(fields, group.FieldAllowBatchImageGeneration)
- }
- if m.image_rate_independent != nil {
- fields = append(fields, group.FieldImageRateIndependent)
- }
- if m.image_rate_multiplier != nil {
- fields = append(fields, group.FieldImageRateMultiplier)
- }
- if m.image_price_1k != nil {
- fields = append(fields, group.FieldImagePrice1k)
- }
- if m.image_price_2k != nil {
- fields = append(fields, group.FieldImagePrice2k)
- }
- if m.image_price_4k != nil {
- fields = append(fields, group.FieldImagePrice4k)
- }
- if m.batch_image_discount_multiplier != nil {
- fields = append(fields, group.FieldBatchImageDiscountMultiplier)
- }
- if m.batch_image_hold_multiplier != nil {
- fields = append(fields, group.FieldBatchImageHoldMultiplier)
- }
- if m.video_rate_independent != nil {
- fields = append(fields, group.FieldVideoRateIndependent)
- }
- if m.video_rate_multiplier != nil {
- fields = append(fields, group.FieldVideoRateMultiplier)
- }
- if m.video_price_480p != nil {
- fields = append(fields, group.FieldVideoPrice480p)
- }
- if m.video_price_720p != nil {
- fields = append(fields, group.FieldVideoPrice720p)
- }
- if m.video_price_1080p != nil {
- fields = append(fields, group.FieldVideoPrice1080p)
- }
- if m.video_model_prices != nil {
- fields = append(fields, group.FieldVideoModelPrices)
- }
- if m.web_search_price_per_call != nil {
- fields = append(fields, group.FieldWebSearchPricePerCall)
- }
- if m.search_price_per_1k != nil {
- fields = append(fields, group.FieldSearchPricePer1k)
- }
- if m.audio_realtime_price_per_min != nil {
- fields = append(fields, group.FieldAudioRealtimePricePerMin)
- }
- if m.audio_tts_price_per_million_chars != nil {
- fields = append(fields, group.FieldAudioTtsPricePerMillionChars)
- }
- if m.audio_stt_price_per_hour != nil {
- fields = append(fields, group.FieldAudioSttPricePerHour)
- }
- if m.long_context_pricing_enabled != nil {
- fields = append(fields, group.FieldLongContextPricingEnabled)
- }
- if m.model_pricing != nil {
- fields = append(fields, group.FieldModelPricing)
- }
- if m.claude_code_only != nil {
- fields = append(fields, group.FieldClaudeCodeOnly)
- }
- if m.fallback_group_id != nil {
- fields = append(fields, group.FieldFallbackGroupID)
- }
- if m.fallback_group_id_on_invalid_request != nil {
- fields = append(fields, group.FieldFallbackGroupIDOnInvalidRequest)
- }
- if m.model_routing != nil {
- fields = append(fields, group.FieldModelRouting)
- }
- if m.model_routing_enabled != nil {
- fields = append(fields, group.FieldModelRoutingEnabled)
- }
- if m.mcp_xml_inject != nil {
- fields = append(fields, group.FieldMcpXMLInject)
- }
- if m.supported_model_scopes != nil {
- fields = append(fields, group.FieldSupportedModelScopes)
- }
- if m.sort_order != nil {
- fields = append(fields, group.FieldSortOrder)
- }
- if m.allow_messages_dispatch != nil {
- fields = append(fields, group.FieldAllowMessagesDispatch)
- }
- if m.allow_live != nil {
- fields = append(fields, group.FieldAllowLive)
- }
- if m.force_openai_fast != nil {
- fields = append(fields, group.FieldForceOpenaiFast)
- }
- if m.free_openai_fast != nil {
- fields = append(fields, group.FieldFreeOpenaiFast)
- }
- if m.require_oauth_only != nil {
- fields = append(fields, group.FieldRequireOauthOnly)
- }
- if m.require_privacy_set != nil {
- fields = append(fields, group.FieldRequirePrivacySet)
- }
- if m.default_mapped_model != nil {
- fields = append(fields, group.FieldDefaultMappedModel)
- }
- if m.messages_dispatch_model_config != nil {
- fields = append(fields, group.FieldMessagesDispatchModelConfig)
- }
- if m.model_allowlist != nil {
- fields = append(fields, group.FieldModelAllowlist)
- }
- if m.codex_models_manifest_config != nil {
- fields = append(fields, group.FieldCodexModelsManifestConfig)
- }
- if m.rpm_limit != nil {
- fields = append(fields, group.FieldRpmLimit)
- }
- if m.max_reasoning_effort != nil {
- fields = append(fields, group.FieldMaxReasoningEffort)
- }
- if m.max_reasoning_effort_over_limit != nil {
- fields = append(fields, group.FieldMaxReasoningEffortOverLimit)
- }
- if m.reasoning_effort_mappings != nil {
- fields = append(fields, group.FieldReasoningEffortMappings)
- }
- if m.profit_control_enabled != nil {
- fields = append(fields, group.FieldProfitControlEnabled)
- }
- if m.profit_min_margin != nil {
- fields = append(fields, group.FieldProfitMinMargin)
- }
- if m.profit_safety_buffer != nil {
- fields = append(fields, group.FieldProfitSafetyBuffer)
- }
- return fields
- }
- // Field returns the value of a field with the given name. The second boolean
- // return value indicates that this field was not set, or was not defined in the
- // schema.
- func (m *GroupMutation) Field(name string) (ent.Value, bool) {
- switch name {
- case group.FieldCreatedAt:
- return m.CreatedAt()
- case group.FieldUpdatedAt:
- return m.UpdatedAt()
- case group.FieldDeletedAt:
- return m.DeletedAt()
- case group.FieldName:
- return m.Name()
- case group.FieldDescription:
- return m.Description()
- case group.FieldRateMultiplier:
- return m.RateMultiplier()
- case group.FieldPeakRateEnabled:
- return m.PeakRateEnabled()
- case group.FieldPeakStart:
- return m.PeakStart()
- case group.FieldPeakEnd:
- return m.PeakEnd()
- case group.FieldPeakRateMultiplier:
- return m.PeakRateMultiplier()
- case group.FieldIsExclusive:
- return m.IsExclusive()
- case group.FieldSecurityPolicyEnabled:
- return m.SecurityPolicyEnabled()
- case group.FieldSecurityPolicyMode:
- return m.SecurityPolicyMode()
- case group.FieldSecurityPolicyEmailEnabled:
- return m.SecurityPolicyEmailEnabled()
- case group.FieldStatus:
- return m.Status()
- case group.FieldDuplicateOperationID:
- return m.DuplicateOperationID()
- case group.FieldPlatform:
- return m.Platform()
- case group.FieldSubscriptionType:
- return m.SubscriptionType()
- case group.FieldDailyLimitUsd:
- return m.DailyLimitUsd()
- case group.FieldWeeklyLimitUsd:
- return m.WeeklyLimitUsd()
- case group.FieldMonthlyLimitUsd:
- return m.MonthlyLimitUsd()
- case group.FieldDefaultValidityDays:
- return m.DefaultValidityDays()
- case group.FieldAllowImageGeneration:
- return m.AllowImageGeneration()
- case group.FieldAllowBatchImageGeneration:
- return m.AllowBatchImageGeneration()
- case group.FieldImageRateIndependent:
- return m.ImageRateIndependent()
- case group.FieldImageRateMultiplier:
- return m.ImageRateMultiplier()
- case group.FieldImagePrice1k:
- return m.ImagePrice1k()
- case group.FieldImagePrice2k:
- return m.ImagePrice2k()
- case group.FieldImagePrice4k:
- return m.ImagePrice4k()
- case group.FieldBatchImageDiscountMultiplier:
- return m.BatchImageDiscountMultiplier()
- case group.FieldBatchImageHoldMultiplier:
- return m.BatchImageHoldMultiplier()
- case group.FieldVideoRateIndependent:
- return m.VideoRateIndependent()
- case group.FieldVideoRateMultiplier:
- return m.VideoRateMultiplier()
- case group.FieldVideoPrice480p:
- return m.VideoPrice480p()
- case group.FieldVideoPrice720p:
- return m.VideoPrice720p()
- case group.FieldVideoPrice1080p:
- return m.VideoPrice1080p()
- case group.FieldVideoModelPrices:
- return m.VideoModelPrices()
- case group.FieldWebSearchPricePerCall:
- return m.WebSearchPricePerCall()
- case group.FieldSearchPricePer1k:
- return m.SearchPricePer1k()
- case group.FieldAudioRealtimePricePerMin:
- return m.AudioRealtimePricePerMin()
- case group.FieldAudioTtsPricePerMillionChars:
- return m.AudioTtsPricePerMillionChars()
- case group.FieldAudioSttPricePerHour:
- return m.AudioSttPricePerHour()
- case group.FieldLongContextPricingEnabled:
- return m.LongContextPricingEnabled()
- case group.FieldModelPricing:
- return m.ModelPricing()
- case group.FieldClaudeCodeOnly:
- return m.ClaudeCodeOnly()
- case group.FieldFallbackGroupID:
- return m.FallbackGroupID()
- case group.FieldFallbackGroupIDOnInvalidRequest:
- return m.FallbackGroupIDOnInvalidRequest()
- case group.FieldModelRouting:
- return m.ModelRouting()
- case group.FieldModelRoutingEnabled:
- return m.ModelRoutingEnabled()
- case group.FieldMcpXMLInject:
- return m.McpXMLInject()
- case group.FieldSupportedModelScopes:
- return m.SupportedModelScopes()
- case group.FieldSortOrder:
- return m.SortOrder()
- case group.FieldAllowMessagesDispatch:
- return m.AllowMessagesDispatch()
- case group.FieldAllowLive:
- return m.AllowLive()
- case group.FieldForceOpenaiFast:
- return m.ForceOpenaiFast()
- case group.FieldFreeOpenaiFast:
- return m.FreeOpenaiFast()
- case group.FieldRequireOauthOnly:
- return m.RequireOauthOnly()
- case group.FieldRequirePrivacySet:
- return m.RequirePrivacySet()
- case group.FieldDefaultMappedModel:
- return m.DefaultMappedModel()
- case group.FieldMessagesDispatchModelConfig:
- return m.MessagesDispatchModelConfig()
- case group.FieldModelAllowlist:
- return m.ModelAllowlist()
- case group.FieldCodexModelsManifestConfig:
- return m.CodexModelsManifestConfig()
- case group.FieldRpmLimit:
- return m.RpmLimit()
- case group.FieldMaxReasoningEffort:
- return m.MaxReasoningEffort()
- case group.FieldMaxReasoningEffortOverLimit:
- return m.MaxReasoningEffortOverLimit()
- case group.FieldReasoningEffortMappings:
- return m.ReasoningEffortMappings()
- case group.FieldProfitControlEnabled:
- return m.ProfitControlEnabled()
- case group.FieldProfitMinMargin:
- return m.ProfitMinMargin()
- case group.FieldProfitSafetyBuffer:
- return m.ProfitSafetyBuffer()
- }
- return nil, false
- }
- // OldField returns the old value of the field from the database. An error is
- // returned if the mutation operation is not UpdateOne, or the query to the
- // database failed.
- func (m *GroupMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
- switch name {
- case group.FieldCreatedAt:
- return m.OldCreatedAt(ctx)
- case group.FieldUpdatedAt:
- return m.OldUpdatedAt(ctx)
- case group.FieldDeletedAt:
- return m.OldDeletedAt(ctx)
- case group.FieldName:
- return m.OldName(ctx)
- case group.FieldDescription:
- return m.OldDescription(ctx)
- case group.FieldRateMultiplier:
- return m.OldRateMultiplier(ctx)
- case group.FieldPeakRateEnabled:
- return m.OldPeakRateEnabled(ctx)
- case group.FieldPeakStart:
- return m.OldPeakStart(ctx)
- case group.FieldPeakEnd:
- return m.OldPeakEnd(ctx)
- case group.FieldPeakRateMultiplier:
- return m.OldPeakRateMultiplier(ctx)
- case group.FieldIsExclusive:
- return m.OldIsExclusive(ctx)
- case group.FieldSecurityPolicyEnabled:
- return m.OldSecurityPolicyEnabled(ctx)
- case group.FieldSecurityPolicyMode:
- return m.OldSecurityPolicyMode(ctx)
- case group.FieldSecurityPolicyEmailEnabled:
- return m.OldSecurityPolicyEmailEnabled(ctx)
- case group.FieldStatus:
- return m.OldStatus(ctx)
- case group.FieldDuplicateOperationID:
- return m.OldDuplicateOperationID(ctx)
- case group.FieldPlatform:
- return m.OldPlatform(ctx)
- case group.FieldSubscriptionType:
- return m.OldSubscriptionType(ctx)
- case group.FieldDailyLimitUsd:
- return m.OldDailyLimitUsd(ctx)
- case group.FieldWeeklyLimitUsd:
- return m.OldWeeklyLimitUsd(ctx)
- case group.FieldMonthlyLimitUsd:
- return m.OldMonthlyLimitUsd(ctx)
- case group.FieldDefaultValidityDays:
- return m.OldDefaultValidityDays(ctx)
- case group.FieldAllowImageGeneration:
- return m.OldAllowImageGeneration(ctx)
- case group.FieldAllowBatchImageGeneration:
- return m.OldAllowBatchImageGeneration(ctx)
- case group.FieldImageRateIndependent:
- return m.OldImageRateIndependent(ctx)
- case group.FieldImageRateMultiplier:
- return m.OldImageRateMultiplier(ctx)
- case group.FieldImagePrice1k:
- return m.OldImagePrice1k(ctx)
- case group.FieldImagePrice2k:
- return m.OldImagePrice2k(ctx)
- case group.FieldImagePrice4k:
- return m.OldImagePrice4k(ctx)
- case group.FieldBatchImageDiscountMultiplier:
- return m.OldBatchImageDiscountMultiplier(ctx)
- case group.FieldBatchImageHoldMultiplier:
- return m.OldBatchImageHoldMultiplier(ctx)
- case group.FieldVideoRateIndependent:
- return m.OldVideoRateIndependent(ctx)
- case group.FieldVideoRateMultiplier:
- return m.OldVideoRateMultiplier(ctx)
- case group.FieldVideoPrice480p:
- return m.OldVideoPrice480p(ctx)
- case group.FieldVideoPrice720p:
- return m.OldVideoPrice720p(ctx)
- case group.FieldVideoPrice1080p:
- return m.OldVideoPrice1080p(ctx)
- case group.FieldVideoModelPrices:
- return m.OldVideoModelPrices(ctx)
- case group.FieldWebSearchPricePerCall:
- return m.OldWebSearchPricePerCall(ctx)
- case group.FieldSearchPricePer1k:
- return m.OldSearchPricePer1k(ctx)
- case group.FieldAudioRealtimePricePerMin:
- return m.OldAudioRealtimePricePerMin(ctx)
- case group.FieldAudioTtsPricePerMillionChars:
- return m.OldAudioTtsPricePerMillionChars(ctx)
- case group.FieldAudioSttPricePerHour:
- return m.OldAudioSttPricePerHour(ctx)
- case group.FieldLongContextPricingEnabled:
- return m.OldLongContextPricingEnabled(ctx)
- case group.FieldModelPricing:
- return m.OldModelPricing(ctx)
- case group.FieldClaudeCodeOnly:
- return m.OldClaudeCodeOnly(ctx)
- case group.FieldFallbackGroupID:
- return m.OldFallbackGroupID(ctx)
- case group.FieldFallbackGroupIDOnInvalidRequest:
- return m.OldFallbackGroupIDOnInvalidRequest(ctx)
- case group.FieldModelRouting:
- return m.OldModelRouting(ctx)
- case group.FieldModelRoutingEnabled:
- return m.OldModelRoutingEnabled(ctx)
- case group.FieldMcpXMLInject:
- return m.OldMcpXMLInject(ctx)
- case group.FieldSupportedModelScopes:
- return m.OldSupportedModelScopes(ctx)
- case group.FieldSortOrder:
- return m.OldSortOrder(ctx)
- case group.FieldAllowMessagesDispatch:
- return m.OldAllowMessagesDispatch(ctx)
- case group.FieldAllowLive:
- return m.OldAllowLive(ctx)
- case group.FieldForceOpenaiFast:
- return m.OldForceOpenaiFast(ctx)
- case group.FieldFreeOpenaiFast:
- return m.OldFreeOpenaiFast(ctx)
- case group.FieldRequireOauthOnly:
- return m.OldRequireOauthOnly(ctx)
- case group.FieldRequirePrivacySet:
- return m.OldRequirePrivacySet(ctx)
- case group.FieldDefaultMappedModel:
- return m.OldDefaultMappedModel(ctx)
- case group.FieldMessagesDispatchModelConfig:
- return m.OldMessagesDispatchModelConfig(ctx)
- case group.FieldModelAllowlist:
- return m.OldModelAllowlist(ctx)
- case group.FieldCodexModelsManifestConfig:
- return m.OldCodexModelsManifestConfig(ctx)
- case group.FieldRpmLimit:
- return m.OldRpmLimit(ctx)
- case group.FieldMaxReasoningEffort:
- return m.OldMaxReasoningEffort(ctx)
- case group.FieldMaxReasoningEffortOverLimit:
- return m.OldMaxReasoningEffortOverLimit(ctx)
- case group.FieldReasoningEffortMappings:
- return m.OldReasoningEffortMappings(ctx)
- case group.FieldProfitControlEnabled:
- return m.OldProfitControlEnabled(ctx)
- case group.FieldProfitMinMargin:
- return m.OldProfitMinMargin(ctx)
- case group.FieldProfitSafetyBuffer:
- return m.OldProfitSafetyBuffer(ctx)
- }
- return nil, fmt.Errorf("unknown Group field %s", name)
- }
- // SetField sets the value of a field with the given name. It returns an error if
- // the field is not defined in the schema, or if the type mismatched the field
- // type.
- func (m *GroupMutation) SetField(name string, value ent.Value) error {
- switch name {
- case group.FieldCreatedAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetCreatedAt(v)
- return nil
- case group.FieldUpdatedAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetUpdatedAt(v)
- return nil
- case group.FieldDeletedAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetDeletedAt(v)
- return nil
- case group.FieldName:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetName(v)
- return nil
- case group.FieldDescription:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetDescription(v)
- return nil
- case group.FieldRateMultiplier:
- v, ok := value.(float64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetRateMultiplier(v)
- return nil
- case group.FieldPeakRateEnabled:
- v, ok := value.(bool)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetPeakRateEnabled(v)
- return nil
- case group.FieldPeakStart:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetPeakStart(v)
- return nil
- case group.FieldPeakEnd:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetPeakEnd(v)
- return nil
- case group.FieldPeakRateMultiplier:
- v, ok := value.(float64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetPeakRateMultiplier(v)
- return nil
- case group.FieldIsExclusive:
- v, ok := value.(bool)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetIsExclusive(v)
- return nil
- case group.FieldSecurityPolicyEnabled:
- v, ok := value.(bool)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetSecurityPolicyEnabled(v)
- return nil
- case group.FieldSecurityPolicyMode:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetSecurityPolicyMode(v)
- return nil
- case group.FieldSecurityPolicyEmailEnabled:
- v, ok := value.(bool)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetSecurityPolicyEmailEnabled(v)
- return nil
- case group.FieldStatus:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetStatus(v)
- return nil
- case group.FieldDuplicateOperationID:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetDuplicateOperationID(v)
- return nil
- case group.FieldPlatform:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetPlatform(v)
- return nil
- case group.FieldSubscriptionType:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetSubscriptionType(v)
- return nil
- case group.FieldDailyLimitUsd:
- v, ok := value.(float64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetDailyLimitUsd(v)
- return nil
- case group.FieldWeeklyLimitUsd:
- v, ok := value.(float64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetWeeklyLimitUsd(v)
- return nil
- case group.FieldMonthlyLimitUsd:
- v, ok := value.(float64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetMonthlyLimitUsd(v)
- return nil
- case group.FieldDefaultValidityDays:
- v, ok := value.(int)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetDefaultValidityDays(v)
- return nil
- case group.FieldAllowImageGeneration:
- v, ok := value.(bool)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetAllowImageGeneration(v)
- return nil
- case group.FieldAllowBatchImageGeneration:
- v, ok := value.(bool)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetAllowBatchImageGeneration(v)
- return nil
- case group.FieldImageRateIndependent:
- v, ok := value.(bool)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetImageRateIndependent(v)
- return nil
- case group.FieldImageRateMultiplier:
- v, ok := value.(float64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetImageRateMultiplier(v)
- return nil
- case group.FieldImagePrice1k:
- v, ok := value.(float64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetImagePrice1k(v)
- return nil
- case group.FieldImagePrice2k:
- v, ok := value.(float64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetImagePrice2k(v)
- return nil
- case group.FieldImagePrice4k:
- v, ok := value.(float64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetImagePrice4k(v)
- return nil
- case group.FieldBatchImageDiscountMultiplier:
- v, ok := value.(float64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetBatchImageDiscountMultiplier(v)
- return nil
- case group.FieldBatchImageHoldMultiplier:
- v, ok := value.(float64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetBatchImageHoldMultiplier(v)
- return nil
- case group.FieldVideoRateIndependent:
- v, ok := value.(bool)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetVideoRateIndependent(v)
- return nil
- case group.FieldVideoRateMultiplier:
- v, ok := value.(float64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetVideoRateMultiplier(v)
- return nil
- case group.FieldVideoPrice480p:
- v, ok := value.(float64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetVideoPrice480p(v)
- return nil
- case group.FieldVideoPrice720p:
- v, ok := value.(float64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetVideoPrice720p(v)
- return nil
- case group.FieldVideoPrice1080p:
- v, ok := value.(float64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetVideoPrice1080p(v)
- return nil
- case group.FieldVideoModelPrices:
- v, ok := value.(map[string]map[string]float64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetVideoModelPrices(v)
- return nil
- case group.FieldWebSearchPricePerCall:
- v, ok := value.(float64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetWebSearchPricePerCall(v)
- return nil
- case group.FieldSearchPricePer1k:
- v, ok := value.(float64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetSearchPricePer1k(v)
- return nil
- case group.FieldAudioRealtimePricePerMin:
- v, ok := value.(float64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetAudioRealtimePricePerMin(v)
- return nil
- case group.FieldAudioTtsPricePerMillionChars:
- v, ok := value.(float64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetAudioTtsPricePerMillionChars(v)
- return nil
- case group.FieldAudioSttPricePerHour:
- v, ok := value.(float64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetAudioSttPricePerHour(v)
- return nil
- case group.FieldLongContextPricingEnabled:
- v, ok := value.(bool)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetLongContextPricingEnabled(v)
- return nil
- case group.FieldModelPricing:
- v, ok := value.(jsontext.Value)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetModelPricing(v)
- return nil
- case group.FieldClaudeCodeOnly:
- v, ok := value.(bool)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetClaudeCodeOnly(v)
- return nil
- case group.FieldFallbackGroupID:
- v, ok := value.(int64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetFallbackGroupID(v)
- return nil
- case group.FieldFallbackGroupIDOnInvalidRequest:
- v, ok := value.(int64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetFallbackGroupIDOnInvalidRequest(v)
- return nil
- case group.FieldModelRouting:
- v, ok := value.(map[string][]int64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetModelRouting(v)
- return nil
- case group.FieldModelRoutingEnabled:
- v, ok := value.(bool)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetModelRoutingEnabled(v)
- return nil
- case group.FieldMcpXMLInject:
- v, ok := value.(bool)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetMcpXMLInject(v)
- return nil
- case group.FieldSupportedModelScopes:
- v, ok := value.([]string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetSupportedModelScopes(v)
- return nil
- case group.FieldSortOrder:
- v, ok := value.(int)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetSortOrder(v)
- return nil
- case group.FieldAllowMessagesDispatch:
- v, ok := value.(bool)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetAllowMessagesDispatch(v)
- return nil
- case group.FieldAllowLive:
- v, ok := value.(bool)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetAllowLive(v)
- return nil
- case group.FieldForceOpenaiFast:
- v, ok := value.(bool)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetForceOpenaiFast(v)
- return nil
- case group.FieldFreeOpenaiFast:
- v, ok := value.(bool)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetFreeOpenaiFast(v)
- return nil
- case group.FieldRequireOauthOnly:
- v, ok := value.(bool)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetRequireOauthOnly(v)
- return nil
- case group.FieldRequirePrivacySet:
- v, ok := value.(bool)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetRequirePrivacySet(v)
- return nil
- case group.FieldDefaultMappedModel:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetDefaultMappedModel(v)
- return nil
- case group.FieldMessagesDispatchModelConfig:
- v, ok := value.(domain.OpenAIMessagesDispatchModelConfig)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetMessagesDispatchModelConfig(v)
- return nil
- case group.FieldModelAllowlist:
- v, ok := value.(domain.GroupModelAllowlist)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetModelAllowlist(v)
- return nil
- case group.FieldCodexModelsManifestConfig:
- v, ok := value.(domain.GroupCodexModelsManifestConfig)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetCodexModelsManifestConfig(v)
- return nil
- case group.FieldRpmLimit:
- v, ok := value.(int)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetRpmLimit(v)
- return nil
- case group.FieldMaxReasoningEffort:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetMaxReasoningEffort(v)
- return nil
- case group.FieldMaxReasoningEffortOverLimit:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetMaxReasoningEffortOverLimit(v)
- return nil
- case group.FieldReasoningEffortMappings:
- v, ok := value.([]domain.ReasoningEffortMapping)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetReasoningEffortMappings(v)
- return nil
- case group.FieldProfitControlEnabled:
- v, ok := value.(bool)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetProfitControlEnabled(v)
- return nil
- case group.FieldProfitMinMargin:
- v, ok := value.(float64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetProfitMinMargin(v)
- return nil
- case group.FieldProfitSafetyBuffer:
- v, ok := value.(float64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetProfitSafetyBuffer(v)
- return nil
- }
- return fmt.Errorf("unknown Group field %s", name)
- }
- // AddedFields returns all numeric fields that were incremented/decremented during
- // this mutation.
- func (m *GroupMutation) AddedFields() []string {
- var fields []string
- if m.addrate_multiplier != nil {
- fields = append(fields, group.FieldRateMultiplier)
- }
- if m.addpeak_rate_multiplier != nil {
- fields = append(fields, group.FieldPeakRateMultiplier)
- }
- if m.adddaily_limit_usd != nil {
- fields = append(fields, group.FieldDailyLimitUsd)
- }
- if m.addweekly_limit_usd != nil {
- fields = append(fields, group.FieldWeeklyLimitUsd)
- }
- if m.addmonthly_limit_usd != nil {
- fields = append(fields, group.FieldMonthlyLimitUsd)
- }
- if m.adddefault_validity_days != nil {
- fields = append(fields, group.FieldDefaultValidityDays)
- }
- if m.addimage_rate_multiplier != nil {
- fields = append(fields, group.FieldImageRateMultiplier)
- }
- if m.addimage_price_1k != nil {
- fields = append(fields, group.FieldImagePrice1k)
- }
- if m.addimage_price_2k != nil {
- fields = append(fields, group.FieldImagePrice2k)
- }
- if m.addimage_price_4k != nil {
- fields = append(fields, group.FieldImagePrice4k)
- }
- if m.addbatch_image_discount_multiplier != nil {
- fields = append(fields, group.FieldBatchImageDiscountMultiplier)
- }
- if m.addbatch_image_hold_multiplier != nil {
- fields = append(fields, group.FieldBatchImageHoldMultiplier)
- }
- if m.addvideo_rate_multiplier != nil {
- fields = append(fields, group.FieldVideoRateMultiplier)
- }
- if m.addvideo_price_480p != nil {
- fields = append(fields, group.FieldVideoPrice480p)
- }
- if m.addvideo_price_720p != nil {
- fields = append(fields, group.FieldVideoPrice720p)
- }
- if m.addvideo_price_1080p != nil {
- fields = append(fields, group.FieldVideoPrice1080p)
- }
- if m.addweb_search_price_per_call != nil {
- fields = append(fields, group.FieldWebSearchPricePerCall)
- }
- if m.addsearch_price_per_1k != nil {
- fields = append(fields, group.FieldSearchPricePer1k)
- }
- if m.addaudio_realtime_price_per_min != nil {
- fields = append(fields, group.FieldAudioRealtimePricePerMin)
- }
- if m.addaudio_tts_price_per_million_chars != nil {
- fields = append(fields, group.FieldAudioTtsPricePerMillionChars)
- }
- if m.addaudio_stt_price_per_hour != nil {
- fields = append(fields, group.FieldAudioSttPricePerHour)
- }
- if m.addfallback_group_id != nil {
- fields = append(fields, group.FieldFallbackGroupID)
- }
- if m.addfallback_group_id_on_invalid_request != nil {
- fields = append(fields, group.FieldFallbackGroupIDOnInvalidRequest)
- }
- if m.addsort_order != nil {
- fields = append(fields, group.FieldSortOrder)
- }
- if m.addrpm_limit != nil {
- fields = append(fields, group.FieldRpmLimit)
- }
- if m.addprofit_min_margin != nil {
- fields = append(fields, group.FieldProfitMinMargin)
- }
- if m.addprofit_safety_buffer != nil {
- fields = append(fields, group.FieldProfitSafetyBuffer)
- }
- return fields
- }
- // AddedField returns the numeric value that was incremented/decremented on a field
- // with the given name. The second boolean return value indicates that this field
- // was not set, or was not defined in the schema.
- func (m *GroupMutation) AddedField(name string) (ent.Value, bool) {
- switch name {
- case group.FieldRateMultiplier:
- return m.AddedRateMultiplier()
- case group.FieldPeakRateMultiplier:
- return m.AddedPeakRateMultiplier()
- case group.FieldDailyLimitUsd:
- return m.AddedDailyLimitUsd()
- case group.FieldWeeklyLimitUsd:
- return m.AddedWeeklyLimitUsd()
- case group.FieldMonthlyLimitUsd:
- return m.AddedMonthlyLimitUsd()
- case group.FieldDefaultValidityDays:
- return m.AddedDefaultValidityDays()
- case group.FieldImageRateMultiplier:
- return m.AddedImageRateMultiplier()
- case group.FieldImagePrice1k:
- return m.AddedImagePrice1k()
- case group.FieldImagePrice2k:
- return m.AddedImagePrice2k()
- case group.FieldImagePrice4k:
- return m.AddedImagePrice4k()
- case group.FieldBatchImageDiscountMultiplier:
- return m.AddedBatchImageDiscountMultiplier()
- case group.FieldBatchImageHoldMultiplier:
- return m.AddedBatchImageHoldMultiplier()
- case group.FieldVideoRateMultiplier:
- return m.AddedVideoRateMultiplier()
- case group.FieldVideoPrice480p:
- return m.AddedVideoPrice480p()
- case group.FieldVideoPrice720p:
- return m.AddedVideoPrice720p()
- case group.FieldVideoPrice1080p:
- return m.AddedVideoPrice1080p()
- case group.FieldWebSearchPricePerCall:
- return m.AddedWebSearchPricePerCall()
- case group.FieldSearchPricePer1k:
- return m.AddedSearchPricePer1k()
- case group.FieldAudioRealtimePricePerMin:
- return m.AddedAudioRealtimePricePerMin()
- case group.FieldAudioTtsPricePerMillionChars:
- return m.AddedAudioTtsPricePerMillionChars()
- case group.FieldAudioSttPricePerHour:
- return m.AddedAudioSttPricePerHour()
- case group.FieldFallbackGroupID:
- return m.AddedFallbackGroupID()
- case group.FieldFallbackGroupIDOnInvalidRequest:
- return m.AddedFallbackGroupIDOnInvalidRequest()
- case group.FieldSortOrder:
- return m.AddedSortOrder()
- case group.FieldRpmLimit:
- return m.AddedRpmLimit()
- case group.FieldProfitMinMargin:
- return m.AddedProfitMinMargin()
- case group.FieldProfitSafetyBuffer:
- return m.AddedProfitSafetyBuffer()
- }
- return nil, false
- }
- // AddField adds the value to the field with the given name. It returns an error if
- // the field is not defined in the schema, or if the type mismatched the field
- // type.
- func (m *GroupMutation) AddField(name string, value ent.Value) error {
- switch name {
- case group.FieldRateMultiplier:
- v, ok := value.(float64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.AddRateMultiplier(v)
- return nil
- case group.FieldPeakRateMultiplier:
- v, ok := value.(float64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.AddPeakRateMultiplier(v)
- return nil
- case group.FieldDailyLimitUsd:
- v, ok := value.(float64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.AddDailyLimitUsd(v)
- return nil
- case group.FieldWeeklyLimitUsd:
- v, ok := value.(float64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.AddWeeklyLimitUsd(v)
- return nil
- case group.FieldMonthlyLimitUsd:
- v, ok := value.(float64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.AddMonthlyLimitUsd(v)
- return nil
- case group.FieldDefaultValidityDays:
- v, ok := value.(int)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.AddDefaultValidityDays(v)
- return nil
- case group.FieldImageRateMultiplier:
- v, ok := value.(float64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.AddImageRateMultiplier(v)
- return nil
- case group.FieldImagePrice1k:
- v, ok := value.(float64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.AddImagePrice1k(v)
- return nil
- case group.FieldImagePrice2k:
- v, ok := value.(float64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.AddImagePrice2k(v)
- return nil
- case group.FieldImagePrice4k:
- v, ok := value.(float64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.AddImagePrice4k(v)
- return nil
- case group.FieldBatchImageDiscountMultiplier:
- v, ok := value.(float64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.AddBatchImageDiscountMultiplier(v)
- return nil
- case group.FieldBatchImageHoldMultiplier:
- v, ok := value.(float64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.AddBatchImageHoldMultiplier(v)
- return nil
- case group.FieldVideoRateMultiplier:
- v, ok := value.(float64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.AddVideoRateMultiplier(v)
- return nil
- case group.FieldVideoPrice480p:
- v, ok := value.(float64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.AddVideoPrice480p(v)
- return nil
- case group.FieldVideoPrice720p:
- v, ok := value.(float64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.AddVideoPrice720p(v)
- return nil
- case group.FieldVideoPrice1080p:
- v, ok := value.(float64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.AddVideoPrice1080p(v)
- return nil
- case group.FieldWebSearchPricePerCall:
- v, ok := value.(float64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.AddWebSearchPricePerCall(v)
- return nil
- case group.FieldSearchPricePer1k:
- v, ok := value.(float64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.AddSearchPricePer1k(v)
- return nil
- case group.FieldAudioRealtimePricePerMin:
- v, ok := value.(float64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.AddAudioRealtimePricePerMin(v)
- return nil
- case group.FieldAudioTtsPricePerMillionChars:
- v, ok := value.(float64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.AddAudioTtsPricePerMillionChars(v)
- return nil
- case group.FieldAudioSttPricePerHour:
- v, ok := value.(float64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.AddAudioSttPricePerHour(v)
- return nil
- case group.FieldFallbackGroupID:
- v, ok := value.(int64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.AddFallbackGroupID(v)
- return nil
- case group.FieldFallbackGroupIDOnInvalidRequest:
- v, ok := value.(int64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.AddFallbackGroupIDOnInvalidRequest(v)
- return nil
- case group.FieldSortOrder:
- v, ok := value.(int)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.AddSortOrder(v)
- return nil
- case group.FieldRpmLimit:
- v, ok := value.(int)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.AddRpmLimit(v)
- return nil
- case group.FieldProfitMinMargin:
- v, ok := value.(float64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.AddProfitMinMargin(v)
- return nil
- case group.FieldProfitSafetyBuffer:
- v, ok := value.(float64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.AddProfitSafetyBuffer(v)
- return nil
- }
- return fmt.Errorf("unknown Group numeric field %s", name)
- }
- // ClearedFields returns all nullable fields that were cleared during this
- // mutation.
- func (m *GroupMutation) ClearedFields() []string {
- var fields []string
- if m.FieldCleared(group.FieldDeletedAt) {
- fields = append(fields, group.FieldDeletedAt)
- }
- if m.FieldCleared(group.FieldDescription) {
- fields = append(fields, group.FieldDescription)
- }
- if m.FieldCleared(group.FieldDuplicateOperationID) {
- fields = append(fields, group.FieldDuplicateOperationID)
- }
- if m.FieldCleared(group.FieldDailyLimitUsd) {
- fields = append(fields, group.FieldDailyLimitUsd)
- }
- if m.FieldCleared(group.FieldWeeklyLimitUsd) {
- fields = append(fields, group.FieldWeeklyLimitUsd)
- }
- if m.FieldCleared(group.FieldMonthlyLimitUsd) {
- fields = append(fields, group.FieldMonthlyLimitUsd)
- }
- if m.FieldCleared(group.FieldImagePrice1k) {
- fields = append(fields, group.FieldImagePrice1k)
- }
- if m.FieldCleared(group.FieldImagePrice2k) {
- fields = append(fields, group.FieldImagePrice2k)
- }
- if m.FieldCleared(group.FieldImagePrice4k) {
- fields = append(fields, group.FieldImagePrice4k)
- }
- if m.FieldCleared(group.FieldVideoPrice480p) {
- fields = append(fields, group.FieldVideoPrice480p)
- }
- if m.FieldCleared(group.FieldVideoPrice720p) {
- fields = append(fields, group.FieldVideoPrice720p)
- }
- if m.FieldCleared(group.FieldVideoPrice1080p) {
- fields = append(fields, group.FieldVideoPrice1080p)
- }
- if m.FieldCleared(group.FieldVideoModelPrices) {
- fields = append(fields, group.FieldVideoModelPrices)
- }
- if m.FieldCleared(group.FieldWebSearchPricePerCall) {
- fields = append(fields, group.FieldWebSearchPricePerCall)
- }
- if m.FieldCleared(group.FieldSearchPricePer1k) {
- fields = append(fields, group.FieldSearchPricePer1k)
- }
- if m.FieldCleared(group.FieldAudioRealtimePricePerMin) {
- fields = append(fields, group.FieldAudioRealtimePricePerMin)
- }
- if m.FieldCleared(group.FieldAudioTtsPricePerMillionChars) {
- fields = append(fields, group.FieldAudioTtsPricePerMillionChars)
- }
- if m.FieldCleared(group.FieldAudioSttPricePerHour) {
- fields = append(fields, group.FieldAudioSttPricePerHour)
- }
- if m.FieldCleared(group.FieldModelPricing) {
- fields = append(fields, group.FieldModelPricing)
- }
- if m.FieldCleared(group.FieldFallbackGroupID) {
- fields = append(fields, group.FieldFallbackGroupID)
- }
- if m.FieldCleared(group.FieldFallbackGroupIDOnInvalidRequest) {
- fields = append(fields, group.FieldFallbackGroupIDOnInvalidRequest)
- }
- if m.FieldCleared(group.FieldModelRouting) {
- fields = append(fields, group.FieldModelRouting)
- }
- return fields
- }
- // FieldCleared returns a boolean indicating if a field with the given name was
- // cleared in this mutation.
- func (m *GroupMutation) FieldCleared(name string) bool {
- _, ok := m.clearedFields[name]
- return ok
- }
- // ClearField clears the value of the field with the given name. It returns an
- // error if the field is not defined in the schema.
- func (m *GroupMutation) ClearField(name string) error {
- switch name {
- case group.FieldDeletedAt:
- m.ClearDeletedAt()
- return nil
- case group.FieldDescription:
- m.ClearDescription()
- return nil
- case group.FieldDuplicateOperationID:
- m.ClearDuplicateOperationID()
- return nil
- case group.FieldDailyLimitUsd:
- m.ClearDailyLimitUsd()
- return nil
- case group.FieldWeeklyLimitUsd:
- m.ClearWeeklyLimitUsd()
- return nil
- case group.FieldMonthlyLimitUsd:
- m.ClearMonthlyLimitUsd()
- return nil
- case group.FieldImagePrice1k:
- m.ClearImagePrice1k()
- return nil
- case group.FieldImagePrice2k:
- m.ClearImagePrice2k()
- return nil
- case group.FieldImagePrice4k:
- m.ClearImagePrice4k()
- return nil
- case group.FieldVideoPrice480p:
- m.ClearVideoPrice480p()
- return nil
- case group.FieldVideoPrice720p:
- m.ClearVideoPrice720p()
- return nil
- case group.FieldVideoPrice1080p:
- m.ClearVideoPrice1080p()
- return nil
- case group.FieldVideoModelPrices:
- m.ClearVideoModelPrices()
- return nil
- case group.FieldWebSearchPricePerCall:
- m.ClearWebSearchPricePerCall()
- return nil
- case group.FieldSearchPricePer1k:
- m.ClearSearchPricePer1k()
- return nil
- case group.FieldAudioRealtimePricePerMin:
- m.ClearAudioRealtimePricePerMin()
- return nil
- case group.FieldAudioTtsPricePerMillionChars:
- m.ClearAudioTtsPricePerMillionChars()
- return nil
- case group.FieldAudioSttPricePerHour:
- m.ClearAudioSttPricePerHour()
- return nil
- case group.FieldModelPricing:
- m.ClearModelPricing()
- return nil
- case group.FieldFallbackGroupID:
- m.ClearFallbackGroupID()
- return nil
- case group.FieldFallbackGroupIDOnInvalidRequest:
- m.ClearFallbackGroupIDOnInvalidRequest()
- return nil
- case group.FieldModelRouting:
- m.ClearModelRouting()
- return nil
- }
- return fmt.Errorf("unknown Group nullable field %s", name)
- }
- // ResetField resets all changes in the mutation for the field with the given name.
- // It returns an error if the field is not defined in the schema.
- func (m *GroupMutation) ResetField(name string) error {
- switch name {
- case group.FieldCreatedAt:
- m.ResetCreatedAt()
- return nil
- case group.FieldUpdatedAt:
- m.ResetUpdatedAt()
- return nil
- case group.FieldDeletedAt:
- m.ResetDeletedAt()
- return nil
- case group.FieldName:
- m.ResetName()
- return nil
- case group.FieldDescription:
- m.ResetDescription()
- return nil
- case group.FieldRateMultiplier:
- m.ResetRateMultiplier()
- return nil
- case group.FieldPeakRateEnabled:
- m.ResetPeakRateEnabled()
- return nil
- case group.FieldPeakStart:
- m.ResetPeakStart()
- return nil
- case group.FieldPeakEnd:
- m.ResetPeakEnd()
- return nil
- case group.FieldPeakRateMultiplier:
- m.ResetPeakRateMultiplier()
- return nil
- case group.FieldIsExclusive:
- m.ResetIsExclusive()
- return nil
- case group.FieldSecurityPolicyEnabled:
- m.ResetSecurityPolicyEnabled()
- return nil
- case group.FieldSecurityPolicyMode:
- m.ResetSecurityPolicyMode()
- return nil
- case group.FieldSecurityPolicyEmailEnabled:
- m.ResetSecurityPolicyEmailEnabled()
- return nil
- case group.FieldStatus:
- m.ResetStatus()
- return nil
- case group.FieldDuplicateOperationID:
- m.ResetDuplicateOperationID()
- return nil
- case group.FieldPlatform:
- m.ResetPlatform()
- return nil
- case group.FieldSubscriptionType:
- m.ResetSubscriptionType()
- return nil
- case group.FieldDailyLimitUsd:
- m.ResetDailyLimitUsd()
- return nil
- case group.FieldWeeklyLimitUsd:
- m.ResetWeeklyLimitUsd()
- return nil
- case group.FieldMonthlyLimitUsd:
- m.ResetMonthlyLimitUsd()
- return nil
- case group.FieldDefaultValidityDays:
- m.ResetDefaultValidityDays()
- return nil
- case group.FieldAllowImageGeneration:
- m.ResetAllowImageGeneration()
- return nil
- case group.FieldAllowBatchImageGeneration:
- m.ResetAllowBatchImageGeneration()
- return nil
- case group.FieldImageRateIndependent:
- m.ResetImageRateIndependent()
- return nil
- case group.FieldImageRateMultiplier:
- m.ResetImageRateMultiplier()
- return nil
- case group.FieldImagePrice1k:
- m.ResetImagePrice1k()
- return nil
- case group.FieldImagePrice2k:
- m.ResetImagePrice2k()
- return nil
- case group.FieldImagePrice4k:
- m.ResetImagePrice4k()
- return nil
- case group.FieldBatchImageDiscountMultiplier:
- m.ResetBatchImageDiscountMultiplier()
- return nil
- case group.FieldBatchImageHoldMultiplier:
- m.ResetBatchImageHoldMultiplier()
- return nil
- case group.FieldVideoRateIndependent:
- m.ResetVideoRateIndependent()
- return nil
- case group.FieldVideoRateMultiplier:
- m.ResetVideoRateMultiplier()
- return nil
- case group.FieldVideoPrice480p:
- m.ResetVideoPrice480p()
- return nil
- case group.FieldVideoPrice720p:
- m.ResetVideoPrice720p()
- return nil
- case group.FieldVideoPrice1080p:
- m.ResetVideoPrice1080p()
- return nil
- case group.FieldVideoModelPrices:
- m.ResetVideoModelPrices()
- return nil
- case group.FieldWebSearchPricePerCall:
- m.ResetWebSearchPricePerCall()
- return nil
- case group.FieldSearchPricePer1k:
- m.ResetSearchPricePer1k()
- return nil
- case group.FieldAudioRealtimePricePerMin:
- m.ResetAudioRealtimePricePerMin()
- return nil
- case group.FieldAudioTtsPricePerMillionChars:
- m.ResetAudioTtsPricePerMillionChars()
- return nil
- case group.FieldAudioSttPricePerHour:
- m.ResetAudioSttPricePerHour()
- return nil
- case group.FieldLongContextPricingEnabled:
- m.ResetLongContextPricingEnabled()
- return nil
- case group.FieldModelPricing:
- m.ResetModelPricing()
- return nil
- case group.FieldClaudeCodeOnly:
- m.ResetClaudeCodeOnly()
- return nil
- case group.FieldFallbackGroupID:
- m.ResetFallbackGroupID()
- return nil
- case group.FieldFallbackGroupIDOnInvalidRequest:
- m.ResetFallbackGroupIDOnInvalidRequest()
- return nil
- case group.FieldModelRouting:
- m.ResetModelRouting()
- return nil
- case group.FieldModelRoutingEnabled:
- m.ResetModelRoutingEnabled()
- return nil
- case group.FieldMcpXMLInject:
- m.ResetMcpXMLInject()
- return nil
- case group.FieldSupportedModelScopes:
- m.ResetSupportedModelScopes()
- return nil
- case group.FieldSortOrder:
- m.ResetSortOrder()
- return nil
- case group.FieldAllowMessagesDispatch:
- m.ResetAllowMessagesDispatch()
- return nil
- case group.FieldAllowLive:
- m.ResetAllowLive()
- return nil
- case group.FieldForceOpenaiFast:
- m.ResetForceOpenaiFast()
- return nil
- case group.FieldFreeOpenaiFast:
- m.ResetFreeOpenaiFast()
- return nil
- case group.FieldRequireOauthOnly:
- m.ResetRequireOauthOnly()
- return nil
- case group.FieldRequirePrivacySet:
- m.ResetRequirePrivacySet()
- return nil
- case group.FieldDefaultMappedModel:
- m.ResetDefaultMappedModel()
- return nil
- case group.FieldMessagesDispatchModelConfig:
- m.ResetMessagesDispatchModelConfig()
- return nil
- case group.FieldModelAllowlist:
- m.ResetModelAllowlist()
- return nil
- case group.FieldCodexModelsManifestConfig:
- m.ResetCodexModelsManifestConfig()
- return nil
- case group.FieldRpmLimit:
- m.ResetRpmLimit()
- return nil
- case group.FieldMaxReasoningEffort:
- m.ResetMaxReasoningEffort()
- return nil
- case group.FieldMaxReasoningEffortOverLimit:
- m.ResetMaxReasoningEffortOverLimit()
- return nil
- case group.FieldReasoningEffortMappings:
- m.ResetReasoningEffortMappings()
- return nil
- case group.FieldProfitControlEnabled:
- m.ResetProfitControlEnabled()
- return nil
- case group.FieldProfitMinMargin:
- m.ResetProfitMinMargin()
- return nil
- case group.FieldProfitSafetyBuffer:
- m.ResetProfitSafetyBuffer()
- return nil
- }
- return fmt.Errorf("unknown Group field %s", name)
- }
- // AddedEdges returns all edge names that were set/added in this mutation.
- func (m *GroupMutation) AddedEdges() []string {
- edges := make([]string, 0, 6)
- if m.api_keys != nil {
- edges = append(edges, group.EdgeAPIKeys)
- }
- if m.redeem_codes != nil {
- edges = append(edges, group.EdgeRedeemCodes)
- }
- if m.subscriptions != nil {
- edges = append(edges, group.EdgeSubscriptions)
- }
- if m.usage_logs != nil {
- edges = append(edges, group.EdgeUsageLogs)
- }
- if m.accounts != nil {
- edges = append(edges, group.EdgeAccounts)
- }
- if m.allowed_users != nil {
- edges = append(edges, group.EdgeAllowedUsers)
- }
- return edges
- }
- // AddedIDs returns all IDs (to other nodes) that were added for the given edge
- // name in this mutation.
- func (m *GroupMutation) AddedIDs(name string) []ent.Value {
- switch name {
- case group.EdgeAPIKeys:
- ids := make([]ent.Value, 0, len(m.api_keys))
- for id := range m.api_keys {
- ids = append(ids, id)
- }
- return ids
- case group.EdgeRedeemCodes:
- ids := make([]ent.Value, 0, len(m.redeem_codes))
- for id := range m.redeem_codes {
- ids = append(ids, id)
- }
- return ids
- case group.EdgeSubscriptions:
- ids := make([]ent.Value, 0, len(m.subscriptions))
- for id := range m.subscriptions {
- ids = append(ids, id)
- }
- return ids
- case group.EdgeUsageLogs:
- ids := make([]ent.Value, 0, len(m.usage_logs))
- for id := range m.usage_logs {
- ids = append(ids, id)
- }
- return ids
- case group.EdgeAccounts:
- ids := make([]ent.Value, 0, len(m.accounts))
- for id := range m.accounts {
- ids = append(ids, id)
- }
- return ids
- case group.EdgeAllowedUsers:
- ids := make([]ent.Value, 0, len(m.allowed_users))
- for id := range m.allowed_users {
- ids = append(ids, id)
- }
- return ids
- }
- return nil
- }
- // RemovedEdges returns all edge names that were removed in this mutation.
- func (m *GroupMutation) RemovedEdges() []string {
- edges := make([]string, 0, 6)
- if m.removedapi_keys != nil {
- edges = append(edges, group.EdgeAPIKeys)
- }
- if m.removedredeem_codes != nil {
- edges = append(edges, group.EdgeRedeemCodes)
- }
- if m.removedsubscriptions != nil {
- edges = append(edges, group.EdgeSubscriptions)
- }
- if m.removedusage_logs != nil {
- edges = append(edges, group.EdgeUsageLogs)
- }
- if m.removedaccounts != nil {
- edges = append(edges, group.EdgeAccounts)
- }
- if m.removedallowed_users != nil {
- edges = append(edges, group.EdgeAllowedUsers)
- }
- return edges
- }
- // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
- // the given name in this mutation.
- func (m *GroupMutation) RemovedIDs(name string) []ent.Value {
- switch name {
- case group.EdgeAPIKeys:
- ids := make([]ent.Value, 0, len(m.removedapi_keys))
- for id := range m.removedapi_keys {
- ids = append(ids, id)
- }
- return ids
- case group.EdgeRedeemCodes:
- ids := make([]ent.Value, 0, len(m.removedredeem_codes))
- for id := range m.removedredeem_codes {
- ids = append(ids, id)
- }
- return ids
- case group.EdgeSubscriptions:
- ids := make([]ent.Value, 0, len(m.removedsubscriptions))
- for id := range m.removedsubscriptions {
- ids = append(ids, id)
- }
- return ids
- case group.EdgeUsageLogs:
- ids := make([]ent.Value, 0, len(m.removedusage_logs))
- for id := range m.removedusage_logs {
- ids = append(ids, id)
- }
- return ids
- case group.EdgeAccounts:
- ids := make([]ent.Value, 0, len(m.removedaccounts))
- for id := range m.removedaccounts {
- ids = append(ids, id)
- }
- return ids
- case group.EdgeAllowedUsers:
- ids := make([]ent.Value, 0, len(m.removedallowed_users))
- for id := range m.removedallowed_users {
- ids = append(ids, id)
- }
- return ids
- }
- return nil
- }
- // ClearedEdges returns all edge names that were cleared in this mutation.
- func (m *GroupMutation) ClearedEdges() []string {
- edges := make([]string, 0, 6)
- if m.clearedapi_keys {
- edges = append(edges, group.EdgeAPIKeys)
- }
- if m.clearedredeem_codes {
- edges = append(edges, group.EdgeRedeemCodes)
- }
- if m.clearedsubscriptions {
- edges = append(edges, group.EdgeSubscriptions)
- }
- if m.clearedusage_logs {
- edges = append(edges, group.EdgeUsageLogs)
- }
- if m.clearedaccounts {
- edges = append(edges, group.EdgeAccounts)
- }
- if m.clearedallowed_users {
- edges = append(edges, group.EdgeAllowedUsers)
- }
- return edges
- }
- // EdgeCleared returns a boolean which indicates if the edge with the given name
- // was cleared in this mutation.
- func (m *GroupMutation) EdgeCleared(name string) bool {
- switch name {
- case group.EdgeAPIKeys:
- return m.clearedapi_keys
- case group.EdgeRedeemCodes:
- return m.clearedredeem_codes
- case group.EdgeSubscriptions:
- return m.clearedsubscriptions
- case group.EdgeUsageLogs:
- return m.clearedusage_logs
- case group.EdgeAccounts:
- return m.clearedaccounts
- case group.EdgeAllowedUsers:
- return m.clearedallowed_users
- }
- return false
- }
- // ClearEdge clears the value of the edge with the given name. It returns an error
- // if that edge is not defined in the schema.
- func (m *GroupMutation) ClearEdge(name string) error {
- switch name {
- }
- return fmt.Errorf("unknown Group unique edge %s", name)
- }
- // ResetEdge resets all changes to the edge with the given name in this mutation.
- // It returns an error if the edge is not defined in the schema.
- func (m *GroupMutation) ResetEdge(name string) error {
- switch name {
- case group.EdgeAPIKeys:
- m.ResetAPIKeys()
- return nil
- case group.EdgeRedeemCodes:
- m.ResetRedeemCodes()
- return nil
- case group.EdgeSubscriptions:
- m.ResetSubscriptions()
- return nil
- case group.EdgeUsageLogs:
- m.ResetUsageLogs()
- return nil
- case group.EdgeAccounts:
- m.ResetAccounts()
- return nil
- case group.EdgeAllowedUsers:
- m.ResetAllowedUsers()
- return nil
- }
- return fmt.Errorf("unknown Group edge %s", name)
- }
- // IdempotencyRecordMutation represents an operation that mutates the IdempotencyRecord nodes in the graph.
- type IdempotencyRecordMutation struct {
- config
- op Op
- typ string
- id *int64
- created_at *time.Time
- updated_at *time.Time
- scope *string
- idempotency_key_hash *string
- request_fingerprint *string
- status *string
- response_status *int
- addresponse_status *int
- response_body *string
- error_reason *string
- locked_until *time.Time
- expires_at *time.Time
- clearedFields map[string]struct{}
- done bool
- oldValue func(context.Context) (*IdempotencyRecord, error)
- predicates []predicate.IdempotencyRecord
- }
- var _ ent.Mutation = (*IdempotencyRecordMutation)(nil)
- // idempotencyrecordOption allows management of the mutation configuration using functional options.
- type idempotencyrecordOption func(*IdempotencyRecordMutation)
- // newIdempotencyRecordMutation creates new mutation for the IdempotencyRecord entity.
- func newIdempotencyRecordMutation(c config, op Op, opts ...idempotencyrecordOption) *IdempotencyRecordMutation {
- m := &IdempotencyRecordMutation{
- config: c,
- op: op,
- typ: TypeIdempotencyRecord,
- clearedFields: make(map[string]struct{}),
- }
- for _, opt := range opts {
- opt(m)
- }
- return m
- }
- // withIdempotencyRecordID sets the ID field of the mutation.
- func withIdempotencyRecordID(id int64) idempotencyrecordOption {
- return func(m *IdempotencyRecordMutation) {
- var (
- err error
- once sync.Once
- value *IdempotencyRecord
- )
- m.oldValue = func(ctx context.Context) (*IdempotencyRecord, error) {
- once.Do(func() {
- if m.done {
- err = errors.New("querying old values post mutation is not allowed")
- } else {
- value, err = m.Client().IdempotencyRecord.Get(ctx, id)
- }
- })
- return value, err
- }
- m.id = &id
- }
- }
- // withIdempotencyRecord sets the old IdempotencyRecord of the mutation.
- func withIdempotencyRecord(node *IdempotencyRecord) idempotencyrecordOption {
- return func(m *IdempotencyRecordMutation) {
- m.oldValue = func(context.Context) (*IdempotencyRecord, error) {
- return node, nil
- }
- m.id = &node.ID
- }
- }
- // Client returns a new `ent.Client` from the mutation. If the mutation was
- // executed in a transaction (ent.Tx), a transactional client is returned.
- func (m IdempotencyRecordMutation) Client() *Client {
- client := &Client{config: m.config}
- client.init()
- return client
- }
- // Tx returns an `ent.Tx` for mutations that were executed in transactions;
- // it returns an error otherwise.
- func (m IdempotencyRecordMutation) Tx() (*Tx, error) {
- if _, ok := m.driver.(*txDriver); !ok {
- return nil, errors.New("ent: mutation is not running in a transaction")
- }
- tx := &Tx{config: m.config}
- tx.init()
- return tx, nil
- }
- // ID returns the ID value in the mutation. Note that the ID is only available
- // if it was provided to the builder or after it was returned from the database.
- func (m *IdempotencyRecordMutation) ID() (id int64, exists bool) {
- if m.id == nil {
- return
- }
- return *m.id, true
- }
- // IDs queries the database and returns the entity ids that match the mutation's predicate.
- // That means, if the mutation is applied within a transaction with an isolation level such
- // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
- // or updated by the mutation.
- func (m *IdempotencyRecordMutation) IDs(ctx context.Context) ([]int64, error) {
- switch {
- case m.op.Is(OpUpdateOne | OpDeleteOne):
- id, exists := m.ID()
- if exists {
- return []int64{id}, nil
- }
- fallthrough
- case m.op.Is(OpUpdate | OpDelete):
- return m.Client().IdempotencyRecord.Query().Where(m.predicates...).IDs(ctx)
- default:
- return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
- }
- }
- // SetCreatedAt sets the "created_at" field.
- func (m *IdempotencyRecordMutation) SetCreatedAt(t time.Time) {
- m.created_at = &t
- }
- // CreatedAt returns the value of the "created_at" field in the mutation.
- func (m *IdempotencyRecordMutation) CreatedAt() (r time.Time, exists bool) {
- v := m.created_at
- if v == nil {
- return
- }
- return *v, true
- }
- // OldCreatedAt returns the old "created_at" field's value of the IdempotencyRecord entity.
- // If the IdempotencyRecord object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *IdempotencyRecordMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldCreatedAt requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
- }
- return oldValue.CreatedAt, nil
- }
- // ResetCreatedAt resets all changes to the "created_at" field.
- func (m *IdempotencyRecordMutation) ResetCreatedAt() {
- m.created_at = nil
- }
- // SetUpdatedAt sets the "updated_at" field.
- func (m *IdempotencyRecordMutation) SetUpdatedAt(t time.Time) {
- m.updated_at = &t
- }
- // UpdatedAt returns the value of the "updated_at" field in the mutation.
- func (m *IdempotencyRecordMutation) UpdatedAt() (r time.Time, exists bool) {
- v := m.updated_at
- if v == nil {
- return
- }
- return *v, true
- }
- // OldUpdatedAt returns the old "updated_at" field's value of the IdempotencyRecord entity.
- // If the IdempotencyRecord object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *IdempotencyRecordMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
- }
- return oldValue.UpdatedAt, nil
- }
- // ResetUpdatedAt resets all changes to the "updated_at" field.
- func (m *IdempotencyRecordMutation) ResetUpdatedAt() {
- m.updated_at = nil
- }
- // SetScope sets the "scope" field.
- func (m *IdempotencyRecordMutation) SetScope(s string) {
- m.scope = &s
- }
- // Scope returns the value of the "scope" field in the mutation.
- func (m *IdempotencyRecordMutation) Scope() (r string, exists bool) {
- v := m.scope
- if v == nil {
- return
- }
- return *v, true
- }
- // OldScope returns the old "scope" field's value of the IdempotencyRecord entity.
- // If the IdempotencyRecord object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *IdempotencyRecordMutation) OldScope(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldScope is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldScope requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldScope: %w", err)
- }
- return oldValue.Scope, nil
- }
- // ResetScope resets all changes to the "scope" field.
- func (m *IdempotencyRecordMutation) ResetScope() {
- m.scope = nil
- }
- // SetIdempotencyKeyHash sets the "idempotency_key_hash" field.
- func (m *IdempotencyRecordMutation) SetIdempotencyKeyHash(s string) {
- m.idempotency_key_hash = &s
- }
- // IdempotencyKeyHash returns the value of the "idempotency_key_hash" field in the mutation.
- func (m *IdempotencyRecordMutation) IdempotencyKeyHash() (r string, exists bool) {
- v := m.idempotency_key_hash
- if v == nil {
- return
- }
- return *v, true
- }
- // OldIdempotencyKeyHash returns the old "idempotency_key_hash" field's value of the IdempotencyRecord entity.
- // If the IdempotencyRecord object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *IdempotencyRecordMutation) OldIdempotencyKeyHash(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldIdempotencyKeyHash is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldIdempotencyKeyHash requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldIdempotencyKeyHash: %w", err)
- }
- return oldValue.IdempotencyKeyHash, nil
- }
- // ResetIdempotencyKeyHash resets all changes to the "idempotency_key_hash" field.
- func (m *IdempotencyRecordMutation) ResetIdempotencyKeyHash() {
- m.idempotency_key_hash = nil
- }
- // SetRequestFingerprint sets the "request_fingerprint" field.
- func (m *IdempotencyRecordMutation) SetRequestFingerprint(s string) {
- m.request_fingerprint = &s
- }
- // RequestFingerprint returns the value of the "request_fingerprint" field in the mutation.
- func (m *IdempotencyRecordMutation) RequestFingerprint() (r string, exists bool) {
- v := m.request_fingerprint
- if v == nil {
- return
- }
- return *v, true
- }
- // OldRequestFingerprint returns the old "request_fingerprint" field's value of the IdempotencyRecord entity.
- // If the IdempotencyRecord object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *IdempotencyRecordMutation) OldRequestFingerprint(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldRequestFingerprint is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldRequestFingerprint requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldRequestFingerprint: %w", err)
- }
- return oldValue.RequestFingerprint, nil
- }
- // ResetRequestFingerprint resets all changes to the "request_fingerprint" field.
- func (m *IdempotencyRecordMutation) ResetRequestFingerprint() {
- m.request_fingerprint = nil
- }
- // SetStatus sets the "status" field.
- func (m *IdempotencyRecordMutation) SetStatus(s string) {
- m.status = &s
- }
- // Status returns the value of the "status" field in the mutation.
- func (m *IdempotencyRecordMutation) Status() (r string, exists bool) {
- v := m.status
- if v == nil {
- return
- }
- return *v, true
- }
- // OldStatus returns the old "status" field's value of the IdempotencyRecord entity.
- // If the IdempotencyRecord object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *IdempotencyRecordMutation) OldStatus(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldStatus is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldStatus requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldStatus: %w", err)
- }
- return oldValue.Status, nil
- }
- // ResetStatus resets all changes to the "status" field.
- func (m *IdempotencyRecordMutation) ResetStatus() {
- m.status = nil
- }
- // SetResponseStatus sets the "response_status" field.
- func (m *IdempotencyRecordMutation) SetResponseStatus(i int) {
- m.response_status = &i
- m.addresponse_status = nil
- }
- // ResponseStatus returns the value of the "response_status" field in the mutation.
- func (m *IdempotencyRecordMutation) ResponseStatus() (r int, exists bool) {
- v := m.response_status
- if v == nil {
- return
- }
- return *v, true
- }
- // OldResponseStatus returns the old "response_status" field's value of the IdempotencyRecord entity.
- // If the IdempotencyRecord object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *IdempotencyRecordMutation) OldResponseStatus(ctx context.Context) (v *int, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldResponseStatus is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldResponseStatus requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldResponseStatus: %w", err)
- }
- return oldValue.ResponseStatus, nil
- }
- // AddResponseStatus adds i to the "response_status" field.
- func (m *IdempotencyRecordMutation) AddResponseStatus(i int) {
- if m.addresponse_status != nil {
- *m.addresponse_status += i
- } else {
- m.addresponse_status = &i
- }
- }
- // AddedResponseStatus returns the value that was added to the "response_status" field in this mutation.
- func (m *IdempotencyRecordMutation) AddedResponseStatus() (r int, exists bool) {
- v := m.addresponse_status
- if v == nil {
- return
- }
- return *v, true
- }
- // ClearResponseStatus clears the value of the "response_status" field.
- func (m *IdempotencyRecordMutation) ClearResponseStatus() {
- m.response_status = nil
- m.addresponse_status = nil
- m.clearedFields[idempotencyrecord.FieldResponseStatus] = struct{}{}
- }
- // ResponseStatusCleared returns if the "response_status" field was cleared in this mutation.
- func (m *IdempotencyRecordMutation) ResponseStatusCleared() bool {
- _, ok := m.clearedFields[idempotencyrecord.FieldResponseStatus]
- return ok
- }
- // ResetResponseStatus resets all changes to the "response_status" field.
- func (m *IdempotencyRecordMutation) ResetResponseStatus() {
- m.response_status = nil
- m.addresponse_status = nil
- delete(m.clearedFields, idempotencyrecord.FieldResponseStatus)
- }
- // SetResponseBody sets the "response_body" field.
- func (m *IdempotencyRecordMutation) SetResponseBody(s string) {
- m.response_body = &s
- }
- // ResponseBody returns the value of the "response_body" field in the mutation.
- func (m *IdempotencyRecordMutation) ResponseBody() (r string, exists bool) {
- v := m.response_body
- if v == nil {
- return
- }
- return *v, true
- }
- // OldResponseBody returns the old "response_body" field's value of the IdempotencyRecord entity.
- // If the IdempotencyRecord object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *IdempotencyRecordMutation) OldResponseBody(ctx context.Context) (v *string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldResponseBody is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldResponseBody requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldResponseBody: %w", err)
- }
- return oldValue.ResponseBody, nil
- }
- // ClearResponseBody clears the value of the "response_body" field.
- func (m *IdempotencyRecordMutation) ClearResponseBody() {
- m.response_body = nil
- m.clearedFields[idempotencyrecord.FieldResponseBody] = struct{}{}
- }
- // ResponseBodyCleared returns if the "response_body" field was cleared in this mutation.
- func (m *IdempotencyRecordMutation) ResponseBodyCleared() bool {
- _, ok := m.clearedFields[idempotencyrecord.FieldResponseBody]
- return ok
- }
- // ResetResponseBody resets all changes to the "response_body" field.
- func (m *IdempotencyRecordMutation) ResetResponseBody() {
- m.response_body = nil
- delete(m.clearedFields, idempotencyrecord.FieldResponseBody)
- }
- // SetErrorReason sets the "error_reason" field.
- func (m *IdempotencyRecordMutation) SetErrorReason(s string) {
- m.error_reason = &s
- }
- // ErrorReason returns the value of the "error_reason" field in the mutation.
- func (m *IdempotencyRecordMutation) ErrorReason() (r string, exists bool) {
- v := m.error_reason
- if v == nil {
- return
- }
- return *v, true
- }
- // OldErrorReason returns the old "error_reason" field's value of the IdempotencyRecord entity.
- // If the IdempotencyRecord object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *IdempotencyRecordMutation) OldErrorReason(ctx context.Context) (v *string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldErrorReason is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldErrorReason requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldErrorReason: %w", err)
- }
- return oldValue.ErrorReason, nil
- }
- // ClearErrorReason clears the value of the "error_reason" field.
- func (m *IdempotencyRecordMutation) ClearErrorReason() {
- m.error_reason = nil
- m.clearedFields[idempotencyrecord.FieldErrorReason] = struct{}{}
- }
- // ErrorReasonCleared returns if the "error_reason" field was cleared in this mutation.
- func (m *IdempotencyRecordMutation) ErrorReasonCleared() bool {
- _, ok := m.clearedFields[idempotencyrecord.FieldErrorReason]
- return ok
- }
- // ResetErrorReason resets all changes to the "error_reason" field.
- func (m *IdempotencyRecordMutation) ResetErrorReason() {
- m.error_reason = nil
- delete(m.clearedFields, idempotencyrecord.FieldErrorReason)
- }
- // SetLockedUntil sets the "locked_until" field.
- func (m *IdempotencyRecordMutation) SetLockedUntil(t time.Time) {
- m.locked_until = &t
- }
- // LockedUntil returns the value of the "locked_until" field in the mutation.
- func (m *IdempotencyRecordMutation) LockedUntil() (r time.Time, exists bool) {
- v := m.locked_until
- if v == nil {
- return
- }
- return *v, true
- }
- // OldLockedUntil returns the old "locked_until" field's value of the IdempotencyRecord entity.
- // If the IdempotencyRecord object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *IdempotencyRecordMutation) OldLockedUntil(ctx context.Context) (v *time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldLockedUntil is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldLockedUntil requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldLockedUntil: %w", err)
- }
- return oldValue.LockedUntil, nil
- }
- // ClearLockedUntil clears the value of the "locked_until" field.
- func (m *IdempotencyRecordMutation) ClearLockedUntil() {
- m.locked_until = nil
- m.clearedFields[idempotencyrecord.FieldLockedUntil] = struct{}{}
- }
- // LockedUntilCleared returns if the "locked_until" field was cleared in this mutation.
- func (m *IdempotencyRecordMutation) LockedUntilCleared() bool {
- _, ok := m.clearedFields[idempotencyrecord.FieldLockedUntil]
- return ok
- }
- // ResetLockedUntil resets all changes to the "locked_until" field.
- func (m *IdempotencyRecordMutation) ResetLockedUntil() {
- m.locked_until = nil
- delete(m.clearedFields, idempotencyrecord.FieldLockedUntil)
- }
- // SetExpiresAt sets the "expires_at" field.
- func (m *IdempotencyRecordMutation) SetExpiresAt(t time.Time) {
- m.expires_at = &t
- }
- // ExpiresAt returns the value of the "expires_at" field in the mutation.
- func (m *IdempotencyRecordMutation) ExpiresAt() (r time.Time, exists bool) {
- v := m.expires_at
- if v == nil {
- return
- }
- return *v, true
- }
- // OldExpiresAt returns the old "expires_at" field's value of the IdempotencyRecord entity.
- // If the IdempotencyRecord object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *IdempotencyRecordMutation) OldExpiresAt(ctx context.Context) (v time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldExpiresAt is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldExpiresAt requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldExpiresAt: %w", err)
- }
- return oldValue.ExpiresAt, nil
- }
- // ResetExpiresAt resets all changes to the "expires_at" field.
- func (m *IdempotencyRecordMutation) ResetExpiresAt() {
- m.expires_at = nil
- }
- // Where appends a list predicates to the IdempotencyRecordMutation builder.
- func (m *IdempotencyRecordMutation) Where(ps ...predicate.IdempotencyRecord) {
- m.predicates = append(m.predicates, ps...)
- }
- // WhereP appends storage-level predicates to the IdempotencyRecordMutation builder. Using this method,
- // users can use type-assertion to append predicates that do not depend on any generated package.
- func (m *IdempotencyRecordMutation) WhereP(ps ...func(*sql.Selector)) {
- p := make([]predicate.IdempotencyRecord, len(ps))
- for i := range ps {
- p[i] = ps[i]
- }
- m.Where(p...)
- }
- // Op returns the operation name.
- func (m *IdempotencyRecordMutation) Op() Op {
- return m.op
- }
- // SetOp allows setting the mutation operation.
- func (m *IdempotencyRecordMutation) SetOp(op Op) {
- m.op = op
- }
- // Type returns the node type of this mutation (IdempotencyRecord).
- func (m *IdempotencyRecordMutation) Type() string {
- return m.typ
- }
- // Fields returns all fields that were changed during this mutation. Note that in
- // order to get all numeric fields that were incremented/decremented, call
- // AddedFields().
- func (m *IdempotencyRecordMutation) Fields() []string {
- fields := make([]string, 0, 11)
- if m.created_at != nil {
- fields = append(fields, idempotencyrecord.FieldCreatedAt)
- }
- if m.updated_at != nil {
- fields = append(fields, idempotencyrecord.FieldUpdatedAt)
- }
- if m.scope != nil {
- fields = append(fields, idempotencyrecord.FieldScope)
- }
- if m.idempotency_key_hash != nil {
- fields = append(fields, idempotencyrecord.FieldIdempotencyKeyHash)
- }
- if m.request_fingerprint != nil {
- fields = append(fields, idempotencyrecord.FieldRequestFingerprint)
- }
- if m.status != nil {
- fields = append(fields, idempotencyrecord.FieldStatus)
- }
- if m.response_status != nil {
- fields = append(fields, idempotencyrecord.FieldResponseStatus)
- }
- if m.response_body != nil {
- fields = append(fields, idempotencyrecord.FieldResponseBody)
- }
- if m.error_reason != nil {
- fields = append(fields, idempotencyrecord.FieldErrorReason)
- }
- if m.locked_until != nil {
- fields = append(fields, idempotencyrecord.FieldLockedUntil)
- }
- if m.expires_at != nil {
- fields = append(fields, idempotencyrecord.FieldExpiresAt)
- }
- return fields
- }
- // Field returns the value of a field with the given name. The second boolean
- // return value indicates that this field was not set, or was not defined in the
- // schema.
- func (m *IdempotencyRecordMutation) Field(name string) (ent.Value, bool) {
- switch name {
- case idempotencyrecord.FieldCreatedAt:
- return m.CreatedAt()
- case idempotencyrecord.FieldUpdatedAt:
- return m.UpdatedAt()
- case idempotencyrecord.FieldScope:
- return m.Scope()
- case idempotencyrecord.FieldIdempotencyKeyHash:
- return m.IdempotencyKeyHash()
- case idempotencyrecord.FieldRequestFingerprint:
- return m.RequestFingerprint()
- case idempotencyrecord.FieldStatus:
- return m.Status()
- case idempotencyrecord.FieldResponseStatus:
- return m.ResponseStatus()
- case idempotencyrecord.FieldResponseBody:
- return m.ResponseBody()
- case idempotencyrecord.FieldErrorReason:
- return m.ErrorReason()
- case idempotencyrecord.FieldLockedUntil:
- return m.LockedUntil()
- case idempotencyrecord.FieldExpiresAt:
- return m.ExpiresAt()
- }
- return nil, false
- }
- // OldField returns the old value of the field from the database. An error is
- // returned if the mutation operation is not UpdateOne, or the query to the
- // database failed.
- func (m *IdempotencyRecordMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
- switch name {
- case idempotencyrecord.FieldCreatedAt:
- return m.OldCreatedAt(ctx)
- case idempotencyrecord.FieldUpdatedAt:
- return m.OldUpdatedAt(ctx)
- case idempotencyrecord.FieldScope:
- return m.OldScope(ctx)
- case idempotencyrecord.FieldIdempotencyKeyHash:
- return m.OldIdempotencyKeyHash(ctx)
- case idempotencyrecord.FieldRequestFingerprint:
- return m.OldRequestFingerprint(ctx)
- case idempotencyrecord.FieldStatus:
- return m.OldStatus(ctx)
- case idempotencyrecord.FieldResponseStatus:
- return m.OldResponseStatus(ctx)
- case idempotencyrecord.FieldResponseBody:
- return m.OldResponseBody(ctx)
- case idempotencyrecord.FieldErrorReason:
- return m.OldErrorReason(ctx)
- case idempotencyrecord.FieldLockedUntil:
- return m.OldLockedUntil(ctx)
- case idempotencyrecord.FieldExpiresAt:
- return m.OldExpiresAt(ctx)
- }
- return nil, fmt.Errorf("unknown IdempotencyRecord field %s", name)
- }
- // SetField sets the value of a field with the given name. It returns an error if
- // the field is not defined in the schema, or if the type mismatched the field
- // type.
- func (m *IdempotencyRecordMutation) SetField(name string, value ent.Value) error {
- switch name {
- case idempotencyrecord.FieldCreatedAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetCreatedAt(v)
- return nil
- case idempotencyrecord.FieldUpdatedAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetUpdatedAt(v)
- return nil
- case idempotencyrecord.FieldScope:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetScope(v)
- return nil
- case idempotencyrecord.FieldIdempotencyKeyHash:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetIdempotencyKeyHash(v)
- return nil
- case idempotencyrecord.FieldRequestFingerprint:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetRequestFingerprint(v)
- return nil
- case idempotencyrecord.FieldStatus:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetStatus(v)
- return nil
- case idempotencyrecord.FieldResponseStatus:
- v, ok := value.(int)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetResponseStatus(v)
- return nil
- case idempotencyrecord.FieldResponseBody:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetResponseBody(v)
- return nil
- case idempotencyrecord.FieldErrorReason:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetErrorReason(v)
- return nil
- case idempotencyrecord.FieldLockedUntil:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetLockedUntil(v)
- return nil
- case idempotencyrecord.FieldExpiresAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetExpiresAt(v)
- return nil
- }
- return fmt.Errorf("unknown IdempotencyRecord field %s", name)
- }
- // AddedFields returns all numeric fields that were incremented/decremented during
- // this mutation.
- func (m *IdempotencyRecordMutation) AddedFields() []string {
- var fields []string
- if m.addresponse_status != nil {
- fields = append(fields, idempotencyrecord.FieldResponseStatus)
- }
- return fields
- }
- // AddedField returns the numeric value that was incremented/decremented on a field
- // with the given name. The second boolean return value indicates that this field
- // was not set, or was not defined in the schema.
- func (m *IdempotencyRecordMutation) AddedField(name string) (ent.Value, bool) {
- switch name {
- case idempotencyrecord.FieldResponseStatus:
- return m.AddedResponseStatus()
- }
- return nil, false
- }
- // AddField adds the value to the field with the given name. It returns an error if
- // the field is not defined in the schema, or if the type mismatched the field
- // type.
- func (m *IdempotencyRecordMutation) AddField(name string, value ent.Value) error {
- switch name {
- case idempotencyrecord.FieldResponseStatus:
- v, ok := value.(int)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.AddResponseStatus(v)
- return nil
- }
- return fmt.Errorf("unknown IdempotencyRecord numeric field %s", name)
- }
- // ClearedFields returns all nullable fields that were cleared during this
- // mutation.
- func (m *IdempotencyRecordMutation) ClearedFields() []string {
- var fields []string
- if m.FieldCleared(idempotencyrecord.FieldResponseStatus) {
- fields = append(fields, idempotencyrecord.FieldResponseStatus)
- }
- if m.FieldCleared(idempotencyrecord.FieldResponseBody) {
- fields = append(fields, idempotencyrecord.FieldResponseBody)
- }
- if m.FieldCleared(idempotencyrecord.FieldErrorReason) {
- fields = append(fields, idempotencyrecord.FieldErrorReason)
- }
- if m.FieldCleared(idempotencyrecord.FieldLockedUntil) {
- fields = append(fields, idempotencyrecord.FieldLockedUntil)
- }
- return fields
- }
- // FieldCleared returns a boolean indicating if a field with the given name was
- // cleared in this mutation.
- func (m *IdempotencyRecordMutation) FieldCleared(name string) bool {
- _, ok := m.clearedFields[name]
- return ok
- }
- // ClearField clears the value of the field with the given name. It returns an
- // error if the field is not defined in the schema.
- func (m *IdempotencyRecordMutation) ClearField(name string) error {
- switch name {
- case idempotencyrecord.FieldResponseStatus:
- m.ClearResponseStatus()
- return nil
- case idempotencyrecord.FieldResponseBody:
- m.ClearResponseBody()
- return nil
- case idempotencyrecord.FieldErrorReason:
- m.ClearErrorReason()
- return nil
- case idempotencyrecord.FieldLockedUntil:
- m.ClearLockedUntil()
- return nil
- }
- return fmt.Errorf("unknown IdempotencyRecord nullable field %s", name)
- }
- // ResetField resets all changes in the mutation for the field with the given name.
- // It returns an error if the field is not defined in the schema.
- func (m *IdempotencyRecordMutation) ResetField(name string) error {
- switch name {
- case idempotencyrecord.FieldCreatedAt:
- m.ResetCreatedAt()
- return nil
- case idempotencyrecord.FieldUpdatedAt:
- m.ResetUpdatedAt()
- return nil
- case idempotencyrecord.FieldScope:
- m.ResetScope()
- return nil
- case idempotencyrecord.FieldIdempotencyKeyHash:
- m.ResetIdempotencyKeyHash()
- return nil
- case idempotencyrecord.FieldRequestFingerprint:
- m.ResetRequestFingerprint()
- return nil
- case idempotencyrecord.FieldStatus:
- m.ResetStatus()
- return nil
- case idempotencyrecord.FieldResponseStatus:
- m.ResetResponseStatus()
- return nil
- case idempotencyrecord.FieldResponseBody:
- m.ResetResponseBody()
- return nil
- case idempotencyrecord.FieldErrorReason:
- m.ResetErrorReason()
- return nil
- case idempotencyrecord.FieldLockedUntil:
- m.ResetLockedUntil()
- return nil
- case idempotencyrecord.FieldExpiresAt:
- m.ResetExpiresAt()
- return nil
- }
- return fmt.Errorf("unknown IdempotencyRecord field %s", name)
- }
- // AddedEdges returns all edge names that were set/added in this mutation.
- func (m *IdempotencyRecordMutation) AddedEdges() []string {
- edges := make([]string, 0, 0)
- return edges
- }
- // AddedIDs returns all IDs (to other nodes) that were added for the given edge
- // name in this mutation.
- func (m *IdempotencyRecordMutation) AddedIDs(name string) []ent.Value {
- return nil
- }
- // RemovedEdges returns all edge names that were removed in this mutation.
- func (m *IdempotencyRecordMutation) RemovedEdges() []string {
- edges := make([]string, 0, 0)
- return edges
- }
- // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
- // the given name in this mutation.
- func (m *IdempotencyRecordMutation) RemovedIDs(name string) []ent.Value {
- return nil
- }
- // ClearedEdges returns all edge names that were cleared in this mutation.
- func (m *IdempotencyRecordMutation) ClearedEdges() []string {
- edges := make([]string, 0, 0)
- return edges
- }
- // EdgeCleared returns a boolean which indicates if the edge with the given name
- // was cleared in this mutation.
- func (m *IdempotencyRecordMutation) EdgeCleared(name string) bool {
- return false
- }
- // ClearEdge clears the value of the edge with the given name. It returns an error
- // if that edge is not defined in the schema.
- func (m *IdempotencyRecordMutation) ClearEdge(name string) error {
- return fmt.Errorf("unknown IdempotencyRecord unique edge %s", name)
- }
- // ResetEdge resets all changes to the edge with the given name in this mutation.
- // It returns an error if the edge is not defined in the schema.
- func (m *IdempotencyRecordMutation) ResetEdge(name string) error {
- return fmt.Errorf("unknown IdempotencyRecord edge %s", name)
- }
- // IdentityAdoptionDecisionMutation represents an operation that mutates the IdentityAdoptionDecision nodes in the graph.
- type IdentityAdoptionDecisionMutation struct {
- config
- op Op
- typ string
- id *int64
- created_at *time.Time
- updated_at *time.Time
- adopt_display_name *bool
- adopt_avatar *bool
- decided_at *time.Time
- clearedFields map[string]struct{}
- pending_auth_session *int64
- clearedpending_auth_session bool
- identity *int64
- clearedidentity bool
- done bool
- oldValue func(context.Context) (*IdentityAdoptionDecision, error)
- predicates []predicate.IdentityAdoptionDecision
- }
- var _ ent.Mutation = (*IdentityAdoptionDecisionMutation)(nil)
- // identityadoptiondecisionOption allows management of the mutation configuration using functional options.
- type identityadoptiondecisionOption func(*IdentityAdoptionDecisionMutation)
- // newIdentityAdoptionDecisionMutation creates new mutation for the IdentityAdoptionDecision entity.
- func newIdentityAdoptionDecisionMutation(c config, op Op, opts ...identityadoptiondecisionOption) *IdentityAdoptionDecisionMutation {
- m := &IdentityAdoptionDecisionMutation{
- config: c,
- op: op,
- typ: TypeIdentityAdoptionDecision,
- clearedFields: make(map[string]struct{}),
- }
- for _, opt := range opts {
- opt(m)
- }
- return m
- }
- // withIdentityAdoptionDecisionID sets the ID field of the mutation.
- func withIdentityAdoptionDecisionID(id int64) identityadoptiondecisionOption {
- return func(m *IdentityAdoptionDecisionMutation) {
- var (
- err error
- once sync.Once
- value *IdentityAdoptionDecision
- )
- m.oldValue = func(ctx context.Context) (*IdentityAdoptionDecision, error) {
- once.Do(func() {
- if m.done {
- err = errors.New("querying old values post mutation is not allowed")
- } else {
- value, err = m.Client().IdentityAdoptionDecision.Get(ctx, id)
- }
- })
- return value, err
- }
- m.id = &id
- }
- }
- // withIdentityAdoptionDecision sets the old IdentityAdoptionDecision of the mutation.
- func withIdentityAdoptionDecision(node *IdentityAdoptionDecision) identityadoptiondecisionOption {
- return func(m *IdentityAdoptionDecisionMutation) {
- m.oldValue = func(context.Context) (*IdentityAdoptionDecision, error) {
- return node, nil
- }
- m.id = &node.ID
- }
- }
- // Client returns a new `ent.Client` from the mutation. If the mutation was
- // executed in a transaction (ent.Tx), a transactional client is returned.
- func (m IdentityAdoptionDecisionMutation) Client() *Client {
- client := &Client{config: m.config}
- client.init()
- return client
- }
- // Tx returns an `ent.Tx` for mutations that were executed in transactions;
- // it returns an error otherwise.
- func (m IdentityAdoptionDecisionMutation) Tx() (*Tx, error) {
- if _, ok := m.driver.(*txDriver); !ok {
- return nil, errors.New("ent: mutation is not running in a transaction")
- }
- tx := &Tx{config: m.config}
- tx.init()
- return tx, nil
- }
- // ID returns the ID value in the mutation. Note that the ID is only available
- // if it was provided to the builder or after it was returned from the database.
- func (m *IdentityAdoptionDecisionMutation) ID() (id int64, exists bool) {
- if m.id == nil {
- return
- }
- return *m.id, true
- }
- // IDs queries the database and returns the entity ids that match the mutation's predicate.
- // That means, if the mutation is applied within a transaction with an isolation level such
- // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
- // or updated by the mutation.
- func (m *IdentityAdoptionDecisionMutation) IDs(ctx context.Context) ([]int64, error) {
- switch {
- case m.op.Is(OpUpdateOne | OpDeleteOne):
- id, exists := m.ID()
- if exists {
- return []int64{id}, nil
- }
- fallthrough
- case m.op.Is(OpUpdate | OpDelete):
- return m.Client().IdentityAdoptionDecision.Query().Where(m.predicates...).IDs(ctx)
- default:
- return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
- }
- }
- // SetCreatedAt sets the "created_at" field.
- func (m *IdentityAdoptionDecisionMutation) SetCreatedAt(t time.Time) {
- m.created_at = &t
- }
- // CreatedAt returns the value of the "created_at" field in the mutation.
- func (m *IdentityAdoptionDecisionMutation) CreatedAt() (r time.Time, exists bool) {
- v := m.created_at
- if v == nil {
- return
- }
- return *v, true
- }
- // OldCreatedAt returns the old "created_at" field's value of the IdentityAdoptionDecision entity.
- // If the IdentityAdoptionDecision object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *IdentityAdoptionDecisionMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldCreatedAt requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
- }
- return oldValue.CreatedAt, nil
- }
- // ResetCreatedAt resets all changes to the "created_at" field.
- func (m *IdentityAdoptionDecisionMutation) ResetCreatedAt() {
- m.created_at = nil
- }
- // SetUpdatedAt sets the "updated_at" field.
- func (m *IdentityAdoptionDecisionMutation) SetUpdatedAt(t time.Time) {
- m.updated_at = &t
- }
- // UpdatedAt returns the value of the "updated_at" field in the mutation.
- func (m *IdentityAdoptionDecisionMutation) UpdatedAt() (r time.Time, exists bool) {
- v := m.updated_at
- if v == nil {
- return
- }
- return *v, true
- }
- // OldUpdatedAt returns the old "updated_at" field's value of the IdentityAdoptionDecision entity.
- // If the IdentityAdoptionDecision object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *IdentityAdoptionDecisionMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
- }
- return oldValue.UpdatedAt, nil
- }
- // ResetUpdatedAt resets all changes to the "updated_at" field.
- func (m *IdentityAdoptionDecisionMutation) ResetUpdatedAt() {
- m.updated_at = nil
- }
- // SetPendingAuthSessionID sets the "pending_auth_session_id" field.
- func (m *IdentityAdoptionDecisionMutation) SetPendingAuthSessionID(i int64) {
- m.pending_auth_session = &i
- }
- // PendingAuthSessionID returns the value of the "pending_auth_session_id" field in the mutation.
- func (m *IdentityAdoptionDecisionMutation) PendingAuthSessionID() (r int64, exists bool) {
- v := m.pending_auth_session
- if v == nil {
- return
- }
- return *v, true
- }
- // OldPendingAuthSessionID returns the old "pending_auth_session_id" field's value of the IdentityAdoptionDecision entity.
- // If the IdentityAdoptionDecision object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *IdentityAdoptionDecisionMutation) OldPendingAuthSessionID(ctx context.Context) (v int64, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldPendingAuthSessionID is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldPendingAuthSessionID requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldPendingAuthSessionID: %w", err)
- }
- return oldValue.PendingAuthSessionID, nil
- }
- // ResetPendingAuthSessionID resets all changes to the "pending_auth_session_id" field.
- func (m *IdentityAdoptionDecisionMutation) ResetPendingAuthSessionID() {
- m.pending_auth_session = nil
- }
- // SetIdentityID sets the "identity_id" field.
- func (m *IdentityAdoptionDecisionMutation) SetIdentityID(i int64) {
- m.identity = &i
- }
- // IdentityID returns the value of the "identity_id" field in the mutation.
- func (m *IdentityAdoptionDecisionMutation) IdentityID() (r int64, exists bool) {
- v := m.identity
- if v == nil {
- return
- }
- return *v, true
- }
- // OldIdentityID returns the old "identity_id" field's value of the IdentityAdoptionDecision entity.
- // If the IdentityAdoptionDecision object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *IdentityAdoptionDecisionMutation) OldIdentityID(ctx context.Context) (v *int64, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldIdentityID is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldIdentityID requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldIdentityID: %w", err)
- }
- return oldValue.IdentityID, nil
- }
- // ClearIdentityID clears the value of the "identity_id" field.
- func (m *IdentityAdoptionDecisionMutation) ClearIdentityID() {
- m.identity = nil
- m.clearedFields[identityadoptiondecision.FieldIdentityID] = struct{}{}
- }
- // IdentityIDCleared returns if the "identity_id" field was cleared in this mutation.
- func (m *IdentityAdoptionDecisionMutation) IdentityIDCleared() bool {
- _, ok := m.clearedFields[identityadoptiondecision.FieldIdentityID]
- return ok
- }
- // ResetIdentityID resets all changes to the "identity_id" field.
- func (m *IdentityAdoptionDecisionMutation) ResetIdentityID() {
- m.identity = nil
- delete(m.clearedFields, identityadoptiondecision.FieldIdentityID)
- }
- // SetAdoptDisplayName sets the "adopt_display_name" field.
- func (m *IdentityAdoptionDecisionMutation) SetAdoptDisplayName(b bool) {
- m.adopt_display_name = &b
- }
- // AdoptDisplayName returns the value of the "adopt_display_name" field in the mutation.
- func (m *IdentityAdoptionDecisionMutation) AdoptDisplayName() (r bool, exists bool) {
- v := m.adopt_display_name
- if v == nil {
- return
- }
- return *v, true
- }
- // OldAdoptDisplayName returns the old "adopt_display_name" field's value of the IdentityAdoptionDecision entity.
- // If the IdentityAdoptionDecision object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *IdentityAdoptionDecisionMutation) OldAdoptDisplayName(ctx context.Context) (v bool, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldAdoptDisplayName is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldAdoptDisplayName requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldAdoptDisplayName: %w", err)
- }
- return oldValue.AdoptDisplayName, nil
- }
- // ResetAdoptDisplayName resets all changes to the "adopt_display_name" field.
- func (m *IdentityAdoptionDecisionMutation) ResetAdoptDisplayName() {
- m.adopt_display_name = nil
- }
- // SetAdoptAvatar sets the "adopt_avatar" field.
- func (m *IdentityAdoptionDecisionMutation) SetAdoptAvatar(b bool) {
- m.adopt_avatar = &b
- }
- // AdoptAvatar returns the value of the "adopt_avatar" field in the mutation.
- func (m *IdentityAdoptionDecisionMutation) AdoptAvatar() (r bool, exists bool) {
- v := m.adopt_avatar
- if v == nil {
- return
- }
- return *v, true
- }
- // OldAdoptAvatar returns the old "adopt_avatar" field's value of the IdentityAdoptionDecision entity.
- // If the IdentityAdoptionDecision object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *IdentityAdoptionDecisionMutation) OldAdoptAvatar(ctx context.Context) (v bool, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldAdoptAvatar is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldAdoptAvatar requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldAdoptAvatar: %w", err)
- }
- return oldValue.AdoptAvatar, nil
- }
- // ResetAdoptAvatar resets all changes to the "adopt_avatar" field.
- func (m *IdentityAdoptionDecisionMutation) ResetAdoptAvatar() {
- m.adopt_avatar = nil
- }
- // SetDecidedAt sets the "decided_at" field.
- func (m *IdentityAdoptionDecisionMutation) SetDecidedAt(t time.Time) {
- m.decided_at = &t
- }
- // DecidedAt returns the value of the "decided_at" field in the mutation.
- func (m *IdentityAdoptionDecisionMutation) DecidedAt() (r time.Time, exists bool) {
- v := m.decided_at
- if v == nil {
- return
- }
- return *v, true
- }
- // OldDecidedAt returns the old "decided_at" field's value of the IdentityAdoptionDecision entity.
- // If the IdentityAdoptionDecision object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *IdentityAdoptionDecisionMutation) OldDecidedAt(ctx context.Context) (v time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldDecidedAt is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldDecidedAt requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldDecidedAt: %w", err)
- }
- return oldValue.DecidedAt, nil
- }
- // ResetDecidedAt resets all changes to the "decided_at" field.
- func (m *IdentityAdoptionDecisionMutation) ResetDecidedAt() {
- m.decided_at = nil
- }
- // ClearPendingAuthSession clears the "pending_auth_session" edge to the PendingAuthSession entity.
- func (m *IdentityAdoptionDecisionMutation) ClearPendingAuthSession() {
- m.clearedpending_auth_session = true
- m.clearedFields[identityadoptiondecision.FieldPendingAuthSessionID] = struct{}{}
- }
- // PendingAuthSessionCleared reports if the "pending_auth_session" edge to the PendingAuthSession entity was cleared.
- func (m *IdentityAdoptionDecisionMutation) PendingAuthSessionCleared() bool {
- return m.clearedpending_auth_session
- }
- // PendingAuthSessionIDs returns the "pending_auth_session" edge IDs in the mutation.
- // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
- // PendingAuthSessionID instead. It exists only for internal usage by the builders.
- func (m *IdentityAdoptionDecisionMutation) PendingAuthSessionIDs() (ids []int64) {
- if id := m.pending_auth_session; id != nil {
- ids = append(ids, *id)
- }
- return
- }
- // ResetPendingAuthSession resets all changes to the "pending_auth_session" edge.
- func (m *IdentityAdoptionDecisionMutation) ResetPendingAuthSession() {
- m.pending_auth_session = nil
- m.clearedpending_auth_session = false
- }
- // ClearIdentity clears the "identity" edge to the AuthIdentity entity.
- func (m *IdentityAdoptionDecisionMutation) ClearIdentity() {
- m.clearedidentity = true
- m.clearedFields[identityadoptiondecision.FieldIdentityID] = struct{}{}
- }
- // IdentityCleared reports if the "identity" edge to the AuthIdentity entity was cleared.
- func (m *IdentityAdoptionDecisionMutation) IdentityCleared() bool {
- return m.IdentityIDCleared() || m.clearedidentity
- }
- // IdentityIDs returns the "identity" edge IDs in the mutation.
- // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
- // IdentityID instead. It exists only for internal usage by the builders.
- func (m *IdentityAdoptionDecisionMutation) IdentityIDs() (ids []int64) {
- if id := m.identity; id != nil {
- ids = append(ids, *id)
- }
- return
- }
- // ResetIdentity resets all changes to the "identity" edge.
- func (m *IdentityAdoptionDecisionMutation) ResetIdentity() {
- m.identity = nil
- m.clearedidentity = false
- }
- // Where appends a list predicates to the IdentityAdoptionDecisionMutation builder.
- func (m *IdentityAdoptionDecisionMutation) Where(ps ...predicate.IdentityAdoptionDecision) {
- m.predicates = append(m.predicates, ps...)
- }
- // WhereP appends storage-level predicates to the IdentityAdoptionDecisionMutation builder. Using this method,
- // users can use type-assertion to append predicates that do not depend on any generated package.
- func (m *IdentityAdoptionDecisionMutation) WhereP(ps ...func(*sql.Selector)) {
- p := make([]predicate.IdentityAdoptionDecision, len(ps))
- for i := range ps {
- p[i] = ps[i]
- }
- m.Where(p...)
- }
- // Op returns the operation name.
- func (m *IdentityAdoptionDecisionMutation) Op() Op {
- return m.op
- }
- // SetOp allows setting the mutation operation.
- func (m *IdentityAdoptionDecisionMutation) SetOp(op Op) {
- m.op = op
- }
- // Type returns the node type of this mutation (IdentityAdoptionDecision).
- func (m *IdentityAdoptionDecisionMutation) Type() string {
- return m.typ
- }
- // Fields returns all fields that were changed during this mutation. Note that in
- // order to get all numeric fields that were incremented/decremented, call
- // AddedFields().
- func (m *IdentityAdoptionDecisionMutation) Fields() []string {
- fields := make([]string, 0, 7)
- if m.created_at != nil {
- fields = append(fields, identityadoptiondecision.FieldCreatedAt)
- }
- if m.updated_at != nil {
- fields = append(fields, identityadoptiondecision.FieldUpdatedAt)
- }
- if m.pending_auth_session != nil {
- fields = append(fields, identityadoptiondecision.FieldPendingAuthSessionID)
- }
- if m.identity != nil {
- fields = append(fields, identityadoptiondecision.FieldIdentityID)
- }
- if m.adopt_display_name != nil {
- fields = append(fields, identityadoptiondecision.FieldAdoptDisplayName)
- }
- if m.adopt_avatar != nil {
- fields = append(fields, identityadoptiondecision.FieldAdoptAvatar)
- }
- if m.decided_at != nil {
- fields = append(fields, identityadoptiondecision.FieldDecidedAt)
- }
- return fields
- }
- // Field returns the value of a field with the given name. The second boolean
- // return value indicates that this field was not set, or was not defined in the
- // schema.
- func (m *IdentityAdoptionDecisionMutation) Field(name string) (ent.Value, bool) {
- switch name {
- case identityadoptiondecision.FieldCreatedAt:
- return m.CreatedAt()
- case identityadoptiondecision.FieldUpdatedAt:
- return m.UpdatedAt()
- case identityadoptiondecision.FieldPendingAuthSessionID:
- return m.PendingAuthSessionID()
- case identityadoptiondecision.FieldIdentityID:
- return m.IdentityID()
- case identityadoptiondecision.FieldAdoptDisplayName:
- return m.AdoptDisplayName()
- case identityadoptiondecision.FieldAdoptAvatar:
- return m.AdoptAvatar()
- case identityadoptiondecision.FieldDecidedAt:
- return m.DecidedAt()
- }
- return nil, false
- }
- // OldField returns the old value of the field from the database. An error is
- // returned if the mutation operation is not UpdateOne, or the query to the
- // database failed.
- func (m *IdentityAdoptionDecisionMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
- switch name {
- case identityadoptiondecision.FieldCreatedAt:
- return m.OldCreatedAt(ctx)
- case identityadoptiondecision.FieldUpdatedAt:
- return m.OldUpdatedAt(ctx)
- case identityadoptiondecision.FieldPendingAuthSessionID:
- return m.OldPendingAuthSessionID(ctx)
- case identityadoptiondecision.FieldIdentityID:
- return m.OldIdentityID(ctx)
- case identityadoptiondecision.FieldAdoptDisplayName:
- return m.OldAdoptDisplayName(ctx)
- case identityadoptiondecision.FieldAdoptAvatar:
- return m.OldAdoptAvatar(ctx)
- case identityadoptiondecision.FieldDecidedAt:
- return m.OldDecidedAt(ctx)
- }
- return nil, fmt.Errorf("unknown IdentityAdoptionDecision field %s", name)
- }
- // SetField sets the value of a field with the given name. It returns an error if
- // the field is not defined in the schema, or if the type mismatched the field
- // type.
- func (m *IdentityAdoptionDecisionMutation) SetField(name string, value ent.Value) error {
- switch name {
- case identityadoptiondecision.FieldCreatedAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetCreatedAt(v)
- return nil
- case identityadoptiondecision.FieldUpdatedAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetUpdatedAt(v)
- return nil
- case identityadoptiondecision.FieldPendingAuthSessionID:
- v, ok := value.(int64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetPendingAuthSessionID(v)
- return nil
- case identityadoptiondecision.FieldIdentityID:
- v, ok := value.(int64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetIdentityID(v)
- return nil
- case identityadoptiondecision.FieldAdoptDisplayName:
- v, ok := value.(bool)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetAdoptDisplayName(v)
- return nil
- case identityadoptiondecision.FieldAdoptAvatar:
- v, ok := value.(bool)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetAdoptAvatar(v)
- return nil
- case identityadoptiondecision.FieldDecidedAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetDecidedAt(v)
- return nil
- }
- return fmt.Errorf("unknown IdentityAdoptionDecision field %s", name)
- }
- // AddedFields returns all numeric fields that were incremented/decremented during
- // this mutation.
- func (m *IdentityAdoptionDecisionMutation) AddedFields() []string {
- var fields []string
- return fields
- }
- // AddedField returns the numeric value that was incremented/decremented on a field
- // with the given name. The second boolean return value indicates that this field
- // was not set, or was not defined in the schema.
- func (m *IdentityAdoptionDecisionMutation) AddedField(name string) (ent.Value, bool) {
- switch name {
- }
- return nil, false
- }
- // AddField adds the value to the field with the given name. It returns an error if
- // the field is not defined in the schema, or if the type mismatched the field
- // type.
- func (m *IdentityAdoptionDecisionMutation) AddField(name string, value ent.Value) error {
- switch name {
- }
- return fmt.Errorf("unknown IdentityAdoptionDecision numeric field %s", name)
- }
- // ClearedFields returns all nullable fields that were cleared during this
- // mutation.
- func (m *IdentityAdoptionDecisionMutation) ClearedFields() []string {
- var fields []string
- if m.FieldCleared(identityadoptiondecision.FieldIdentityID) {
- fields = append(fields, identityadoptiondecision.FieldIdentityID)
- }
- return fields
- }
- // FieldCleared returns a boolean indicating if a field with the given name was
- // cleared in this mutation.
- func (m *IdentityAdoptionDecisionMutation) FieldCleared(name string) bool {
- _, ok := m.clearedFields[name]
- return ok
- }
- // ClearField clears the value of the field with the given name. It returns an
- // error if the field is not defined in the schema.
- func (m *IdentityAdoptionDecisionMutation) ClearField(name string) error {
- switch name {
- case identityadoptiondecision.FieldIdentityID:
- m.ClearIdentityID()
- return nil
- }
- return fmt.Errorf("unknown IdentityAdoptionDecision nullable field %s", name)
- }
- // ResetField resets all changes in the mutation for the field with the given name.
- // It returns an error if the field is not defined in the schema.
- func (m *IdentityAdoptionDecisionMutation) ResetField(name string) error {
- switch name {
- case identityadoptiondecision.FieldCreatedAt:
- m.ResetCreatedAt()
- return nil
- case identityadoptiondecision.FieldUpdatedAt:
- m.ResetUpdatedAt()
- return nil
- case identityadoptiondecision.FieldPendingAuthSessionID:
- m.ResetPendingAuthSessionID()
- return nil
- case identityadoptiondecision.FieldIdentityID:
- m.ResetIdentityID()
- return nil
- case identityadoptiondecision.FieldAdoptDisplayName:
- m.ResetAdoptDisplayName()
- return nil
- case identityadoptiondecision.FieldAdoptAvatar:
- m.ResetAdoptAvatar()
- return nil
- case identityadoptiondecision.FieldDecidedAt:
- m.ResetDecidedAt()
- return nil
- }
- return fmt.Errorf("unknown IdentityAdoptionDecision field %s", name)
- }
- // AddedEdges returns all edge names that were set/added in this mutation.
- func (m *IdentityAdoptionDecisionMutation) AddedEdges() []string {
- edges := make([]string, 0, 2)
- if m.pending_auth_session != nil {
- edges = append(edges, identityadoptiondecision.EdgePendingAuthSession)
- }
- if m.identity != nil {
- edges = append(edges, identityadoptiondecision.EdgeIdentity)
- }
- return edges
- }
- // AddedIDs returns all IDs (to other nodes) that were added for the given edge
- // name in this mutation.
- func (m *IdentityAdoptionDecisionMutation) AddedIDs(name string) []ent.Value {
- switch name {
- case identityadoptiondecision.EdgePendingAuthSession:
- if id := m.pending_auth_session; id != nil {
- return []ent.Value{*id}
- }
- case identityadoptiondecision.EdgeIdentity:
- if id := m.identity; id != nil {
- return []ent.Value{*id}
- }
- }
- return nil
- }
- // RemovedEdges returns all edge names that were removed in this mutation.
- func (m *IdentityAdoptionDecisionMutation) RemovedEdges() []string {
- edges := make([]string, 0, 2)
- return edges
- }
- // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
- // the given name in this mutation.
- func (m *IdentityAdoptionDecisionMutation) RemovedIDs(name string) []ent.Value {
- return nil
- }
- // ClearedEdges returns all edge names that were cleared in this mutation.
- func (m *IdentityAdoptionDecisionMutation) ClearedEdges() []string {
- edges := make([]string, 0, 2)
- if m.clearedpending_auth_session {
- edges = append(edges, identityadoptiondecision.EdgePendingAuthSession)
- }
- if m.clearedidentity {
- edges = append(edges, identityadoptiondecision.EdgeIdentity)
- }
- return edges
- }
- // EdgeCleared returns a boolean which indicates if the edge with the given name
- // was cleared in this mutation.
- func (m *IdentityAdoptionDecisionMutation) EdgeCleared(name string) bool {
- switch name {
- case identityadoptiondecision.EdgePendingAuthSession:
- return m.clearedpending_auth_session
- case identityadoptiondecision.EdgeIdentity:
- return m.clearedidentity
- }
- return false
- }
- // ClearEdge clears the value of the edge with the given name. It returns an error
- // if that edge is not defined in the schema.
- func (m *IdentityAdoptionDecisionMutation) ClearEdge(name string) error {
- switch name {
- case identityadoptiondecision.EdgePendingAuthSession:
- m.ClearPendingAuthSession()
- return nil
- case identityadoptiondecision.EdgeIdentity:
- m.ClearIdentity()
- return nil
- }
- return fmt.Errorf("unknown IdentityAdoptionDecision unique edge %s", name)
- }
- // ResetEdge resets all changes to the edge with the given name in this mutation.
- // It returns an error if the edge is not defined in the schema.
- func (m *IdentityAdoptionDecisionMutation) ResetEdge(name string) error {
- switch name {
- case identityadoptiondecision.EdgePendingAuthSession:
- m.ResetPendingAuthSession()
- return nil
- case identityadoptiondecision.EdgeIdentity:
- m.ResetIdentity()
- return nil
- }
- return fmt.Errorf("unknown IdentityAdoptionDecision edge %s", name)
- }
- // PaymentAuditLogMutation represents an operation that mutates the PaymentAuditLog nodes in the graph.
- type PaymentAuditLogMutation struct {
- config
- op Op
- typ string
- id *int64
- order_id *string
- action *string
- detail *string
- operator *string
- created_at *time.Time
- clearedFields map[string]struct{}
- done bool
- oldValue func(context.Context) (*PaymentAuditLog, error)
- predicates []predicate.PaymentAuditLog
- }
- var _ ent.Mutation = (*PaymentAuditLogMutation)(nil)
- // paymentauditlogOption allows management of the mutation configuration using functional options.
- type paymentauditlogOption func(*PaymentAuditLogMutation)
- // newPaymentAuditLogMutation creates new mutation for the PaymentAuditLog entity.
- func newPaymentAuditLogMutation(c config, op Op, opts ...paymentauditlogOption) *PaymentAuditLogMutation {
- m := &PaymentAuditLogMutation{
- config: c,
- op: op,
- typ: TypePaymentAuditLog,
- clearedFields: make(map[string]struct{}),
- }
- for _, opt := range opts {
- opt(m)
- }
- return m
- }
- // withPaymentAuditLogID sets the ID field of the mutation.
- func withPaymentAuditLogID(id int64) paymentauditlogOption {
- return func(m *PaymentAuditLogMutation) {
- var (
- err error
- once sync.Once
- value *PaymentAuditLog
- )
- m.oldValue = func(ctx context.Context) (*PaymentAuditLog, error) {
- once.Do(func() {
- if m.done {
- err = errors.New("querying old values post mutation is not allowed")
- } else {
- value, err = m.Client().PaymentAuditLog.Get(ctx, id)
- }
- })
- return value, err
- }
- m.id = &id
- }
- }
- // withPaymentAuditLog sets the old PaymentAuditLog of the mutation.
- func withPaymentAuditLog(node *PaymentAuditLog) paymentauditlogOption {
- return func(m *PaymentAuditLogMutation) {
- m.oldValue = func(context.Context) (*PaymentAuditLog, error) {
- return node, nil
- }
- m.id = &node.ID
- }
- }
- // Client returns a new `ent.Client` from the mutation. If the mutation was
- // executed in a transaction (ent.Tx), a transactional client is returned.
- func (m PaymentAuditLogMutation) Client() *Client {
- client := &Client{config: m.config}
- client.init()
- return client
- }
- // Tx returns an `ent.Tx` for mutations that were executed in transactions;
- // it returns an error otherwise.
- func (m PaymentAuditLogMutation) Tx() (*Tx, error) {
- if _, ok := m.driver.(*txDriver); !ok {
- return nil, errors.New("ent: mutation is not running in a transaction")
- }
- tx := &Tx{config: m.config}
- tx.init()
- return tx, nil
- }
- // ID returns the ID value in the mutation. Note that the ID is only available
- // if it was provided to the builder or after it was returned from the database.
- func (m *PaymentAuditLogMutation) ID() (id int64, exists bool) {
- if m.id == nil {
- return
- }
- return *m.id, true
- }
- // IDs queries the database and returns the entity ids that match the mutation's predicate.
- // That means, if the mutation is applied within a transaction with an isolation level such
- // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
- // or updated by the mutation.
- func (m *PaymentAuditLogMutation) IDs(ctx context.Context) ([]int64, error) {
- switch {
- case m.op.Is(OpUpdateOne | OpDeleteOne):
- id, exists := m.ID()
- if exists {
- return []int64{id}, nil
- }
- fallthrough
- case m.op.Is(OpUpdate | OpDelete):
- return m.Client().PaymentAuditLog.Query().Where(m.predicates...).IDs(ctx)
- default:
- return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
- }
- }
- // SetOrderID sets the "order_id" field.
- func (m *PaymentAuditLogMutation) SetOrderID(s string) {
- m.order_id = &s
- }
- // OrderID returns the value of the "order_id" field in the mutation.
- func (m *PaymentAuditLogMutation) OrderID() (r string, exists bool) {
- v := m.order_id
- if v == nil {
- return
- }
- return *v, true
- }
- // OldOrderID returns the old "order_id" field's value of the PaymentAuditLog entity.
- // If the PaymentAuditLog object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *PaymentAuditLogMutation) OldOrderID(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldOrderID is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldOrderID requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldOrderID: %w", err)
- }
- return oldValue.OrderID, nil
- }
- // ResetOrderID resets all changes to the "order_id" field.
- func (m *PaymentAuditLogMutation) ResetOrderID() {
- m.order_id = nil
- }
- // SetAction sets the "action" field.
- func (m *PaymentAuditLogMutation) SetAction(s string) {
- m.action = &s
- }
- // Action returns the value of the "action" field in the mutation.
- func (m *PaymentAuditLogMutation) Action() (r string, exists bool) {
- v := m.action
- if v == nil {
- return
- }
- return *v, true
- }
- // OldAction returns the old "action" field's value of the PaymentAuditLog entity.
- // If the PaymentAuditLog object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *PaymentAuditLogMutation) OldAction(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldAction is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldAction requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldAction: %w", err)
- }
- return oldValue.Action, nil
- }
- // ResetAction resets all changes to the "action" field.
- func (m *PaymentAuditLogMutation) ResetAction() {
- m.action = nil
- }
- // SetDetail sets the "detail" field.
- func (m *PaymentAuditLogMutation) SetDetail(s string) {
- m.detail = &s
- }
- // Detail returns the value of the "detail" field in the mutation.
- func (m *PaymentAuditLogMutation) Detail() (r string, exists bool) {
- v := m.detail
- if v == nil {
- return
- }
- return *v, true
- }
- // OldDetail returns the old "detail" field's value of the PaymentAuditLog entity.
- // If the PaymentAuditLog object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *PaymentAuditLogMutation) OldDetail(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldDetail is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldDetail requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldDetail: %w", err)
- }
- return oldValue.Detail, nil
- }
- // ResetDetail resets all changes to the "detail" field.
- func (m *PaymentAuditLogMutation) ResetDetail() {
- m.detail = nil
- }
- // SetOperator sets the "operator" field.
- func (m *PaymentAuditLogMutation) SetOperator(s string) {
- m.operator = &s
- }
- // Operator returns the value of the "operator" field in the mutation.
- func (m *PaymentAuditLogMutation) Operator() (r string, exists bool) {
- v := m.operator
- if v == nil {
- return
- }
- return *v, true
- }
- // OldOperator returns the old "operator" field's value of the PaymentAuditLog entity.
- // If the PaymentAuditLog object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *PaymentAuditLogMutation) OldOperator(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldOperator is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldOperator requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldOperator: %w", err)
- }
- return oldValue.Operator, nil
- }
- // ResetOperator resets all changes to the "operator" field.
- func (m *PaymentAuditLogMutation) ResetOperator() {
- m.operator = nil
- }
- // SetCreatedAt sets the "created_at" field.
- func (m *PaymentAuditLogMutation) SetCreatedAt(t time.Time) {
- m.created_at = &t
- }
- // CreatedAt returns the value of the "created_at" field in the mutation.
- func (m *PaymentAuditLogMutation) CreatedAt() (r time.Time, exists bool) {
- v := m.created_at
- if v == nil {
- return
- }
- return *v, true
- }
- // OldCreatedAt returns the old "created_at" field's value of the PaymentAuditLog entity.
- // If the PaymentAuditLog object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *PaymentAuditLogMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldCreatedAt requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
- }
- return oldValue.CreatedAt, nil
- }
- // ResetCreatedAt resets all changes to the "created_at" field.
- func (m *PaymentAuditLogMutation) ResetCreatedAt() {
- m.created_at = nil
- }
- // Where appends a list predicates to the PaymentAuditLogMutation builder.
- func (m *PaymentAuditLogMutation) Where(ps ...predicate.PaymentAuditLog) {
- m.predicates = append(m.predicates, ps...)
- }
- // WhereP appends storage-level predicates to the PaymentAuditLogMutation builder. Using this method,
- // users can use type-assertion to append predicates that do not depend on any generated package.
- func (m *PaymentAuditLogMutation) WhereP(ps ...func(*sql.Selector)) {
- p := make([]predicate.PaymentAuditLog, len(ps))
- for i := range ps {
- p[i] = ps[i]
- }
- m.Where(p...)
- }
- // Op returns the operation name.
- func (m *PaymentAuditLogMutation) Op() Op {
- return m.op
- }
- // SetOp allows setting the mutation operation.
- func (m *PaymentAuditLogMutation) SetOp(op Op) {
- m.op = op
- }
- // Type returns the node type of this mutation (PaymentAuditLog).
- func (m *PaymentAuditLogMutation) Type() string {
- return m.typ
- }
- // Fields returns all fields that were changed during this mutation. Note that in
- // order to get all numeric fields that were incremented/decremented, call
- // AddedFields().
- func (m *PaymentAuditLogMutation) Fields() []string {
- fields := make([]string, 0, 5)
- if m.order_id != nil {
- fields = append(fields, paymentauditlog.FieldOrderID)
- }
- if m.action != nil {
- fields = append(fields, paymentauditlog.FieldAction)
- }
- if m.detail != nil {
- fields = append(fields, paymentauditlog.FieldDetail)
- }
- if m.operator != nil {
- fields = append(fields, paymentauditlog.FieldOperator)
- }
- if m.created_at != nil {
- fields = append(fields, paymentauditlog.FieldCreatedAt)
- }
- return fields
- }
- // Field returns the value of a field with the given name. The second boolean
- // return value indicates that this field was not set, or was not defined in the
- // schema.
- func (m *PaymentAuditLogMutation) Field(name string) (ent.Value, bool) {
- switch name {
- case paymentauditlog.FieldOrderID:
- return m.OrderID()
- case paymentauditlog.FieldAction:
- return m.Action()
- case paymentauditlog.FieldDetail:
- return m.Detail()
- case paymentauditlog.FieldOperator:
- return m.Operator()
- case paymentauditlog.FieldCreatedAt:
- return m.CreatedAt()
- }
- return nil, false
- }
- // OldField returns the old value of the field from the database. An error is
- // returned if the mutation operation is not UpdateOne, or the query to the
- // database failed.
- func (m *PaymentAuditLogMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
- switch name {
- case paymentauditlog.FieldOrderID:
- return m.OldOrderID(ctx)
- case paymentauditlog.FieldAction:
- return m.OldAction(ctx)
- case paymentauditlog.FieldDetail:
- return m.OldDetail(ctx)
- case paymentauditlog.FieldOperator:
- return m.OldOperator(ctx)
- case paymentauditlog.FieldCreatedAt:
- return m.OldCreatedAt(ctx)
- }
- return nil, fmt.Errorf("unknown PaymentAuditLog field %s", name)
- }
- // SetField sets the value of a field with the given name. It returns an error if
- // the field is not defined in the schema, or if the type mismatched the field
- // type.
- func (m *PaymentAuditLogMutation) SetField(name string, value ent.Value) error {
- switch name {
- case paymentauditlog.FieldOrderID:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetOrderID(v)
- return nil
- case paymentauditlog.FieldAction:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetAction(v)
- return nil
- case paymentauditlog.FieldDetail:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetDetail(v)
- return nil
- case paymentauditlog.FieldOperator:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetOperator(v)
- return nil
- case paymentauditlog.FieldCreatedAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetCreatedAt(v)
- return nil
- }
- return fmt.Errorf("unknown PaymentAuditLog field %s", name)
- }
- // AddedFields returns all numeric fields that were incremented/decremented during
- // this mutation.
- func (m *PaymentAuditLogMutation) AddedFields() []string {
- return nil
- }
- // AddedField returns the numeric value that was incremented/decremented on a field
- // with the given name. The second boolean return value indicates that this field
- // was not set, or was not defined in the schema.
- func (m *PaymentAuditLogMutation) AddedField(name string) (ent.Value, bool) {
- return nil, false
- }
- // AddField adds the value to the field with the given name. It returns an error if
- // the field is not defined in the schema, or if the type mismatched the field
- // type.
- func (m *PaymentAuditLogMutation) AddField(name string, value ent.Value) error {
- switch name {
- }
- return fmt.Errorf("unknown PaymentAuditLog numeric field %s", name)
- }
- // ClearedFields returns all nullable fields that were cleared during this
- // mutation.
- func (m *PaymentAuditLogMutation) ClearedFields() []string {
- return nil
- }
- // FieldCleared returns a boolean indicating if a field with the given name was
- // cleared in this mutation.
- func (m *PaymentAuditLogMutation) FieldCleared(name string) bool {
- _, ok := m.clearedFields[name]
- return ok
- }
- // ClearField clears the value of the field with the given name. It returns an
- // error if the field is not defined in the schema.
- func (m *PaymentAuditLogMutation) ClearField(name string) error {
- return fmt.Errorf("unknown PaymentAuditLog nullable field %s", name)
- }
- // ResetField resets all changes in the mutation for the field with the given name.
- // It returns an error if the field is not defined in the schema.
- func (m *PaymentAuditLogMutation) ResetField(name string) error {
- switch name {
- case paymentauditlog.FieldOrderID:
- m.ResetOrderID()
- return nil
- case paymentauditlog.FieldAction:
- m.ResetAction()
- return nil
- case paymentauditlog.FieldDetail:
- m.ResetDetail()
- return nil
- case paymentauditlog.FieldOperator:
- m.ResetOperator()
- return nil
- case paymentauditlog.FieldCreatedAt:
- m.ResetCreatedAt()
- return nil
- }
- return fmt.Errorf("unknown PaymentAuditLog field %s", name)
- }
- // AddedEdges returns all edge names that were set/added in this mutation.
- func (m *PaymentAuditLogMutation) AddedEdges() []string {
- edges := make([]string, 0, 0)
- return edges
- }
- // AddedIDs returns all IDs (to other nodes) that were added for the given edge
- // name in this mutation.
- func (m *PaymentAuditLogMutation) AddedIDs(name string) []ent.Value {
- return nil
- }
- // RemovedEdges returns all edge names that were removed in this mutation.
- func (m *PaymentAuditLogMutation) RemovedEdges() []string {
- edges := make([]string, 0, 0)
- return edges
- }
- // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
- // the given name in this mutation.
- func (m *PaymentAuditLogMutation) RemovedIDs(name string) []ent.Value {
- return nil
- }
- // ClearedEdges returns all edge names that were cleared in this mutation.
- func (m *PaymentAuditLogMutation) ClearedEdges() []string {
- edges := make([]string, 0, 0)
- return edges
- }
- // EdgeCleared returns a boolean which indicates if the edge with the given name
- // was cleared in this mutation.
- func (m *PaymentAuditLogMutation) EdgeCleared(name string) bool {
- return false
- }
- // ClearEdge clears the value of the edge with the given name. It returns an error
- // if that edge is not defined in the schema.
- func (m *PaymentAuditLogMutation) ClearEdge(name string) error {
- return fmt.Errorf("unknown PaymentAuditLog unique edge %s", name)
- }
- // ResetEdge resets all changes to the edge with the given name in this mutation.
- // It returns an error if the edge is not defined in the schema.
- func (m *PaymentAuditLogMutation) ResetEdge(name string) error {
- return fmt.Errorf("unknown PaymentAuditLog edge %s", name)
- }
- // PaymentOrderMutation represents an operation that mutates the PaymentOrder nodes in the graph.
- type PaymentOrderMutation struct {
- config
- op Op
- typ string
- id *int64
- user_email *string
- user_name *string
- user_notes *string
- amount *float64
- addamount *float64
- pay_amount *float64
- addpay_amount *float64
- fee_rate *float64
- addfee_rate *float64
- recharge_code *string
- out_trade_no *string
- payment_type *string
- payment_trade_no *string
- pay_url *string
- qr_code *string
- qr_code_img *string
- order_type *string
- plan_id *int64
- addplan_id *int64
- subscription_group_id *int64
- addsubscription_group_id *int64
- subscription_days *int
- addsubscription_days *int
- provider_instance_id *string
- provider_key *string
- provider_snapshot *map[string]interface{}
- status *string
- refund_amount *float64
- addrefund_amount *float64
- refund_reason *string
- refund_at *time.Time
- force_refund *bool
- refund_requested_at *time.Time
- refund_request_reason *string
- refund_requested_by *string
- expires_at *time.Time
- paid_at *time.Time
- completed_at *time.Time
- failed_at *time.Time
- failed_reason *string
- client_ip *string
- src_host *string
- src_url *string
- created_at *time.Time
- updated_at *time.Time
- clearedFields map[string]struct{}
- user *int64
- cleareduser bool
- done bool
- oldValue func(context.Context) (*PaymentOrder, error)
- predicates []predicate.PaymentOrder
- }
- var _ ent.Mutation = (*PaymentOrderMutation)(nil)
- // paymentorderOption allows management of the mutation configuration using functional options.
- type paymentorderOption func(*PaymentOrderMutation)
- // newPaymentOrderMutation creates new mutation for the PaymentOrder entity.
- func newPaymentOrderMutation(c config, op Op, opts ...paymentorderOption) *PaymentOrderMutation {
- m := &PaymentOrderMutation{
- config: c,
- op: op,
- typ: TypePaymentOrder,
- clearedFields: make(map[string]struct{}),
- }
- for _, opt := range opts {
- opt(m)
- }
- return m
- }
- // withPaymentOrderID sets the ID field of the mutation.
- func withPaymentOrderID(id int64) paymentorderOption {
- return func(m *PaymentOrderMutation) {
- var (
- err error
- once sync.Once
- value *PaymentOrder
- )
- m.oldValue = func(ctx context.Context) (*PaymentOrder, error) {
- once.Do(func() {
- if m.done {
- err = errors.New("querying old values post mutation is not allowed")
- } else {
- value, err = m.Client().PaymentOrder.Get(ctx, id)
- }
- })
- return value, err
- }
- m.id = &id
- }
- }
- // withPaymentOrder sets the old PaymentOrder of the mutation.
- func withPaymentOrder(node *PaymentOrder) paymentorderOption {
- return func(m *PaymentOrderMutation) {
- m.oldValue = func(context.Context) (*PaymentOrder, error) {
- return node, nil
- }
- m.id = &node.ID
- }
- }
- // Client returns a new `ent.Client` from the mutation. If the mutation was
- // executed in a transaction (ent.Tx), a transactional client is returned.
- func (m PaymentOrderMutation) Client() *Client {
- client := &Client{config: m.config}
- client.init()
- return client
- }
- // Tx returns an `ent.Tx` for mutations that were executed in transactions;
- // it returns an error otherwise.
- func (m PaymentOrderMutation) Tx() (*Tx, error) {
- if _, ok := m.driver.(*txDriver); !ok {
- return nil, errors.New("ent: mutation is not running in a transaction")
- }
- tx := &Tx{config: m.config}
- tx.init()
- return tx, nil
- }
- // ID returns the ID value in the mutation. Note that the ID is only available
- // if it was provided to the builder or after it was returned from the database.
- func (m *PaymentOrderMutation) ID() (id int64, exists bool) {
- if m.id == nil {
- return
- }
- return *m.id, true
- }
- // IDs queries the database and returns the entity ids that match the mutation's predicate.
- // That means, if the mutation is applied within a transaction with an isolation level such
- // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
- // or updated by the mutation.
- func (m *PaymentOrderMutation) IDs(ctx context.Context) ([]int64, error) {
- switch {
- case m.op.Is(OpUpdateOne | OpDeleteOne):
- id, exists := m.ID()
- if exists {
- return []int64{id}, nil
- }
- fallthrough
- case m.op.Is(OpUpdate | OpDelete):
- return m.Client().PaymentOrder.Query().Where(m.predicates...).IDs(ctx)
- default:
- return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
- }
- }
- // SetUserID sets the "user_id" field.
- func (m *PaymentOrderMutation) SetUserID(i int64) {
- m.user = &i
- }
- // UserID returns the value of the "user_id" field in the mutation.
- func (m *PaymentOrderMutation) UserID() (r int64, exists bool) {
- v := m.user
- if v == nil {
- return
- }
- return *v, true
- }
- // OldUserID returns the old "user_id" field's value of the PaymentOrder entity.
- // If the PaymentOrder object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *PaymentOrderMutation) OldUserID(ctx context.Context) (v int64, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldUserID is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldUserID requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldUserID: %w", err)
- }
- return oldValue.UserID, nil
- }
- // ResetUserID resets all changes to the "user_id" field.
- func (m *PaymentOrderMutation) ResetUserID() {
- m.user = nil
- }
- // SetUserEmail sets the "user_email" field.
- func (m *PaymentOrderMutation) SetUserEmail(s string) {
- m.user_email = &s
- }
- // UserEmail returns the value of the "user_email" field in the mutation.
- func (m *PaymentOrderMutation) UserEmail() (r string, exists bool) {
- v := m.user_email
- if v == nil {
- return
- }
- return *v, true
- }
- // OldUserEmail returns the old "user_email" field's value of the PaymentOrder entity.
- // If the PaymentOrder object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *PaymentOrderMutation) OldUserEmail(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldUserEmail is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldUserEmail requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldUserEmail: %w", err)
- }
- return oldValue.UserEmail, nil
- }
- // ResetUserEmail resets all changes to the "user_email" field.
- func (m *PaymentOrderMutation) ResetUserEmail() {
- m.user_email = nil
- }
- // SetUserName sets the "user_name" field.
- func (m *PaymentOrderMutation) SetUserName(s string) {
- m.user_name = &s
- }
- // UserName returns the value of the "user_name" field in the mutation.
- func (m *PaymentOrderMutation) UserName() (r string, exists bool) {
- v := m.user_name
- if v == nil {
- return
- }
- return *v, true
- }
- // OldUserName returns the old "user_name" field's value of the PaymentOrder entity.
- // If the PaymentOrder object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *PaymentOrderMutation) OldUserName(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldUserName is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldUserName requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldUserName: %w", err)
- }
- return oldValue.UserName, nil
- }
- // ResetUserName resets all changes to the "user_name" field.
- func (m *PaymentOrderMutation) ResetUserName() {
- m.user_name = nil
- }
- // SetUserNotes sets the "user_notes" field.
- func (m *PaymentOrderMutation) SetUserNotes(s string) {
- m.user_notes = &s
- }
- // UserNotes returns the value of the "user_notes" field in the mutation.
- func (m *PaymentOrderMutation) UserNotes() (r string, exists bool) {
- v := m.user_notes
- if v == nil {
- return
- }
- return *v, true
- }
- // OldUserNotes returns the old "user_notes" field's value of the PaymentOrder entity.
- // If the PaymentOrder object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *PaymentOrderMutation) OldUserNotes(ctx context.Context) (v *string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldUserNotes is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldUserNotes requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldUserNotes: %w", err)
- }
- return oldValue.UserNotes, nil
- }
- // ClearUserNotes clears the value of the "user_notes" field.
- func (m *PaymentOrderMutation) ClearUserNotes() {
- m.user_notes = nil
- m.clearedFields[paymentorder.FieldUserNotes] = struct{}{}
- }
- // UserNotesCleared returns if the "user_notes" field was cleared in this mutation.
- func (m *PaymentOrderMutation) UserNotesCleared() bool {
- _, ok := m.clearedFields[paymentorder.FieldUserNotes]
- return ok
- }
- // ResetUserNotes resets all changes to the "user_notes" field.
- func (m *PaymentOrderMutation) ResetUserNotes() {
- m.user_notes = nil
- delete(m.clearedFields, paymentorder.FieldUserNotes)
- }
- // SetAmount sets the "amount" field.
- func (m *PaymentOrderMutation) SetAmount(f float64) {
- m.amount = &f
- m.addamount = nil
- }
- // Amount returns the value of the "amount" field in the mutation.
- func (m *PaymentOrderMutation) Amount() (r float64, exists bool) {
- v := m.amount
- if v == nil {
- return
- }
- return *v, true
- }
- // OldAmount returns the old "amount" field's value of the PaymentOrder entity.
- // If the PaymentOrder object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *PaymentOrderMutation) OldAmount(ctx context.Context) (v float64, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldAmount is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldAmount requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldAmount: %w", err)
- }
- return oldValue.Amount, nil
- }
- // AddAmount adds f to the "amount" field.
- func (m *PaymentOrderMutation) AddAmount(f float64) {
- if m.addamount != nil {
- *m.addamount += f
- } else {
- m.addamount = &f
- }
- }
- // AddedAmount returns the value that was added to the "amount" field in this mutation.
- func (m *PaymentOrderMutation) AddedAmount() (r float64, exists bool) {
- v := m.addamount
- if v == nil {
- return
- }
- return *v, true
- }
- // ResetAmount resets all changes to the "amount" field.
- func (m *PaymentOrderMutation) ResetAmount() {
- m.amount = nil
- m.addamount = nil
- }
- // SetPayAmount sets the "pay_amount" field.
- func (m *PaymentOrderMutation) SetPayAmount(f float64) {
- m.pay_amount = &f
- m.addpay_amount = nil
- }
- // PayAmount returns the value of the "pay_amount" field in the mutation.
- func (m *PaymentOrderMutation) PayAmount() (r float64, exists bool) {
- v := m.pay_amount
- if v == nil {
- return
- }
- return *v, true
- }
- // OldPayAmount returns the old "pay_amount" field's value of the PaymentOrder entity.
- // If the PaymentOrder object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *PaymentOrderMutation) OldPayAmount(ctx context.Context) (v float64, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldPayAmount is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldPayAmount requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldPayAmount: %w", err)
- }
- return oldValue.PayAmount, nil
- }
- // AddPayAmount adds f to the "pay_amount" field.
- func (m *PaymentOrderMutation) AddPayAmount(f float64) {
- if m.addpay_amount != nil {
- *m.addpay_amount += f
- } else {
- m.addpay_amount = &f
- }
- }
- // AddedPayAmount returns the value that was added to the "pay_amount" field in this mutation.
- func (m *PaymentOrderMutation) AddedPayAmount() (r float64, exists bool) {
- v := m.addpay_amount
- if v == nil {
- return
- }
- return *v, true
- }
- // ResetPayAmount resets all changes to the "pay_amount" field.
- func (m *PaymentOrderMutation) ResetPayAmount() {
- m.pay_amount = nil
- m.addpay_amount = nil
- }
- // SetFeeRate sets the "fee_rate" field.
- func (m *PaymentOrderMutation) SetFeeRate(f float64) {
- m.fee_rate = &f
- m.addfee_rate = nil
- }
- // FeeRate returns the value of the "fee_rate" field in the mutation.
- func (m *PaymentOrderMutation) FeeRate() (r float64, exists bool) {
- v := m.fee_rate
- if v == nil {
- return
- }
- return *v, true
- }
- // OldFeeRate returns the old "fee_rate" field's value of the PaymentOrder entity.
- // If the PaymentOrder object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *PaymentOrderMutation) OldFeeRate(ctx context.Context) (v float64, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldFeeRate is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldFeeRate requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldFeeRate: %w", err)
- }
- return oldValue.FeeRate, nil
- }
- // AddFeeRate adds f to the "fee_rate" field.
- func (m *PaymentOrderMutation) AddFeeRate(f float64) {
- if m.addfee_rate != nil {
- *m.addfee_rate += f
- } else {
- m.addfee_rate = &f
- }
- }
- // AddedFeeRate returns the value that was added to the "fee_rate" field in this mutation.
- func (m *PaymentOrderMutation) AddedFeeRate() (r float64, exists bool) {
- v := m.addfee_rate
- if v == nil {
- return
- }
- return *v, true
- }
- // ResetFeeRate resets all changes to the "fee_rate" field.
- func (m *PaymentOrderMutation) ResetFeeRate() {
- m.fee_rate = nil
- m.addfee_rate = nil
- }
- // SetRechargeCode sets the "recharge_code" field.
- func (m *PaymentOrderMutation) SetRechargeCode(s string) {
- m.recharge_code = &s
- }
- // RechargeCode returns the value of the "recharge_code" field in the mutation.
- func (m *PaymentOrderMutation) RechargeCode() (r string, exists bool) {
- v := m.recharge_code
- if v == nil {
- return
- }
- return *v, true
- }
- // OldRechargeCode returns the old "recharge_code" field's value of the PaymentOrder entity.
- // If the PaymentOrder object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *PaymentOrderMutation) OldRechargeCode(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldRechargeCode is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldRechargeCode requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldRechargeCode: %w", err)
- }
- return oldValue.RechargeCode, nil
- }
- // ResetRechargeCode resets all changes to the "recharge_code" field.
- func (m *PaymentOrderMutation) ResetRechargeCode() {
- m.recharge_code = nil
- }
- // SetOutTradeNo sets the "out_trade_no" field.
- func (m *PaymentOrderMutation) SetOutTradeNo(s string) {
- m.out_trade_no = &s
- }
- // OutTradeNo returns the value of the "out_trade_no" field in the mutation.
- func (m *PaymentOrderMutation) OutTradeNo() (r string, exists bool) {
- v := m.out_trade_no
- if v == nil {
- return
- }
- return *v, true
- }
- // OldOutTradeNo returns the old "out_trade_no" field's value of the PaymentOrder entity.
- // If the PaymentOrder object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *PaymentOrderMutation) OldOutTradeNo(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldOutTradeNo is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldOutTradeNo requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldOutTradeNo: %w", err)
- }
- return oldValue.OutTradeNo, nil
- }
- // ResetOutTradeNo resets all changes to the "out_trade_no" field.
- func (m *PaymentOrderMutation) ResetOutTradeNo() {
- m.out_trade_no = nil
- }
- // SetPaymentType sets the "payment_type" field.
- func (m *PaymentOrderMutation) SetPaymentType(s string) {
- m.payment_type = &s
- }
- // PaymentType returns the value of the "payment_type" field in the mutation.
- func (m *PaymentOrderMutation) PaymentType() (r string, exists bool) {
- v := m.payment_type
- if v == nil {
- return
- }
- return *v, true
- }
- // OldPaymentType returns the old "payment_type" field's value of the PaymentOrder entity.
- // If the PaymentOrder object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *PaymentOrderMutation) OldPaymentType(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldPaymentType is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldPaymentType requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldPaymentType: %w", err)
- }
- return oldValue.PaymentType, nil
- }
- // ResetPaymentType resets all changes to the "payment_type" field.
- func (m *PaymentOrderMutation) ResetPaymentType() {
- m.payment_type = nil
- }
- // SetPaymentTradeNo sets the "payment_trade_no" field.
- func (m *PaymentOrderMutation) SetPaymentTradeNo(s string) {
- m.payment_trade_no = &s
- }
- // PaymentTradeNo returns the value of the "payment_trade_no" field in the mutation.
- func (m *PaymentOrderMutation) PaymentTradeNo() (r string, exists bool) {
- v := m.payment_trade_no
- if v == nil {
- return
- }
- return *v, true
- }
- // OldPaymentTradeNo returns the old "payment_trade_no" field's value of the PaymentOrder entity.
- // If the PaymentOrder object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *PaymentOrderMutation) OldPaymentTradeNo(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldPaymentTradeNo is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldPaymentTradeNo requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldPaymentTradeNo: %w", err)
- }
- return oldValue.PaymentTradeNo, nil
- }
- // ResetPaymentTradeNo resets all changes to the "payment_trade_no" field.
- func (m *PaymentOrderMutation) ResetPaymentTradeNo() {
- m.payment_trade_no = nil
- }
- // SetPayURL sets the "pay_url" field.
- func (m *PaymentOrderMutation) SetPayURL(s string) {
- m.pay_url = &s
- }
- // PayURL returns the value of the "pay_url" field in the mutation.
- func (m *PaymentOrderMutation) PayURL() (r string, exists bool) {
- v := m.pay_url
- if v == nil {
- return
- }
- return *v, true
- }
- // OldPayURL returns the old "pay_url" field's value of the PaymentOrder entity.
- // If the PaymentOrder object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *PaymentOrderMutation) OldPayURL(ctx context.Context) (v *string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldPayURL is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldPayURL requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldPayURL: %w", err)
- }
- return oldValue.PayURL, nil
- }
- // ClearPayURL clears the value of the "pay_url" field.
- func (m *PaymentOrderMutation) ClearPayURL() {
- m.pay_url = nil
- m.clearedFields[paymentorder.FieldPayURL] = struct{}{}
- }
- // PayURLCleared returns if the "pay_url" field was cleared in this mutation.
- func (m *PaymentOrderMutation) PayURLCleared() bool {
- _, ok := m.clearedFields[paymentorder.FieldPayURL]
- return ok
- }
- // ResetPayURL resets all changes to the "pay_url" field.
- func (m *PaymentOrderMutation) ResetPayURL() {
- m.pay_url = nil
- delete(m.clearedFields, paymentorder.FieldPayURL)
- }
- // SetQrCode sets the "qr_code" field.
- func (m *PaymentOrderMutation) SetQrCode(s string) {
- m.qr_code = &s
- }
- // QrCode returns the value of the "qr_code" field in the mutation.
- func (m *PaymentOrderMutation) QrCode() (r string, exists bool) {
- v := m.qr_code
- if v == nil {
- return
- }
- return *v, true
- }
- // OldQrCode returns the old "qr_code" field's value of the PaymentOrder entity.
- // If the PaymentOrder object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *PaymentOrderMutation) OldQrCode(ctx context.Context) (v *string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldQrCode is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldQrCode requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldQrCode: %w", err)
- }
- return oldValue.QrCode, nil
- }
- // ClearQrCode clears the value of the "qr_code" field.
- func (m *PaymentOrderMutation) ClearQrCode() {
- m.qr_code = nil
- m.clearedFields[paymentorder.FieldQrCode] = struct{}{}
- }
- // QrCodeCleared returns if the "qr_code" field was cleared in this mutation.
- func (m *PaymentOrderMutation) QrCodeCleared() bool {
- _, ok := m.clearedFields[paymentorder.FieldQrCode]
- return ok
- }
- // ResetQrCode resets all changes to the "qr_code" field.
- func (m *PaymentOrderMutation) ResetQrCode() {
- m.qr_code = nil
- delete(m.clearedFields, paymentorder.FieldQrCode)
- }
- // SetQrCodeImg sets the "qr_code_img" field.
- func (m *PaymentOrderMutation) SetQrCodeImg(s string) {
- m.qr_code_img = &s
- }
- // QrCodeImg returns the value of the "qr_code_img" field in the mutation.
- func (m *PaymentOrderMutation) QrCodeImg() (r string, exists bool) {
- v := m.qr_code_img
- if v == nil {
- return
- }
- return *v, true
- }
- // OldQrCodeImg returns the old "qr_code_img" field's value of the PaymentOrder entity.
- // If the PaymentOrder object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *PaymentOrderMutation) OldQrCodeImg(ctx context.Context) (v *string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldQrCodeImg is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldQrCodeImg requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldQrCodeImg: %w", err)
- }
- return oldValue.QrCodeImg, nil
- }
- // ClearQrCodeImg clears the value of the "qr_code_img" field.
- func (m *PaymentOrderMutation) ClearQrCodeImg() {
- m.qr_code_img = nil
- m.clearedFields[paymentorder.FieldQrCodeImg] = struct{}{}
- }
- // QrCodeImgCleared returns if the "qr_code_img" field was cleared in this mutation.
- func (m *PaymentOrderMutation) QrCodeImgCleared() bool {
- _, ok := m.clearedFields[paymentorder.FieldQrCodeImg]
- return ok
- }
- // ResetQrCodeImg resets all changes to the "qr_code_img" field.
- func (m *PaymentOrderMutation) ResetQrCodeImg() {
- m.qr_code_img = nil
- delete(m.clearedFields, paymentorder.FieldQrCodeImg)
- }
- // SetOrderType sets the "order_type" field.
- func (m *PaymentOrderMutation) SetOrderType(s string) {
- m.order_type = &s
- }
- // OrderType returns the value of the "order_type" field in the mutation.
- func (m *PaymentOrderMutation) OrderType() (r string, exists bool) {
- v := m.order_type
- if v == nil {
- return
- }
- return *v, true
- }
- // OldOrderType returns the old "order_type" field's value of the PaymentOrder entity.
- // If the PaymentOrder object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *PaymentOrderMutation) OldOrderType(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldOrderType is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldOrderType requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldOrderType: %w", err)
- }
- return oldValue.OrderType, nil
- }
- // ResetOrderType resets all changes to the "order_type" field.
- func (m *PaymentOrderMutation) ResetOrderType() {
- m.order_type = nil
- }
- // SetPlanID sets the "plan_id" field.
- func (m *PaymentOrderMutation) SetPlanID(i int64) {
- m.plan_id = &i
- m.addplan_id = nil
- }
- // PlanID returns the value of the "plan_id" field in the mutation.
- func (m *PaymentOrderMutation) PlanID() (r int64, exists bool) {
- v := m.plan_id
- if v == nil {
- return
- }
- return *v, true
- }
- // OldPlanID returns the old "plan_id" field's value of the PaymentOrder entity.
- // If the PaymentOrder object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *PaymentOrderMutation) OldPlanID(ctx context.Context) (v *int64, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldPlanID is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldPlanID requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldPlanID: %w", err)
- }
- return oldValue.PlanID, nil
- }
- // AddPlanID adds i to the "plan_id" field.
- func (m *PaymentOrderMutation) AddPlanID(i int64) {
- if m.addplan_id != nil {
- *m.addplan_id += i
- } else {
- m.addplan_id = &i
- }
- }
- // AddedPlanID returns the value that was added to the "plan_id" field in this mutation.
- func (m *PaymentOrderMutation) AddedPlanID() (r int64, exists bool) {
- v := m.addplan_id
- if v == nil {
- return
- }
- return *v, true
- }
- // ClearPlanID clears the value of the "plan_id" field.
- func (m *PaymentOrderMutation) ClearPlanID() {
- m.plan_id = nil
- m.addplan_id = nil
- m.clearedFields[paymentorder.FieldPlanID] = struct{}{}
- }
- // PlanIDCleared returns if the "plan_id" field was cleared in this mutation.
- func (m *PaymentOrderMutation) PlanIDCleared() bool {
- _, ok := m.clearedFields[paymentorder.FieldPlanID]
- return ok
- }
- // ResetPlanID resets all changes to the "plan_id" field.
- func (m *PaymentOrderMutation) ResetPlanID() {
- m.plan_id = nil
- m.addplan_id = nil
- delete(m.clearedFields, paymentorder.FieldPlanID)
- }
- // SetSubscriptionGroupID sets the "subscription_group_id" field.
- func (m *PaymentOrderMutation) SetSubscriptionGroupID(i int64) {
- m.subscription_group_id = &i
- m.addsubscription_group_id = nil
- }
- // SubscriptionGroupID returns the value of the "subscription_group_id" field in the mutation.
- func (m *PaymentOrderMutation) SubscriptionGroupID() (r int64, exists bool) {
- v := m.subscription_group_id
- if v == nil {
- return
- }
- return *v, true
- }
- // OldSubscriptionGroupID returns the old "subscription_group_id" field's value of the PaymentOrder entity.
- // If the PaymentOrder object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *PaymentOrderMutation) OldSubscriptionGroupID(ctx context.Context) (v *int64, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldSubscriptionGroupID is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldSubscriptionGroupID requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldSubscriptionGroupID: %w", err)
- }
- return oldValue.SubscriptionGroupID, nil
- }
- // AddSubscriptionGroupID adds i to the "subscription_group_id" field.
- func (m *PaymentOrderMutation) AddSubscriptionGroupID(i int64) {
- if m.addsubscription_group_id != nil {
- *m.addsubscription_group_id += i
- } else {
- m.addsubscription_group_id = &i
- }
- }
- // AddedSubscriptionGroupID returns the value that was added to the "subscription_group_id" field in this mutation.
- func (m *PaymentOrderMutation) AddedSubscriptionGroupID() (r int64, exists bool) {
- v := m.addsubscription_group_id
- if v == nil {
- return
- }
- return *v, true
- }
- // ClearSubscriptionGroupID clears the value of the "subscription_group_id" field.
- func (m *PaymentOrderMutation) ClearSubscriptionGroupID() {
- m.subscription_group_id = nil
- m.addsubscription_group_id = nil
- m.clearedFields[paymentorder.FieldSubscriptionGroupID] = struct{}{}
- }
- // SubscriptionGroupIDCleared returns if the "subscription_group_id" field was cleared in this mutation.
- func (m *PaymentOrderMutation) SubscriptionGroupIDCleared() bool {
- _, ok := m.clearedFields[paymentorder.FieldSubscriptionGroupID]
- return ok
- }
- // ResetSubscriptionGroupID resets all changes to the "subscription_group_id" field.
- func (m *PaymentOrderMutation) ResetSubscriptionGroupID() {
- m.subscription_group_id = nil
- m.addsubscription_group_id = nil
- delete(m.clearedFields, paymentorder.FieldSubscriptionGroupID)
- }
- // SetSubscriptionDays sets the "subscription_days" field.
- func (m *PaymentOrderMutation) SetSubscriptionDays(i int) {
- m.subscription_days = &i
- m.addsubscription_days = nil
- }
- // SubscriptionDays returns the value of the "subscription_days" field in the mutation.
- func (m *PaymentOrderMutation) SubscriptionDays() (r int, exists bool) {
- v := m.subscription_days
- if v == nil {
- return
- }
- return *v, true
- }
- // OldSubscriptionDays returns the old "subscription_days" field's value of the PaymentOrder entity.
- // If the PaymentOrder object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *PaymentOrderMutation) OldSubscriptionDays(ctx context.Context) (v *int, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldSubscriptionDays is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldSubscriptionDays requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldSubscriptionDays: %w", err)
- }
- return oldValue.SubscriptionDays, nil
- }
- // AddSubscriptionDays adds i to the "subscription_days" field.
- func (m *PaymentOrderMutation) AddSubscriptionDays(i int) {
- if m.addsubscription_days != nil {
- *m.addsubscription_days += i
- } else {
- m.addsubscription_days = &i
- }
- }
- // AddedSubscriptionDays returns the value that was added to the "subscription_days" field in this mutation.
- func (m *PaymentOrderMutation) AddedSubscriptionDays() (r int, exists bool) {
- v := m.addsubscription_days
- if v == nil {
- return
- }
- return *v, true
- }
- // ClearSubscriptionDays clears the value of the "subscription_days" field.
- func (m *PaymentOrderMutation) ClearSubscriptionDays() {
- m.subscription_days = nil
- m.addsubscription_days = nil
- m.clearedFields[paymentorder.FieldSubscriptionDays] = struct{}{}
- }
- // SubscriptionDaysCleared returns if the "subscription_days" field was cleared in this mutation.
- func (m *PaymentOrderMutation) SubscriptionDaysCleared() bool {
- _, ok := m.clearedFields[paymentorder.FieldSubscriptionDays]
- return ok
- }
- // ResetSubscriptionDays resets all changes to the "subscription_days" field.
- func (m *PaymentOrderMutation) ResetSubscriptionDays() {
- m.subscription_days = nil
- m.addsubscription_days = nil
- delete(m.clearedFields, paymentorder.FieldSubscriptionDays)
- }
- // SetProviderInstanceID sets the "provider_instance_id" field.
- func (m *PaymentOrderMutation) SetProviderInstanceID(s string) {
- m.provider_instance_id = &s
- }
- // ProviderInstanceID returns the value of the "provider_instance_id" field in the mutation.
- func (m *PaymentOrderMutation) ProviderInstanceID() (r string, exists bool) {
- v := m.provider_instance_id
- if v == nil {
- return
- }
- return *v, true
- }
- // OldProviderInstanceID returns the old "provider_instance_id" field's value of the PaymentOrder entity.
- // If the PaymentOrder object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *PaymentOrderMutation) OldProviderInstanceID(ctx context.Context) (v *string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldProviderInstanceID is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldProviderInstanceID requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldProviderInstanceID: %w", err)
- }
- return oldValue.ProviderInstanceID, nil
- }
- // ClearProviderInstanceID clears the value of the "provider_instance_id" field.
- func (m *PaymentOrderMutation) ClearProviderInstanceID() {
- m.provider_instance_id = nil
- m.clearedFields[paymentorder.FieldProviderInstanceID] = struct{}{}
- }
- // ProviderInstanceIDCleared returns if the "provider_instance_id" field was cleared in this mutation.
- func (m *PaymentOrderMutation) ProviderInstanceIDCleared() bool {
- _, ok := m.clearedFields[paymentorder.FieldProviderInstanceID]
- return ok
- }
- // ResetProviderInstanceID resets all changes to the "provider_instance_id" field.
- func (m *PaymentOrderMutation) ResetProviderInstanceID() {
- m.provider_instance_id = nil
- delete(m.clearedFields, paymentorder.FieldProviderInstanceID)
- }
- // SetProviderKey sets the "provider_key" field.
- func (m *PaymentOrderMutation) SetProviderKey(s string) {
- m.provider_key = &s
- }
- // ProviderKey returns the value of the "provider_key" field in the mutation.
- func (m *PaymentOrderMutation) ProviderKey() (r string, exists bool) {
- v := m.provider_key
- if v == nil {
- return
- }
- return *v, true
- }
- // OldProviderKey returns the old "provider_key" field's value of the PaymentOrder entity.
- // If the PaymentOrder object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *PaymentOrderMutation) OldProviderKey(ctx context.Context) (v *string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldProviderKey is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldProviderKey requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldProviderKey: %w", err)
- }
- return oldValue.ProviderKey, nil
- }
- // ClearProviderKey clears the value of the "provider_key" field.
- func (m *PaymentOrderMutation) ClearProviderKey() {
- m.provider_key = nil
- m.clearedFields[paymentorder.FieldProviderKey] = struct{}{}
- }
- // ProviderKeyCleared returns if the "provider_key" field was cleared in this mutation.
- func (m *PaymentOrderMutation) ProviderKeyCleared() bool {
- _, ok := m.clearedFields[paymentorder.FieldProviderKey]
- return ok
- }
- // ResetProviderKey resets all changes to the "provider_key" field.
- func (m *PaymentOrderMutation) ResetProviderKey() {
- m.provider_key = nil
- delete(m.clearedFields, paymentorder.FieldProviderKey)
- }
- // SetProviderSnapshot sets the "provider_snapshot" field.
- func (m *PaymentOrderMutation) SetProviderSnapshot(value map[string]interface{}) {
- m.provider_snapshot = &value
- }
- // ProviderSnapshot returns the value of the "provider_snapshot" field in the mutation.
- func (m *PaymentOrderMutation) ProviderSnapshot() (r map[string]interface{}, exists bool) {
- v := m.provider_snapshot
- if v == nil {
- return
- }
- return *v, true
- }
- // OldProviderSnapshot returns the old "provider_snapshot" field's value of the PaymentOrder entity.
- // If the PaymentOrder object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *PaymentOrderMutation) OldProviderSnapshot(ctx context.Context) (v map[string]interface{}, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldProviderSnapshot is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldProviderSnapshot requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldProviderSnapshot: %w", err)
- }
- return oldValue.ProviderSnapshot, nil
- }
- // ClearProviderSnapshot clears the value of the "provider_snapshot" field.
- func (m *PaymentOrderMutation) ClearProviderSnapshot() {
- m.provider_snapshot = nil
- m.clearedFields[paymentorder.FieldProviderSnapshot] = struct{}{}
- }
- // ProviderSnapshotCleared returns if the "provider_snapshot" field was cleared in this mutation.
- func (m *PaymentOrderMutation) ProviderSnapshotCleared() bool {
- _, ok := m.clearedFields[paymentorder.FieldProviderSnapshot]
- return ok
- }
- // ResetProviderSnapshot resets all changes to the "provider_snapshot" field.
- func (m *PaymentOrderMutation) ResetProviderSnapshot() {
- m.provider_snapshot = nil
- delete(m.clearedFields, paymentorder.FieldProviderSnapshot)
- }
- // SetStatus sets the "status" field.
- func (m *PaymentOrderMutation) SetStatus(s string) {
- m.status = &s
- }
- // Status returns the value of the "status" field in the mutation.
- func (m *PaymentOrderMutation) Status() (r string, exists bool) {
- v := m.status
- if v == nil {
- return
- }
- return *v, true
- }
- // OldStatus returns the old "status" field's value of the PaymentOrder entity.
- // If the PaymentOrder object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *PaymentOrderMutation) OldStatus(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldStatus is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldStatus requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldStatus: %w", err)
- }
- return oldValue.Status, nil
- }
- // ResetStatus resets all changes to the "status" field.
- func (m *PaymentOrderMutation) ResetStatus() {
- m.status = nil
- }
- // SetRefundAmount sets the "refund_amount" field.
- func (m *PaymentOrderMutation) SetRefundAmount(f float64) {
- m.refund_amount = &f
- m.addrefund_amount = nil
- }
- // RefundAmount returns the value of the "refund_amount" field in the mutation.
- func (m *PaymentOrderMutation) RefundAmount() (r float64, exists bool) {
- v := m.refund_amount
- if v == nil {
- return
- }
- return *v, true
- }
- // OldRefundAmount returns the old "refund_amount" field's value of the PaymentOrder entity.
- // If the PaymentOrder object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *PaymentOrderMutation) OldRefundAmount(ctx context.Context) (v float64, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldRefundAmount is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldRefundAmount requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldRefundAmount: %w", err)
- }
- return oldValue.RefundAmount, nil
- }
- // AddRefundAmount adds f to the "refund_amount" field.
- func (m *PaymentOrderMutation) AddRefundAmount(f float64) {
- if m.addrefund_amount != nil {
- *m.addrefund_amount += f
- } else {
- m.addrefund_amount = &f
- }
- }
- // AddedRefundAmount returns the value that was added to the "refund_amount" field in this mutation.
- func (m *PaymentOrderMutation) AddedRefundAmount() (r float64, exists bool) {
- v := m.addrefund_amount
- if v == nil {
- return
- }
- return *v, true
- }
- // ResetRefundAmount resets all changes to the "refund_amount" field.
- func (m *PaymentOrderMutation) ResetRefundAmount() {
- m.refund_amount = nil
- m.addrefund_amount = nil
- }
- // SetRefundReason sets the "refund_reason" field.
- func (m *PaymentOrderMutation) SetRefundReason(s string) {
- m.refund_reason = &s
- }
- // RefundReason returns the value of the "refund_reason" field in the mutation.
- func (m *PaymentOrderMutation) RefundReason() (r string, exists bool) {
- v := m.refund_reason
- if v == nil {
- return
- }
- return *v, true
- }
- // OldRefundReason returns the old "refund_reason" field's value of the PaymentOrder entity.
- // If the PaymentOrder object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *PaymentOrderMutation) OldRefundReason(ctx context.Context) (v *string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldRefundReason is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldRefundReason requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldRefundReason: %w", err)
- }
- return oldValue.RefundReason, nil
- }
- // ClearRefundReason clears the value of the "refund_reason" field.
- func (m *PaymentOrderMutation) ClearRefundReason() {
- m.refund_reason = nil
- m.clearedFields[paymentorder.FieldRefundReason] = struct{}{}
- }
- // RefundReasonCleared returns if the "refund_reason" field was cleared in this mutation.
- func (m *PaymentOrderMutation) RefundReasonCleared() bool {
- _, ok := m.clearedFields[paymentorder.FieldRefundReason]
- return ok
- }
- // ResetRefundReason resets all changes to the "refund_reason" field.
- func (m *PaymentOrderMutation) ResetRefundReason() {
- m.refund_reason = nil
- delete(m.clearedFields, paymentorder.FieldRefundReason)
- }
- // SetRefundAt sets the "refund_at" field.
- func (m *PaymentOrderMutation) SetRefundAt(t time.Time) {
- m.refund_at = &t
- }
- // RefundAt returns the value of the "refund_at" field in the mutation.
- func (m *PaymentOrderMutation) RefundAt() (r time.Time, exists bool) {
- v := m.refund_at
- if v == nil {
- return
- }
- return *v, true
- }
- // OldRefundAt returns the old "refund_at" field's value of the PaymentOrder entity.
- // If the PaymentOrder object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *PaymentOrderMutation) OldRefundAt(ctx context.Context) (v *time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldRefundAt is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldRefundAt requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldRefundAt: %w", err)
- }
- return oldValue.RefundAt, nil
- }
- // ClearRefundAt clears the value of the "refund_at" field.
- func (m *PaymentOrderMutation) ClearRefundAt() {
- m.refund_at = nil
- m.clearedFields[paymentorder.FieldRefundAt] = struct{}{}
- }
- // RefundAtCleared returns if the "refund_at" field was cleared in this mutation.
- func (m *PaymentOrderMutation) RefundAtCleared() bool {
- _, ok := m.clearedFields[paymentorder.FieldRefundAt]
- return ok
- }
- // ResetRefundAt resets all changes to the "refund_at" field.
- func (m *PaymentOrderMutation) ResetRefundAt() {
- m.refund_at = nil
- delete(m.clearedFields, paymentorder.FieldRefundAt)
- }
- // SetForceRefund sets the "force_refund" field.
- func (m *PaymentOrderMutation) SetForceRefund(b bool) {
- m.force_refund = &b
- }
- // ForceRefund returns the value of the "force_refund" field in the mutation.
- func (m *PaymentOrderMutation) ForceRefund() (r bool, exists bool) {
- v := m.force_refund
- if v == nil {
- return
- }
- return *v, true
- }
- // OldForceRefund returns the old "force_refund" field's value of the PaymentOrder entity.
- // If the PaymentOrder object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *PaymentOrderMutation) OldForceRefund(ctx context.Context) (v bool, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldForceRefund is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldForceRefund requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldForceRefund: %w", err)
- }
- return oldValue.ForceRefund, nil
- }
- // ResetForceRefund resets all changes to the "force_refund" field.
- func (m *PaymentOrderMutation) ResetForceRefund() {
- m.force_refund = nil
- }
- // SetRefundRequestedAt sets the "refund_requested_at" field.
- func (m *PaymentOrderMutation) SetRefundRequestedAt(t time.Time) {
- m.refund_requested_at = &t
- }
- // RefundRequestedAt returns the value of the "refund_requested_at" field in the mutation.
- func (m *PaymentOrderMutation) RefundRequestedAt() (r time.Time, exists bool) {
- v := m.refund_requested_at
- if v == nil {
- return
- }
- return *v, true
- }
- // OldRefundRequestedAt returns the old "refund_requested_at" field's value of the PaymentOrder entity.
- // If the PaymentOrder object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *PaymentOrderMutation) OldRefundRequestedAt(ctx context.Context) (v *time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldRefundRequestedAt is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldRefundRequestedAt requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldRefundRequestedAt: %w", err)
- }
- return oldValue.RefundRequestedAt, nil
- }
- // ClearRefundRequestedAt clears the value of the "refund_requested_at" field.
- func (m *PaymentOrderMutation) ClearRefundRequestedAt() {
- m.refund_requested_at = nil
- m.clearedFields[paymentorder.FieldRefundRequestedAt] = struct{}{}
- }
- // RefundRequestedAtCleared returns if the "refund_requested_at" field was cleared in this mutation.
- func (m *PaymentOrderMutation) RefundRequestedAtCleared() bool {
- _, ok := m.clearedFields[paymentorder.FieldRefundRequestedAt]
- return ok
- }
- // ResetRefundRequestedAt resets all changes to the "refund_requested_at" field.
- func (m *PaymentOrderMutation) ResetRefundRequestedAt() {
- m.refund_requested_at = nil
- delete(m.clearedFields, paymentorder.FieldRefundRequestedAt)
- }
- // SetRefundRequestReason sets the "refund_request_reason" field.
- func (m *PaymentOrderMutation) SetRefundRequestReason(s string) {
- m.refund_request_reason = &s
- }
- // RefundRequestReason returns the value of the "refund_request_reason" field in the mutation.
- func (m *PaymentOrderMutation) RefundRequestReason() (r string, exists bool) {
- v := m.refund_request_reason
- if v == nil {
- return
- }
- return *v, true
- }
- // OldRefundRequestReason returns the old "refund_request_reason" field's value of the PaymentOrder entity.
- // If the PaymentOrder object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *PaymentOrderMutation) OldRefundRequestReason(ctx context.Context) (v *string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldRefundRequestReason is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldRefundRequestReason requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldRefundRequestReason: %w", err)
- }
- return oldValue.RefundRequestReason, nil
- }
- // ClearRefundRequestReason clears the value of the "refund_request_reason" field.
- func (m *PaymentOrderMutation) ClearRefundRequestReason() {
- m.refund_request_reason = nil
- m.clearedFields[paymentorder.FieldRefundRequestReason] = struct{}{}
- }
- // RefundRequestReasonCleared returns if the "refund_request_reason" field was cleared in this mutation.
- func (m *PaymentOrderMutation) RefundRequestReasonCleared() bool {
- _, ok := m.clearedFields[paymentorder.FieldRefundRequestReason]
- return ok
- }
- // ResetRefundRequestReason resets all changes to the "refund_request_reason" field.
- func (m *PaymentOrderMutation) ResetRefundRequestReason() {
- m.refund_request_reason = nil
- delete(m.clearedFields, paymentorder.FieldRefundRequestReason)
- }
- // SetRefundRequestedBy sets the "refund_requested_by" field.
- func (m *PaymentOrderMutation) SetRefundRequestedBy(s string) {
- m.refund_requested_by = &s
- }
- // RefundRequestedBy returns the value of the "refund_requested_by" field in the mutation.
- func (m *PaymentOrderMutation) RefundRequestedBy() (r string, exists bool) {
- v := m.refund_requested_by
- if v == nil {
- return
- }
- return *v, true
- }
- // OldRefundRequestedBy returns the old "refund_requested_by" field's value of the PaymentOrder entity.
- // If the PaymentOrder object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *PaymentOrderMutation) OldRefundRequestedBy(ctx context.Context) (v *string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldRefundRequestedBy is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldRefundRequestedBy requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldRefundRequestedBy: %w", err)
- }
- return oldValue.RefundRequestedBy, nil
- }
- // ClearRefundRequestedBy clears the value of the "refund_requested_by" field.
- func (m *PaymentOrderMutation) ClearRefundRequestedBy() {
- m.refund_requested_by = nil
- m.clearedFields[paymentorder.FieldRefundRequestedBy] = struct{}{}
- }
- // RefundRequestedByCleared returns if the "refund_requested_by" field was cleared in this mutation.
- func (m *PaymentOrderMutation) RefundRequestedByCleared() bool {
- _, ok := m.clearedFields[paymentorder.FieldRefundRequestedBy]
- return ok
- }
- // ResetRefundRequestedBy resets all changes to the "refund_requested_by" field.
- func (m *PaymentOrderMutation) ResetRefundRequestedBy() {
- m.refund_requested_by = nil
- delete(m.clearedFields, paymentorder.FieldRefundRequestedBy)
- }
- // SetExpiresAt sets the "expires_at" field.
- func (m *PaymentOrderMutation) SetExpiresAt(t time.Time) {
- m.expires_at = &t
- }
- // ExpiresAt returns the value of the "expires_at" field in the mutation.
- func (m *PaymentOrderMutation) ExpiresAt() (r time.Time, exists bool) {
- v := m.expires_at
- if v == nil {
- return
- }
- return *v, true
- }
- // OldExpiresAt returns the old "expires_at" field's value of the PaymentOrder entity.
- // If the PaymentOrder object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *PaymentOrderMutation) OldExpiresAt(ctx context.Context) (v time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldExpiresAt is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldExpiresAt requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldExpiresAt: %w", err)
- }
- return oldValue.ExpiresAt, nil
- }
- // ResetExpiresAt resets all changes to the "expires_at" field.
- func (m *PaymentOrderMutation) ResetExpiresAt() {
- m.expires_at = nil
- }
- // SetPaidAt sets the "paid_at" field.
- func (m *PaymentOrderMutation) SetPaidAt(t time.Time) {
- m.paid_at = &t
- }
- // PaidAt returns the value of the "paid_at" field in the mutation.
- func (m *PaymentOrderMutation) PaidAt() (r time.Time, exists bool) {
- v := m.paid_at
- if v == nil {
- return
- }
- return *v, true
- }
- // OldPaidAt returns the old "paid_at" field's value of the PaymentOrder entity.
- // If the PaymentOrder object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *PaymentOrderMutation) OldPaidAt(ctx context.Context) (v *time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldPaidAt is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldPaidAt requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldPaidAt: %w", err)
- }
- return oldValue.PaidAt, nil
- }
- // ClearPaidAt clears the value of the "paid_at" field.
- func (m *PaymentOrderMutation) ClearPaidAt() {
- m.paid_at = nil
- m.clearedFields[paymentorder.FieldPaidAt] = struct{}{}
- }
- // PaidAtCleared returns if the "paid_at" field was cleared in this mutation.
- func (m *PaymentOrderMutation) PaidAtCleared() bool {
- _, ok := m.clearedFields[paymentorder.FieldPaidAt]
- return ok
- }
- // ResetPaidAt resets all changes to the "paid_at" field.
- func (m *PaymentOrderMutation) ResetPaidAt() {
- m.paid_at = nil
- delete(m.clearedFields, paymentorder.FieldPaidAt)
- }
- // SetCompletedAt sets the "completed_at" field.
- func (m *PaymentOrderMutation) SetCompletedAt(t time.Time) {
- m.completed_at = &t
- }
- // CompletedAt returns the value of the "completed_at" field in the mutation.
- func (m *PaymentOrderMutation) CompletedAt() (r time.Time, exists bool) {
- v := m.completed_at
- if v == nil {
- return
- }
- return *v, true
- }
- // OldCompletedAt returns the old "completed_at" field's value of the PaymentOrder entity.
- // If the PaymentOrder object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *PaymentOrderMutation) OldCompletedAt(ctx context.Context) (v *time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldCompletedAt is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldCompletedAt requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldCompletedAt: %w", err)
- }
- return oldValue.CompletedAt, nil
- }
- // ClearCompletedAt clears the value of the "completed_at" field.
- func (m *PaymentOrderMutation) ClearCompletedAt() {
- m.completed_at = nil
- m.clearedFields[paymentorder.FieldCompletedAt] = struct{}{}
- }
- // CompletedAtCleared returns if the "completed_at" field was cleared in this mutation.
- func (m *PaymentOrderMutation) CompletedAtCleared() bool {
- _, ok := m.clearedFields[paymentorder.FieldCompletedAt]
- return ok
- }
- // ResetCompletedAt resets all changes to the "completed_at" field.
- func (m *PaymentOrderMutation) ResetCompletedAt() {
- m.completed_at = nil
- delete(m.clearedFields, paymentorder.FieldCompletedAt)
- }
- // SetFailedAt sets the "failed_at" field.
- func (m *PaymentOrderMutation) SetFailedAt(t time.Time) {
- m.failed_at = &t
- }
- // FailedAt returns the value of the "failed_at" field in the mutation.
- func (m *PaymentOrderMutation) FailedAt() (r time.Time, exists bool) {
- v := m.failed_at
- if v == nil {
- return
- }
- return *v, true
- }
- // OldFailedAt returns the old "failed_at" field's value of the PaymentOrder entity.
- // If the PaymentOrder object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *PaymentOrderMutation) OldFailedAt(ctx context.Context) (v *time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldFailedAt is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldFailedAt requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldFailedAt: %w", err)
- }
- return oldValue.FailedAt, nil
- }
- // ClearFailedAt clears the value of the "failed_at" field.
- func (m *PaymentOrderMutation) ClearFailedAt() {
- m.failed_at = nil
- m.clearedFields[paymentorder.FieldFailedAt] = struct{}{}
- }
- // FailedAtCleared returns if the "failed_at" field was cleared in this mutation.
- func (m *PaymentOrderMutation) FailedAtCleared() bool {
- _, ok := m.clearedFields[paymentorder.FieldFailedAt]
- return ok
- }
- // ResetFailedAt resets all changes to the "failed_at" field.
- func (m *PaymentOrderMutation) ResetFailedAt() {
- m.failed_at = nil
- delete(m.clearedFields, paymentorder.FieldFailedAt)
- }
- // SetFailedReason sets the "failed_reason" field.
- func (m *PaymentOrderMutation) SetFailedReason(s string) {
- m.failed_reason = &s
- }
- // FailedReason returns the value of the "failed_reason" field in the mutation.
- func (m *PaymentOrderMutation) FailedReason() (r string, exists bool) {
- v := m.failed_reason
- if v == nil {
- return
- }
- return *v, true
- }
- // OldFailedReason returns the old "failed_reason" field's value of the PaymentOrder entity.
- // If the PaymentOrder object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *PaymentOrderMutation) OldFailedReason(ctx context.Context) (v *string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldFailedReason is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldFailedReason requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldFailedReason: %w", err)
- }
- return oldValue.FailedReason, nil
- }
- // ClearFailedReason clears the value of the "failed_reason" field.
- func (m *PaymentOrderMutation) ClearFailedReason() {
- m.failed_reason = nil
- m.clearedFields[paymentorder.FieldFailedReason] = struct{}{}
- }
- // FailedReasonCleared returns if the "failed_reason" field was cleared in this mutation.
- func (m *PaymentOrderMutation) FailedReasonCleared() bool {
- _, ok := m.clearedFields[paymentorder.FieldFailedReason]
- return ok
- }
- // ResetFailedReason resets all changes to the "failed_reason" field.
- func (m *PaymentOrderMutation) ResetFailedReason() {
- m.failed_reason = nil
- delete(m.clearedFields, paymentorder.FieldFailedReason)
- }
- // SetClientIP sets the "client_ip" field.
- func (m *PaymentOrderMutation) SetClientIP(s string) {
- m.client_ip = &s
- }
- // ClientIP returns the value of the "client_ip" field in the mutation.
- func (m *PaymentOrderMutation) ClientIP() (r string, exists bool) {
- v := m.client_ip
- if v == nil {
- return
- }
- return *v, true
- }
- // OldClientIP returns the old "client_ip" field's value of the PaymentOrder entity.
- // If the PaymentOrder object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *PaymentOrderMutation) OldClientIP(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldClientIP is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldClientIP requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldClientIP: %w", err)
- }
- return oldValue.ClientIP, nil
- }
- // ResetClientIP resets all changes to the "client_ip" field.
- func (m *PaymentOrderMutation) ResetClientIP() {
- m.client_ip = nil
- }
- // SetSrcHost sets the "src_host" field.
- func (m *PaymentOrderMutation) SetSrcHost(s string) {
- m.src_host = &s
- }
- // SrcHost returns the value of the "src_host" field in the mutation.
- func (m *PaymentOrderMutation) SrcHost() (r string, exists bool) {
- v := m.src_host
- if v == nil {
- return
- }
- return *v, true
- }
- // OldSrcHost returns the old "src_host" field's value of the PaymentOrder entity.
- // If the PaymentOrder object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *PaymentOrderMutation) OldSrcHost(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldSrcHost is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldSrcHost requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldSrcHost: %w", err)
- }
- return oldValue.SrcHost, nil
- }
- // ResetSrcHost resets all changes to the "src_host" field.
- func (m *PaymentOrderMutation) ResetSrcHost() {
- m.src_host = nil
- }
- // SetSrcURL sets the "src_url" field.
- func (m *PaymentOrderMutation) SetSrcURL(s string) {
- m.src_url = &s
- }
- // SrcURL returns the value of the "src_url" field in the mutation.
- func (m *PaymentOrderMutation) SrcURL() (r string, exists bool) {
- v := m.src_url
- if v == nil {
- return
- }
- return *v, true
- }
- // OldSrcURL returns the old "src_url" field's value of the PaymentOrder entity.
- // If the PaymentOrder object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *PaymentOrderMutation) OldSrcURL(ctx context.Context) (v *string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldSrcURL is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldSrcURL requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldSrcURL: %w", err)
- }
- return oldValue.SrcURL, nil
- }
- // ClearSrcURL clears the value of the "src_url" field.
- func (m *PaymentOrderMutation) ClearSrcURL() {
- m.src_url = nil
- m.clearedFields[paymentorder.FieldSrcURL] = struct{}{}
- }
- // SrcURLCleared returns if the "src_url" field was cleared in this mutation.
- func (m *PaymentOrderMutation) SrcURLCleared() bool {
- _, ok := m.clearedFields[paymentorder.FieldSrcURL]
- return ok
- }
- // ResetSrcURL resets all changes to the "src_url" field.
- func (m *PaymentOrderMutation) ResetSrcURL() {
- m.src_url = nil
- delete(m.clearedFields, paymentorder.FieldSrcURL)
- }
- // SetCreatedAt sets the "created_at" field.
- func (m *PaymentOrderMutation) SetCreatedAt(t time.Time) {
- m.created_at = &t
- }
- // CreatedAt returns the value of the "created_at" field in the mutation.
- func (m *PaymentOrderMutation) CreatedAt() (r time.Time, exists bool) {
- v := m.created_at
- if v == nil {
- return
- }
- return *v, true
- }
- // OldCreatedAt returns the old "created_at" field's value of the PaymentOrder entity.
- // If the PaymentOrder object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *PaymentOrderMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldCreatedAt requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
- }
- return oldValue.CreatedAt, nil
- }
- // ResetCreatedAt resets all changes to the "created_at" field.
- func (m *PaymentOrderMutation) ResetCreatedAt() {
- m.created_at = nil
- }
- // SetUpdatedAt sets the "updated_at" field.
- func (m *PaymentOrderMutation) SetUpdatedAt(t time.Time) {
- m.updated_at = &t
- }
- // UpdatedAt returns the value of the "updated_at" field in the mutation.
- func (m *PaymentOrderMutation) UpdatedAt() (r time.Time, exists bool) {
- v := m.updated_at
- if v == nil {
- return
- }
- return *v, true
- }
- // OldUpdatedAt returns the old "updated_at" field's value of the PaymentOrder entity.
- // If the PaymentOrder object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *PaymentOrderMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
- }
- return oldValue.UpdatedAt, nil
- }
- // ResetUpdatedAt resets all changes to the "updated_at" field.
- func (m *PaymentOrderMutation) ResetUpdatedAt() {
- m.updated_at = nil
- }
- // ClearUser clears the "user" edge to the User entity.
- func (m *PaymentOrderMutation) ClearUser() {
- m.cleareduser = true
- m.clearedFields[paymentorder.FieldUserID] = struct{}{}
- }
- // UserCleared reports if the "user" edge to the User entity was cleared.
- func (m *PaymentOrderMutation) UserCleared() bool {
- return m.cleareduser
- }
- // UserIDs returns the "user" edge IDs in the mutation.
- // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
- // UserID instead. It exists only for internal usage by the builders.
- func (m *PaymentOrderMutation) UserIDs() (ids []int64) {
- if id := m.user; id != nil {
- ids = append(ids, *id)
- }
- return
- }
- // ResetUser resets all changes to the "user" edge.
- func (m *PaymentOrderMutation) ResetUser() {
- m.user = nil
- m.cleareduser = false
- }
- // Where appends a list predicates to the PaymentOrderMutation builder.
- func (m *PaymentOrderMutation) Where(ps ...predicate.PaymentOrder) {
- m.predicates = append(m.predicates, ps...)
- }
- // WhereP appends storage-level predicates to the PaymentOrderMutation builder. Using this method,
- // users can use type-assertion to append predicates that do not depend on any generated package.
- func (m *PaymentOrderMutation) WhereP(ps ...func(*sql.Selector)) {
- p := make([]predicate.PaymentOrder, len(ps))
- for i := range ps {
- p[i] = ps[i]
- }
- m.Where(p...)
- }
- // Op returns the operation name.
- func (m *PaymentOrderMutation) Op() Op {
- return m.op
- }
- // SetOp allows setting the mutation operation.
- func (m *PaymentOrderMutation) SetOp(op Op) {
- m.op = op
- }
- // Type returns the node type of this mutation (PaymentOrder).
- func (m *PaymentOrderMutation) Type() string {
- return m.typ
- }
- // Fields returns all fields that were changed during this mutation. Note that in
- // order to get all numeric fields that were incremented/decremented, call
- // AddedFields().
- func (m *PaymentOrderMutation) Fields() []string {
- fields := make([]string, 0, 39)
- if m.user != nil {
- fields = append(fields, paymentorder.FieldUserID)
- }
- if m.user_email != nil {
- fields = append(fields, paymentorder.FieldUserEmail)
- }
- if m.user_name != nil {
- fields = append(fields, paymentorder.FieldUserName)
- }
- if m.user_notes != nil {
- fields = append(fields, paymentorder.FieldUserNotes)
- }
- if m.amount != nil {
- fields = append(fields, paymentorder.FieldAmount)
- }
- if m.pay_amount != nil {
- fields = append(fields, paymentorder.FieldPayAmount)
- }
- if m.fee_rate != nil {
- fields = append(fields, paymentorder.FieldFeeRate)
- }
- if m.recharge_code != nil {
- fields = append(fields, paymentorder.FieldRechargeCode)
- }
- if m.out_trade_no != nil {
- fields = append(fields, paymentorder.FieldOutTradeNo)
- }
- if m.payment_type != nil {
- fields = append(fields, paymentorder.FieldPaymentType)
- }
- if m.payment_trade_no != nil {
- fields = append(fields, paymentorder.FieldPaymentTradeNo)
- }
- if m.pay_url != nil {
- fields = append(fields, paymentorder.FieldPayURL)
- }
- if m.qr_code != nil {
- fields = append(fields, paymentorder.FieldQrCode)
- }
- if m.qr_code_img != nil {
- fields = append(fields, paymentorder.FieldQrCodeImg)
- }
- if m.order_type != nil {
- fields = append(fields, paymentorder.FieldOrderType)
- }
- if m.plan_id != nil {
- fields = append(fields, paymentorder.FieldPlanID)
- }
- if m.subscription_group_id != nil {
- fields = append(fields, paymentorder.FieldSubscriptionGroupID)
- }
- if m.subscription_days != nil {
- fields = append(fields, paymentorder.FieldSubscriptionDays)
- }
- if m.provider_instance_id != nil {
- fields = append(fields, paymentorder.FieldProviderInstanceID)
- }
- if m.provider_key != nil {
- fields = append(fields, paymentorder.FieldProviderKey)
- }
- if m.provider_snapshot != nil {
- fields = append(fields, paymentorder.FieldProviderSnapshot)
- }
- if m.status != nil {
- fields = append(fields, paymentorder.FieldStatus)
- }
- if m.refund_amount != nil {
- fields = append(fields, paymentorder.FieldRefundAmount)
- }
- if m.refund_reason != nil {
- fields = append(fields, paymentorder.FieldRefundReason)
- }
- if m.refund_at != nil {
- fields = append(fields, paymentorder.FieldRefundAt)
- }
- if m.force_refund != nil {
- fields = append(fields, paymentorder.FieldForceRefund)
- }
- if m.refund_requested_at != nil {
- fields = append(fields, paymentorder.FieldRefundRequestedAt)
- }
- if m.refund_request_reason != nil {
- fields = append(fields, paymentorder.FieldRefundRequestReason)
- }
- if m.refund_requested_by != nil {
- fields = append(fields, paymentorder.FieldRefundRequestedBy)
- }
- if m.expires_at != nil {
- fields = append(fields, paymentorder.FieldExpiresAt)
- }
- if m.paid_at != nil {
- fields = append(fields, paymentorder.FieldPaidAt)
- }
- if m.completed_at != nil {
- fields = append(fields, paymentorder.FieldCompletedAt)
- }
- if m.failed_at != nil {
- fields = append(fields, paymentorder.FieldFailedAt)
- }
- if m.failed_reason != nil {
- fields = append(fields, paymentorder.FieldFailedReason)
- }
- if m.client_ip != nil {
- fields = append(fields, paymentorder.FieldClientIP)
- }
- if m.src_host != nil {
- fields = append(fields, paymentorder.FieldSrcHost)
- }
- if m.src_url != nil {
- fields = append(fields, paymentorder.FieldSrcURL)
- }
- if m.created_at != nil {
- fields = append(fields, paymentorder.FieldCreatedAt)
- }
- if m.updated_at != nil {
- fields = append(fields, paymentorder.FieldUpdatedAt)
- }
- return fields
- }
- // Field returns the value of a field with the given name. The second boolean
- // return value indicates that this field was not set, or was not defined in the
- // schema.
- func (m *PaymentOrderMutation) Field(name string) (ent.Value, bool) {
- switch name {
- case paymentorder.FieldUserID:
- return m.UserID()
- case paymentorder.FieldUserEmail:
- return m.UserEmail()
- case paymentorder.FieldUserName:
- return m.UserName()
- case paymentorder.FieldUserNotes:
- return m.UserNotes()
- case paymentorder.FieldAmount:
- return m.Amount()
- case paymentorder.FieldPayAmount:
- return m.PayAmount()
- case paymentorder.FieldFeeRate:
- return m.FeeRate()
- case paymentorder.FieldRechargeCode:
- return m.RechargeCode()
- case paymentorder.FieldOutTradeNo:
- return m.OutTradeNo()
- case paymentorder.FieldPaymentType:
- return m.PaymentType()
- case paymentorder.FieldPaymentTradeNo:
- return m.PaymentTradeNo()
- case paymentorder.FieldPayURL:
- return m.PayURL()
- case paymentorder.FieldQrCode:
- return m.QrCode()
- case paymentorder.FieldQrCodeImg:
- return m.QrCodeImg()
- case paymentorder.FieldOrderType:
- return m.OrderType()
- case paymentorder.FieldPlanID:
- return m.PlanID()
- case paymentorder.FieldSubscriptionGroupID:
- return m.SubscriptionGroupID()
- case paymentorder.FieldSubscriptionDays:
- return m.SubscriptionDays()
- case paymentorder.FieldProviderInstanceID:
- return m.ProviderInstanceID()
- case paymentorder.FieldProviderKey:
- return m.ProviderKey()
- case paymentorder.FieldProviderSnapshot:
- return m.ProviderSnapshot()
- case paymentorder.FieldStatus:
- return m.Status()
- case paymentorder.FieldRefundAmount:
- return m.RefundAmount()
- case paymentorder.FieldRefundReason:
- return m.RefundReason()
- case paymentorder.FieldRefundAt:
- return m.RefundAt()
- case paymentorder.FieldForceRefund:
- return m.ForceRefund()
- case paymentorder.FieldRefundRequestedAt:
- return m.RefundRequestedAt()
- case paymentorder.FieldRefundRequestReason:
- return m.RefundRequestReason()
- case paymentorder.FieldRefundRequestedBy:
- return m.RefundRequestedBy()
- case paymentorder.FieldExpiresAt:
- return m.ExpiresAt()
- case paymentorder.FieldPaidAt:
- return m.PaidAt()
- case paymentorder.FieldCompletedAt:
- return m.CompletedAt()
- case paymentorder.FieldFailedAt:
- return m.FailedAt()
- case paymentorder.FieldFailedReason:
- return m.FailedReason()
- case paymentorder.FieldClientIP:
- return m.ClientIP()
- case paymentorder.FieldSrcHost:
- return m.SrcHost()
- case paymentorder.FieldSrcURL:
- return m.SrcURL()
- case paymentorder.FieldCreatedAt:
- return m.CreatedAt()
- case paymentorder.FieldUpdatedAt:
- return m.UpdatedAt()
- }
- return nil, false
- }
- // OldField returns the old value of the field from the database. An error is
- // returned if the mutation operation is not UpdateOne, or the query to the
- // database failed.
- func (m *PaymentOrderMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
- switch name {
- case paymentorder.FieldUserID:
- return m.OldUserID(ctx)
- case paymentorder.FieldUserEmail:
- return m.OldUserEmail(ctx)
- case paymentorder.FieldUserName:
- return m.OldUserName(ctx)
- case paymentorder.FieldUserNotes:
- return m.OldUserNotes(ctx)
- case paymentorder.FieldAmount:
- return m.OldAmount(ctx)
- case paymentorder.FieldPayAmount:
- return m.OldPayAmount(ctx)
- case paymentorder.FieldFeeRate:
- return m.OldFeeRate(ctx)
- case paymentorder.FieldRechargeCode:
- return m.OldRechargeCode(ctx)
- case paymentorder.FieldOutTradeNo:
- return m.OldOutTradeNo(ctx)
- case paymentorder.FieldPaymentType:
- return m.OldPaymentType(ctx)
- case paymentorder.FieldPaymentTradeNo:
- return m.OldPaymentTradeNo(ctx)
- case paymentorder.FieldPayURL:
- return m.OldPayURL(ctx)
- case paymentorder.FieldQrCode:
- return m.OldQrCode(ctx)
- case paymentorder.FieldQrCodeImg:
- return m.OldQrCodeImg(ctx)
- case paymentorder.FieldOrderType:
- return m.OldOrderType(ctx)
- case paymentorder.FieldPlanID:
- return m.OldPlanID(ctx)
- case paymentorder.FieldSubscriptionGroupID:
- return m.OldSubscriptionGroupID(ctx)
- case paymentorder.FieldSubscriptionDays:
- return m.OldSubscriptionDays(ctx)
- case paymentorder.FieldProviderInstanceID:
- return m.OldProviderInstanceID(ctx)
- case paymentorder.FieldProviderKey:
- return m.OldProviderKey(ctx)
- case paymentorder.FieldProviderSnapshot:
- return m.OldProviderSnapshot(ctx)
- case paymentorder.FieldStatus:
- return m.OldStatus(ctx)
- case paymentorder.FieldRefundAmount:
- return m.OldRefundAmount(ctx)
- case paymentorder.FieldRefundReason:
- return m.OldRefundReason(ctx)
- case paymentorder.FieldRefundAt:
- return m.OldRefundAt(ctx)
- case paymentorder.FieldForceRefund:
- return m.OldForceRefund(ctx)
- case paymentorder.FieldRefundRequestedAt:
- return m.OldRefundRequestedAt(ctx)
- case paymentorder.FieldRefundRequestReason:
- return m.OldRefundRequestReason(ctx)
- case paymentorder.FieldRefundRequestedBy:
- return m.OldRefundRequestedBy(ctx)
- case paymentorder.FieldExpiresAt:
- return m.OldExpiresAt(ctx)
- case paymentorder.FieldPaidAt:
- return m.OldPaidAt(ctx)
- case paymentorder.FieldCompletedAt:
- return m.OldCompletedAt(ctx)
- case paymentorder.FieldFailedAt:
- return m.OldFailedAt(ctx)
- case paymentorder.FieldFailedReason:
- return m.OldFailedReason(ctx)
- case paymentorder.FieldClientIP:
- return m.OldClientIP(ctx)
- case paymentorder.FieldSrcHost:
- return m.OldSrcHost(ctx)
- case paymentorder.FieldSrcURL:
- return m.OldSrcURL(ctx)
- case paymentorder.FieldCreatedAt:
- return m.OldCreatedAt(ctx)
- case paymentorder.FieldUpdatedAt:
- return m.OldUpdatedAt(ctx)
- }
- return nil, fmt.Errorf("unknown PaymentOrder field %s", name)
- }
- // SetField sets the value of a field with the given name. It returns an error if
- // the field is not defined in the schema, or if the type mismatched the field
- // type.
- func (m *PaymentOrderMutation) SetField(name string, value ent.Value) error {
- switch name {
- case paymentorder.FieldUserID:
- v, ok := value.(int64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetUserID(v)
- return nil
- case paymentorder.FieldUserEmail:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetUserEmail(v)
- return nil
- case paymentorder.FieldUserName:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetUserName(v)
- return nil
- case paymentorder.FieldUserNotes:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetUserNotes(v)
- return nil
- case paymentorder.FieldAmount:
- v, ok := value.(float64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetAmount(v)
- return nil
- case paymentorder.FieldPayAmount:
- v, ok := value.(float64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetPayAmount(v)
- return nil
- case paymentorder.FieldFeeRate:
- v, ok := value.(float64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetFeeRate(v)
- return nil
- case paymentorder.FieldRechargeCode:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetRechargeCode(v)
- return nil
- case paymentorder.FieldOutTradeNo:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetOutTradeNo(v)
- return nil
- case paymentorder.FieldPaymentType:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetPaymentType(v)
- return nil
- case paymentorder.FieldPaymentTradeNo:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetPaymentTradeNo(v)
- return nil
- case paymentorder.FieldPayURL:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetPayURL(v)
- return nil
- case paymentorder.FieldQrCode:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetQrCode(v)
- return nil
- case paymentorder.FieldQrCodeImg:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetQrCodeImg(v)
- return nil
- case paymentorder.FieldOrderType:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetOrderType(v)
- return nil
- case paymentorder.FieldPlanID:
- v, ok := value.(int64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetPlanID(v)
- return nil
- case paymentorder.FieldSubscriptionGroupID:
- v, ok := value.(int64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetSubscriptionGroupID(v)
- return nil
- case paymentorder.FieldSubscriptionDays:
- v, ok := value.(int)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetSubscriptionDays(v)
- return nil
- case paymentorder.FieldProviderInstanceID:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetProviderInstanceID(v)
- return nil
- case paymentorder.FieldProviderKey:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetProviderKey(v)
- return nil
- case paymentorder.FieldProviderSnapshot:
- v, ok := value.(map[string]interface{})
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetProviderSnapshot(v)
- return nil
- case paymentorder.FieldStatus:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetStatus(v)
- return nil
- case paymentorder.FieldRefundAmount:
- v, ok := value.(float64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetRefundAmount(v)
- return nil
- case paymentorder.FieldRefundReason:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetRefundReason(v)
- return nil
- case paymentorder.FieldRefundAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetRefundAt(v)
- return nil
- case paymentorder.FieldForceRefund:
- v, ok := value.(bool)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetForceRefund(v)
- return nil
- case paymentorder.FieldRefundRequestedAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetRefundRequestedAt(v)
- return nil
- case paymentorder.FieldRefundRequestReason:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetRefundRequestReason(v)
- return nil
- case paymentorder.FieldRefundRequestedBy:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetRefundRequestedBy(v)
- return nil
- case paymentorder.FieldExpiresAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetExpiresAt(v)
- return nil
- case paymentorder.FieldPaidAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetPaidAt(v)
- return nil
- case paymentorder.FieldCompletedAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetCompletedAt(v)
- return nil
- case paymentorder.FieldFailedAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetFailedAt(v)
- return nil
- case paymentorder.FieldFailedReason:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetFailedReason(v)
- return nil
- case paymentorder.FieldClientIP:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetClientIP(v)
- return nil
- case paymentorder.FieldSrcHost:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetSrcHost(v)
- return nil
- case paymentorder.FieldSrcURL:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetSrcURL(v)
- return nil
- case paymentorder.FieldCreatedAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetCreatedAt(v)
- return nil
- case paymentorder.FieldUpdatedAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetUpdatedAt(v)
- return nil
- }
- return fmt.Errorf("unknown PaymentOrder field %s", name)
- }
- // AddedFields returns all numeric fields that were incremented/decremented during
- // this mutation.
- func (m *PaymentOrderMutation) AddedFields() []string {
- var fields []string
- if m.addamount != nil {
- fields = append(fields, paymentorder.FieldAmount)
- }
- if m.addpay_amount != nil {
- fields = append(fields, paymentorder.FieldPayAmount)
- }
- if m.addfee_rate != nil {
- fields = append(fields, paymentorder.FieldFeeRate)
- }
- if m.addplan_id != nil {
- fields = append(fields, paymentorder.FieldPlanID)
- }
- if m.addsubscription_group_id != nil {
- fields = append(fields, paymentorder.FieldSubscriptionGroupID)
- }
- if m.addsubscription_days != nil {
- fields = append(fields, paymentorder.FieldSubscriptionDays)
- }
- if m.addrefund_amount != nil {
- fields = append(fields, paymentorder.FieldRefundAmount)
- }
- return fields
- }
- // AddedField returns the numeric value that was incremented/decremented on a field
- // with the given name. The second boolean return value indicates that this field
- // was not set, or was not defined in the schema.
- func (m *PaymentOrderMutation) AddedField(name string) (ent.Value, bool) {
- switch name {
- case paymentorder.FieldAmount:
- return m.AddedAmount()
- case paymentorder.FieldPayAmount:
- return m.AddedPayAmount()
- case paymentorder.FieldFeeRate:
- return m.AddedFeeRate()
- case paymentorder.FieldPlanID:
- return m.AddedPlanID()
- case paymentorder.FieldSubscriptionGroupID:
- return m.AddedSubscriptionGroupID()
- case paymentorder.FieldSubscriptionDays:
- return m.AddedSubscriptionDays()
- case paymentorder.FieldRefundAmount:
- return m.AddedRefundAmount()
- }
- return nil, false
- }
- // AddField adds the value to the field with the given name. It returns an error if
- // the field is not defined in the schema, or if the type mismatched the field
- // type.
- func (m *PaymentOrderMutation) AddField(name string, value ent.Value) error {
- switch name {
- case paymentorder.FieldAmount:
- v, ok := value.(float64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.AddAmount(v)
- return nil
- case paymentorder.FieldPayAmount:
- v, ok := value.(float64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.AddPayAmount(v)
- return nil
- case paymentorder.FieldFeeRate:
- v, ok := value.(float64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.AddFeeRate(v)
- return nil
- case paymentorder.FieldPlanID:
- v, ok := value.(int64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.AddPlanID(v)
- return nil
- case paymentorder.FieldSubscriptionGroupID:
- v, ok := value.(int64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.AddSubscriptionGroupID(v)
- return nil
- case paymentorder.FieldSubscriptionDays:
- v, ok := value.(int)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.AddSubscriptionDays(v)
- return nil
- case paymentorder.FieldRefundAmount:
- v, ok := value.(float64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.AddRefundAmount(v)
- return nil
- }
- return fmt.Errorf("unknown PaymentOrder numeric field %s", name)
- }
- // ClearedFields returns all nullable fields that were cleared during this
- // mutation.
- func (m *PaymentOrderMutation) ClearedFields() []string {
- var fields []string
- if m.FieldCleared(paymentorder.FieldUserNotes) {
- fields = append(fields, paymentorder.FieldUserNotes)
- }
- if m.FieldCleared(paymentorder.FieldPayURL) {
- fields = append(fields, paymentorder.FieldPayURL)
- }
- if m.FieldCleared(paymentorder.FieldQrCode) {
- fields = append(fields, paymentorder.FieldQrCode)
- }
- if m.FieldCleared(paymentorder.FieldQrCodeImg) {
- fields = append(fields, paymentorder.FieldQrCodeImg)
- }
- if m.FieldCleared(paymentorder.FieldPlanID) {
- fields = append(fields, paymentorder.FieldPlanID)
- }
- if m.FieldCleared(paymentorder.FieldSubscriptionGroupID) {
- fields = append(fields, paymentorder.FieldSubscriptionGroupID)
- }
- if m.FieldCleared(paymentorder.FieldSubscriptionDays) {
- fields = append(fields, paymentorder.FieldSubscriptionDays)
- }
- if m.FieldCleared(paymentorder.FieldProviderInstanceID) {
- fields = append(fields, paymentorder.FieldProviderInstanceID)
- }
- if m.FieldCleared(paymentorder.FieldProviderKey) {
- fields = append(fields, paymentorder.FieldProviderKey)
- }
- if m.FieldCleared(paymentorder.FieldProviderSnapshot) {
- fields = append(fields, paymentorder.FieldProviderSnapshot)
- }
- if m.FieldCleared(paymentorder.FieldRefundReason) {
- fields = append(fields, paymentorder.FieldRefundReason)
- }
- if m.FieldCleared(paymentorder.FieldRefundAt) {
- fields = append(fields, paymentorder.FieldRefundAt)
- }
- if m.FieldCleared(paymentorder.FieldRefundRequestedAt) {
- fields = append(fields, paymentorder.FieldRefundRequestedAt)
- }
- if m.FieldCleared(paymentorder.FieldRefundRequestReason) {
- fields = append(fields, paymentorder.FieldRefundRequestReason)
- }
- if m.FieldCleared(paymentorder.FieldRefundRequestedBy) {
- fields = append(fields, paymentorder.FieldRefundRequestedBy)
- }
- if m.FieldCleared(paymentorder.FieldPaidAt) {
- fields = append(fields, paymentorder.FieldPaidAt)
- }
- if m.FieldCleared(paymentorder.FieldCompletedAt) {
- fields = append(fields, paymentorder.FieldCompletedAt)
- }
- if m.FieldCleared(paymentorder.FieldFailedAt) {
- fields = append(fields, paymentorder.FieldFailedAt)
- }
- if m.FieldCleared(paymentorder.FieldFailedReason) {
- fields = append(fields, paymentorder.FieldFailedReason)
- }
- if m.FieldCleared(paymentorder.FieldSrcURL) {
- fields = append(fields, paymentorder.FieldSrcURL)
- }
- return fields
- }
- // FieldCleared returns a boolean indicating if a field with the given name was
- // cleared in this mutation.
- func (m *PaymentOrderMutation) FieldCleared(name string) bool {
- _, ok := m.clearedFields[name]
- return ok
- }
- // ClearField clears the value of the field with the given name. It returns an
- // error if the field is not defined in the schema.
- func (m *PaymentOrderMutation) ClearField(name string) error {
- switch name {
- case paymentorder.FieldUserNotes:
- m.ClearUserNotes()
- return nil
- case paymentorder.FieldPayURL:
- m.ClearPayURL()
- return nil
- case paymentorder.FieldQrCode:
- m.ClearQrCode()
- return nil
- case paymentorder.FieldQrCodeImg:
- m.ClearQrCodeImg()
- return nil
- case paymentorder.FieldPlanID:
- m.ClearPlanID()
- return nil
- case paymentorder.FieldSubscriptionGroupID:
- m.ClearSubscriptionGroupID()
- return nil
- case paymentorder.FieldSubscriptionDays:
- m.ClearSubscriptionDays()
- return nil
- case paymentorder.FieldProviderInstanceID:
- m.ClearProviderInstanceID()
- return nil
- case paymentorder.FieldProviderKey:
- m.ClearProviderKey()
- return nil
- case paymentorder.FieldProviderSnapshot:
- m.ClearProviderSnapshot()
- return nil
- case paymentorder.FieldRefundReason:
- m.ClearRefundReason()
- return nil
- case paymentorder.FieldRefundAt:
- m.ClearRefundAt()
- return nil
- case paymentorder.FieldRefundRequestedAt:
- m.ClearRefundRequestedAt()
- return nil
- case paymentorder.FieldRefundRequestReason:
- m.ClearRefundRequestReason()
- return nil
- case paymentorder.FieldRefundRequestedBy:
- m.ClearRefundRequestedBy()
- return nil
- case paymentorder.FieldPaidAt:
- m.ClearPaidAt()
- return nil
- case paymentorder.FieldCompletedAt:
- m.ClearCompletedAt()
- return nil
- case paymentorder.FieldFailedAt:
- m.ClearFailedAt()
- return nil
- case paymentorder.FieldFailedReason:
- m.ClearFailedReason()
- return nil
- case paymentorder.FieldSrcURL:
- m.ClearSrcURL()
- return nil
- }
- return fmt.Errorf("unknown PaymentOrder nullable field %s", name)
- }
- // ResetField resets all changes in the mutation for the field with the given name.
- // It returns an error if the field is not defined in the schema.
- func (m *PaymentOrderMutation) ResetField(name string) error {
- switch name {
- case paymentorder.FieldUserID:
- m.ResetUserID()
- return nil
- case paymentorder.FieldUserEmail:
- m.ResetUserEmail()
- return nil
- case paymentorder.FieldUserName:
- m.ResetUserName()
- return nil
- case paymentorder.FieldUserNotes:
- m.ResetUserNotes()
- return nil
- case paymentorder.FieldAmount:
- m.ResetAmount()
- return nil
- case paymentorder.FieldPayAmount:
- m.ResetPayAmount()
- return nil
- case paymentorder.FieldFeeRate:
- m.ResetFeeRate()
- return nil
- case paymentorder.FieldRechargeCode:
- m.ResetRechargeCode()
- return nil
- case paymentorder.FieldOutTradeNo:
- m.ResetOutTradeNo()
- return nil
- case paymentorder.FieldPaymentType:
- m.ResetPaymentType()
- return nil
- case paymentorder.FieldPaymentTradeNo:
- m.ResetPaymentTradeNo()
- return nil
- case paymentorder.FieldPayURL:
- m.ResetPayURL()
- return nil
- case paymentorder.FieldQrCode:
- m.ResetQrCode()
- return nil
- case paymentorder.FieldQrCodeImg:
- m.ResetQrCodeImg()
- return nil
- case paymentorder.FieldOrderType:
- m.ResetOrderType()
- return nil
- case paymentorder.FieldPlanID:
- m.ResetPlanID()
- return nil
- case paymentorder.FieldSubscriptionGroupID:
- m.ResetSubscriptionGroupID()
- return nil
- case paymentorder.FieldSubscriptionDays:
- m.ResetSubscriptionDays()
- return nil
- case paymentorder.FieldProviderInstanceID:
- m.ResetProviderInstanceID()
- return nil
- case paymentorder.FieldProviderKey:
- m.ResetProviderKey()
- return nil
- case paymentorder.FieldProviderSnapshot:
- m.ResetProviderSnapshot()
- return nil
- case paymentorder.FieldStatus:
- m.ResetStatus()
- return nil
- case paymentorder.FieldRefundAmount:
- m.ResetRefundAmount()
- return nil
- case paymentorder.FieldRefundReason:
- m.ResetRefundReason()
- return nil
- case paymentorder.FieldRefundAt:
- m.ResetRefundAt()
- return nil
- case paymentorder.FieldForceRefund:
- m.ResetForceRefund()
- return nil
- case paymentorder.FieldRefundRequestedAt:
- m.ResetRefundRequestedAt()
- return nil
- case paymentorder.FieldRefundRequestReason:
- m.ResetRefundRequestReason()
- return nil
- case paymentorder.FieldRefundRequestedBy:
- m.ResetRefundRequestedBy()
- return nil
- case paymentorder.FieldExpiresAt:
- m.ResetExpiresAt()
- return nil
- case paymentorder.FieldPaidAt:
- m.ResetPaidAt()
- return nil
- case paymentorder.FieldCompletedAt:
- m.ResetCompletedAt()
- return nil
- case paymentorder.FieldFailedAt:
- m.ResetFailedAt()
- return nil
- case paymentorder.FieldFailedReason:
- m.ResetFailedReason()
- return nil
- case paymentorder.FieldClientIP:
- m.ResetClientIP()
- return nil
- case paymentorder.FieldSrcHost:
- m.ResetSrcHost()
- return nil
- case paymentorder.FieldSrcURL:
- m.ResetSrcURL()
- return nil
- case paymentorder.FieldCreatedAt:
- m.ResetCreatedAt()
- return nil
- case paymentorder.FieldUpdatedAt:
- m.ResetUpdatedAt()
- return nil
- }
- return fmt.Errorf("unknown PaymentOrder field %s", name)
- }
- // AddedEdges returns all edge names that were set/added in this mutation.
- func (m *PaymentOrderMutation) AddedEdges() []string {
- edges := make([]string, 0, 1)
- if m.user != nil {
- edges = append(edges, paymentorder.EdgeUser)
- }
- return edges
- }
- // AddedIDs returns all IDs (to other nodes) that were added for the given edge
- // name in this mutation.
- func (m *PaymentOrderMutation) AddedIDs(name string) []ent.Value {
- switch name {
- case paymentorder.EdgeUser:
- if id := m.user; id != nil {
- return []ent.Value{*id}
- }
- }
- return nil
- }
- // RemovedEdges returns all edge names that were removed in this mutation.
- func (m *PaymentOrderMutation) RemovedEdges() []string {
- edges := make([]string, 0, 1)
- return edges
- }
- // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
- // the given name in this mutation.
- func (m *PaymentOrderMutation) RemovedIDs(name string) []ent.Value {
- return nil
- }
- // ClearedEdges returns all edge names that were cleared in this mutation.
- func (m *PaymentOrderMutation) ClearedEdges() []string {
- edges := make([]string, 0, 1)
- if m.cleareduser {
- edges = append(edges, paymentorder.EdgeUser)
- }
- return edges
- }
- // EdgeCleared returns a boolean which indicates if the edge with the given name
- // was cleared in this mutation.
- func (m *PaymentOrderMutation) EdgeCleared(name string) bool {
- switch name {
- case paymentorder.EdgeUser:
- return m.cleareduser
- }
- return false
- }
- // ClearEdge clears the value of the edge with the given name. It returns an error
- // if that edge is not defined in the schema.
- func (m *PaymentOrderMutation) ClearEdge(name string) error {
- switch name {
- case paymentorder.EdgeUser:
- m.ClearUser()
- return nil
- }
- return fmt.Errorf("unknown PaymentOrder unique edge %s", name)
- }
- // ResetEdge resets all changes to the edge with the given name in this mutation.
- // It returns an error if the edge is not defined in the schema.
- func (m *PaymentOrderMutation) ResetEdge(name string) error {
- switch name {
- case paymentorder.EdgeUser:
- m.ResetUser()
- return nil
- }
- return fmt.Errorf("unknown PaymentOrder edge %s", name)
- }
- // PaymentProviderInstanceMutation represents an operation that mutates the PaymentProviderInstance nodes in the graph.
- type PaymentProviderInstanceMutation struct {
- config
- op Op
- typ string
- id *int64
- provider_key *string
- name *string
- _config *string
- supported_types *string
- enabled *bool
- payment_mode *string
- sort_order *int
- addsort_order *int
- limits *string
- refund_enabled *bool
- allow_user_refund *bool
- created_at *time.Time
- updated_at *time.Time
- clearedFields map[string]struct{}
- done bool
- oldValue func(context.Context) (*PaymentProviderInstance, error)
- predicates []predicate.PaymentProviderInstance
- }
- var _ ent.Mutation = (*PaymentProviderInstanceMutation)(nil)
- // paymentproviderinstanceOption allows management of the mutation configuration using functional options.
- type paymentproviderinstanceOption func(*PaymentProviderInstanceMutation)
- // newPaymentProviderInstanceMutation creates new mutation for the PaymentProviderInstance entity.
- func newPaymentProviderInstanceMutation(c config, op Op, opts ...paymentproviderinstanceOption) *PaymentProviderInstanceMutation {
- m := &PaymentProviderInstanceMutation{
- config: c,
- op: op,
- typ: TypePaymentProviderInstance,
- clearedFields: make(map[string]struct{}),
- }
- for _, opt := range opts {
- opt(m)
- }
- return m
- }
- // withPaymentProviderInstanceID sets the ID field of the mutation.
- func withPaymentProviderInstanceID(id int64) paymentproviderinstanceOption {
- return func(m *PaymentProviderInstanceMutation) {
- var (
- err error
- once sync.Once
- value *PaymentProviderInstance
- )
- m.oldValue = func(ctx context.Context) (*PaymentProviderInstance, error) {
- once.Do(func() {
- if m.done {
- err = errors.New("querying old values post mutation is not allowed")
- } else {
- value, err = m.Client().PaymentProviderInstance.Get(ctx, id)
- }
- })
- return value, err
- }
- m.id = &id
- }
- }
- // withPaymentProviderInstance sets the old PaymentProviderInstance of the mutation.
- func withPaymentProviderInstance(node *PaymentProviderInstance) paymentproviderinstanceOption {
- return func(m *PaymentProviderInstanceMutation) {
- m.oldValue = func(context.Context) (*PaymentProviderInstance, error) {
- return node, nil
- }
- m.id = &node.ID
- }
- }
- // Client returns a new `ent.Client` from the mutation. If the mutation was
- // executed in a transaction (ent.Tx), a transactional client is returned.
- func (m PaymentProviderInstanceMutation) Client() *Client {
- client := &Client{config: m.config}
- client.init()
- return client
- }
- // Tx returns an `ent.Tx` for mutations that were executed in transactions;
- // it returns an error otherwise.
- func (m PaymentProviderInstanceMutation) Tx() (*Tx, error) {
- if _, ok := m.driver.(*txDriver); !ok {
- return nil, errors.New("ent: mutation is not running in a transaction")
- }
- tx := &Tx{config: m.config}
- tx.init()
- return tx, nil
- }
- // ID returns the ID value in the mutation. Note that the ID is only available
- // if it was provided to the builder or after it was returned from the database.
- func (m *PaymentProviderInstanceMutation) ID() (id int64, exists bool) {
- if m.id == nil {
- return
- }
- return *m.id, true
- }
- // IDs queries the database and returns the entity ids that match the mutation's predicate.
- // That means, if the mutation is applied within a transaction with an isolation level such
- // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
- // or updated by the mutation.
- func (m *PaymentProviderInstanceMutation) IDs(ctx context.Context) ([]int64, error) {
- switch {
- case m.op.Is(OpUpdateOne | OpDeleteOne):
- id, exists := m.ID()
- if exists {
- return []int64{id}, nil
- }
- fallthrough
- case m.op.Is(OpUpdate | OpDelete):
- return m.Client().PaymentProviderInstance.Query().Where(m.predicates...).IDs(ctx)
- default:
- return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
- }
- }
- // SetProviderKey sets the "provider_key" field.
- func (m *PaymentProviderInstanceMutation) SetProviderKey(s string) {
- m.provider_key = &s
- }
- // ProviderKey returns the value of the "provider_key" field in the mutation.
- func (m *PaymentProviderInstanceMutation) ProviderKey() (r string, exists bool) {
- v := m.provider_key
- if v == nil {
- return
- }
- return *v, true
- }
- // OldProviderKey returns the old "provider_key" field's value of the PaymentProviderInstance entity.
- // If the PaymentProviderInstance object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *PaymentProviderInstanceMutation) OldProviderKey(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldProviderKey is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldProviderKey requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldProviderKey: %w", err)
- }
- return oldValue.ProviderKey, nil
- }
- // ResetProviderKey resets all changes to the "provider_key" field.
- func (m *PaymentProviderInstanceMutation) ResetProviderKey() {
- m.provider_key = nil
- }
- // SetName sets the "name" field.
- func (m *PaymentProviderInstanceMutation) SetName(s string) {
- m.name = &s
- }
- // Name returns the value of the "name" field in the mutation.
- func (m *PaymentProviderInstanceMutation) Name() (r string, exists bool) {
- v := m.name
- if v == nil {
- return
- }
- return *v, true
- }
- // OldName returns the old "name" field's value of the PaymentProviderInstance entity.
- // If the PaymentProviderInstance object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *PaymentProviderInstanceMutation) OldName(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldName is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldName requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldName: %w", err)
- }
- return oldValue.Name, nil
- }
- // ResetName resets all changes to the "name" field.
- func (m *PaymentProviderInstanceMutation) ResetName() {
- m.name = nil
- }
- // SetConfig sets the "config" field.
- func (m *PaymentProviderInstanceMutation) SetConfig(s string) {
- m._config = &s
- }
- // Config returns the value of the "config" field in the mutation.
- func (m *PaymentProviderInstanceMutation) Config() (r string, exists bool) {
- v := m._config
- if v == nil {
- return
- }
- return *v, true
- }
- // OldConfig returns the old "config" field's value of the PaymentProviderInstance entity.
- // If the PaymentProviderInstance object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *PaymentProviderInstanceMutation) OldConfig(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldConfig is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldConfig requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldConfig: %w", err)
- }
- return oldValue.Config, nil
- }
- // ResetConfig resets all changes to the "config" field.
- func (m *PaymentProviderInstanceMutation) ResetConfig() {
- m._config = nil
- }
- // SetSupportedTypes sets the "supported_types" field.
- func (m *PaymentProviderInstanceMutation) SetSupportedTypes(s string) {
- m.supported_types = &s
- }
- // SupportedTypes returns the value of the "supported_types" field in the mutation.
- func (m *PaymentProviderInstanceMutation) SupportedTypes() (r string, exists bool) {
- v := m.supported_types
- if v == nil {
- return
- }
- return *v, true
- }
- // OldSupportedTypes returns the old "supported_types" field's value of the PaymentProviderInstance entity.
- // If the PaymentProviderInstance object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *PaymentProviderInstanceMutation) OldSupportedTypes(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldSupportedTypes is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldSupportedTypes requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldSupportedTypes: %w", err)
- }
- return oldValue.SupportedTypes, nil
- }
- // ResetSupportedTypes resets all changes to the "supported_types" field.
- func (m *PaymentProviderInstanceMutation) ResetSupportedTypes() {
- m.supported_types = nil
- }
- // SetEnabled sets the "enabled" field.
- func (m *PaymentProviderInstanceMutation) SetEnabled(b bool) {
- m.enabled = &b
- }
- // Enabled returns the value of the "enabled" field in the mutation.
- func (m *PaymentProviderInstanceMutation) Enabled() (r bool, exists bool) {
- v := m.enabled
- if v == nil {
- return
- }
- return *v, true
- }
- // OldEnabled returns the old "enabled" field's value of the PaymentProviderInstance entity.
- // If the PaymentProviderInstance object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *PaymentProviderInstanceMutation) OldEnabled(ctx context.Context) (v bool, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldEnabled is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldEnabled requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldEnabled: %w", err)
- }
- return oldValue.Enabled, nil
- }
- // ResetEnabled resets all changes to the "enabled" field.
- func (m *PaymentProviderInstanceMutation) ResetEnabled() {
- m.enabled = nil
- }
- // SetPaymentMode sets the "payment_mode" field.
- func (m *PaymentProviderInstanceMutation) SetPaymentMode(s string) {
- m.payment_mode = &s
- }
- // PaymentMode returns the value of the "payment_mode" field in the mutation.
- func (m *PaymentProviderInstanceMutation) PaymentMode() (r string, exists bool) {
- v := m.payment_mode
- if v == nil {
- return
- }
- return *v, true
- }
- // OldPaymentMode returns the old "payment_mode" field's value of the PaymentProviderInstance entity.
- // If the PaymentProviderInstance object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *PaymentProviderInstanceMutation) OldPaymentMode(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldPaymentMode is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldPaymentMode requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldPaymentMode: %w", err)
- }
- return oldValue.PaymentMode, nil
- }
- // ResetPaymentMode resets all changes to the "payment_mode" field.
- func (m *PaymentProviderInstanceMutation) ResetPaymentMode() {
- m.payment_mode = nil
- }
- // SetSortOrder sets the "sort_order" field.
- func (m *PaymentProviderInstanceMutation) SetSortOrder(i int) {
- m.sort_order = &i
- m.addsort_order = nil
- }
- // SortOrder returns the value of the "sort_order" field in the mutation.
- func (m *PaymentProviderInstanceMutation) SortOrder() (r int, exists bool) {
- v := m.sort_order
- if v == nil {
- return
- }
- return *v, true
- }
- // OldSortOrder returns the old "sort_order" field's value of the PaymentProviderInstance entity.
- // If the PaymentProviderInstance object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *PaymentProviderInstanceMutation) OldSortOrder(ctx context.Context) (v int, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldSortOrder is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldSortOrder requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldSortOrder: %w", err)
- }
- return oldValue.SortOrder, nil
- }
- // AddSortOrder adds i to the "sort_order" field.
- func (m *PaymentProviderInstanceMutation) AddSortOrder(i int) {
- if m.addsort_order != nil {
- *m.addsort_order += i
- } else {
- m.addsort_order = &i
- }
- }
- // AddedSortOrder returns the value that was added to the "sort_order" field in this mutation.
- func (m *PaymentProviderInstanceMutation) AddedSortOrder() (r int, exists bool) {
- v := m.addsort_order
- if v == nil {
- return
- }
- return *v, true
- }
- // ResetSortOrder resets all changes to the "sort_order" field.
- func (m *PaymentProviderInstanceMutation) ResetSortOrder() {
- m.sort_order = nil
- m.addsort_order = nil
- }
- // SetLimits sets the "limits" field.
- func (m *PaymentProviderInstanceMutation) SetLimits(s string) {
- m.limits = &s
- }
- // Limits returns the value of the "limits" field in the mutation.
- func (m *PaymentProviderInstanceMutation) Limits() (r string, exists bool) {
- v := m.limits
- if v == nil {
- return
- }
- return *v, true
- }
- // OldLimits returns the old "limits" field's value of the PaymentProviderInstance entity.
- // If the PaymentProviderInstance object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *PaymentProviderInstanceMutation) OldLimits(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldLimits is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldLimits requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldLimits: %w", err)
- }
- return oldValue.Limits, nil
- }
- // ResetLimits resets all changes to the "limits" field.
- func (m *PaymentProviderInstanceMutation) ResetLimits() {
- m.limits = nil
- }
- // SetRefundEnabled sets the "refund_enabled" field.
- func (m *PaymentProviderInstanceMutation) SetRefundEnabled(b bool) {
- m.refund_enabled = &b
- }
- // RefundEnabled returns the value of the "refund_enabled" field in the mutation.
- func (m *PaymentProviderInstanceMutation) RefundEnabled() (r bool, exists bool) {
- v := m.refund_enabled
- if v == nil {
- return
- }
- return *v, true
- }
- // OldRefundEnabled returns the old "refund_enabled" field's value of the PaymentProviderInstance entity.
- // If the PaymentProviderInstance object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *PaymentProviderInstanceMutation) OldRefundEnabled(ctx context.Context) (v bool, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldRefundEnabled is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldRefundEnabled requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldRefundEnabled: %w", err)
- }
- return oldValue.RefundEnabled, nil
- }
- // ResetRefundEnabled resets all changes to the "refund_enabled" field.
- func (m *PaymentProviderInstanceMutation) ResetRefundEnabled() {
- m.refund_enabled = nil
- }
- // SetAllowUserRefund sets the "allow_user_refund" field.
- func (m *PaymentProviderInstanceMutation) SetAllowUserRefund(b bool) {
- m.allow_user_refund = &b
- }
- // AllowUserRefund returns the value of the "allow_user_refund" field in the mutation.
- func (m *PaymentProviderInstanceMutation) AllowUserRefund() (r bool, exists bool) {
- v := m.allow_user_refund
- if v == nil {
- return
- }
- return *v, true
- }
- // OldAllowUserRefund returns the old "allow_user_refund" field's value of the PaymentProviderInstance entity.
- // If the PaymentProviderInstance object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *PaymentProviderInstanceMutation) OldAllowUserRefund(ctx context.Context) (v bool, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldAllowUserRefund is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldAllowUserRefund requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldAllowUserRefund: %w", err)
- }
- return oldValue.AllowUserRefund, nil
- }
- // ResetAllowUserRefund resets all changes to the "allow_user_refund" field.
- func (m *PaymentProviderInstanceMutation) ResetAllowUserRefund() {
- m.allow_user_refund = nil
- }
- // SetCreatedAt sets the "created_at" field.
- func (m *PaymentProviderInstanceMutation) SetCreatedAt(t time.Time) {
- m.created_at = &t
- }
- // CreatedAt returns the value of the "created_at" field in the mutation.
- func (m *PaymentProviderInstanceMutation) CreatedAt() (r time.Time, exists bool) {
- v := m.created_at
- if v == nil {
- return
- }
- return *v, true
- }
- // OldCreatedAt returns the old "created_at" field's value of the PaymentProviderInstance entity.
- // If the PaymentProviderInstance object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *PaymentProviderInstanceMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldCreatedAt requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
- }
- return oldValue.CreatedAt, nil
- }
- // ResetCreatedAt resets all changes to the "created_at" field.
- func (m *PaymentProviderInstanceMutation) ResetCreatedAt() {
- m.created_at = nil
- }
- // SetUpdatedAt sets the "updated_at" field.
- func (m *PaymentProviderInstanceMutation) SetUpdatedAt(t time.Time) {
- m.updated_at = &t
- }
- // UpdatedAt returns the value of the "updated_at" field in the mutation.
- func (m *PaymentProviderInstanceMutation) UpdatedAt() (r time.Time, exists bool) {
- v := m.updated_at
- if v == nil {
- return
- }
- return *v, true
- }
- // OldUpdatedAt returns the old "updated_at" field's value of the PaymentProviderInstance entity.
- // If the PaymentProviderInstance object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *PaymentProviderInstanceMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
- }
- return oldValue.UpdatedAt, nil
- }
- // ResetUpdatedAt resets all changes to the "updated_at" field.
- func (m *PaymentProviderInstanceMutation) ResetUpdatedAt() {
- m.updated_at = nil
- }
- // Where appends a list predicates to the PaymentProviderInstanceMutation builder.
- func (m *PaymentProviderInstanceMutation) Where(ps ...predicate.PaymentProviderInstance) {
- m.predicates = append(m.predicates, ps...)
- }
- // WhereP appends storage-level predicates to the PaymentProviderInstanceMutation builder. Using this method,
- // users can use type-assertion to append predicates that do not depend on any generated package.
- func (m *PaymentProviderInstanceMutation) WhereP(ps ...func(*sql.Selector)) {
- p := make([]predicate.PaymentProviderInstance, len(ps))
- for i := range ps {
- p[i] = ps[i]
- }
- m.Where(p...)
- }
- // Op returns the operation name.
- func (m *PaymentProviderInstanceMutation) Op() Op {
- return m.op
- }
- // SetOp allows setting the mutation operation.
- func (m *PaymentProviderInstanceMutation) SetOp(op Op) {
- m.op = op
- }
- // Type returns the node type of this mutation (PaymentProviderInstance).
- func (m *PaymentProviderInstanceMutation) Type() string {
- return m.typ
- }
- // Fields returns all fields that were changed during this mutation. Note that in
- // order to get all numeric fields that were incremented/decremented, call
- // AddedFields().
- func (m *PaymentProviderInstanceMutation) Fields() []string {
- fields := make([]string, 0, 12)
- if m.provider_key != nil {
- fields = append(fields, paymentproviderinstance.FieldProviderKey)
- }
- if m.name != nil {
- fields = append(fields, paymentproviderinstance.FieldName)
- }
- if m._config != nil {
- fields = append(fields, paymentproviderinstance.FieldConfig)
- }
- if m.supported_types != nil {
- fields = append(fields, paymentproviderinstance.FieldSupportedTypes)
- }
- if m.enabled != nil {
- fields = append(fields, paymentproviderinstance.FieldEnabled)
- }
- if m.payment_mode != nil {
- fields = append(fields, paymentproviderinstance.FieldPaymentMode)
- }
- if m.sort_order != nil {
- fields = append(fields, paymentproviderinstance.FieldSortOrder)
- }
- if m.limits != nil {
- fields = append(fields, paymentproviderinstance.FieldLimits)
- }
- if m.refund_enabled != nil {
- fields = append(fields, paymentproviderinstance.FieldRefundEnabled)
- }
- if m.allow_user_refund != nil {
- fields = append(fields, paymentproviderinstance.FieldAllowUserRefund)
- }
- if m.created_at != nil {
- fields = append(fields, paymentproviderinstance.FieldCreatedAt)
- }
- if m.updated_at != nil {
- fields = append(fields, paymentproviderinstance.FieldUpdatedAt)
- }
- return fields
- }
- // Field returns the value of a field with the given name. The second boolean
- // return value indicates that this field was not set, or was not defined in the
- // schema.
- func (m *PaymentProviderInstanceMutation) Field(name string) (ent.Value, bool) {
- switch name {
- case paymentproviderinstance.FieldProviderKey:
- return m.ProviderKey()
- case paymentproviderinstance.FieldName:
- return m.Name()
- case paymentproviderinstance.FieldConfig:
- return m.Config()
- case paymentproviderinstance.FieldSupportedTypes:
- return m.SupportedTypes()
- case paymentproviderinstance.FieldEnabled:
- return m.Enabled()
- case paymentproviderinstance.FieldPaymentMode:
- return m.PaymentMode()
- case paymentproviderinstance.FieldSortOrder:
- return m.SortOrder()
- case paymentproviderinstance.FieldLimits:
- return m.Limits()
- case paymentproviderinstance.FieldRefundEnabled:
- return m.RefundEnabled()
- case paymentproviderinstance.FieldAllowUserRefund:
- return m.AllowUserRefund()
- case paymentproviderinstance.FieldCreatedAt:
- return m.CreatedAt()
- case paymentproviderinstance.FieldUpdatedAt:
- return m.UpdatedAt()
- }
- return nil, false
- }
- // OldField returns the old value of the field from the database. An error is
- // returned if the mutation operation is not UpdateOne, or the query to the
- // database failed.
- func (m *PaymentProviderInstanceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
- switch name {
- case paymentproviderinstance.FieldProviderKey:
- return m.OldProviderKey(ctx)
- case paymentproviderinstance.FieldName:
- return m.OldName(ctx)
- case paymentproviderinstance.FieldConfig:
- return m.OldConfig(ctx)
- case paymentproviderinstance.FieldSupportedTypes:
- return m.OldSupportedTypes(ctx)
- case paymentproviderinstance.FieldEnabled:
- return m.OldEnabled(ctx)
- case paymentproviderinstance.FieldPaymentMode:
- return m.OldPaymentMode(ctx)
- case paymentproviderinstance.FieldSortOrder:
- return m.OldSortOrder(ctx)
- case paymentproviderinstance.FieldLimits:
- return m.OldLimits(ctx)
- case paymentproviderinstance.FieldRefundEnabled:
- return m.OldRefundEnabled(ctx)
- case paymentproviderinstance.FieldAllowUserRefund:
- return m.OldAllowUserRefund(ctx)
- case paymentproviderinstance.FieldCreatedAt:
- return m.OldCreatedAt(ctx)
- case paymentproviderinstance.FieldUpdatedAt:
- return m.OldUpdatedAt(ctx)
- }
- return nil, fmt.Errorf("unknown PaymentProviderInstance field %s", name)
- }
- // SetField sets the value of a field with the given name. It returns an error if
- // the field is not defined in the schema, or if the type mismatched the field
- // type.
- func (m *PaymentProviderInstanceMutation) SetField(name string, value ent.Value) error {
- switch name {
- case paymentproviderinstance.FieldProviderKey:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetProviderKey(v)
- return nil
- case paymentproviderinstance.FieldName:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetName(v)
- return nil
- case paymentproviderinstance.FieldConfig:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetConfig(v)
- return nil
- case paymentproviderinstance.FieldSupportedTypes:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetSupportedTypes(v)
- return nil
- case paymentproviderinstance.FieldEnabled:
- v, ok := value.(bool)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetEnabled(v)
- return nil
- case paymentproviderinstance.FieldPaymentMode:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetPaymentMode(v)
- return nil
- case paymentproviderinstance.FieldSortOrder:
- v, ok := value.(int)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetSortOrder(v)
- return nil
- case paymentproviderinstance.FieldLimits:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetLimits(v)
- return nil
- case paymentproviderinstance.FieldRefundEnabled:
- v, ok := value.(bool)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetRefundEnabled(v)
- return nil
- case paymentproviderinstance.FieldAllowUserRefund:
- v, ok := value.(bool)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetAllowUserRefund(v)
- return nil
- case paymentproviderinstance.FieldCreatedAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetCreatedAt(v)
- return nil
- case paymentproviderinstance.FieldUpdatedAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetUpdatedAt(v)
- return nil
- }
- return fmt.Errorf("unknown PaymentProviderInstance field %s", name)
- }
- // AddedFields returns all numeric fields that were incremented/decremented during
- // this mutation.
- func (m *PaymentProviderInstanceMutation) AddedFields() []string {
- var fields []string
- if m.addsort_order != nil {
- fields = append(fields, paymentproviderinstance.FieldSortOrder)
- }
- return fields
- }
- // AddedField returns the numeric value that was incremented/decremented on a field
- // with the given name. The second boolean return value indicates that this field
- // was not set, or was not defined in the schema.
- func (m *PaymentProviderInstanceMutation) AddedField(name string) (ent.Value, bool) {
- switch name {
- case paymentproviderinstance.FieldSortOrder:
- return m.AddedSortOrder()
- }
- return nil, false
- }
- // AddField adds the value to the field with the given name. It returns an error if
- // the field is not defined in the schema, or if the type mismatched the field
- // type.
- func (m *PaymentProviderInstanceMutation) AddField(name string, value ent.Value) error {
- switch name {
- case paymentproviderinstance.FieldSortOrder:
- v, ok := value.(int)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.AddSortOrder(v)
- return nil
- }
- return fmt.Errorf("unknown PaymentProviderInstance numeric field %s", name)
- }
- // ClearedFields returns all nullable fields that were cleared during this
- // mutation.
- func (m *PaymentProviderInstanceMutation) ClearedFields() []string {
- return nil
- }
- // FieldCleared returns a boolean indicating if a field with the given name was
- // cleared in this mutation.
- func (m *PaymentProviderInstanceMutation) FieldCleared(name string) bool {
- _, ok := m.clearedFields[name]
- return ok
- }
- // ClearField clears the value of the field with the given name. It returns an
- // error if the field is not defined in the schema.
- func (m *PaymentProviderInstanceMutation) ClearField(name string) error {
- return fmt.Errorf("unknown PaymentProviderInstance nullable field %s", name)
- }
- // ResetField resets all changes in the mutation for the field with the given name.
- // It returns an error if the field is not defined in the schema.
- func (m *PaymentProviderInstanceMutation) ResetField(name string) error {
- switch name {
- case paymentproviderinstance.FieldProviderKey:
- m.ResetProviderKey()
- return nil
- case paymentproviderinstance.FieldName:
- m.ResetName()
- return nil
- case paymentproviderinstance.FieldConfig:
- m.ResetConfig()
- return nil
- case paymentproviderinstance.FieldSupportedTypes:
- m.ResetSupportedTypes()
- return nil
- case paymentproviderinstance.FieldEnabled:
- m.ResetEnabled()
- return nil
- case paymentproviderinstance.FieldPaymentMode:
- m.ResetPaymentMode()
- return nil
- case paymentproviderinstance.FieldSortOrder:
- m.ResetSortOrder()
- return nil
- case paymentproviderinstance.FieldLimits:
- m.ResetLimits()
- return nil
- case paymentproviderinstance.FieldRefundEnabled:
- m.ResetRefundEnabled()
- return nil
- case paymentproviderinstance.FieldAllowUserRefund:
- m.ResetAllowUserRefund()
- return nil
- case paymentproviderinstance.FieldCreatedAt:
- m.ResetCreatedAt()
- return nil
- case paymentproviderinstance.FieldUpdatedAt:
- m.ResetUpdatedAt()
- return nil
- }
- return fmt.Errorf("unknown PaymentProviderInstance field %s", name)
- }
- // AddedEdges returns all edge names that were set/added in this mutation.
- func (m *PaymentProviderInstanceMutation) AddedEdges() []string {
- edges := make([]string, 0, 0)
- return edges
- }
- // AddedIDs returns all IDs (to other nodes) that were added for the given edge
- // name in this mutation.
- func (m *PaymentProviderInstanceMutation) AddedIDs(name string) []ent.Value {
- return nil
- }
- // RemovedEdges returns all edge names that were removed in this mutation.
- func (m *PaymentProviderInstanceMutation) RemovedEdges() []string {
- edges := make([]string, 0, 0)
- return edges
- }
- // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
- // the given name in this mutation.
- func (m *PaymentProviderInstanceMutation) RemovedIDs(name string) []ent.Value {
- return nil
- }
- // ClearedEdges returns all edge names that were cleared in this mutation.
- func (m *PaymentProviderInstanceMutation) ClearedEdges() []string {
- edges := make([]string, 0, 0)
- return edges
- }
- // EdgeCleared returns a boolean which indicates if the edge with the given name
- // was cleared in this mutation.
- func (m *PaymentProviderInstanceMutation) EdgeCleared(name string) bool {
- return false
- }
- // ClearEdge clears the value of the edge with the given name. It returns an error
- // if that edge is not defined in the schema.
- func (m *PaymentProviderInstanceMutation) ClearEdge(name string) error {
- return fmt.Errorf("unknown PaymentProviderInstance unique edge %s", name)
- }
- // ResetEdge resets all changes to the edge with the given name in this mutation.
- // It returns an error if the edge is not defined in the schema.
- func (m *PaymentProviderInstanceMutation) ResetEdge(name string) error {
- return fmt.Errorf("unknown PaymentProviderInstance edge %s", name)
- }
- // PendingAuthSessionMutation represents an operation that mutates the PendingAuthSession nodes in the graph.
- type PendingAuthSessionMutation struct {
- config
- op Op
- typ string
- id *int64
- created_at *time.Time
- updated_at *time.Time
- session_token *string
- intent *string
- provider_type *string
- provider_key *string
- provider_subject *string
- redirect_to *string
- resolved_email *string
- registration_password_hash *string
- upstream_identity_claims *map[string]interface{}
- local_flow_state *map[string]interface{}
- browser_session_key *string
- completion_code_hash *string
- completion_code_expires_at *time.Time
- email_verified_at *time.Time
- password_verified_at *time.Time
- totp_verified_at *time.Time
- expires_at *time.Time
- consumed_at *time.Time
- clearedFields map[string]struct{}
- target_user *int64
- clearedtarget_user bool
- adoption_decision *int64
- clearedadoption_decision bool
- done bool
- oldValue func(context.Context) (*PendingAuthSession, error)
- predicates []predicate.PendingAuthSession
- }
- var _ ent.Mutation = (*PendingAuthSessionMutation)(nil)
- // pendingauthsessionOption allows management of the mutation configuration using functional options.
- type pendingauthsessionOption func(*PendingAuthSessionMutation)
- // newPendingAuthSessionMutation creates new mutation for the PendingAuthSession entity.
- func newPendingAuthSessionMutation(c config, op Op, opts ...pendingauthsessionOption) *PendingAuthSessionMutation {
- m := &PendingAuthSessionMutation{
- config: c,
- op: op,
- typ: TypePendingAuthSession,
- clearedFields: make(map[string]struct{}),
- }
- for _, opt := range opts {
- opt(m)
- }
- return m
- }
- // withPendingAuthSessionID sets the ID field of the mutation.
- func withPendingAuthSessionID(id int64) pendingauthsessionOption {
- return func(m *PendingAuthSessionMutation) {
- var (
- err error
- once sync.Once
- value *PendingAuthSession
- )
- m.oldValue = func(ctx context.Context) (*PendingAuthSession, error) {
- once.Do(func() {
- if m.done {
- err = errors.New("querying old values post mutation is not allowed")
- } else {
- value, err = m.Client().PendingAuthSession.Get(ctx, id)
- }
- })
- return value, err
- }
- m.id = &id
- }
- }
- // withPendingAuthSession sets the old PendingAuthSession of the mutation.
- func withPendingAuthSession(node *PendingAuthSession) pendingauthsessionOption {
- return func(m *PendingAuthSessionMutation) {
- m.oldValue = func(context.Context) (*PendingAuthSession, error) {
- return node, nil
- }
- m.id = &node.ID
- }
- }
- // Client returns a new `ent.Client` from the mutation. If the mutation was
- // executed in a transaction (ent.Tx), a transactional client is returned.
- func (m PendingAuthSessionMutation) Client() *Client {
- client := &Client{config: m.config}
- client.init()
- return client
- }
- // Tx returns an `ent.Tx` for mutations that were executed in transactions;
- // it returns an error otherwise.
- func (m PendingAuthSessionMutation) Tx() (*Tx, error) {
- if _, ok := m.driver.(*txDriver); !ok {
- return nil, errors.New("ent: mutation is not running in a transaction")
- }
- tx := &Tx{config: m.config}
- tx.init()
- return tx, nil
- }
- // ID returns the ID value in the mutation. Note that the ID is only available
- // if it was provided to the builder or after it was returned from the database.
- func (m *PendingAuthSessionMutation) ID() (id int64, exists bool) {
- if m.id == nil {
- return
- }
- return *m.id, true
- }
- // IDs queries the database and returns the entity ids that match the mutation's predicate.
- // That means, if the mutation is applied within a transaction with an isolation level such
- // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
- // or updated by the mutation.
- func (m *PendingAuthSessionMutation) IDs(ctx context.Context) ([]int64, error) {
- switch {
- case m.op.Is(OpUpdateOne | OpDeleteOne):
- id, exists := m.ID()
- if exists {
- return []int64{id}, nil
- }
- fallthrough
- case m.op.Is(OpUpdate | OpDelete):
- return m.Client().PendingAuthSession.Query().Where(m.predicates...).IDs(ctx)
- default:
- return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
- }
- }
- // SetCreatedAt sets the "created_at" field.
- func (m *PendingAuthSessionMutation) SetCreatedAt(t time.Time) {
- m.created_at = &t
- }
- // CreatedAt returns the value of the "created_at" field in the mutation.
- func (m *PendingAuthSessionMutation) CreatedAt() (r time.Time, exists bool) {
- v := m.created_at
- if v == nil {
- return
- }
- return *v, true
- }
- // OldCreatedAt returns the old "created_at" field's value of the PendingAuthSession entity.
- // If the PendingAuthSession object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *PendingAuthSessionMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldCreatedAt requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
- }
- return oldValue.CreatedAt, nil
- }
- // ResetCreatedAt resets all changes to the "created_at" field.
- func (m *PendingAuthSessionMutation) ResetCreatedAt() {
- m.created_at = nil
- }
- // SetUpdatedAt sets the "updated_at" field.
- func (m *PendingAuthSessionMutation) SetUpdatedAt(t time.Time) {
- m.updated_at = &t
- }
- // UpdatedAt returns the value of the "updated_at" field in the mutation.
- func (m *PendingAuthSessionMutation) UpdatedAt() (r time.Time, exists bool) {
- v := m.updated_at
- if v == nil {
- return
- }
- return *v, true
- }
- // OldUpdatedAt returns the old "updated_at" field's value of the PendingAuthSession entity.
- // If the PendingAuthSession object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *PendingAuthSessionMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
- }
- return oldValue.UpdatedAt, nil
- }
- // ResetUpdatedAt resets all changes to the "updated_at" field.
- func (m *PendingAuthSessionMutation) ResetUpdatedAt() {
- m.updated_at = nil
- }
- // SetSessionToken sets the "session_token" field.
- func (m *PendingAuthSessionMutation) SetSessionToken(s string) {
- m.session_token = &s
- }
- // SessionToken returns the value of the "session_token" field in the mutation.
- func (m *PendingAuthSessionMutation) SessionToken() (r string, exists bool) {
- v := m.session_token
- if v == nil {
- return
- }
- return *v, true
- }
- // OldSessionToken returns the old "session_token" field's value of the PendingAuthSession entity.
- // If the PendingAuthSession object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *PendingAuthSessionMutation) OldSessionToken(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldSessionToken is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldSessionToken requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldSessionToken: %w", err)
- }
- return oldValue.SessionToken, nil
- }
- // ResetSessionToken resets all changes to the "session_token" field.
- func (m *PendingAuthSessionMutation) ResetSessionToken() {
- m.session_token = nil
- }
- // SetIntent sets the "intent" field.
- func (m *PendingAuthSessionMutation) SetIntent(s string) {
- m.intent = &s
- }
- // Intent returns the value of the "intent" field in the mutation.
- func (m *PendingAuthSessionMutation) Intent() (r string, exists bool) {
- v := m.intent
- if v == nil {
- return
- }
- return *v, true
- }
- // OldIntent returns the old "intent" field's value of the PendingAuthSession entity.
- // If the PendingAuthSession object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *PendingAuthSessionMutation) OldIntent(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldIntent is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldIntent requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldIntent: %w", err)
- }
- return oldValue.Intent, nil
- }
- // ResetIntent resets all changes to the "intent" field.
- func (m *PendingAuthSessionMutation) ResetIntent() {
- m.intent = nil
- }
- // SetProviderType sets the "provider_type" field.
- func (m *PendingAuthSessionMutation) SetProviderType(s string) {
- m.provider_type = &s
- }
- // ProviderType returns the value of the "provider_type" field in the mutation.
- func (m *PendingAuthSessionMutation) ProviderType() (r string, exists bool) {
- v := m.provider_type
- if v == nil {
- return
- }
- return *v, true
- }
- // OldProviderType returns the old "provider_type" field's value of the PendingAuthSession entity.
- // If the PendingAuthSession object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *PendingAuthSessionMutation) OldProviderType(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldProviderType is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldProviderType requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldProviderType: %w", err)
- }
- return oldValue.ProviderType, nil
- }
- // ResetProviderType resets all changes to the "provider_type" field.
- func (m *PendingAuthSessionMutation) ResetProviderType() {
- m.provider_type = nil
- }
- // SetProviderKey sets the "provider_key" field.
- func (m *PendingAuthSessionMutation) SetProviderKey(s string) {
- m.provider_key = &s
- }
- // ProviderKey returns the value of the "provider_key" field in the mutation.
- func (m *PendingAuthSessionMutation) ProviderKey() (r string, exists bool) {
- v := m.provider_key
- if v == nil {
- return
- }
- return *v, true
- }
- // OldProviderKey returns the old "provider_key" field's value of the PendingAuthSession entity.
- // If the PendingAuthSession object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *PendingAuthSessionMutation) OldProviderKey(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldProviderKey is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldProviderKey requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldProviderKey: %w", err)
- }
- return oldValue.ProviderKey, nil
- }
- // ResetProviderKey resets all changes to the "provider_key" field.
- func (m *PendingAuthSessionMutation) ResetProviderKey() {
- m.provider_key = nil
- }
- // SetProviderSubject sets the "provider_subject" field.
- func (m *PendingAuthSessionMutation) SetProviderSubject(s string) {
- m.provider_subject = &s
- }
- // ProviderSubject returns the value of the "provider_subject" field in the mutation.
- func (m *PendingAuthSessionMutation) ProviderSubject() (r string, exists bool) {
- v := m.provider_subject
- if v == nil {
- return
- }
- return *v, true
- }
- // OldProviderSubject returns the old "provider_subject" field's value of the PendingAuthSession entity.
- // If the PendingAuthSession object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *PendingAuthSessionMutation) OldProviderSubject(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldProviderSubject is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldProviderSubject requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldProviderSubject: %w", err)
- }
- return oldValue.ProviderSubject, nil
- }
- // ResetProviderSubject resets all changes to the "provider_subject" field.
- func (m *PendingAuthSessionMutation) ResetProviderSubject() {
- m.provider_subject = nil
- }
- // SetTargetUserID sets the "target_user_id" field.
- func (m *PendingAuthSessionMutation) SetTargetUserID(i int64) {
- m.target_user = &i
- }
- // TargetUserID returns the value of the "target_user_id" field in the mutation.
- func (m *PendingAuthSessionMutation) TargetUserID() (r int64, exists bool) {
- v := m.target_user
- if v == nil {
- return
- }
- return *v, true
- }
- // OldTargetUserID returns the old "target_user_id" field's value of the PendingAuthSession entity.
- // If the PendingAuthSession object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *PendingAuthSessionMutation) OldTargetUserID(ctx context.Context) (v *int64, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldTargetUserID is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldTargetUserID requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldTargetUserID: %w", err)
- }
- return oldValue.TargetUserID, nil
- }
- // ClearTargetUserID clears the value of the "target_user_id" field.
- func (m *PendingAuthSessionMutation) ClearTargetUserID() {
- m.target_user = nil
- m.clearedFields[pendingauthsession.FieldTargetUserID] = struct{}{}
- }
- // TargetUserIDCleared returns if the "target_user_id" field was cleared in this mutation.
- func (m *PendingAuthSessionMutation) TargetUserIDCleared() bool {
- _, ok := m.clearedFields[pendingauthsession.FieldTargetUserID]
- return ok
- }
- // ResetTargetUserID resets all changes to the "target_user_id" field.
- func (m *PendingAuthSessionMutation) ResetTargetUserID() {
- m.target_user = nil
- delete(m.clearedFields, pendingauthsession.FieldTargetUserID)
- }
- // SetRedirectTo sets the "redirect_to" field.
- func (m *PendingAuthSessionMutation) SetRedirectTo(s string) {
- m.redirect_to = &s
- }
- // RedirectTo returns the value of the "redirect_to" field in the mutation.
- func (m *PendingAuthSessionMutation) RedirectTo() (r string, exists bool) {
- v := m.redirect_to
- if v == nil {
- return
- }
- return *v, true
- }
- // OldRedirectTo returns the old "redirect_to" field's value of the PendingAuthSession entity.
- // If the PendingAuthSession object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *PendingAuthSessionMutation) OldRedirectTo(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldRedirectTo is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldRedirectTo requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldRedirectTo: %w", err)
- }
- return oldValue.RedirectTo, nil
- }
- // ResetRedirectTo resets all changes to the "redirect_to" field.
- func (m *PendingAuthSessionMutation) ResetRedirectTo() {
- m.redirect_to = nil
- }
- // SetResolvedEmail sets the "resolved_email" field.
- func (m *PendingAuthSessionMutation) SetResolvedEmail(s string) {
- m.resolved_email = &s
- }
- // ResolvedEmail returns the value of the "resolved_email" field in the mutation.
- func (m *PendingAuthSessionMutation) ResolvedEmail() (r string, exists bool) {
- v := m.resolved_email
- if v == nil {
- return
- }
- return *v, true
- }
- // OldResolvedEmail returns the old "resolved_email" field's value of the PendingAuthSession entity.
- // If the PendingAuthSession object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *PendingAuthSessionMutation) OldResolvedEmail(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldResolvedEmail is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldResolvedEmail requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldResolvedEmail: %w", err)
- }
- return oldValue.ResolvedEmail, nil
- }
- // ResetResolvedEmail resets all changes to the "resolved_email" field.
- func (m *PendingAuthSessionMutation) ResetResolvedEmail() {
- m.resolved_email = nil
- }
- // SetRegistrationPasswordHash sets the "registration_password_hash" field.
- func (m *PendingAuthSessionMutation) SetRegistrationPasswordHash(s string) {
- m.registration_password_hash = &s
- }
- // RegistrationPasswordHash returns the value of the "registration_password_hash" field in the mutation.
- func (m *PendingAuthSessionMutation) RegistrationPasswordHash() (r string, exists bool) {
- v := m.registration_password_hash
- if v == nil {
- return
- }
- return *v, true
- }
- // OldRegistrationPasswordHash returns the old "registration_password_hash" field's value of the PendingAuthSession entity.
- // If the PendingAuthSession object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *PendingAuthSessionMutation) OldRegistrationPasswordHash(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldRegistrationPasswordHash is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldRegistrationPasswordHash requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldRegistrationPasswordHash: %w", err)
- }
- return oldValue.RegistrationPasswordHash, nil
- }
- // ResetRegistrationPasswordHash resets all changes to the "registration_password_hash" field.
- func (m *PendingAuthSessionMutation) ResetRegistrationPasswordHash() {
- m.registration_password_hash = nil
- }
- // SetUpstreamIdentityClaims sets the "upstream_identity_claims" field.
- func (m *PendingAuthSessionMutation) SetUpstreamIdentityClaims(value map[string]interface{}) {
- m.upstream_identity_claims = &value
- }
- // UpstreamIdentityClaims returns the value of the "upstream_identity_claims" field in the mutation.
- func (m *PendingAuthSessionMutation) UpstreamIdentityClaims() (r map[string]interface{}, exists bool) {
- v := m.upstream_identity_claims
- if v == nil {
- return
- }
- return *v, true
- }
- // OldUpstreamIdentityClaims returns the old "upstream_identity_claims" field's value of the PendingAuthSession entity.
- // If the PendingAuthSession object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *PendingAuthSessionMutation) OldUpstreamIdentityClaims(ctx context.Context) (v map[string]interface{}, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldUpstreamIdentityClaims is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldUpstreamIdentityClaims requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldUpstreamIdentityClaims: %w", err)
- }
- return oldValue.UpstreamIdentityClaims, nil
- }
- // ResetUpstreamIdentityClaims resets all changes to the "upstream_identity_claims" field.
- func (m *PendingAuthSessionMutation) ResetUpstreamIdentityClaims() {
- m.upstream_identity_claims = nil
- }
- // SetLocalFlowState sets the "local_flow_state" field.
- func (m *PendingAuthSessionMutation) SetLocalFlowState(value map[string]interface{}) {
- m.local_flow_state = &value
- }
- // LocalFlowState returns the value of the "local_flow_state" field in the mutation.
- func (m *PendingAuthSessionMutation) LocalFlowState() (r map[string]interface{}, exists bool) {
- v := m.local_flow_state
- if v == nil {
- return
- }
- return *v, true
- }
- // OldLocalFlowState returns the old "local_flow_state" field's value of the PendingAuthSession entity.
- // If the PendingAuthSession object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *PendingAuthSessionMutation) OldLocalFlowState(ctx context.Context) (v map[string]interface{}, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldLocalFlowState is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldLocalFlowState requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldLocalFlowState: %w", err)
- }
- return oldValue.LocalFlowState, nil
- }
- // ResetLocalFlowState resets all changes to the "local_flow_state" field.
- func (m *PendingAuthSessionMutation) ResetLocalFlowState() {
- m.local_flow_state = nil
- }
- // SetBrowserSessionKey sets the "browser_session_key" field.
- func (m *PendingAuthSessionMutation) SetBrowserSessionKey(s string) {
- m.browser_session_key = &s
- }
- // BrowserSessionKey returns the value of the "browser_session_key" field in the mutation.
- func (m *PendingAuthSessionMutation) BrowserSessionKey() (r string, exists bool) {
- v := m.browser_session_key
- if v == nil {
- return
- }
- return *v, true
- }
- // OldBrowserSessionKey returns the old "browser_session_key" field's value of the PendingAuthSession entity.
- // If the PendingAuthSession object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *PendingAuthSessionMutation) OldBrowserSessionKey(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldBrowserSessionKey is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldBrowserSessionKey requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldBrowserSessionKey: %w", err)
- }
- return oldValue.BrowserSessionKey, nil
- }
- // ResetBrowserSessionKey resets all changes to the "browser_session_key" field.
- func (m *PendingAuthSessionMutation) ResetBrowserSessionKey() {
- m.browser_session_key = nil
- }
- // SetCompletionCodeHash sets the "completion_code_hash" field.
- func (m *PendingAuthSessionMutation) SetCompletionCodeHash(s string) {
- m.completion_code_hash = &s
- }
- // CompletionCodeHash returns the value of the "completion_code_hash" field in the mutation.
- func (m *PendingAuthSessionMutation) CompletionCodeHash() (r string, exists bool) {
- v := m.completion_code_hash
- if v == nil {
- return
- }
- return *v, true
- }
- // OldCompletionCodeHash returns the old "completion_code_hash" field's value of the PendingAuthSession entity.
- // If the PendingAuthSession object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *PendingAuthSessionMutation) OldCompletionCodeHash(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldCompletionCodeHash is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldCompletionCodeHash requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldCompletionCodeHash: %w", err)
- }
- return oldValue.CompletionCodeHash, nil
- }
- // ResetCompletionCodeHash resets all changes to the "completion_code_hash" field.
- func (m *PendingAuthSessionMutation) ResetCompletionCodeHash() {
- m.completion_code_hash = nil
- }
- // SetCompletionCodeExpiresAt sets the "completion_code_expires_at" field.
- func (m *PendingAuthSessionMutation) SetCompletionCodeExpiresAt(t time.Time) {
- m.completion_code_expires_at = &t
- }
- // CompletionCodeExpiresAt returns the value of the "completion_code_expires_at" field in the mutation.
- func (m *PendingAuthSessionMutation) CompletionCodeExpiresAt() (r time.Time, exists bool) {
- v := m.completion_code_expires_at
- if v == nil {
- return
- }
- return *v, true
- }
- // OldCompletionCodeExpiresAt returns the old "completion_code_expires_at" field's value of the PendingAuthSession entity.
- // If the PendingAuthSession object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *PendingAuthSessionMutation) OldCompletionCodeExpiresAt(ctx context.Context) (v *time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldCompletionCodeExpiresAt is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldCompletionCodeExpiresAt requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldCompletionCodeExpiresAt: %w", err)
- }
- return oldValue.CompletionCodeExpiresAt, nil
- }
- // ClearCompletionCodeExpiresAt clears the value of the "completion_code_expires_at" field.
- func (m *PendingAuthSessionMutation) ClearCompletionCodeExpiresAt() {
- m.completion_code_expires_at = nil
- m.clearedFields[pendingauthsession.FieldCompletionCodeExpiresAt] = struct{}{}
- }
- // CompletionCodeExpiresAtCleared returns if the "completion_code_expires_at" field was cleared in this mutation.
- func (m *PendingAuthSessionMutation) CompletionCodeExpiresAtCleared() bool {
- _, ok := m.clearedFields[pendingauthsession.FieldCompletionCodeExpiresAt]
- return ok
- }
- // ResetCompletionCodeExpiresAt resets all changes to the "completion_code_expires_at" field.
- func (m *PendingAuthSessionMutation) ResetCompletionCodeExpiresAt() {
- m.completion_code_expires_at = nil
- delete(m.clearedFields, pendingauthsession.FieldCompletionCodeExpiresAt)
- }
- // SetEmailVerifiedAt sets the "email_verified_at" field.
- func (m *PendingAuthSessionMutation) SetEmailVerifiedAt(t time.Time) {
- m.email_verified_at = &t
- }
- // EmailVerifiedAt returns the value of the "email_verified_at" field in the mutation.
- func (m *PendingAuthSessionMutation) EmailVerifiedAt() (r time.Time, exists bool) {
- v := m.email_verified_at
- if v == nil {
- return
- }
- return *v, true
- }
- // OldEmailVerifiedAt returns the old "email_verified_at" field's value of the PendingAuthSession entity.
- // If the PendingAuthSession object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *PendingAuthSessionMutation) OldEmailVerifiedAt(ctx context.Context) (v *time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldEmailVerifiedAt is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldEmailVerifiedAt requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldEmailVerifiedAt: %w", err)
- }
- return oldValue.EmailVerifiedAt, nil
- }
- // ClearEmailVerifiedAt clears the value of the "email_verified_at" field.
- func (m *PendingAuthSessionMutation) ClearEmailVerifiedAt() {
- m.email_verified_at = nil
- m.clearedFields[pendingauthsession.FieldEmailVerifiedAt] = struct{}{}
- }
- // EmailVerifiedAtCleared returns if the "email_verified_at" field was cleared in this mutation.
- func (m *PendingAuthSessionMutation) EmailVerifiedAtCleared() bool {
- _, ok := m.clearedFields[pendingauthsession.FieldEmailVerifiedAt]
- return ok
- }
- // ResetEmailVerifiedAt resets all changes to the "email_verified_at" field.
- func (m *PendingAuthSessionMutation) ResetEmailVerifiedAt() {
- m.email_verified_at = nil
- delete(m.clearedFields, pendingauthsession.FieldEmailVerifiedAt)
- }
- // SetPasswordVerifiedAt sets the "password_verified_at" field.
- func (m *PendingAuthSessionMutation) SetPasswordVerifiedAt(t time.Time) {
- m.password_verified_at = &t
- }
- // PasswordVerifiedAt returns the value of the "password_verified_at" field in the mutation.
- func (m *PendingAuthSessionMutation) PasswordVerifiedAt() (r time.Time, exists bool) {
- v := m.password_verified_at
- if v == nil {
- return
- }
- return *v, true
- }
- // OldPasswordVerifiedAt returns the old "password_verified_at" field's value of the PendingAuthSession entity.
- // If the PendingAuthSession object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *PendingAuthSessionMutation) OldPasswordVerifiedAt(ctx context.Context) (v *time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldPasswordVerifiedAt is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldPasswordVerifiedAt requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldPasswordVerifiedAt: %w", err)
- }
- return oldValue.PasswordVerifiedAt, nil
- }
- // ClearPasswordVerifiedAt clears the value of the "password_verified_at" field.
- func (m *PendingAuthSessionMutation) ClearPasswordVerifiedAt() {
- m.password_verified_at = nil
- m.clearedFields[pendingauthsession.FieldPasswordVerifiedAt] = struct{}{}
- }
- // PasswordVerifiedAtCleared returns if the "password_verified_at" field was cleared in this mutation.
- func (m *PendingAuthSessionMutation) PasswordVerifiedAtCleared() bool {
- _, ok := m.clearedFields[pendingauthsession.FieldPasswordVerifiedAt]
- return ok
- }
- // ResetPasswordVerifiedAt resets all changes to the "password_verified_at" field.
- func (m *PendingAuthSessionMutation) ResetPasswordVerifiedAt() {
- m.password_verified_at = nil
- delete(m.clearedFields, pendingauthsession.FieldPasswordVerifiedAt)
- }
- // SetTotpVerifiedAt sets the "totp_verified_at" field.
- func (m *PendingAuthSessionMutation) SetTotpVerifiedAt(t time.Time) {
- m.totp_verified_at = &t
- }
- // TotpVerifiedAt returns the value of the "totp_verified_at" field in the mutation.
- func (m *PendingAuthSessionMutation) TotpVerifiedAt() (r time.Time, exists bool) {
- v := m.totp_verified_at
- if v == nil {
- return
- }
- return *v, true
- }
- // OldTotpVerifiedAt returns the old "totp_verified_at" field's value of the PendingAuthSession entity.
- // If the PendingAuthSession object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *PendingAuthSessionMutation) OldTotpVerifiedAt(ctx context.Context) (v *time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldTotpVerifiedAt is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldTotpVerifiedAt requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldTotpVerifiedAt: %w", err)
- }
- return oldValue.TotpVerifiedAt, nil
- }
- // ClearTotpVerifiedAt clears the value of the "totp_verified_at" field.
- func (m *PendingAuthSessionMutation) ClearTotpVerifiedAt() {
- m.totp_verified_at = nil
- m.clearedFields[pendingauthsession.FieldTotpVerifiedAt] = struct{}{}
- }
- // TotpVerifiedAtCleared returns if the "totp_verified_at" field was cleared in this mutation.
- func (m *PendingAuthSessionMutation) TotpVerifiedAtCleared() bool {
- _, ok := m.clearedFields[pendingauthsession.FieldTotpVerifiedAt]
- return ok
- }
- // ResetTotpVerifiedAt resets all changes to the "totp_verified_at" field.
- func (m *PendingAuthSessionMutation) ResetTotpVerifiedAt() {
- m.totp_verified_at = nil
- delete(m.clearedFields, pendingauthsession.FieldTotpVerifiedAt)
- }
- // SetExpiresAt sets the "expires_at" field.
- func (m *PendingAuthSessionMutation) SetExpiresAt(t time.Time) {
- m.expires_at = &t
- }
- // ExpiresAt returns the value of the "expires_at" field in the mutation.
- func (m *PendingAuthSessionMutation) ExpiresAt() (r time.Time, exists bool) {
- v := m.expires_at
- if v == nil {
- return
- }
- return *v, true
- }
- // OldExpiresAt returns the old "expires_at" field's value of the PendingAuthSession entity.
- // If the PendingAuthSession object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *PendingAuthSessionMutation) OldExpiresAt(ctx context.Context) (v time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldExpiresAt is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldExpiresAt requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldExpiresAt: %w", err)
- }
- return oldValue.ExpiresAt, nil
- }
- // ResetExpiresAt resets all changes to the "expires_at" field.
- func (m *PendingAuthSessionMutation) ResetExpiresAt() {
- m.expires_at = nil
- }
- // SetConsumedAt sets the "consumed_at" field.
- func (m *PendingAuthSessionMutation) SetConsumedAt(t time.Time) {
- m.consumed_at = &t
- }
- // ConsumedAt returns the value of the "consumed_at" field in the mutation.
- func (m *PendingAuthSessionMutation) ConsumedAt() (r time.Time, exists bool) {
- v := m.consumed_at
- if v == nil {
- return
- }
- return *v, true
- }
- // OldConsumedAt returns the old "consumed_at" field's value of the PendingAuthSession entity.
- // If the PendingAuthSession object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *PendingAuthSessionMutation) OldConsumedAt(ctx context.Context) (v *time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldConsumedAt is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldConsumedAt requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldConsumedAt: %w", err)
- }
- return oldValue.ConsumedAt, nil
- }
- // ClearConsumedAt clears the value of the "consumed_at" field.
- func (m *PendingAuthSessionMutation) ClearConsumedAt() {
- m.consumed_at = nil
- m.clearedFields[pendingauthsession.FieldConsumedAt] = struct{}{}
- }
- // ConsumedAtCleared returns if the "consumed_at" field was cleared in this mutation.
- func (m *PendingAuthSessionMutation) ConsumedAtCleared() bool {
- _, ok := m.clearedFields[pendingauthsession.FieldConsumedAt]
- return ok
- }
- // ResetConsumedAt resets all changes to the "consumed_at" field.
- func (m *PendingAuthSessionMutation) ResetConsumedAt() {
- m.consumed_at = nil
- delete(m.clearedFields, pendingauthsession.FieldConsumedAt)
- }
- // ClearTargetUser clears the "target_user" edge to the User entity.
- func (m *PendingAuthSessionMutation) ClearTargetUser() {
- m.clearedtarget_user = true
- m.clearedFields[pendingauthsession.FieldTargetUserID] = struct{}{}
- }
- // TargetUserCleared reports if the "target_user" edge to the User entity was cleared.
- func (m *PendingAuthSessionMutation) TargetUserCleared() bool {
- return m.TargetUserIDCleared() || m.clearedtarget_user
- }
- // TargetUserIDs returns the "target_user" edge IDs in the mutation.
- // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
- // TargetUserID instead. It exists only for internal usage by the builders.
- func (m *PendingAuthSessionMutation) TargetUserIDs() (ids []int64) {
- if id := m.target_user; id != nil {
- ids = append(ids, *id)
- }
- return
- }
- // ResetTargetUser resets all changes to the "target_user" edge.
- func (m *PendingAuthSessionMutation) ResetTargetUser() {
- m.target_user = nil
- m.clearedtarget_user = false
- }
- // SetAdoptionDecisionID sets the "adoption_decision" edge to the IdentityAdoptionDecision entity by id.
- func (m *PendingAuthSessionMutation) SetAdoptionDecisionID(id int64) {
- m.adoption_decision = &id
- }
- // ClearAdoptionDecision clears the "adoption_decision" edge to the IdentityAdoptionDecision entity.
- func (m *PendingAuthSessionMutation) ClearAdoptionDecision() {
- m.clearedadoption_decision = true
- }
- // AdoptionDecisionCleared reports if the "adoption_decision" edge to the IdentityAdoptionDecision entity was cleared.
- func (m *PendingAuthSessionMutation) AdoptionDecisionCleared() bool {
- return m.clearedadoption_decision
- }
- // AdoptionDecisionID returns the "adoption_decision" edge ID in the mutation.
- func (m *PendingAuthSessionMutation) AdoptionDecisionID() (id int64, exists bool) {
- if m.adoption_decision != nil {
- return *m.adoption_decision, true
- }
- return
- }
- // AdoptionDecisionIDs returns the "adoption_decision" edge IDs in the mutation.
- // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
- // AdoptionDecisionID instead. It exists only for internal usage by the builders.
- func (m *PendingAuthSessionMutation) AdoptionDecisionIDs() (ids []int64) {
- if id := m.adoption_decision; id != nil {
- ids = append(ids, *id)
- }
- return
- }
- // ResetAdoptionDecision resets all changes to the "adoption_decision" edge.
- func (m *PendingAuthSessionMutation) ResetAdoptionDecision() {
- m.adoption_decision = nil
- m.clearedadoption_decision = false
- }
- // Where appends a list predicates to the PendingAuthSessionMutation builder.
- func (m *PendingAuthSessionMutation) Where(ps ...predicate.PendingAuthSession) {
- m.predicates = append(m.predicates, ps...)
- }
- // WhereP appends storage-level predicates to the PendingAuthSessionMutation builder. Using this method,
- // users can use type-assertion to append predicates that do not depend on any generated package.
- func (m *PendingAuthSessionMutation) WhereP(ps ...func(*sql.Selector)) {
- p := make([]predicate.PendingAuthSession, len(ps))
- for i := range ps {
- p[i] = ps[i]
- }
- m.Where(p...)
- }
- // Op returns the operation name.
- func (m *PendingAuthSessionMutation) Op() Op {
- return m.op
- }
- // SetOp allows setting the mutation operation.
- func (m *PendingAuthSessionMutation) SetOp(op Op) {
- m.op = op
- }
- // Type returns the node type of this mutation (PendingAuthSession).
- func (m *PendingAuthSessionMutation) Type() string {
- return m.typ
- }
- // Fields returns all fields that were changed during this mutation. Note that in
- // order to get all numeric fields that were incremented/decremented, call
- // AddedFields().
- func (m *PendingAuthSessionMutation) Fields() []string {
- fields := make([]string, 0, 21)
- if m.created_at != nil {
- fields = append(fields, pendingauthsession.FieldCreatedAt)
- }
- if m.updated_at != nil {
- fields = append(fields, pendingauthsession.FieldUpdatedAt)
- }
- if m.session_token != nil {
- fields = append(fields, pendingauthsession.FieldSessionToken)
- }
- if m.intent != nil {
- fields = append(fields, pendingauthsession.FieldIntent)
- }
- if m.provider_type != nil {
- fields = append(fields, pendingauthsession.FieldProviderType)
- }
- if m.provider_key != nil {
- fields = append(fields, pendingauthsession.FieldProviderKey)
- }
- if m.provider_subject != nil {
- fields = append(fields, pendingauthsession.FieldProviderSubject)
- }
- if m.target_user != nil {
- fields = append(fields, pendingauthsession.FieldTargetUserID)
- }
- if m.redirect_to != nil {
- fields = append(fields, pendingauthsession.FieldRedirectTo)
- }
- if m.resolved_email != nil {
- fields = append(fields, pendingauthsession.FieldResolvedEmail)
- }
- if m.registration_password_hash != nil {
- fields = append(fields, pendingauthsession.FieldRegistrationPasswordHash)
- }
- if m.upstream_identity_claims != nil {
- fields = append(fields, pendingauthsession.FieldUpstreamIdentityClaims)
- }
- if m.local_flow_state != nil {
- fields = append(fields, pendingauthsession.FieldLocalFlowState)
- }
- if m.browser_session_key != nil {
- fields = append(fields, pendingauthsession.FieldBrowserSessionKey)
- }
- if m.completion_code_hash != nil {
- fields = append(fields, pendingauthsession.FieldCompletionCodeHash)
- }
- if m.completion_code_expires_at != nil {
- fields = append(fields, pendingauthsession.FieldCompletionCodeExpiresAt)
- }
- if m.email_verified_at != nil {
- fields = append(fields, pendingauthsession.FieldEmailVerifiedAt)
- }
- if m.password_verified_at != nil {
- fields = append(fields, pendingauthsession.FieldPasswordVerifiedAt)
- }
- if m.totp_verified_at != nil {
- fields = append(fields, pendingauthsession.FieldTotpVerifiedAt)
- }
- if m.expires_at != nil {
- fields = append(fields, pendingauthsession.FieldExpiresAt)
- }
- if m.consumed_at != nil {
- fields = append(fields, pendingauthsession.FieldConsumedAt)
- }
- return fields
- }
- // Field returns the value of a field with the given name. The second boolean
- // return value indicates that this field was not set, or was not defined in the
- // schema.
- func (m *PendingAuthSessionMutation) Field(name string) (ent.Value, bool) {
- switch name {
- case pendingauthsession.FieldCreatedAt:
- return m.CreatedAt()
- case pendingauthsession.FieldUpdatedAt:
- return m.UpdatedAt()
- case pendingauthsession.FieldSessionToken:
- return m.SessionToken()
- case pendingauthsession.FieldIntent:
- return m.Intent()
- case pendingauthsession.FieldProviderType:
- return m.ProviderType()
- case pendingauthsession.FieldProviderKey:
- return m.ProviderKey()
- case pendingauthsession.FieldProviderSubject:
- return m.ProviderSubject()
- case pendingauthsession.FieldTargetUserID:
- return m.TargetUserID()
- case pendingauthsession.FieldRedirectTo:
- return m.RedirectTo()
- case pendingauthsession.FieldResolvedEmail:
- return m.ResolvedEmail()
- case pendingauthsession.FieldRegistrationPasswordHash:
- return m.RegistrationPasswordHash()
- case pendingauthsession.FieldUpstreamIdentityClaims:
- return m.UpstreamIdentityClaims()
- case pendingauthsession.FieldLocalFlowState:
- return m.LocalFlowState()
- case pendingauthsession.FieldBrowserSessionKey:
- return m.BrowserSessionKey()
- case pendingauthsession.FieldCompletionCodeHash:
- return m.CompletionCodeHash()
- case pendingauthsession.FieldCompletionCodeExpiresAt:
- return m.CompletionCodeExpiresAt()
- case pendingauthsession.FieldEmailVerifiedAt:
- return m.EmailVerifiedAt()
- case pendingauthsession.FieldPasswordVerifiedAt:
- return m.PasswordVerifiedAt()
- case pendingauthsession.FieldTotpVerifiedAt:
- return m.TotpVerifiedAt()
- case pendingauthsession.FieldExpiresAt:
- return m.ExpiresAt()
- case pendingauthsession.FieldConsumedAt:
- return m.ConsumedAt()
- }
- return nil, false
- }
- // OldField returns the old value of the field from the database. An error is
- // returned if the mutation operation is not UpdateOne, or the query to the
- // database failed.
- func (m *PendingAuthSessionMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
- switch name {
- case pendingauthsession.FieldCreatedAt:
- return m.OldCreatedAt(ctx)
- case pendingauthsession.FieldUpdatedAt:
- return m.OldUpdatedAt(ctx)
- case pendingauthsession.FieldSessionToken:
- return m.OldSessionToken(ctx)
- case pendingauthsession.FieldIntent:
- return m.OldIntent(ctx)
- case pendingauthsession.FieldProviderType:
- return m.OldProviderType(ctx)
- case pendingauthsession.FieldProviderKey:
- return m.OldProviderKey(ctx)
- case pendingauthsession.FieldProviderSubject:
- return m.OldProviderSubject(ctx)
- case pendingauthsession.FieldTargetUserID:
- return m.OldTargetUserID(ctx)
- case pendingauthsession.FieldRedirectTo:
- return m.OldRedirectTo(ctx)
- case pendingauthsession.FieldResolvedEmail:
- return m.OldResolvedEmail(ctx)
- case pendingauthsession.FieldRegistrationPasswordHash:
- return m.OldRegistrationPasswordHash(ctx)
- case pendingauthsession.FieldUpstreamIdentityClaims:
- return m.OldUpstreamIdentityClaims(ctx)
- case pendingauthsession.FieldLocalFlowState:
- return m.OldLocalFlowState(ctx)
- case pendingauthsession.FieldBrowserSessionKey:
- return m.OldBrowserSessionKey(ctx)
- case pendingauthsession.FieldCompletionCodeHash:
- return m.OldCompletionCodeHash(ctx)
- case pendingauthsession.FieldCompletionCodeExpiresAt:
- return m.OldCompletionCodeExpiresAt(ctx)
- case pendingauthsession.FieldEmailVerifiedAt:
- return m.OldEmailVerifiedAt(ctx)
- case pendingauthsession.FieldPasswordVerifiedAt:
- return m.OldPasswordVerifiedAt(ctx)
- case pendingauthsession.FieldTotpVerifiedAt:
- return m.OldTotpVerifiedAt(ctx)
- case pendingauthsession.FieldExpiresAt:
- return m.OldExpiresAt(ctx)
- case pendingauthsession.FieldConsumedAt:
- return m.OldConsumedAt(ctx)
- }
- return nil, fmt.Errorf("unknown PendingAuthSession field %s", name)
- }
- // SetField sets the value of a field with the given name. It returns an error if
- // the field is not defined in the schema, or if the type mismatched the field
- // type.
- func (m *PendingAuthSessionMutation) SetField(name string, value ent.Value) error {
- switch name {
- case pendingauthsession.FieldCreatedAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetCreatedAt(v)
- return nil
- case pendingauthsession.FieldUpdatedAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetUpdatedAt(v)
- return nil
- case pendingauthsession.FieldSessionToken:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetSessionToken(v)
- return nil
- case pendingauthsession.FieldIntent:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetIntent(v)
- return nil
- case pendingauthsession.FieldProviderType:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetProviderType(v)
- return nil
- case pendingauthsession.FieldProviderKey:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetProviderKey(v)
- return nil
- case pendingauthsession.FieldProviderSubject:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetProviderSubject(v)
- return nil
- case pendingauthsession.FieldTargetUserID:
- v, ok := value.(int64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetTargetUserID(v)
- return nil
- case pendingauthsession.FieldRedirectTo:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetRedirectTo(v)
- return nil
- case pendingauthsession.FieldResolvedEmail:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetResolvedEmail(v)
- return nil
- case pendingauthsession.FieldRegistrationPasswordHash:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetRegistrationPasswordHash(v)
- return nil
- case pendingauthsession.FieldUpstreamIdentityClaims:
- v, ok := value.(map[string]interface{})
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetUpstreamIdentityClaims(v)
- return nil
- case pendingauthsession.FieldLocalFlowState:
- v, ok := value.(map[string]interface{})
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetLocalFlowState(v)
- return nil
- case pendingauthsession.FieldBrowserSessionKey:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetBrowserSessionKey(v)
- return nil
- case pendingauthsession.FieldCompletionCodeHash:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetCompletionCodeHash(v)
- return nil
- case pendingauthsession.FieldCompletionCodeExpiresAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetCompletionCodeExpiresAt(v)
- return nil
- case pendingauthsession.FieldEmailVerifiedAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetEmailVerifiedAt(v)
- return nil
- case pendingauthsession.FieldPasswordVerifiedAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetPasswordVerifiedAt(v)
- return nil
- case pendingauthsession.FieldTotpVerifiedAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetTotpVerifiedAt(v)
- return nil
- case pendingauthsession.FieldExpiresAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetExpiresAt(v)
- return nil
- case pendingauthsession.FieldConsumedAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetConsumedAt(v)
- return nil
- }
- return fmt.Errorf("unknown PendingAuthSession field %s", name)
- }
- // AddedFields returns all numeric fields that were incremented/decremented during
- // this mutation.
- func (m *PendingAuthSessionMutation) AddedFields() []string {
- var fields []string
- return fields
- }
- // AddedField returns the numeric value that was incremented/decremented on a field
- // with the given name. The second boolean return value indicates that this field
- // was not set, or was not defined in the schema.
- func (m *PendingAuthSessionMutation) AddedField(name string) (ent.Value, bool) {
- switch name {
- }
- return nil, false
- }
- // AddField adds the value to the field with the given name. It returns an error if
- // the field is not defined in the schema, or if the type mismatched the field
- // type.
- func (m *PendingAuthSessionMutation) AddField(name string, value ent.Value) error {
- switch name {
- }
- return fmt.Errorf("unknown PendingAuthSession numeric field %s", name)
- }
- // ClearedFields returns all nullable fields that were cleared during this
- // mutation.
- func (m *PendingAuthSessionMutation) ClearedFields() []string {
- var fields []string
- if m.FieldCleared(pendingauthsession.FieldTargetUserID) {
- fields = append(fields, pendingauthsession.FieldTargetUserID)
- }
- if m.FieldCleared(pendingauthsession.FieldCompletionCodeExpiresAt) {
- fields = append(fields, pendingauthsession.FieldCompletionCodeExpiresAt)
- }
- if m.FieldCleared(pendingauthsession.FieldEmailVerifiedAt) {
- fields = append(fields, pendingauthsession.FieldEmailVerifiedAt)
- }
- if m.FieldCleared(pendingauthsession.FieldPasswordVerifiedAt) {
- fields = append(fields, pendingauthsession.FieldPasswordVerifiedAt)
- }
- if m.FieldCleared(pendingauthsession.FieldTotpVerifiedAt) {
- fields = append(fields, pendingauthsession.FieldTotpVerifiedAt)
- }
- if m.FieldCleared(pendingauthsession.FieldConsumedAt) {
- fields = append(fields, pendingauthsession.FieldConsumedAt)
- }
- return fields
- }
- // FieldCleared returns a boolean indicating if a field with the given name was
- // cleared in this mutation.
- func (m *PendingAuthSessionMutation) FieldCleared(name string) bool {
- _, ok := m.clearedFields[name]
- return ok
- }
- // ClearField clears the value of the field with the given name. It returns an
- // error if the field is not defined in the schema.
- func (m *PendingAuthSessionMutation) ClearField(name string) error {
- switch name {
- case pendingauthsession.FieldTargetUserID:
- m.ClearTargetUserID()
- return nil
- case pendingauthsession.FieldCompletionCodeExpiresAt:
- m.ClearCompletionCodeExpiresAt()
- return nil
- case pendingauthsession.FieldEmailVerifiedAt:
- m.ClearEmailVerifiedAt()
- return nil
- case pendingauthsession.FieldPasswordVerifiedAt:
- m.ClearPasswordVerifiedAt()
- return nil
- case pendingauthsession.FieldTotpVerifiedAt:
- m.ClearTotpVerifiedAt()
- return nil
- case pendingauthsession.FieldConsumedAt:
- m.ClearConsumedAt()
- return nil
- }
- return fmt.Errorf("unknown PendingAuthSession nullable field %s", name)
- }
- // ResetField resets all changes in the mutation for the field with the given name.
- // It returns an error if the field is not defined in the schema.
- func (m *PendingAuthSessionMutation) ResetField(name string) error {
- switch name {
- case pendingauthsession.FieldCreatedAt:
- m.ResetCreatedAt()
- return nil
- case pendingauthsession.FieldUpdatedAt:
- m.ResetUpdatedAt()
- return nil
- case pendingauthsession.FieldSessionToken:
- m.ResetSessionToken()
- return nil
- case pendingauthsession.FieldIntent:
- m.ResetIntent()
- return nil
- case pendingauthsession.FieldProviderType:
- m.ResetProviderType()
- return nil
- case pendingauthsession.FieldProviderKey:
- m.ResetProviderKey()
- return nil
- case pendingauthsession.FieldProviderSubject:
- m.ResetProviderSubject()
- return nil
- case pendingauthsession.FieldTargetUserID:
- m.ResetTargetUserID()
- return nil
- case pendingauthsession.FieldRedirectTo:
- m.ResetRedirectTo()
- return nil
- case pendingauthsession.FieldResolvedEmail:
- m.ResetResolvedEmail()
- return nil
- case pendingauthsession.FieldRegistrationPasswordHash:
- m.ResetRegistrationPasswordHash()
- return nil
- case pendingauthsession.FieldUpstreamIdentityClaims:
- m.ResetUpstreamIdentityClaims()
- return nil
- case pendingauthsession.FieldLocalFlowState:
- m.ResetLocalFlowState()
- return nil
- case pendingauthsession.FieldBrowserSessionKey:
- m.ResetBrowserSessionKey()
- return nil
- case pendingauthsession.FieldCompletionCodeHash:
- m.ResetCompletionCodeHash()
- return nil
- case pendingauthsession.FieldCompletionCodeExpiresAt:
- m.ResetCompletionCodeExpiresAt()
- return nil
- case pendingauthsession.FieldEmailVerifiedAt:
- m.ResetEmailVerifiedAt()
- return nil
- case pendingauthsession.FieldPasswordVerifiedAt:
- m.ResetPasswordVerifiedAt()
- return nil
- case pendingauthsession.FieldTotpVerifiedAt:
- m.ResetTotpVerifiedAt()
- return nil
- case pendingauthsession.FieldExpiresAt:
- m.ResetExpiresAt()
- return nil
- case pendingauthsession.FieldConsumedAt:
- m.ResetConsumedAt()
- return nil
- }
- return fmt.Errorf("unknown PendingAuthSession field %s", name)
- }
- // AddedEdges returns all edge names that were set/added in this mutation.
- func (m *PendingAuthSessionMutation) AddedEdges() []string {
- edges := make([]string, 0, 2)
- if m.target_user != nil {
- edges = append(edges, pendingauthsession.EdgeTargetUser)
- }
- if m.adoption_decision != nil {
- edges = append(edges, pendingauthsession.EdgeAdoptionDecision)
- }
- return edges
- }
- // AddedIDs returns all IDs (to other nodes) that were added for the given edge
- // name in this mutation.
- func (m *PendingAuthSessionMutation) AddedIDs(name string) []ent.Value {
- switch name {
- case pendingauthsession.EdgeTargetUser:
- if id := m.target_user; id != nil {
- return []ent.Value{*id}
- }
- case pendingauthsession.EdgeAdoptionDecision:
- if id := m.adoption_decision; id != nil {
- return []ent.Value{*id}
- }
- }
- return nil
- }
- // RemovedEdges returns all edge names that were removed in this mutation.
- func (m *PendingAuthSessionMutation) RemovedEdges() []string {
- edges := make([]string, 0, 2)
- return edges
- }
- // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
- // the given name in this mutation.
- func (m *PendingAuthSessionMutation) RemovedIDs(name string) []ent.Value {
- return nil
- }
- // ClearedEdges returns all edge names that were cleared in this mutation.
- func (m *PendingAuthSessionMutation) ClearedEdges() []string {
- edges := make([]string, 0, 2)
- if m.clearedtarget_user {
- edges = append(edges, pendingauthsession.EdgeTargetUser)
- }
- if m.clearedadoption_decision {
- edges = append(edges, pendingauthsession.EdgeAdoptionDecision)
- }
- return edges
- }
- // EdgeCleared returns a boolean which indicates if the edge with the given name
- // was cleared in this mutation.
- func (m *PendingAuthSessionMutation) EdgeCleared(name string) bool {
- switch name {
- case pendingauthsession.EdgeTargetUser:
- return m.clearedtarget_user
- case pendingauthsession.EdgeAdoptionDecision:
- return m.clearedadoption_decision
- }
- return false
- }
- // ClearEdge clears the value of the edge with the given name. It returns an error
- // if that edge is not defined in the schema.
- func (m *PendingAuthSessionMutation) ClearEdge(name string) error {
- switch name {
- case pendingauthsession.EdgeTargetUser:
- m.ClearTargetUser()
- return nil
- case pendingauthsession.EdgeAdoptionDecision:
- m.ClearAdoptionDecision()
- return nil
- }
- return fmt.Errorf("unknown PendingAuthSession unique edge %s", name)
- }
- // ResetEdge resets all changes to the edge with the given name in this mutation.
- // It returns an error if the edge is not defined in the schema.
- func (m *PendingAuthSessionMutation) ResetEdge(name string) error {
- switch name {
- case pendingauthsession.EdgeTargetUser:
- m.ResetTargetUser()
- return nil
- case pendingauthsession.EdgeAdoptionDecision:
- m.ResetAdoptionDecision()
- return nil
- }
- return fmt.Errorf("unknown PendingAuthSession edge %s", name)
- }
- // PromoCodeMutation represents an operation that mutates the PromoCode nodes in the graph.
- type PromoCodeMutation struct {
- config
- op Op
- typ string
- id *int64
- code *string
- bonus_amount *float64
- addbonus_amount *float64
- max_uses *int
- addmax_uses *int
- used_count *int
- addused_count *int
- status *string
- expires_at *time.Time
- notes *string
- created_at *time.Time
- updated_at *time.Time
- clearedFields map[string]struct{}
- usage_records map[int64]struct{}
- removedusage_records map[int64]struct{}
- clearedusage_records bool
- done bool
- oldValue func(context.Context) (*PromoCode, error)
- predicates []predicate.PromoCode
- }
- var _ ent.Mutation = (*PromoCodeMutation)(nil)
- // promocodeOption allows management of the mutation configuration using functional options.
- type promocodeOption func(*PromoCodeMutation)
- // newPromoCodeMutation creates new mutation for the PromoCode entity.
- func newPromoCodeMutation(c config, op Op, opts ...promocodeOption) *PromoCodeMutation {
- m := &PromoCodeMutation{
- config: c,
- op: op,
- typ: TypePromoCode,
- clearedFields: make(map[string]struct{}),
- }
- for _, opt := range opts {
- opt(m)
- }
- return m
- }
- // withPromoCodeID sets the ID field of the mutation.
- func withPromoCodeID(id int64) promocodeOption {
- return func(m *PromoCodeMutation) {
- var (
- err error
- once sync.Once
- value *PromoCode
- )
- m.oldValue = func(ctx context.Context) (*PromoCode, error) {
- once.Do(func() {
- if m.done {
- err = errors.New("querying old values post mutation is not allowed")
- } else {
- value, err = m.Client().PromoCode.Get(ctx, id)
- }
- })
- return value, err
- }
- m.id = &id
- }
- }
- // withPromoCode sets the old PromoCode of the mutation.
- func withPromoCode(node *PromoCode) promocodeOption {
- return func(m *PromoCodeMutation) {
- m.oldValue = func(context.Context) (*PromoCode, error) {
- return node, nil
- }
- m.id = &node.ID
- }
- }
- // Client returns a new `ent.Client` from the mutation. If the mutation was
- // executed in a transaction (ent.Tx), a transactional client is returned.
- func (m PromoCodeMutation) Client() *Client {
- client := &Client{config: m.config}
- client.init()
- return client
- }
- // Tx returns an `ent.Tx` for mutations that were executed in transactions;
- // it returns an error otherwise.
- func (m PromoCodeMutation) Tx() (*Tx, error) {
- if _, ok := m.driver.(*txDriver); !ok {
- return nil, errors.New("ent: mutation is not running in a transaction")
- }
- tx := &Tx{config: m.config}
- tx.init()
- return tx, nil
- }
- // ID returns the ID value in the mutation. Note that the ID is only available
- // if it was provided to the builder or after it was returned from the database.
- func (m *PromoCodeMutation) ID() (id int64, exists bool) {
- if m.id == nil {
- return
- }
- return *m.id, true
- }
- // IDs queries the database and returns the entity ids that match the mutation's predicate.
- // That means, if the mutation is applied within a transaction with an isolation level such
- // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
- // or updated by the mutation.
- func (m *PromoCodeMutation) IDs(ctx context.Context) ([]int64, error) {
- switch {
- case m.op.Is(OpUpdateOne | OpDeleteOne):
- id, exists := m.ID()
- if exists {
- return []int64{id}, nil
- }
- fallthrough
- case m.op.Is(OpUpdate | OpDelete):
- return m.Client().PromoCode.Query().Where(m.predicates...).IDs(ctx)
- default:
- return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
- }
- }
- // SetCode sets the "code" field.
- func (m *PromoCodeMutation) SetCode(s string) {
- m.code = &s
- }
- // Code returns the value of the "code" field in the mutation.
- func (m *PromoCodeMutation) Code() (r string, exists bool) {
- v := m.code
- if v == nil {
- return
- }
- return *v, true
- }
- // OldCode returns the old "code" field's value of the PromoCode entity.
- // If the PromoCode object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *PromoCodeMutation) OldCode(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldCode is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldCode requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldCode: %w", err)
- }
- return oldValue.Code, nil
- }
- // ResetCode resets all changes to the "code" field.
- func (m *PromoCodeMutation) ResetCode() {
- m.code = nil
- }
- // SetBonusAmount sets the "bonus_amount" field.
- func (m *PromoCodeMutation) SetBonusAmount(f float64) {
- m.bonus_amount = &f
- m.addbonus_amount = nil
- }
- // BonusAmount returns the value of the "bonus_amount" field in the mutation.
- func (m *PromoCodeMutation) BonusAmount() (r float64, exists bool) {
- v := m.bonus_amount
- if v == nil {
- return
- }
- return *v, true
- }
- // OldBonusAmount returns the old "bonus_amount" field's value of the PromoCode entity.
- // If the PromoCode object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *PromoCodeMutation) OldBonusAmount(ctx context.Context) (v float64, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldBonusAmount is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldBonusAmount requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldBonusAmount: %w", err)
- }
- return oldValue.BonusAmount, nil
- }
- // AddBonusAmount adds f to the "bonus_amount" field.
- func (m *PromoCodeMutation) AddBonusAmount(f float64) {
- if m.addbonus_amount != nil {
- *m.addbonus_amount += f
- } else {
- m.addbonus_amount = &f
- }
- }
- // AddedBonusAmount returns the value that was added to the "bonus_amount" field in this mutation.
- func (m *PromoCodeMutation) AddedBonusAmount() (r float64, exists bool) {
- v := m.addbonus_amount
- if v == nil {
- return
- }
- return *v, true
- }
- // ResetBonusAmount resets all changes to the "bonus_amount" field.
- func (m *PromoCodeMutation) ResetBonusAmount() {
- m.bonus_amount = nil
- m.addbonus_amount = nil
- }
- // SetMaxUses sets the "max_uses" field.
- func (m *PromoCodeMutation) SetMaxUses(i int) {
- m.max_uses = &i
- m.addmax_uses = nil
- }
- // MaxUses returns the value of the "max_uses" field in the mutation.
- func (m *PromoCodeMutation) MaxUses() (r int, exists bool) {
- v := m.max_uses
- if v == nil {
- return
- }
- return *v, true
- }
- // OldMaxUses returns the old "max_uses" field's value of the PromoCode entity.
- // If the PromoCode object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *PromoCodeMutation) OldMaxUses(ctx context.Context) (v int, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldMaxUses is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldMaxUses requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldMaxUses: %w", err)
- }
- return oldValue.MaxUses, nil
- }
- // AddMaxUses adds i to the "max_uses" field.
- func (m *PromoCodeMutation) AddMaxUses(i int) {
- if m.addmax_uses != nil {
- *m.addmax_uses += i
- } else {
- m.addmax_uses = &i
- }
- }
- // AddedMaxUses returns the value that was added to the "max_uses" field in this mutation.
- func (m *PromoCodeMutation) AddedMaxUses() (r int, exists bool) {
- v := m.addmax_uses
- if v == nil {
- return
- }
- return *v, true
- }
- // ResetMaxUses resets all changes to the "max_uses" field.
- func (m *PromoCodeMutation) ResetMaxUses() {
- m.max_uses = nil
- m.addmax_uses = nil
- }
- // SetUsedCount sets the "used_count" field.
- func (m *PromoCodeMutation) SetUsedCount(i int) {
- m.used_count = &i
- m.addused_count = nil
- }
- // UsedCount returns the value of the "used_count" field in the mutation.
- func (m *PromoCodeMutation) UsedCount() (r int, exists bool) {
- v := m.used_count
- if v == nil {
- return
- }
- return *v, true
- }
- // OldUsedCount returns the old "used_count" field's value of the PromoCode entity.
- // If the PromoCode object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *PromoCodeMutation) OldUsedCount(ctx context.Context) (v int, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldUsedCount is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldUsedCount requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldUsedCount: %w", err)
- }
- return oldValue.UsedCount, nil
- }
- // AddUsedCount adds i to the "used_count" field.
- func (m *PromoCodeMutation) AddUsedCount(i int) {
- if m.addused_count != nil {
- *m.addused_count += i
- } else {
- m.addused_count = &i
- }
- }
- // AddedUsedCount returns the value that was added to the "used_count" field in this mutation.
- func (m *PromoCodeMutation) AddedUsedCount() (r int, exists bool) {
- v := m.addused_count
- if v == nil {
- return
- }
- return *v, true
- }
- // ResetUsedCount resets all changes to the "used_count" field.
- func (m *PromoCodeMutation) ResetUsedCount() {
- m.used_count = nil
- m.addused_count = nil
- }
- // SetStatus sets the "status" field.
- func (m *PromoCodeMutation) SetStatus(s string) {
- m.status = &s
- }
- // Status returns the value of the "status" field in the mutation.
- func (m *PromoCodeMutation) Status() (r string, exists bool) {
- v := m.status
- if v == nil {
- return
- }
- return *v, true
- }
- // OldStatus returns the old "status" field's value of the PromoCode entity.
- // If the PromoCode object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *PromoCodeMutation) OldStatus(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldStatus is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldStatus requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldStatus: %w", err)
- }
- return oldValue.Status, nil
- }
- // ResetStatus resets all changes to the "status" field.
- func (m *PromoCodeMutation) ResetStatus() {
- m.status = nil
- }
- // SetExpiresAt sets the "expires_at" field.
- func (m *PromoCodeMutation) SetExpiresAt(t time.Time) {
- m.expires_at = &t
- }
- // ExpiresAt returns the value of the "expires_at" field in the mutation.
- func (m *PromoCodeMutation) ExpiresAt() (r time.Time, exists bool) {
- v := m.expires_at
- if v == nil {
- return
- }
- return *v, true
- }
- // OldExpiresAt returns the old "expires_at" field's value of the PromoCode entity.
- // If the PromoCode object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *PromoCodeMutation) OldExpiresAt(ctx context.Context) (v *time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldExpiresAt is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldExpiresAt requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldExpiresAt: %w", err)
- }
- return oldValue.ExpiresAt, nil
- }
- // ClearExpiresAt clears the value of the "expires_at" field.
- func (m *PromoCodeMutation) ClearExpiresAt() {
- m.expires_at = nil
- m.clearedFields[promocode.FieldExpiresAt] = struct{}{}
- }
- // ExpiresAtCleared returns if the "expires_at" field was cleared in this mutation.
- func (m *PromoCodeMutation) ExpiresAtCleared() bool {
- _, ok := m.clearedFields[promocode.FieldExpiresAt]
- return ok
- }
- // ResetExpiresAt resets all changes to the "expires_at" field.
- func (m *PromoCodeMutation) ResetExpiresAt() {
- m.expires_at = nil
- delete(m.clearedFields, promocode.FieldExpiresAt)
- }
- // SetNotes sets the "notes" field.
- func (m *PromoCodeMutation) SetNotes(s string) {
- m.notes = &s
- }
- // Notes returns the value of the "notes" field in the mutation.
- func (m *PromoCodeMutation) Notes() (r string, exists bool) {
- v := m.notes
- if v == nil {
- return
- }
- return *v, true
- }
- // OldNotes returns the old "notes" field's value of the PromoCode entity.
- // If the PromoCode object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *PromoCodeMutation) OldNotes(ctx context.Context) (v *string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldNotes is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldNotes requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldNotes: %w", err)
- }
- return oldValue.Notes, nil
- }
- // ClearNotes clears the value of the "notes" field.
- func (m *PromoCodeMutation) ClearNotes() {
- m.notes = nil
- m.clearedFields[promocode.FieldNotes] = struct{}{}
- }
- // NotesCleared returns if the "notes" field was cleared in this mutation.
- func (m *PromoCodeMutation) NotesCleared() bool {
- _, ok := m.clearedFields[promocode.FieldNotes]
- return ok
- }
- // ResetNotes resets all changes to the "notes" field.
- func (m *PromoCodeMutation) ResetNotes() {
- m.notes = nil
- delete(m.clearedFields, promocode.FieldNotes)
- }
- // SetCreatedAt sets the "created_at" field.
- func (m *PromoCodeMutation) SetCreatedAt(t time.Time) {
- m.created_at = &t
- }
- // CreatedAt returns the value of the "created_at" field in the mutation.
- func (m *PromoCodeMutation) CreatedAt() (r time.Time, exists bool) {
- v := m.created_at
- if v == nil {
- return
- }
- return *v, true
- }
- // OldCreatedAt returns the old "created_at" field's value of the PromoCode entity.
- // If the PromoCode object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *PromoCodeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldCreatedAt requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
- }
- return oldValue.CreatedAt, nil
- }
- // ResetCreatedAt resets all changes to the "created_at" field.
- func (m *PromoCodeMutation) ResetCreatedAt() {
- m.created_at = nil
- }
- // SetUpdatedAt sets the "updated_at" field.
- func (m *PromoCodeMutation) SetUpdatedAt(t time.Time) {
- m.updated_at = &t
- }
- // UpdatedAt returns the value of the "updated_at" field in the mutation.
- func (m *PromoCodeMutation) UpdatedAt() (r time.Time, exists bool) {
- v := m.updated_at
- if v == nil {
- return
- }
- return *v, true
- }
- // OldUpdatedAt returns the old "updated_at" field's value of the PromoCode entity.
- // If the PromoCode object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *PromoCodeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
- }
- return oldValue.UpdatedAt, nil
- }
- // ResetUpdatedAt resets all changes to the "updated_at" field.
- func (m *PromoCodeMutation) ResetUpdatedAt() {
- m.updated_at = nil
- }
- // AddUsageRecordIDs adds the "usage_records" edge to the PromoCodeUsage entity by ids.
- func (m *PromoCodeMutation) AddUsageRecordIDs(ids ...int64) {
- if m.usage_records == nil {
- m.usage_records = make(map[int64]struct{})
- }
- for i := range ids {
- m.usage_records[ids[i]] = struct{}{}
- }
- }
- // ClearUsageRecords clears the "usage_records" edge to the PromoCodeUsage entity.
- func (m *PromoCodeMutation) ClearUsageRecords() {
- m.clearedusage_records = true
- }
- // UsageRecordsCleared reports if the "usage_records" edge to the PromoCodeUsage entity was cleared.
- func (m *PromoCodeMutation) UsageRecordsCleared() bool {
- return m.clearedusage_records
- }
- // RemoveUsageRecordIDs removes the "usage_records" edge to the PromoCodeUsage entity by IDs.
- func (m *PromoCodeMutation) RemoveUsageRecordIDs(ids ...int64) {
- if m.removedusage_records == nil {
- m.removedusage_records = make(map[int64]struct{})
- }
- for i := range ids {
- delete(m.usage_records, ids[i])
- m.removedusage_records[ids[i]] = struct{}{}
- }
- }
- // RemovedUsageRecords returns the removed IDs of the "usage_records" edge to the PromoCodeUsage entity.
- func (m *PromoCodeMutation) RemovedUsageRecordsIDs() (ids []int64) {
- for id := range m.removedusage_records {
- ids = append(ids, id)
- }
- return
- }
- // UsageRecordsIDs returns the "usage_records" edge IDs in the mutation.
- func (m *PromoCodeMutation) UsageRecordsIDs() (ids []int64) {
- for id := range m.usage_records {
- ids = append(ids, id)
- }
- return
- }
- // ResetUsageRecords resets all changes to the "usage_records" edge.
- func (m *PromoCodeMutation) ResetUsageRecords() {
- m.usage_records = nil
- m.clearedusage_records = false
- m.removedusage_records = nil
- }
- // Where appends a list predicates to the PromoCodeMutation builder.
- func (m *PromoCodeMutation) Where(ps ...predicate.PromoCode) {
- m.predicates = append(m.predicates, ps...)
- }
- // WhereP appends storage-level predicates to the PromoCodeMutation builder. Using this method,
- // users can use type-assertion to append predicates that do not depend on any generated package.
- func (m *PromoCodeMutation) WhereP(ps ...func(*sql.Selector)) {
- p := make([]predicate.PromoCode, len(ps))
- for i := range ps {
- p[i] = ps[i]
- }
- m.Where(p...)
- }
- // Op returns the operation name.
- func (m *PromoCodeMutation) Op() Op {
- return m.op
- }
- // SetOp allows setting the mutation operation.
- func (m *PromoCodeMutation) SetOp(op Op) {
- m.op = op
- }
- // Type returns the node type of this mutation (PromoCode).
- func (m *PromoCodeMutation) Type() string {
- return m.typ
- }
- // Fields returns all fields that were changed during this mutation. Note that in
- // order to get all numeric fields that were incremented/decremented, call
- // AddedFields().
- func (m *PromoCodeMutation) Fields() []string {
- fields := make([]string, 0, 9)
- if m.code != nil {
- fields = append(fields, promocode.FieldCode)
- }
- if m.bonus_amount != nil {
- fields = append(fields, promocode.FieldBonusAmount)
- }
- if m.max_uses != nil {
- fields = append(fields, promocode.FieldMaxUses)
- }
- if m.used_count != nil {
- fields = append(fields, promocode.FieldUsedCount)
- }
- if m.status != nil {
- fields = append(fields, promocode.FieldStatus)
- }
- if m.expires_at != nil {
- fields = append(fields, promocode.FieldExpiresAt)
- }
- if m.notes != nil {
- fields = append(fields, promocode.FieldNotes)
- }
- if m.created_at != nil {
- fields = append(fields, promocode.FieldCreatedAt)
- }
- if m.updated_at != nil {
- fields = append(fields, promocode.FieldUpdatedAt)
- }
- return fields
- }
- // Field returns the value of a field with the given name. The second boolean
- // return value indicates that this field was not set, or was not defined in the
- // schema.
- func (m *PromoCodeMutation) Field(name string) (ent.Value, bool) {
- switch name {
- case promocode.FieldCode:
- return m.Code()
- case promocode.FieldBonusAmount:
- return m.BonusAmount()
- case promocode.FieldMaxUses:
- return m.MaxUses()
- case promocode.FieldUsedCount:
- return m.UsedCount()
- case promocode.FieldStatus:
- return m.Status()
- case promocode.FieldExpiresAt:
- return m.ExpiresAt()
- case promocode.FieldNotes:
- return m.Notes()
- case promocode.FieldCreatedAt:
- return m.CreatedAt()
- case promocode.FieldUpdatedAt:
- return m.UpdatedAt()
- }
- return nil, false
- }
- // OldField returns the old value of the field from the database. An error is
- // returned if the mutation operation is not UpdateOne, or the query to the
- // database failed.
- func (m *PromoCodeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
- switch name {
- case promocode.FieldCode:
- return m.OldCode(ctx)
- case promocode.FieldBonusAmount:
- return m.OldBonusAmount(ctx)
- case promocode.FieldMaxUses:
- return m.OldMaxUses(ctx)
- case promocode.FieldUsedCount:
- return m.OldUsedCount(ctx)
- case promocode.FieldStatus:
- return m.OldStatus(ctx)
- case promocode.FieldExpiresAt:
- return m.OldExpiresAt(ctx)
- case promocode.FieldNotes:
- return m.OldNotes(ctx)
- case promocode.FieldCreatedAt:
- return m.OldCreatedAt(ctx)
- case promocode.FieldUpdatedAt:
- return m.OldUpdatedAt(ctx)
- }
- return nil, fmt.Errorf("unknown PromoCode field %s", name)
- }
- // SetField sets the value of a field with the given name. It returns an error if
- // the field is not defined in the schema, or if the type mismatched the field
- // type.
- func (m *PromoCodeMutation) SetField(name string, value ent.Value) error {
- switch name {
- case promocode.FieldCode:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetCode(v)
- return nil
- case promocode.FieldBonusAmount:
- v, ok := value.(float64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetBonusAmount(v)
- return nil
- case promocode.FieldMaxUses:
- v, ok := value.(int)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetMaxUses(v)
- return nil
- case promocode.FieldUsedCount:
- v, ok := value.(int)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetUsedCount(v)
- return nil
- case promocode.FieldStatus:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetStatus(v)
- return nil
- case promocode.FieldExpiresAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetExpiresAt(v)
- return nil
- case promocode.FieldNotes:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetNotes(v)
- return nil
- case promocode.FieldCreatedAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetCreatedAt(v)
- return nil
- case promocode.FieldUpdatedAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetUpdatedAt(v)
- return nil
- }
- return fmt.Errorf("unknown PromoCode field %s", name)
- }
- // AddedFields returns all numeric fields that were incremented/decremented during
- // this mutation.
- func (m *PromoCodeMutation) AddedFields() []string {
- var fields []string
- if m.addbonus_amount != nil {
- fields = append(fields, promocode.FieldBonusAmount)
- }
- if m.addmax_uses != nil {
- fields = append(fields, promocode.FieldMaxUses)
- }
- if m.addused_count != nil {
- fields = append(fields, promocode.FieldUsedCount)
- }
- return fields
- }
- // AddedField returns the numeric value that was incremented/decremented on a field
- // with the given name. The second boolean return value indicates that this field
- // was not set, or was not defined in the schema.
- func (m *PromoCodeMutation) AddedField(name string) (ent.Value, bool) {
- switch name {
- case promocode.FieldBonusAmount:
- return m.AddedBonusAmount()
- case promocode.FieldMaxUses:
- return m.AddedMaxUses()
- case promocode.FieldUsedCount:
- return m.AddedUsedCount()
- }
- return nil, false
- }
- // AddField adds the value to the field with the given name. It returns an error if
- // the field is not defined in the schema, or if the type mismatched the field
- // type.
- func (m *PromoCodeMutation) AddField(name string, value ent.Value) error {
- switch name {
- case promocode.FieldBonusAmount:
- v, ok := value.(float64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.AddBonusAmount(v)
- return nil
- case promocode.FieldMaxUses:
- v, ok := value.(int)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.AddMaxUses(v)
- return nil
- case promocode.FieldUsedCount:
- v, ok := value.(int)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.AddUsedCount(v)
- return nil
- }
- return fmt.Errorf("unknown PromoCode numeric field %s", name)
- }
- // ClearedFields returns all nullable fields that were cleared during this
- // mutation.
- func (m *PromoCodeMutation) ClearedFields() []string {
- var fields []string
- if m.FieldCleared(promocode.FieldExpiresAt) {
- fields = append(fields, promocode.FieldExpiresAt)
- }
- if m.FieldCleared(promocode.FieldNotes) {
- fields = append(fields, promocode.FieldNotes)
- }
- return fields
- }
- // FieldCleared returns a boolean indicating if a field with the given name was
- // cleared in this mutation.
- func (m *PromoCodeMutation) FieldCleared(name string) bool {
- _, ok := m.clearedFields[name]
- return ok
- }
- // ClearField clears the value of the field with the given name. It returns an
- // error if the field is not defined in the schema.
- func (m *PromoCodeMutation) ClearField(name string) error {
- switch name {
- case promocode.FieldExpiresAt:
- m.ClearExpiresAt()
- return nil
- case promocode.FieldNotes:
- m.ClearNotes()
- return nil
- }
- return fmt.Errorf("unknown PromoCode nullable field %s", name)
- }
- // ResetField resets all changes in the mutation for the field with the given name.
- // It returns an error if the field is not defined in the schema.
- func (m *PromoCodeMutation) ResetField(name string) error {
- switch name {
- case promocode.FieldCode:
- m.ResetCode()
- return nil
- case promocode.FieldBonusAmount:
- m.ResetBonusAmount()
- return nil
- case promocode.FieldMaxUses:
- m.ResetMaxUses()
- return nil
- case promocode.FieldUsedCount:
- m.ResetUsedCount()
- return nil
- case promocode.FieldStatus:
- m.ResetStatus()
- return nil
- case promocode.FieldExpiresAt:
- m.ResetExpiresAt()
- return nil
- case promocode.FieldNotes:
- m.ResetNotes()
- return nil
- case promocode.FieldCreatedAt:
- m.ResetCreatedAt()
- return nil
- case promocode.FieldUpdatedAt:
- m.ResetUpdatedAt()
- return nil
- }
- return fmt.Errorf("unknown PromoCode field %s", name)
- }
- // AddedEdges returns all edge names that were set/added in this mutation.
- func (m *PromoCodeMutation) AddedEdges() []string {
- edges := make([]string, 0, 1)
- if m.usage_records != nil {
- edges = append(edges, promocode.EdgeUsageRecords)
- }
- return edges
- }
- // AddedIDs returns all IDs (to other nodes) that were added for the given edge
- // name in this mutation.
- func (m *PromoCodeMutation) AddedIDs(name string) []ent.Value {
- switch name {
- case promocode.EdgeUsageRecords:
- ids := make([]ent.Value, 0, len(m.usage_records))
- for id := range m.usage_records {
- ids = append(ids, id)
- }
- return ids
- }
- return nil
- }
- // RemovedEdges returns all edge names that were removed in this mutation.
- func (m *PromoCodeMutation) RemovedEdges() []string {
- edges := make([]string, 0, 1)
- if m.removedusage_records != nil {
- edges = append(edges, promocode.EdgeUsageRecords)
- }
- return edges
- }
- // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
- // the given name in this mutation.
- func (m *PromoCodeMutation) RemovedIDs(name string) []ent.Value {
- switch name {
- case promocode.EdgeUsageRecords:
- ids := make([]ent.Value, 0, len(m.removedusage_records))
- for id := range m.removedusage_records {
- ids = append(ids, id)
- }
- return ids
- }
- return nil
- }
- // ClearedEdges returns all edge names that were cleared in this mutation.
- func (m *PromoCodeMutation) ClearedEdges() []string {
- edges := make([]string, 0, 1)
- if m.clearedusage_records {
- edges = append(edges, promocode.EdgeUsageRecords)
- }
- return edges
- }
- // EdgeCleared returns a boolean which indicates if the edge with the given name
- // was cleared in this mutation.
- func (m *PromoCodeMutation) EdgeCleared(name string) bool {
- switch name {
- case promocode.EdgeUsageRecords:
- return m.clearedusage_records
- }
- return false
- }
- // ClearEdge clears the value of the edge with the given name. It returns an error
- // if that edge is not defined in the schema.
- func (m *PromoCodeMutation) ClearEdge(name string) error {
- switch name {
- }
- return fmt.Errorf("unknown PromoCode unique edge %s", name)
- }
- // ResetEdge resets all changes to the edge with the given name in this mutation.
- // It returns an error if the edge is not defined in the schema.
- func (m *PromoCodeMutation) ResetEdge(name string) error {
- switch name {
- case promocode.EdgeUsageRecords:
- m.ResetUsageRecords()
- return nil
- }
- return fmt.Errorf("unknown PromoCode edge %s", name)
- }
- // PromoCodeUsageMutation represents an operation that mutates the PromoCodeUsage nodes in the graph.
- type PromoCodeUsageMutation struct {
- config
- op Op
- typ string
- id *int64
- bonus_amount *float64
- addbonus_amount *float64
- used_at *time.Time
- clearedFields map[string]struct{}
- promo_code *int64
- clearedpromo_code bool
- user *int64
- cleareduser bool
- done bool
- oldValue func(context.Context) (*PromoCodeUsage, error)
- predicates []predicate.PromoCodeUsage
- }
- var _ ent.Mutation = (*PromoCodeUsageMutation)(nil)
- // promocodeusageOption allows management of the mutation configuration using functional options.
- type promocodeusageOption func(*PromoCodeUsageMutation)
- // newPromoCodeUsageMutation creates new mutation for the PromoCodeUsage entity.
- func newPromoCodeUsageMutation(c config, op Op, opts ...promocodeusageOption) *PromoCodeUsageMutation {
- m := &PromoCodeUsageMutation{
- config: c,
- op: op,
- typ: TypePromoCodeUsage,
- clearedFields: make(map[string]struct{}),
- }
- for _, opt := range opts {
- opt(m)
- }
- return m
- }
- // withPromoCodeUsageID sets the ID field of the mutation.
- func withPromoCodeUsageID(id int64) promocodeusageOption {
- return func(m *PromoCodeUsageMutation) {
- var (
- err error
- once sync.Once
- value *PromoCodeUsage
- )
- m.oldValue = func(ctx context.Context) (*PromoCodeUsage, error) {
- once.Do(func() {
- if m.done {
- err = errors.New("querying old values post mutation is not allowed")
- } else {
- value, err = m.Client().PromoCodeUsage.Get(ctx, id)
- }
- })
- return value, err
- }
- m.id = &id
- }
- }
- // withPromoCodeUsage sets the old PromoCodeUsage of the mutation.
- func withPromoCodeUsage(node *PromoCodeUsage) promocodeusageOption {
- return func(m *PromoCodeUsageMutation) {
- m.oldValue = func(context.Context) (*PromoCodeUsage, error) {
- return node, nil
- }
- m.id = &node.ID
- }
- }
- // Client returns a new `ent.Client` from the mutation. If the mutation was
- // executed in a transaction (ent.Tx), a transactional client is returned.
- func (m PromoCodeUsageMutation) Client() *Client {
- client := &Client{config: m.config}
- client.init()
- return client
- }
- // Tx returns an `ent.Tx` for mutations that were executed in transactions;
- // it returns an error otherwise.
- func (m PromoCodeUsageMutation) Tx() (*Tx, error) {
- if _, ok := m.driver.(*txDriver); !ok {
- return nil, errors.New("ent: mutation is not running in a transaction")
- }
- tx := &Tx{config: m.config}
- tx.init()
- return tx, nil
- }
- // ID returns the ID value in the mutation. Note that the ID is only available
- // if it was provided to the builder or after it was returned from the database.
- func (m *PromoCodeUsageMutation) ID() (id int64, exists bool) {
- if m.id == nil {
- return
- }
- return *m.id, true
- }
- // IDs queries the database and returns the entity ids that match the mutation's predicate.
- // That means, if the mutation is applied within a transaction with an isolation level such
- // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
- // or updated by the mutation.
- func (m *PromoCodeUsageMutation) IDs(ctx context.Context) ([]int64, error) {
- switch {
- case m.op.Is(OpUpdateOne | OpDeleteOne):
- id, exists := m.ID()
- if exists {
- return []int64{id}, nil
- }
- fallthrough
- case m.op.Is(OpUpdate | OpDelete):
- return m.Client().PromoCodeUsage.Query().Where(m.predicates...).IDs(ctx)
- default:
- return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
- }
- }
- // SetPromoCodeID sets the "promo_code_id" field.
- func (m *PromoCodeUsageMutation) SetPromoCodeID(i int64) {
- m.promo_code = &i
- }
- // PromoCodeID returns the value of the "promo_code_id" field in the mutation.
- func (m *PromoCodeUsageMutation) PromoCodeID() (r int64, exists bool) {
- v := m.promo_code
- if v == nil {
- return
- }
- return *v, true
- }
- // OldPromoCodeID returns the old "promo_code_id" field's value of the PromoCodeUsage entity.
- // If the PromoCodeUsage object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *PromoCodeUsageMutation) OldPromoCodeID(ctx context.Context) (v int64, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldPromoCodeID is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldPromoCodeID requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldPromoCodeID: %w", err)
- }
- return oldValue.PromoCodeID, nil
- }
- // ResetPromoCodeID resets all changes to the "promo_code_id" field.
- func (m *PromoCodeUsageMutation) ResetPromoCodeID() {
- m.promo_code = nil
- }
- // SetUserID sets the "user_id" field.
- func (m *PromoCodeUsageMutation) SetUserID(i int64) {
- m.user = &i
- }
- // UserID returns the value of the "user_id" field in the mutation.
- func (m *PromoCodeUsageMutation) UserID() (r int64, exists bool) {
- v := m.user
- if v == nil {
- return
- }
- return *v, true
- }
- // OldUserID returns the old "user_id" field's value of the PromoCodeUsage entity.
- // If the PromoCodeUsage object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *PromoCodeUsageMutation) OldUserID(ctx context.Context) (v int64, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldUserID is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldUserID requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldUserID: %w", err)
- }
- return oldValue.UserID, nil
- }
- // ResetUserID resets all changes to the "user_id" field.
- func (m *PromoCodeUsageMutation) ResetUserID() {
- m.user = nil
- }
- // SetBonusAmount sets the "bonus_amount" field.
- func (m *PromoCodeUsageMutation) SetBonusAmount(f float64) {
- m.bonus_amount = &f
- m.addbonus_amount = nil
- }
- // BonusAmount returns the value of the "bonus_amount" field in the mutation.
- func (m *PromoCodeUsageMutation) BonusAmount() (r float64, exists bool) {
- v := m.bonus_amount
- if v == nil {
- return
- }
- return *v, true
- }
- // OldBonusAmount returns the old "bonus_amount" field's value of the PromoCodeUsage entity.
- // If the PromoCodeUsage object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *PromoCodeUsageMutation) OldBonusAmount(ctx context.Context) (v float64, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldBonusAmount is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldBonusAmount requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldBonusAmount: %w", err)
- }
- return oldValue.BonusAmount, nil
- }
- // AddBonusAmount adds f to the "bonus_amount" field.
- func (m *PromoCodeUsageMutation) AddBonusAmount(f float64) {
- if m.addbonus_amount != nil {
- *m.addbonus_amount += f
- } else {
- m.addbonus_amount = &f
- }
- }
- // AddedBonusAmount returns the value that was added to the "bonus_amount" field in this mutation.
- func (m *PromoCodeUsageMutation) AddedBonusAmount() (r float64, exists bool) {
- v := m.addbonus_amount
- if v == nil {
- return
- }
- return *v, true
- }
- // ResetBonusAmount resets all changes to the "bonus_amount" field.
- func (m *PromoCodeUsageMutation) ResetBonusAmount() {
- m.bonus_amount = nil
- m.addbonus_amount = nil
- }
- // SetUsedAt sets the "used_at" field.
- func (m *PromoCodeUsageMutation) SetUsedAt(t time.Time) {
- m.used_at = &t
- }
- // UsedAt returns the value of the "used_at" field in the mutation.
- func (m *PromoCodeUsageMutation) UsedAt() (r time.Time, exists bool) {
- v := m.used_at
- if v == nil {
- return
- }
- return *v, true
- }
- // OldUsedAt returns the old "used_at" field's value of the PromoCodeUsage entity.
- // If the PromoCodeUsage object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *PromoCodeUsageMutation) OldUsedAt(ctx context.Context) (v time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldUsedAt is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldUsedAt requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldUsedAt: %w", err)
- }
- return oldValue.UsedAt, nil
- }
- // ResetUsedAt resets all changes to the "used_at" field.
- func (m *PromoCodeUsageMutation) ResetUsedAt() {
- m.used_at = nil
- }
- // ClearPromoCode clears the "promo_code" edge to the PromoCode entity.
- func (m *PromoCodeUsageMutation) ClearPromoCode() {
- m.clearedpromo_code = true
- m.clearedFields[promocodeusage.FieldPromoCodeID] = struct{}{}
- }
- // PromoCodeCleared reports if the "promo_code" edge to the PromoCode entity was cleared.
- func (m *PromoCodeUsageMutation) PromoCodeCleared() bool {
- return m.clearedpromo_code
- }
- // PromoCodeIDs returns the "promo_code" edge IDs in the mutation.
- // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
- // PromoCodeID instead. It exists only for internal usage by the builders.
- func (m *PromoCodeUsageMutation) PromoCodeIDs() (ids []int64) {
- if id := m.promo_code; id != nil {
- ids = append(ids, *id)
- }
- return
- }
- // ResetPromoCode resets all changes to the "promo_code" edge.
- func (m *PromoCodeUsageMutation) ResetPromoCode() {
- m.promo_code = nil
- m.clearedpromo_code = false
- }
- // ClearUser clears the "user" edge to the User entity.
- func (m *PromoCodeUsageMutation) ClearUser() {
- m.cleareduser = true
- m.clearedFields[promocodeusage.FieldUserID] = struct{}{}
- }
- // UserCleared reports if the "user" edge to the User entity was cleared.
- func (m *PromoCodeUsageMutation) UserCleared() bool {
- return m.cleareduser
- }
- // UserIDs returns the "user" edge IDs in the mutation.
- // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
- // UserID instead. It exists only for internal usage by the builders.
- func (m *PromoCodeUsageMutation) UserIDs() (ids []int64) {
- if id := m.user; id != nil {
- ids = append(ids, *id)
- }
- return
- }
- // ResetUser resets all changes to the "user" edge.
- func (m *PromoCodeUsageMutation) ResetUser() {
- m.user = nil
- m.cleareduser = false
- }
- // Where appends a list predicates to the PromoCodeUsageMutation builder.
- func (m *PromoCodeUsageMutation) Where(ps ...predicate.PromoCodeUsage) {
- m.predicates = append(m.predicates, ps...)
- }
- // WhereP appends storage-level predicates to the PromoCodeUsageMutation builder. Using this method,
- // users can use type-assertion to append predicates that do not depend on any generated package.
- func (m *PromoCodeUsageMutation) WhereP(ps ...func(*sql.Selector)) {
- p := make([]predicate.PromoCodeUsage, len(ps))
- for i := range ps {
- p[i] = ps[i]
- }
- m.Where(p...)
- }
- // Op returns the operation name.
- func (m *PromoCodeUsageMutation) Op() Op {
- return m.op
- }
- // SetOp allows setting the mutation operation.
- func (m *PromoCodeUsageMutation) SetOp(op Op) {
- m.op = op
- }
- // Type returns the node type of this mutation (PromoCodeUsage).
- func (m *PromoCodeUsageMutation) Type() string {
- return m.typ
- }
- // Fields returns all fields that were changed during this mutation. Note that in
- // order to get all numeric fields that were incremented/decremented, call
- // AddedFields().
- func (m *PromoCodeUsageMutation) Fields() []string {
- fields := make([]string, 0, 4)
- if m.promo_code != nil {
- fields = append(fields, promocodeusage.FieldPromoCodeID)
- }
- if m.user != nil {
- fields = append(fields, promocodeusage.FieldUserID)
- }
- if m.bonus_amount != nil {
- fields = append(fields, promocodeusage.FieldBonusAmount)
- }
- if m.used_at != nil {
- fields = append(fields, promocodeusage.FieldUsedAt)
- }
- return fields
- }
- // Field returns the value of a field with the given name. The second boolean
- // return value indicates that this field was not set, or was not defined in the
- // schema.
- func (m *PromoCodeUsageMutation) Field(name string) (ent.Value, bool) {
- switch name {
- case promocodeusage.FieldPromoCodeID:
- return m.PromoCodeID()
- case promocodeusage.FieldUserID:
- return m.UserID()
- case promocodeusage.FieldBonusAmount:
- return m.BonusAmount()
- case promocodeusage.FieldUsedAt:
- return m.UsedAt()
- }
- return nil, false
- }
- // OldField returns the old value of the field from the database. An error is
- // returned if the mutation operation is not UpdateOne, or the query to the
- // database failed.
- func (m *PromoCodeUsageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
- switch name {
- case promocodeusage.FieldPromoCodeID:
- return m.OldPromoCodeID(ctx)
- case promocodeusage.FieldUserID:
- return m.OldUserID(ctx)
- case promocodeusage.FieldBonusAmount:
- return m.OldBonusAmount(ctx)
- case promocodeusage.FieldUsedAt:
- return m.OldUsedAt(ctx)
- }
- return nil, fmt.Errorf("unknown PromoCodeUsage field %s", name)
- }
- // SetField sets the value of a field with the given name. It returns an error if
- // the field is not defined in the schema, or if the type mismatched the field
- // type.
- func (m *PromoCodeUsageMutation) SetField(name string, value ent.Value) error {
- switch name {
- case promocodeusage.FieldPromoCodeID:
- v, ok := value.(int64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetPromoCodeID(v)
- return nil
- case promocodeusage.FieldUserID:
- v, ok := value.(int64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetUserID(v)
- return nil
- case promocodeusage.FieldBonusAmount:
- v, ok := value.(float64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetBonusAmount(v)
- return nil
- case promocodeusage.FieldUsedAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetUsedAt(v)
- return nil
- }
- return fmt.Errorf("unknown PromoCodeUsage field %s", name)
- }
- // AddedFields returns all numeric fields that were incremented/decremented during
- // this mutation.
- func (m *PromoCodeUsageMutation) AddedFields() []string {
- var fields []string
- if m.addbonus_amount != nil {
- fields = append(fields, promocodeusage.FieldBonusAmount)
- }
- return fields
- }
- // AddedField returns the numeric value that was incremented/decremented on a field
- // with the given name. The second boolean return value indicates that this field
- // was not set, or was not defined in the schema.
- func (m *PromoCodeUsageMutation) AddedField(name string) (ent.Value, bool) {
- switch name {
- case promocodeusage.FieldBonusAmount:
- return m.AddedBonusAmount()
- }
- return nil, false
- }
- // AddField adds the value to the field with the given name. It returns an error if
- // the field is not defined in the schema, or if the type mismatched the field
- // type.
- func (m *PromoCodeUsageMutation) AddField(name string, value ent.Value) error {
- switch name {
- case promocodeusage.FieldBonusAmount:
- v, ok := value.(float64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.AddBonusAmount(v)
- return nil
- }
- return fmt.Errorf("unknown PromoCodeUsage numeric field %s", name)
- }
- // ClearedFields returns all nullable fields that were cleared during this
- // mutation.
- func (m *PromoCodeUsageMutation) ClearedFields() []string {
- return nil
- }
- // FieldCleared returns a boolean indicating if a field with the given name was
- // cleared in this mutation.
- func (m *PromoCodeUsageMutation) FieldCleared(name string) bool {
- _, ok := m.clearedFields[name]
- return ok
- }
- // ClearField clears the value of the field with the given name. It returns an
- // error if the field is not defined in the schema.
- func (m *PromoCodeUsageMutation) ClearField(name string) error {
- return fmt.Errorf("unknown PromoCodeUsage nullable field %s", name)
- }
- // ResetField resets all changes in the mutation for the field with the given name.
- // It returns an error if the field is not defined in the schema.
- func (m *PromoCodeUsageMutation) ResetField(name string) error {
- switch name {
- case promocodeusage.FieldPromoCodeID:
- m.ResetPromoCodeID()
- return nil
- case promocodeusage.FieldUserID:
- m.ResetUserID()
- return nil
- case promocodeusage.FieldBonusAmount:
- m.ResetBonusAmount()
- return nil
- case promocodeusage.FieldUsedAt:
- m.ResetUsedAt()
- return nil
- }
- return fmt.Errorf("unknown PromoCodeUsage field %s", name)
- }
- // AddedEdges returns all edge names that were set/added in this mutation.
- func (m *PromoCodeUsageMutation) AddedEdges() []string {
- edges := make([]string, 0, 2)
- if m.promo_code != nil {
- edges = append(edges, promocodeusage.EdgePromoCode)
- }
- if m.user != nil {
- edges = append(edges, promocodeusage.EdgeUser)
- }
- return edges
- }
- // AddedIDs returns all IDs (to other nodes) that were added for the given edge
- // name in this mutation.
- func (m *PromoCodeUsageMutation) AddedIDs(name string) []ent.Value {
- switch name {
- case promocodeusage.EdgePromoCode:
- if id := m.promo_code; id != nil {
- return []ent.Value{*id}
- }
- case promocodeusage.EdgeUser:
- if id := m.user; id != nil {
- return []ent.Value{*id}
- }
- }
- return nil
- }
- // RemovedEdges returns all edge names that were removed in this mutation.
- func (m *PromoCodeUsageMutation) RemovedEdges() []string {
- edges := make([]string, 0, 2)
- return edges
- }
- // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
- // the given name in this mutation.
- func (m *PromoCodeUsageMutation) RemovedIDs(name string) []ent.Value {
- return nil
- }
- // ClearedEdges returns all edge names that were cleared in this mutation.
- func (m *PromoCodeUsageMutation) ClearedEdges() []string {
- edges := make([]string, 0, 2)
- if m.clearedpromo_code {
- edges = append(edges, promocodeusage.EdgePromoCode)
- }
- if m.cleareduser {
- edges = append(edges, promocodeusage.EdgeUser)
- }
- return edges
- }
- // EdgeCleared returns a boolean which indicates if the edge with the given name
- // was cleared in this mutation.
- func (m *PromoCodeUsageMutation) EdgeCleared(name string) bool {
- switch name {
- case promocodeusage.EdgePromoCode:
- return m.clearedpromo_code
- case promocodeusage.EdgeUser:
- return m.cleareduser
- }
- return false
- }
- // ClearEdge clears the value of the edge with the given name. It returns an error
- // if that edge is not defined in the schema.
- func (m *PromoCodeUsageMutation) ClearEdge(name string) error {
- switch name {
- case promocodeusage.EdgePromoCode:
- m.ClearPromoCode()
- return nil
- case promocodeusage.EdgeUser:
- m.ClearUser()
- return nil
- }
- return fmt.Errorf("unknown PromoCodeUsage unique edge %s", name)
- }
- // ResetEdge resets all changes to the edge with the given name in this mutation.
- // It returns an error if the edge is not defined in the schema.
- func (m *PromoCodeUsageMutation) ResetEdge(name string) error {
- switch name {
- case promocodeusage.EdgePromoCode:
- m.ResetPromoCode()
- return nil
- case promocodeusage.EdgeUser:
- m.ResetUser()
- return nil
- }
- return fmt.Errorf("unknown PromoCodeUsage edge %s", name)
- }
- // ProxyMutation represents an operation that mutates the Proxy nodes in the graph.
- type ProxyMutation struct {
- config
- op Op
- typ string
- id *int64
- created_at *time.Time
- updated_at *time.Time
- deleted_at *time.Time
- name *string
- protocol *string
- host *string
- port *int
- addport *int
- username *string
- password *string
- status *string
- expires_at *time.Time
- fallback_mode *string
- expiry_warn_days *int
- addexpiry_warn_days *int
- clearedFields map[string]struct{}
- accounts map[int64]struct{}
- removedaccounts map[int64]struct{}
- clearedaccounts bool
- primary_proxies map[int64]struct{}
- removedprimary_proxies map[int64]struct{}
- clearedprimary_proxies bool
- backup_proxy *int64
- clearedbackup_proxy bool
- done bool
- oldValue func(context.Context) (*Proxy, error)
- predicates []predicate.Proxy
- }
- var _ ent.Mutation = (*ProxyMutation)(nil)
- // proxyOption allows management of the mutation configuration using functional options.
- type proxyOption func(*ProxyMutation)
- // newProxyMutation creates new mutation for the Proxy entity.
- func newProxyMutation(c config, op Op, opts ...proxyOption) *ProxyMutation {
- m := &ProxyMutation{
- config: c,
- op: op,
- typ: TypeProxy,
- clearedFields: make(map[string]struct{}),
- }
- for _, opt := range opts {
- opt(m)
- }
- return m
- }
- // withProxyID sets the ID field of the mutation.
- func withProxyID(id int64) proxyOption {
- return func(m *ProxyMutation) {
- var (
- err error
- once sync.Once
- value *Proxy
- )
- m.oldValue = func(ctx context.Context) (*Proxy, error) {
- once.Do(func() {
- if m.done {
- err = errors.New("querying old values post mutation is not allowed")
- } else {
- value, err = m.Client().Proxy.Get(ctx, id)
- }
- })
- return value, err
- }
- m.id = &id
- }
- }
- // withProxy sets the old Proxy of the mutation.
- func withProxy(node *Proxy) proxyOption {
- return func(m *ProxyMutation) {
- m.oldValue = func(context.Context) (*Proxy, error) {
- return node, nil
- }
- m.id = &node.ID
- }
- }
- // Client returns a new `ent.Client` from the mutation. If the mutation was
- // executed in a transaction (ent.Tx), a transactional client is returned.
- func (m ProxyMutation) Client() *Client {
- client := &Client{config: m.config}
- client.init()
- return client
- }
- // Tx returns an `ent.Tx` for mutations that were executed in transactions;
- // it returns an error otherwise.
- func (m ProxyMutation) Tx() (*Tx, error) {
- if _, ok := m.driver.(*txDriver); !ok {
- return nil, errors.New("ent: mutation is not running in a transaction")
- }
- tx := &Tx{config: m.config}
- tx.init()
- return tx, nil
- }
- // ID returns the ID value in the mutation. Note that the ID is only available
- // if it was provided to the builder or after it was returned from the database.
- func (m *ProxyMutation) ID() (id int64, exists bool) {
- if m.id == nil {
- return
- }
- return *m.id, true
- }
- // IDs queries the database and returns the entity ids that match the mutation's predicate.
- // That means, if the mutation is applied within a transaction with an isolation level such
- // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
- // or updated by the mutation.
- func (m *ProxyMutation) IDs(ctx context.Context) ([]int64, error) {
- switch {
- case m.op.Is(OpUpdateOne | OpDeleteOne):
- id, exists := m.ID()
- if exists {
- return []int64{id}, nil
- }
- fallthrough
- case m.op.Is(OpUpdate | OpDelete):
- return m.Client().Proxy.Query().Where(m.predicates...).IDs(ctx)
- default:
- return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
- }
- }
- // SetCreatedAt sets the "created_at" field.
- func (m *ProxyMutation) SetCreatedAt(t time.Time) {
- m.created_at = &t
- }
- // CreatedAt returns the value of the "created_at" field in the mutation.
- func (m *ProxyMutation) CreatedAt() (r time.Time, exists bool) {
- v := m.created_at
- if v == nil {
- return
- }
- return *v, true
- }
- // OldCreatedAt returns the old "created_at" field's value of the Proxy entity.
- // If the Proxy object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *ProxyMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldCreatedAt requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
- }
- return oldValue.CreatedAt, nil
- }
- // ResetCreatedAt resets all changes to the "created_at" field.
- func (m *ProxyMutation) ResetCreatedAt() {
- m.created_at = nil
- }
- // SetUpdatedAt sets the "updated_at" field.
- func (m *ProxyMutation) SetUpdatedAt(t time.Time) {
- m.updated_at = &t
- }
- // UpdatedAt returns the value of the "updated_at" field in the mutation.
- func (m *ProxyMutation) UpdatedAt() (r time.Time, exists bool) {
- v := m.updated_at
- if v == nil {
- return
- }
- return *v, true
- }
- // OldUpdatedAt returns the old "updated_at" field's value of the Proxy entity.
- // If the Proxy object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *ProxyMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
- }
- return oldValue.UpdatedAt, nil
- }
- // ResetUpdatedAt resets all changes to the "updated_at" field.
- func (m *ProxyMutation) ResetUpdatedAt() {
- m.updated_at = nil
- }
- // SetDeletedAt sets the "deleted_at" field.
- func (m *ProxyMutation) SetDeletedAt(t time.Time) {
- m.deleted_at = &t
- }
- // DeletedAt returns the value of the "deleted_at" field in the mutation.
- func (m *ProxyMutation) DeletedAt() (r time.Time, exists bool) {
- v := m.deleted_at
- if v == nil {
- return
- }
- return *v, true
- }
- // OldDeletedAt returns the old "deleted_at" field's value of the Proxy entity.
- // If the Proxy object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *ProxyMutation) OldDeletedAt(ctx context.Context) (v *time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldDeletedAt requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
- }
- return oldValue.DeletedAt, nil
- }
- // ClearDeletedAt clears the value of the "deleted_at" field.
- func (m *ProxyMutation) ClearDeletedAt() {
- m.deleted_at = nil
- m.clearedFields[proxy.FieldDeletedAt] = struct{}{}
- }
- // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
- func (m *ProxyMutation) DeletedAtCleared() bool {
- _, ok := m.clearedFields[proxy.FieldDeletedAt]
- return ok
- }
- // ResetDeletedAt resets all changes to the "deleted_at" field.
- func (m *ProxyMutation) ResetDeletedAt() {
- m.deleted_at = nil
- delete(m.clearedFields, proxy.FieldDeletedAt)
- }
- // SetName sets the "name" field.
- func (m *ProxyMutation) SetName(s string) {
- m.name = &s
- }
- // Name returns the value of the "name" field in the mutation.
- func (m *ProxyMutation) Name() (r string, exists bool) {
- v := m.name
- if v == nil {
- return
- }
- return *v, true
- }
- // OldName returns the old "name" field's value of the Proxy entity.
- // If the Proxy object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *ProxyMutation) OldName(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldName is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldName requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldName: %w", err)
- }
- return oldValue.Name, nil
- }
- // ResetName resets all changes to the "name" field.
- func (m *ProxyMutation) ResetName() {
- m.name = nil
- }
- // SetProtocol sets the "protocol" field.
- func (m *ProxyMutation) SetProtocol(s string) {
- m.protocol = &s
- }
- // Protocol returns the value of the "protocol" field in the mutation.
- func (m *ProxyMutation) Protocol() (r string, exists bool) {
- v := m.protocol
- if v == nil {
- return
- }
- return *v, true
- }
- // OldProtocol returns the old "protocol" field's value of the Proxy entity.
- // If the Proxy object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *ProxyMutation) OldProtocol(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldProtocol is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldProtocol requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldProtocol: %w", err)
- }
- return oldValue.Protocol, nil
- }
- // ResetProtocol resets all changes to the "protocol" field.
- func (m *ProxyMutation) ResetProtocol() {
- m.protocol = nil
- }
- // SetHost sets the "host" field.
- func (m *ProxyMutation) SetHost(s string) {
- m.host = &s
- }
- // Host returns the value of the "host" field in the mutation.
- func (m *ProxyMutation) Host() (r string, exists bool) {
- v := m.host
- if v == nil {
- return
- }
- return *v, true
- }
- // OldHost returns the old "host" field's value of the Proxy entity.
- // If the Proxy object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *ProxyMutation) OldHost(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldHost is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldHost requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldHost: %w", err)
- }
- return oldValue.Host, nil
- }
- // ResetHost resets all changes to the "host" field.
- func (m *ProxyMutation) ResetHost() {
- m.host = nil
- }
- // SetPort sets the "port" field.
- func (m *ProxyMutation) SetPort(i int) {
- m.port = &i
- m.addport = nil
- }
- // Port returns the value of the "port" field in the mutation.
- func (m *ProxyMutation) Port() (r int, exists bool) {
- v := m.port
- if v == nil {
- return
- }
- return *v, true
- }
- // OldPort returns the old "port" field's value of the Proxy entity.
- // If the Proxy object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *ProxyMutation) OldPort(ctx context.Context) (v int, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldPort is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldPort requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldPort: %w", err)
- }
- return oldValue.Port, nil
- }
- // AddPort adds i to the "port" field.
- func (m *ProxyMutation) AddPort(i int) {
- if m.addport != nil {
- *m.addport += i
- } else {
- m.addport = &i
- }
- }
- // AddedPort returns the value that was added to the "port" field in this mutation.
- func (m *ProxyMutation) AddedPort() (r int, exists bool) {
- v := m.addport
- if v == nil {
- return
- }
- return *v, true
- }
- // ResetPort resets all changes to the "port" field.
- func (m *ProxyMutation) ResetPort() {
- m.port = nil
- m.addport = nil
- }
- // SetUsername sets the "username" field.
- func (m *ProxyMutation) SetUsername(s string) {
- m.username = &s
- }
- // Username returns the value of the "username" field in the mutation.
- func (m *ProxyMutation) Username() (r string, exists bool) {
- v := m.username
- if v == nil {
- return
- }
- return *v, true
- }
- // OldUsername returns the old "username" field's value of the Proxy entity.
- // If the Proxy object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *ProxyMutation) OldUsername(ctx context.Context) (v *string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldUsername is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldUsername requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldUsername: %w", err)
- }
- return oldValue.Username, nil
- }
- // ClearUsername clears the value of the "username" field.
- func (m *ProxyMutation) ClearUsername() {
- m.username = nil
- m.clearedFields[proxy.FieldUsername] = struct{}{}
- }
- // UsernameCleared returns if the "username" field was cleared in this mutation.
- func (m *ProxyMutation) UsernameCleared() bool {
- _, ok := m.clearedFields[proxy.FieldUsername]
- return ok
- }
- // ResetUsername resets all changes to the "username" field.
- func (m *ProxyMutation) ResetUsername() {
- m.username = nil
- delete(m.clearedFields, proxy.FieldUsername)
- }
- // SetPassword sets the "password" field.
- func (m *ProxyMutation) SetPassword(s string) {
- m.password = &s
- }
- // Password returns the value of the "password" field in the mutation.
- func (m *ProxyMutation) Password() (r string, exists bool) {
- v := m.password
- if v == nil {
- return
- }
- return *v, true
- }
- // OldPassword returns the old "password" field's value of the Proxy entity.
- // If the Proxy object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *ProxyMutation) OldPassword(ctx context.Context) (v *string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldPassword is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldPassword requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldPassword: %w", err)
- }
- return oldValue.Password, nil
- }
- // ClearPassword clears the value of the "password" field.
- func (m *ProxyMutation) ClearPassword() {
- m.password = nil
- m.clearedFields[proxy.FieldPassword] = struct{}{}
- }
- // PasswordCleared returns if the "password" field was cleared in this mutation.
- func (m *ProxyMutation) PasswordCleared() bool {
- _, ok := m.clearedFields[proxy.FieldPassword]
- return ok
- }
- // ResetPassword resets all changes to the "password" field.
- func (m *ProxyMutation) ResetPassword() {
- m.password = nil
- delete(m.clearedFields, proxy.FieldPassword)
- }
- // SetStatus sets the "status" field.
- func (m *ProxyMutation) SetStatus(s string) {
- m.status = &s
- }
- // Status returns the value of the "status" field in the mutation.
- func (m *ProxyMutation) Status() (r string, exists bool) {
- v := m.status
- if v == nil {
- return
- }
- return *v, true
- }
- // OldStatus returns the old "status" field's value of the Proxy entity.
- // If the Proxy object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *ProxyMutation) OldStatus(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldStatus is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldStatus requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldStatus: %w", err)
- }
- return oldValue.Status, nil
- }
- // ResetStatus resets all changes to the "status" field.
- func (m *ProxyMutation) ResetStatus() {
- m.status = nil
- }
- // SetExpiresAt sets the "expires_at" field.
- func (m *ProxyMutation) SetExpiresAt(t time.Time) {
- m.expires_at = &t
- }
- // ExpiresAt returns the value of the "expires_at" field in the mutation.
- func (m *ProxyMutation) ExpiresAt() (r time.Time, exists bool) {
- v := m.expires_at
- if v == nil {
- return
- }
- return *v, true
- }
- // OldExpiresAt returns the old "expires_at" field's value of the Proxy entity.
- // If the Proxy object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *ProxyMutation) OldExpiresAt(ctx context.Context) (v *time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldExpiresAt is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldExpiresAt requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldExpiresAt: %w", err)
- }
- return oldValue.ExpiresAt, nil
- }
- // ClearExpiresAt clears the value of the "expires_at" field.
- func (m *ProxyMutation) ClearExpiresAt() {
- m.expires_at = nil
- m.clearedFields[proxy.FieldExpiresAt] = struct{}{}
- }
- // ExpiresAtCleared returns if the "expires_at" field was cleared in this mutation.
- func (m *ProxyMutation) ExpiresAtCleared() bool {
- _, ok := m.clearedFields[proxy.FieldExpiresAt]
- return ok
- }
- // ResetExpiresAt resets all changes to the "expires_at" field.
- func (m *ProxyMutation) ResetExpiresAt() {
- m.expires_at = nil
- delete(m.clearedFields, proxy.FieldExpiresAt)
- }
- // SetFallbackMode sets the "fallback_mode" field.
- func (m *ProxyMutation) SetFallbackMode(s string) {
- m.fallback_mode = &s
- }
- // FallbackMode returns the value of the "fallback_mode" field in the mutation.
- func (m *ProxyMutation) FallbackMode() (r string, exists bool) {
- v := m.fallback_mode
- if v == nil {
- return
- }
- return *v, true
- }
- // OldFallbackMode returns the old "fallback_mode" field's value of the Proxy entity.
- // If the Proxy object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *ProxyMutation) OldFallbackMode(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldFallbackMode is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldFallbackMode requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldFallbackMode: %w", err)
- }
- return oldValue.FallbackMode, nil
- }
- // ResetFallbackMode resets all changes to the "fallback_mode" field.
- func (m *ProxyMutation) ResetFallbackMode() {
- m.fallback_mode = nil
- }
- // SetBackupProxyID sets the "backup_proxy_id" field.
- func (m *ProxyMutation) SetBackupProxyID(i int64) {
- m.backup_proxy = &i
- }
- // BackupProxyID returns the value of the "backup_proxy_id" field in the mutation.
- func (m *ProxyMutation) BackupProxyID() (r int64, exists bool) {
- v := m.backup_proxy
- if v == nil {
- return
- }
- return *v, true
- }
- // OldBackupProxyID returns the old "backup_proxy_id" field's value of the Proxy entity.
- // If the Proxy object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *ProxyMutation) OldBackupProxyID(ctx context.Context) (v *int64, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldBackupProxyID is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldBackupProxyID requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldBackupProxyID: %w", err)
- }
- return oldValue.BackupProxyID, nil
- }
- // ClearBackupProxyID clears the value of the "backup_proxy_id" field.
- func (m *ProxyMutation) ClearBackupProxyID() {
- m.backup_proxy = nil
- m.clearedFields[proxy.FieldBackupProxyID] = struct{}{}
- }
- // BackupProxyIDCleared returns if the "backup_proxy_id" field was cleared in this mutation.
- func (m *ProxyMutation) BackupProxyIDCleared() bool {
- _, ok := m.clearedFields[proxy.FieldBackupProxyID]
- return ok
- }
- // ResetBackupProxyID resets all changes to the "backup_proxy_id" field.
- func (m *ProxyMutation) ResetBackupProxyID() {
- m.backup_proxy = nil
- delete(m.clearedFields, proxy.FieldBackupProxyID)
- }
- // SetExpiryWarnDays sets the "expiry_warn_days" field.
- func (m *ProxyMutation) SetExpiryWarnDays(i int) {
- m.expiry_warn_days = &i
- m.addexpiry_warn_days = nil
- }
- // ExpiryWarnDays returns the value of the "expiry_warn_days" field in the mutation.
- func (m *ProxyMutation) ExpiryWarnDays() (r int, exists bool) {
- v := m.expiry_warn_days
- if v == nil {
- return
- }
- return *v, true
- }
- // OldExpiryWarnDays returns the old "expiry_warn_days" field's value of the Proxy entity.
- // If the Proxy object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *ProxyMutation) OldExpiryWarnDays(ctx context.Context) (v int, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldExpiryWarnDays is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldExpiryWarnDays requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldExpiryWarnDays: %w", err)
- }
- return oldValue.ExpiryWarnDays, nil
- }
- // AddExpiryWarnDays adds i to the "expiry_warn_days" field.
- func (m *ProxyMutation) AddExpiryWarnDays(i int) {
- if m.addexpiry_warn_days != nil {
- *m.addexpiry_warn_days += i
- } else {
- m.addexpiry_warn_days = &i
- }
- }
- // AddedExpiryWarnDays returns the value that was added to the "expiry_warn_days" field in this mutation.
- func (m *ProxyMutation) AddedExpiryWarnDays() (r int, exists bool) {
- v := m.addexpiry_warn_days
- if v == nil {
- return
- }
- return *v, true
- }
- // ResetExpiryWarnDays resets all changes to the "expiry_warn_days" field.
- func (m *ProxyMutation) ResetExpiryWarnDays() {
- m.expiry_warn_days = nil
- m.addexpiry_warn_days = nil
- }
- // AddAccountIDs adds the "accounts" edge to the Account entity by ids.
- func (m *ProxyMutation) AddAccountIDs(ids ...int64) {
- if m.accounts == nil {
- m.accounts = make(map[int64]struct{})
- }
- for i := range ids {
- m.accounts[ids[i]] = struct{}{}
- }
- }
- // ClearAccounts clears the "accounts" edge to the Account entity.
- func (m *ProxyMutation) ClearAccounts() {
- m.clearedaccounts = true
- }
- // AccountsCleared reports if the "accounts" edge to the Account entity was cleared.
- func (m *ProxyMutation) AccountsCleared() bool {
- return m.clearedaccounts
- }
- // RemoveAccountIDs removes the "accounts" edge to the Account entity by IDs.
- func (m *ProxyMutation) RemoveAccountIDs(ids ...int64) {
- if m.removedaccounts == nil {
- m.removedaccounts = make(map[int64]struct{})
- }
- for i := range ids {
- delete(m.accounts, ids[i])
- m.removedaccounts[ids[i]] = struct{}{}
- }
- }
- // RemovedAccounts returns the removed IDs of the "accounts" edge to the Account entity.
- func (m *ProxyMutation) RemovedAccountsIDs() (ids []int64) {
- for id := range m.removedaccounts {
- ids = append(ids, id)
- }
- return
- }
- // AccountsIDs returns the "accounts" edge IDs in the mutation.
- func (m *ProxyMutation) AccountsIDs() (ids []int64) {
- for id := range m.accounts {
- ids = append(ids, id)
- }
- return
- }
- // ResetAccounts resets all changes to the "accounts" edge.
- func (m *ProxyMutation) ResetAccounts() {
- m.accounts = nil
- m.clearedaccounts = false
- m.removedaccounts = nil
- }
- // AddPrimaryProxyIDs adds the "primary_proxies" edge to the Proxy entity by ids.
- func (m *ProxyMutation) AddPrimaryProxyIDs(ids ...int64) {
- if m.primary_proxies == nil {
- m.primary_proxies = make(map[int64]struct{})
- }
- for i := range ids {
- m.primary_proxies[ids[i]] = struct{}{}
- }
- }
- // ClearPrimaryProxies clears the "primary_proxies" edge to the Proxy entity.
- func (m *ProxyMutation) ClearPrimaryProxies() {
- m.clearedprimary_proxies = true
- }
- // PrimaryProxiesCleared reports if the "primary_proxies" edge to the Proxy entity was cleared.
- func (m *ProxyMutation) PrimaryProxiesCleared() bool {
- return m.clearedprimary_proxies
- }
- // RemovePrimaryProxyIDs removes the "primary_proxies" edge to the Proxy entity by IDs.
- func (m *ProxyMutation) RemovePrimaryProxyIDs(ids ...int64) {
- if m.removedprimary_proxies == nil {
- m.removedprimary_proxies = make(map[int64]struct{})
- }
- for i := range ids {
- delete(m.primary_proxies, ids[i])
- m.removedprimary_proxies[ids[i]] = struct{}{}
- }
- }
- // RemovedPrimaryProxies returns the removed IDs of the "primary_proxies" edge to the Proxy entity.
- func (m *ProxyMutation) RemovedPrimaryProxiesIDs() (ids []int64) {
- for id := range m.removedprimary_proxies {
- ids = append(ids, id)
- }
- return
- }
- // PrimaryProxiesIDs returns the "primary_proxies" edge IDs in the mutation.
- func (m *ProxyMutation) PrimaryProxiesIDs() (ids []int64) {
- for id := range m.primary_proxies {
- ids = append(ids, id)
- }
- return
- }
- // ResetPrimaryProxies resets all changes to the "primary_proxies" edge.
- func (m *ProxyMutation) ResetPrimaryProxies() {
- m.primary_proxies = nil
- m.clearedprimary_proxies = false
- m.removedprimary_proxies = nil
- }
- // ClearBackupProxy clears the "backup_proxy" edge to the Proxy entity.
- func (m *ProxyMutation) ClearBackupProxy() {
- m.clearedbackup_proxy = true
- m.clearedFields[proxy.FieldBackupProxyID] = struct{}{}
- }
- // BackupProxyCleared reports if the "backup_proxy" edge to the Proxy entity was cleared.
- func (m *ProxyMutation) BackupProxyCleared() bool {
- return m.BackupProxyIDCleared() || m.clearedbackup_proxy
- }
- // BackupProxyIDs returns the "backup_proxy" edge IDs in the mutation.
- // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
- // BackupProxyID instead. It exists only for internal usage by the builders.
- func (m *ProxyMutation) BackupProxyIDs() (ids []int64) {
- if id := m.backup_proxy; id != nil {
- ids = append(ids, *id)
- }
- return
- }
- // ResetBackupProxy resets all changes to the "backup_proxy" edge.
- func (m *ProxyMutation) ResetBackupProxy() {
- m.backup_proxy = nil
- m.clearedbackup_proxy = false
- }
- // Where appends a list predicates to the ProxyMutation builder.
- func (m *ProxyMutation) Where(ps ...predicate.Proxy) {
- m.predicates = append(m.predicates, ps...)
- }
- // WhereP appends storage-level predicates to the ProxyMutation builder. Using this method,
- // users can use type-assertion to append predicates that do not depend on any generated package.
- func (m *ProxyMutation) WhereP(ps ...func(*sql.Selector)) {
- p := make([]predicate.Proxy, len(ps))
- for i := range ps {
- p[i] = ps[i]
- }
- m.Where(p...)
- }
- // Op returns the operation name.
- func (m *ProxyMutation) Op() Op {
- return m.op
- }
- // SetOp allows setting the mutation operation.
- func (m *ProxyMutation) SetOp(op Op) {
- m.op = op
- }
- // Type returns the node type of this mutation (Proxy).
- func (m *ProxyMutation) Type() string {
- return m.typ
- }
- // Fields returns all fields that were changed during this mutation. Note that in
- // order to get all numeric fields that were incremented/decremented, call
- // AddedFields().
- func (m *ProxyMutation) Fields() []string {
- fields := make([]string, 0, 14)
- if m.created_at != nil {
- fields = append(fields, proxy.FieldCreatedAt)
- }
- if m.updated_at != nil {
- fields = append(fields, proxy.FieldUpdatedAt)
- }
- if m.deleted_at != nil {
- fields = append(fields, proxy.FieldDeletedAt)
- }
- if m.name != nil {
- fields = append(fields, proxy.FieldName)
- }
- if m.protocol != nil {
- fields = append(fields, proxy.FieldProtocol)
- }
- if m.host != nil {
- fields = append(fields, proxy.FieldHost)
- }
- if m.port != nil {
- fields = append(fields, proxy.FieldPort)
- }
- if m.username != nil {
- fields = append(fields, proxy.FieldUsername)
- }
- if m.password != nil {
- fields = append(fields, proxy.FieldPassword)
- }
- if m.status != nil {
- fields = append(fields, proxy.FieldStatus)
- }
- if m.expires_at != nil {
- fields = append(fields, proxy.FieldExpiresAt)
- }
- if m.fallback_mode != nil {
- fields = append(fields, proxy.FieldFallbackMode)
- }
- if m.backup_proxy != nil {
- fields = append(fields, proxy.FieldBackupProxyID)
- }
- if m.expiry_warn_days != nil {
- fields = append(fields, proxy.FieldExpiryWarnDays)
- }
- return fields
- }
- // Field returns the value of a field with the given name. The second boolean
- // return value indicates that this field was not set, or was not defined in the
- // schema.
- func (m *ProxyMutation) Field(name string) (ent.Value, bool) {
- switch name {
- case proxy.FieldCreatedAt:
- return m.CreatedAt()
- case proxy.FieldUpdatedAt:
- return m.UpdatedAt()
- case proxy.FieldDeletedAt:
- return m.DeletedAt()
- case proxy.FieldName:
- return m.Name()
- case proxy.FieldProtocol:
- return m.Protocol()
- case proxy.FieldHost:
- return m.Host()
- case proxy.FieldPort:
- return m.Port()
- case proxy.FieldUsername:
- return m.Username()
- case proxy.FieldPassword:
- return m.Password()
- case proxy.FieldStatus:
- return m.Status()
- case proxy.FieldExpiresAt:
- return m.ExpiresAt()
- case proxy.FieldFallbackMode:
- return m.FallbackMode()
- case proxy.FieldBackupProxyID:
- return m.BackupProxyID()
- case proxy.FieldExpiryWarnDays:
- return m.ExpiryWarnDays()
- }
- return nil, false
- }
- // OldField returns the old value of the field from the database. An error is
- // returned if the mutation operation is not UpdateOne, or the query to the
- // database failed.
- func (m *ProxyMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
- switch name {
- case proxy.FieldCreatedAt:
- return m.OldCreatedAt(ctx)
- case proxy.FieldUpdatedAt:
- return m.OldUpdatedAt(ctx)
- case proxy.FieldDeletedAt:
- return m.OldDeletedAt(ctx)
- case proxy.FieldName:
- return m.OldName(ctx)
- case proxy.FieldProtocol:
- return m.OldProtocol(ctx)
- case proxy.FieldHost:
- return m.OldHost(ctx)
- case proxy.FieldPort:
- return m.OldPort(ctx)
- case proxy.FieldUsername:
- return m.OldUsername(ctx)
- case proxy.FieldPassword:
- return m.OldPassword(ctx)
- case proxy.FieldStatus:
- return m.OldStatus(ctx)
- case proxy.FieldExpiresAt:
- return m.OldExpiresAt(ctx)
- case proxy.FieldFallbackMode:
- return m.OldFallbackMode(ctx)
- case proxy.FieldBackupProxyID:
- return m.OldBackupProxyID(ctx)
- case proxy.FieldExpiryWarnDays:
- return m.OldExpiryWarnDays(ctx)
- }
- return nil, fmt.Errorf("unknown Proxy field %s", name)
- }
- // SetField sets the value of a field with the given name. It returns an error if
- // the field is not defined in the schema, or if the type mismatched the field
- // type.
- func (m *ProxyMutation) SetField(name string, value ent.Value) error {
- switch name {
- case proxy.FieldCreatedAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetCreatedAt(v)
- return nil
- case proxy.FieldUpdatedAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetUpdatedAt(v)
- return nil
- case proxy.FieldDeletedAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetDeletedAt(v)
- return nil
- case proxy.FieldName:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetName(v)
- return nil
- case proxy.FieldProtocol:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetProtocol(v)
- return nil
- case proxy.FieldHost:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetHost(v)
- return nil
- case proxy.FieldPort:
- v, ok := value.(int)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetPort(v)
- return nil
- case proxy.FieldUsername:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetUsername(v)
- return nil
- case proxy.FieldPassword:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetPassword(v)
- return nil
- case proxy.FieldStatus:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetStatus(v)
- return nil
- case proxy.FieldExpiresAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetExpiresAt(v)
- return nil
- case proxy.FieldFallbackMode:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetFallbackMode(v)
- return nil
- case proxy.FieldBackupProxyID:
- v, ok := value.(int64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetBackupProxyID(v)
- return nil
- case proxy.FieldExpiryWarnDays:
- v, ok := value.(int)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetExpiryWarnDays(v)
- return nil
- }
- return fmt.Errorf("unknown Proxy field %s", name)
- }
- // AddedFields returns all numeric fields that were incremented/decremented during
- // this mutation.
- func (m *ProxyMutation) AddedFields() []string {
- var fields []string
- if m.addport != nil {
- fields = append(fields, proxy.FieldPort)
- }
- if m.addexpiry_warn_days != nil {
- fields = append(fields, proxy.FieldExpiryWarnDays)
- }
- return fields
- }
- // AddedField returns the numeric value that was incremented/decremented on a field
- // with the given name. The second boolean return value indicates that this field
- // was not set, or was not defined in the schema.
- func (m *ProxyMutation) AddedField(name string) (ent.Value, bool) {
- switch name {
- case proxy.FieldPort:
- return m.AddedPort()
- case proxy.FieldExpiryWarnDays:
- return m.AddedExpiryWarnDays()
- }
- return nil, false
- }
- // AddField adds the value to the field with the given name. It returns an error if
- // the field is not defined in the schema, or if the type mismatched the field
- // type.
- func (m *ProxyMutation) AddField(name string, value ent.Value) error {
- switch name {
- case proxy.FieldPort:
- v, ok := value.(int)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.AddPort(v)
- return nil
- case proxy.FieldExpiryWarnDays:
- v, ok := value.(int)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.AddExpiryWarnDays(v)
- return nil
- }
- return fmt.Errorf("unknown Proxy numeric field %s", name)
- }
- // ClearedFields returns all nullable fields that were cleared during this
- // mutation.
- func (m *ProxyMutation) ClearedFields() []string {
- var fields []string
- if m.FieldCleared(proxy.FieldDeletedAt) {
- fields = append(fields, proxy.FieldDeletedAt)
- }
- if m.FieldCleared(proxy.FieldUsername) {
- fields = append(fields, proxy.FieldUsername)
- }
- if m.FieldCleared(proxy.FieldPassword) {
- fields = append(fields, proxy.FieldPassword)
- }
- if m.FieldCleared(proxy.FieldExpiresAt) {
- fields = append(fields, proxy.FieldExpiresAt)
- }
- if m.FieldCleared(proxy.FieldBackupProxyID) {
- fields = append(fields, proxy.FieldBackupProxyID)
- }
- return fields
- }
- // FieldCleared returns a boolean indicating if a field with the given name was
- // cleared in this mutation.
- func (m *ProxyMutation) FieldCleared(name string) bool {
- _, ok := m.clearedFields[name]
- return ok
- }
- // ClearField clears the value of the field with the given name. It returns an
- // error if the field is not defined in the schema.
- func (m *ProxyMutation) ClearField(name string) error {
- switch name {
- case proxy.FieldDeletedAt:
- m.ClearDeletedAt()
- return nil
- case proxy.FieldUsername:
- m.ClearUsername()
- return nil
- case proxy.FieldPassword:
- m.ClearPassword()
- return nil
- case proxy.FieldExpiresAt:
- m.ClearExpiresAt()
- return nil
- case proxy.FieldBackupProxyID:
- m.ClearBackupProxyID()
- return nil
- }
- return fmt.Errorf("unknown Proxy nullable field %s", name)
- }
- // ResetField resets all changes in the mutation for the field with the given name.
- // It returns an error if the field is not defined in the schema.
- func (m *ProxyMutation) ResetField(name string) error {
- switch name {
- case proxy.FieldCreatedAt:
- m.ResetCreatedAt()
- return nil
- case proxy.FieldUpdatedAt:
- m.ResetUpdatedAt()
- return nil
- case proxy.FieldDeletedAt:
- m.ResetDeletedAt()
- return nil
- case proxy.FieldName:
- m.ResetName()
- return nil
- case proxy.FieldProtocol:
- m.ResetProtocol()
- return nil
- case proxy.FieldHost:
- m.ResetHost()
- return nil
- case proxy.FieldPort:
- m.ResetPort()
- return nil
- case proxy.FieldUsername:
- m.ResetUsername()
- return nil
- case proxy.FieldPassword:
- m.ResetPassword()
- return nil
- case proxy.FieldStatus:
- m.ResetStatus()
- return nil
- case proxy.FieldExpiresAt:
- m.ResetExpiresAt()
- return nil
- case proxy.FieldFallbackMode:
- m.ResetFallbackMode()
- return nil
- case proxy.FieldBackupProxyID:
- m.ResetBackupProxyID()
- return nil
- case proxy.FieldExpiryWarnDays:
- m.ResetExpiryWarnDays()
- return nil
- }
- return fmt.Errorf("unknown Proxy field %s", name)
- }
- // AddedEdges returns all edge names that were set/added in this mutation.
- func (m *ProxyMutation) AddedEdges() []string {
- edges := make([]string, 0, 3)
- if m.accounts != nil {
- edges = append(edges, proxy.EdgeAccounts)
- }
- if m.primary_proxies != nil {
- edges = append(edges, proxy.EdgePrimaryProxies)
- }
- if m.backup_proxy != nil {
- edges = append(edges, proxy.EdgeBackupProxy)
- }
- return edges
- }
- // AddedIDs returns all IDs (to other nodes) that were added for the given edge
- // name in this mutation.
- func (m *ProxyMutation) AddedIDs(name string) []ent.Value {
- switch name {
- case proxy.EdgeAccounts:
- ids := make([]ent.Value, 0, len(m.accounts))
- for id := range m.accounts {
- ids = append(ids, id)
- }
- return ids
- case proxy.EdgePrimaryProxies:
- ids := make([]ent.Value, 0, len(m.primary_proxies))
- for id := range m.primary_proxies {
- ids = append(ids, id)
- }
- return ids
- case proxy.EdgeBackupProxy:
- if id := m.backup_proxy; id != nil {
- return []ent.Value{*id}
- }
- }
- return nil
- }
- // RemovedEdges returns all edge names that were removed in this mutation.
- func (m *ProxyMutation) RemovedEdges() []string {
- edges := make([]string, 0, 3)
- if m.removedaccounts != nil {
- edges = append(edges, proxy.EdgeAccounts)
- }
- if m.removedprimary_proxies != nil {
- edges = append(edges, proxy.EdgePrimaryProxies)
- }
- return edges
- }
- // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
- // the given name in this mutation.
- func (m *ProxyMutation) RemovedIDs(name string) []ent.Value {
- switch name {
- case proxy.EdgeAccounts:
- ids := make([]ent.Value, 0, len(m.removedaccounts))
- for id := range m.removedaccounts {
- ids = append(ids, id)
- }
- return ids
- case proxy.EdgePrimaryProxies:
- ids := make([]ent.Value, 0, len(m.removedprimary_proxies))
- for id := range m.removedprimary_proxies {
- ids = append(ids, id)
- }
- return ids
- }
- return nil
- }
- // ClearedEdges returns all edge names that were cleared in this mutation.
- func (m *ProxyMutation) ClearedEdges() []string {
- edges := make([]string, 0, 3)
- if m.clearedaccounts {
- edges = append(edges, proxy.EdgeAccounts)
- }
- if m.clearedprimary_proxies {
- edges = append(edges, proxy.EdgePrimaryProxies)
- }
- if m.clearedbackup_proxy {
- edges = append(edges, proxy.EdgeBackupProxy)
- }
- return edges
- }
- // EdgeCleared returns a boolean which indicates if the edge with the given name
- // was cleared in this mutation.
- func (m *ProxyMutation) EdgeCleared(name string) bool {
- switch name {
- case proxy.EdgeAccounts:
- return m.clearedaccounts
- case proxy.EdgePrimaryProxies:
- return m.clearedprimary_proxies
- case proxy.EdgeBackupProxy:
- return m.clearedbackup_proxy
- }
- return false
- }
- // ClearEdge clears the value of the edge with the given name. It returns an error
- // if that edge is not defined in the schema.
- func (m *ProxyMutation) ClearEdge(name string) error {
- switch name {
- case proxy.EdgeBackupProxy:
- m.ClearBackupProxy()
- return nil
- }
- return fmt.Errorf("unknown Proxy unique edge %s", name)
- }
- // ResetEdge resets all changes to the edge with the given name in this mutation.
- // It returns an error if the edge is not defined in the schema.
- func (m *ProxyMutation) ResetEdge(name string) error {
- switch name {
- case proxy.EdgeAccounts:
- m.ResetAccounts()
- return nil
- case proxy.EdgePrimaryProxies:
- m.ResetPrimaryProxies()
- return nil
- case proxy.EdgeBackupProxy:
- m.ResetBackupProxy()
- return nil
- }
- return fmt.Errorf("unknown Proxy edge %s", name)
- }
- // RedeemCodeMutation represents an operation that mutates the RedeemCode nodes in the graph.
- type RedeemCodeMutation struct {
- config
- op Op
- typ string
- id *int64
- code *string
- _type *string
- value *float64
- addvalue *float64
- status *string
- used_at *time.Time
- notes *string
- created_at *time.Time
- expires_at *time.Time
- validity_days *int
- addvalidity_days *int
- clearedFields map[string]struct{}
- user *int64
- cleareduser bool
- group *int64
- clearedgroup bool
- done bool
- oldValue func(context.Context) (*RedeemCode, error)
- predicates []predicate.RedeemCode
- }
- var _ ent.Mutation = (*RedeemCodeMutation)(nil)
- // redeemcodeOption allows management of the mutation configuration using functional options.
- type redeemcodeOption func(*RedeemCodeMutation)
- // newRedeemCodeMutation creates new mutation for the RedeemCode entity.
- func newRedeemCodeMutation(c config, op Op, opts ...redeemcodeOption) *RedeemCodeMutation {
- m := &RedeemCodeMutation{
- config: c,
- op: op,
- typ: TypeRedeemCode,
- clearedFields: make(map[string]struct{}),
- }
- for _, opt := range opts {
- opt(m)
- }
- return m
- }
- // withRedeemCodeID sets the ID field of the mutation.
- func withRedeemCodeID(id int64) redeemcodeOption {
- return func(m *RedeemCodeMutation) {
- var (
- err error
- once sync.Once
- value *RedeemCode
- )
- m.oldValue = func(ctx context.Context) (*RedeemCode, error) {
- once.Do(func() {
- if m.done {
- err = errors.New("querying old values post mutation is not allowed")
- } else {
- value, err = m.Client().RedeemCode.Get(ctx, id)
- }
- })
- return value, err
- }
- m.id = &id
- }
- }
- // withRedeemCode sets the old RedeemCode of the mutation.
- func withRedeemCode(node *RedeemCode) redeemcodeOption {
- return func(m *RedeemCodeMutation) {
- m.oldValue = func(context.Context) (*RedeemCode, error) {
- return node, nil
- }
- m.id = &node.ID
- }
- }
- // Client returns a new `ent.Client` from the mutation. If the mutation was
- // executed in a transaction (ent.Tx), a transactional client is returned.
- func (m RedeemCodeMutation) Client() *Client {
- client := &Client{config: m.config}
- client.init()
- return client
- }
- // Tx returns an `ent.Tx` for mutations that were executed in transactions;
- // it returns an error otherwise.
- func (m RedeemCodeMutation) Tx() (*Tx, error) {
- if _, ok := m.driver.(*txDriver); !ok {
- return nil, errors.New("ent: mutation is not running in a transaction")
- }
- tx := &Tx{config: m.config}
- tx.init()
- return tx, nil
- }
- // ID returns the ID value in the mutation. Note that the ID is only available
- // if it was provided to the builder or after it was returned from the database.
- func (m *RedeemCodeMutation) ID() (id int64, exists bool) {
- if m.id == nil {
- return
- }
- return *m.id, true
- }
- // IDs queries the database and returns the entity ids that match the mutation's predicate.
- // That means, if the mutation is applied within a transaction with an isolation level such
- // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
- // or updated by the mutation.
- func (m *RedeemCodeMutation) IDs(ctx context.Context) ([]int64, error) {
- switch {
- case m.op.Is(OpUpdateOne | OpDeleteOne):
- id, exists := m.ID()
- if exists {
- return []int64{id}, nil
- }
- fallthrough
- case m.op.Is(OpUpdate | OpDelete):
- return m.Client().RedeemCode.Query().Where(m.predicates...).IDs(ctx)
- default:
- return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
- }
- }
- // SetCode sets the "code" field.
- func (m *RedeemCodeMutation) SetCode(s string) {
- m.code = &s
- }
- // Code returns the value of the "code" field in the mutation.
- func (m *RedeemCodeMutation) Code() (r string, exists bool) {
- v := m.code
- if v == nil {
- return
- }
- return *v, true
- }
- // OldCode returns the old "code" field's value of the RedeemCode entity.
- // If the RedeemCode object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *RedeemCodeMutation) OldCode(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldCode is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldCode requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldCode: %w", err)
- }
- return oldValue.Code, nil
- }
- // ResetCode resets all changes to the "code" field.
- func (m *RedeemCodeMutation) ResetCode() {
- m.code = nil
- }
- // SetType sets the "type" field.
- func (m *RedeemCodeMutation) SetType(s string) {
- m._type = &s
- }
- // GetType returns the value of the "type" field in the mutation.
- func (m *RedeemCodeMutation) GetType() (r string, exists bool) {
- v := m._type
- if v == nil {
- return
- }
- return *v, true
- }
- // OldType returns the old "type" field's value of the RedeemCode entity.
- // If the RedeemCode object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *RedeemCodeMutation) OldType(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldType is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldType requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldType: %w", err)
- }
- return oldValue.Type, nil
- }
- // ResetType resets all changes to the "type" field.
- func (m *RedeemCodeMutation) ResetType() {
- m._type = nil
- }
- // SetValue sets the "value" field.
- func (m *RedeemCodeMutation) SetValue(f float64) {
- m.value = &f
- m.addvalue = nil
- }
- // Value returns the value of the "value" field in the mutation.
- func (m *RedeemCodeMutation) Value() (r float64, exists bool) {
- v := m.value
- if v == nil {
- return
- }
- return *v, true
- }
- // OldValue returns the old "value" field's value of the RedeemCode entity.
- // If the RedeemCode object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *RedeemCodeMutation) OldValue(ctx context.Context) (v float64, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldValue is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldValue requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldValue: %w", err)
- }
- return oldValue.Value, nil
- }
- // AddValue adds f to the "value" field.
- func (m *RedeemCodeMutation) AddValue(f float64) {
- if m.addvalue != nil {
- *m.addvalue += f
- } else {
- m.addvalue = &f
- }
- }
- // AddedValue returns the value that was added to the "value" field in this mutation.
- func (m *RedeemCodeMutation) AddedValue() (r float64, exists bool) {
- v := m.addvalue
- if v == nil {
- return
- }
- return *v, true
- }
- // ResetValue resets all changes to the "value" field.
- func (m *RedeemCodeMutation) ResetValue() {
- m.value = nil
- m.addvalue = nil
- }
- // SetStatus sets the "status" field.
- func (m *RedeemCodeMutation) SetStatus(s string) {
- m.status = &s
- }
- // Status returns the value of the "status" field in the mutation.
- func (m *RedeemCodeMutation) Status() (r string, exists bool) {
- v := m.status
- if v == nil {
- return
- }
- return *v, true
- }
- // OldStatus returns the old "status" field's value of the RedeemCode entity.
- // If the RedeemCode object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *RedeemCodeMutation) OldStatus(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldStatus is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldStatus requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldStatus: %w", err)
- }
- return oldValue.Status, nil
- }
- // ResetStatus resets all changes to the "status" field.
- func (m *RedeemCodeMutation) ResetStatus() {
- m.status = nil
- }
- // SetUsedBy sets the "used_by" field.
- func (m *RedeemCodeMutation) SetUsedBy(i int64) {
- m.user = &i
- }
- // UsedBy returns the value of the "used_by" field in the mutation.
- func (m *RedeemCodeMutation) UsedBy() (r int64, exists bool) {
- v := m.user
- if v == nil {
- return
- }
- return *v, true
- }
- // OldUsedBy returns the old "used_by" field's value of the RedeemCode entity.
- // If the RedeemCode object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *RedeemCodeMutation) OldUsedBy(ctx context.Context) (v *int64, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldUsedBy is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldUsedBy requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldUsedBy: %w", err)
- }
- return oldValue.UsedBy, nil
- }
- // ClearUsedBy clears the value of the "used_by" field.
- func (m *RedeemCodeMutation) ClearUsedBy() {
- m.user = nil
- m.clearedFields[redeemcode.FieldUsedBy] = struct{}{}
- }
- // UsedByCleared returns if the "used_by" field was cleared in this mutation.
- func (m *RedeemCodeMutation) UsedByCleared() bool {
- _, ok := m.clearedFields[redeemcode.FieldUsedBy]
- return ok
- }
- // ResetUsedBy resets all changes to the "used_by" field.
- func (m *RedeemCodeMutation) ResetUsedBy() {
- m.user = nil
- delete(m.clearedFields, redeemcode.FieldUsedBy)
- }
- // SetUsedAt sets the "used_at" field.
- func (m *RedeemCodeMutation) SetUsedAt(t time.Time) {
- m.used_at = &t
- }
- // UsedAt returns the value of the "used_at" field in the mutation.
- func (m *RedeemCodeMutation) UsedAt() (r time.Time, exists bool) {
- v := m.used_at
- if v == nil {
- return
- }
- return *v, true
- }
- // OldUsedAt returns the old "used_at" field's value of the RedeemCode entity.
- // If the RedeemCode object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *RedeemCodeMutation) OldUsedAt(ctx context.Context) (v *time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldUsedAt is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldUsedAt requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldUsedAt: %w", err)
- }
- return oldValue.UsedAt, nil
- }
- // ClearUsedAt clears the value of the "used_at" field.
- func (m *RedeemCodeMutation) ClearUsedAt() {
- m.used_at = nil
- m.clearedFields[redeemcode.FieldUsedAt] = struct{}{}
- }
- // UsedAtCleared returns if the "used_at" field was cleared in this mutation.
- func (m *RedeemCodeMutation) UsedAtCleared() bool {
- _, ok := m.clearedFields[redeemcode.FieldUsedAt]
- return ok
- }
- // ResetUsedAt resets all changes to the "used_at" field.
- func (m *RedeemCodeMutation) ResetUsedAt() {
- m.used_at = nil
- delete(m.clearedFields, redeemcode.FieldUsedAt)
- }
- // SetNotes sets the "notes" field.
- func (m *RedeemCodeMutation) SetNotes(s string) {
- m.notes = &s
- }
- // Notes returns the value of the "notes" field in the mutation.
- func (m *RedeemCodeMutation) Notes() (r string, exists bool) {
- v := m.notes
- if v == nil {
- return
- }
- return *v, true
- }
- // OldNotes returns the old "notes" field's value of the RedeemCode entity.
- // If the RedeemCode object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *RedeemCodeMutation) OldNotes(ctx context.Context) (v *string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldNotes is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldNotes requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldNotes: %w", err)
- }
- return oldValue.Notes, nil
- }
- // ClearNotes clears the value of the "notes" field.
- func (m *RedeemCodeMutation) ClearNotes() {
- m.notes = nil
- m.clearedFields[redeemcode.FieldNotes] = struct{}{}
- }
- // NotesCleared returns if the "notes" field was cleared in this mutation.
- func (m *RedeemCodeMutation) NotesCleared() bool {
- _, ok := m.clearedFields[redeemcode.FieldNotes]
- return ok
- }
- // ResetNotes resets all changes to the "notes" field.
- func (m *RedeemCodeMutation) ResetNotes() {
- m.notes = nil
- delete(m.clearedFields, redeemcode.FieldNotes)
- }
- // SetCreatedAt sets the "created_at" field.
- func (m *RedeemCodeMutation) SetCreatedAt(t time.Time) {
- m.created_at = &t
- }
- // CreatedAt returns the value of the "created_at" field in the mutation.
- func (m *RedeemCodeMutation) CreatedAt() (r time.Time, exists bool) {
- v := m.created_at
- if v == nil {
- return
- }
- return *v, true
- }
- // OldCreatedAt returns the old "created_at" field's value of the RedeemCode entity.
- // If the RedeemCode object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *RedeemCodeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldCreatedAt requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
- }
- return oldValue.CreatedAt, nil
- }
- // ResetCreatedAt resets all changes to the "created_at" field.
- func (m *RedeemCodeMutation) ResetCreatedAt() {
- m.created_at = nil
- }
- // SetExpiresAt sets the "expires_at" field.
- func (m *RedeemCodeMutation) SetExpiresAt(t time.Time) {
- m.expires_at = &t
- }
- // ExpiresAt returns the value of the "expires_at" field in the mutation.
- func (m *RedeemCodeMutation) ExpiresAt() (r time.Time, exists bool) {
- v := m.expires_at
- if v == nil {
- return
- }
- return *v, true
- }
- // OldExpiresAt returns the old "expires_at" field's value of the RedeemCode entity.
- // If the RedeemCode object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *RedeemCodeMutation) OldExpiresAt(ctx context.Context) (v *time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldExpiresAt is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldExpiresAt requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldExpiresAt: %w", err)
- }
- return oldValue.ExpiresAt, nil
- }
- // ClearExpiresAt clears the value of the "expires_at" field.
- func (m *RedeemCodeMutation) ClearExpiresAt() {
- m.expires_at = nil
- m.clearedFields[redeemcode.FieldExpiresAt] = struct{}{}
- }
- // ExpiresAtCleared returns if the "expires_at" field was cleared in this mutation.
- func (m *RedeemCodeMutation) ExpiresAtCleared() bool {
- _, ok := m.clearedFields[redeemcode.FieldExpiresAt]
- return ok
- }
- // ResetExpiresAt resets all changes to the "expires_at" field.
- func (m *RedeemCodeMutation) ResetExpiresAt() {
- m.expires_at = nil
- delete(m.clearedFields, redeemcode.FieldExpiresAt)
- }
- // SetGroupID sets the "group_id" field.
- func (m *RedeemCodeMutation) SetGroupID(i int64) {
- m.group = &i
- }
- // GroupID returns the value of the "group_id" field in the mutation.
- func (m *RedeemCodeMutation) GroupID() (r int64, exists bool) {
- v := m.group
- if v == nil {
- return
- }
- return *v, true
- }
- // OldGroupID returns the old "group_id" field's value of the RedeemCode entity.
- // If the RedeemCode object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *RedeemCodeMutation) OldGroupID(ctx context.Context) (v *int64, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldGroupID is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldGroupID requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldGroupID: %w", err)
- }
- return oldValue.GroupID, nil
- }
- // ClearGroupID clears the value of the "group_id" field.
- func (m *RedeemCodeMutation) ClearGroupID() {
- m.group = nil
- m.clearedFields[redeemcode.FieldGroupID] = struct{}{}
- }
- // GroupIDCleared returns if the "group_id" field was cleared in this mutation.
- func (m *RedeemCodeMutation) GroupIDCleared() bool {
- _, ok := m.clearedFields[redeemcode.FieldGroupID]
- return ok
- }
- // ResetGroupID resets all changes to the "group_id" field.
- func (m *RedeemCodeMutation) ResetGroupID() {
- m.group = nil
- delete(m.clearedFields, redeemcode.FieldGroupID)
- }
- // SetValidityDays sets the "validity_days" field.
- func (m *RedeemCodeMutation) SetValidityDays(i int) {
- m.validity_days = &i
- m.addvalidity_days = nil
- }
- // ValidityDays returns the value of the "validity_days" field in the mutation.
- func (m *RedeemCodeMutation) ValidityDays() (r int, exists bool) {
- v := m.validity_days
- if v == nil {
- return
- }
- return *v, true
- }
- // OldValidityDays returns the old "validity_days" field's value of the RedeemCode entity.
- // If the RedeemCode object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *RedeemCodeMutation) OldValidityDays(ctx context.Context) (v int, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldValidityDays is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldValidityDays requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldValidityDays: %w", err)
- }
- return oldValue.ValidityDays, nil
- }
- // AddValidityDays adds i to the "validity_days" field.
- func (m *RedeemCodeMutation) AddValidityDays(i int) {
- if m.addvalidity_days != nil {
- *m.addvalidity_days += i
- } else {
- m.addvalidity_days = &i
- }
- }
- // AddedValidityDays returns the value that was added to the "validity_days" field in this mutation.
- func (m *RedeemCodeMutation) AddedValidityDays() (r int, exists bool) {
- v := m.addvalidity_days
- if v == nil {
- return
- }
- return *v, true
- }
- // ResetValidityDays resets all changes to the "validity_days" field.
- func (m *RedeemCodeMutation) ResetValidityDays() {
- m.validity_days = nil
- m.addvalidity_days = nil
- }
- // SetUserID sets the "user" edge to the User entity by id.
- func (m *RedeemCodeMutation) SetUserID(id int64) {
- m.user = &id
- }
- // ClearUser clears the "user" edge to the User entity.
- func (m *RedeemCodeMutation) ClearUser() {
- m.cleareduser = true
- m.clearedFields[redeemcode.FieldUsedBy] = struct{}{}
- }
- // UserCleared reports if the "user" edge to the User entity was cleared.
- func (m *RedeemCodeMutation) UserCleared() bool {
- return m.UsedByCleared() || m.cleareduser
- }
- // UserID returns the "user" edge ID in the mutation.
- func (m *RedeemCodeMutation) UserID() (id int64, exists bool) {
- if m.user != nil {
- return *m.user, true
- }
- return
- }
- // UserIDs returns the "user" edge IDs in the mutation.
- // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
- // UserID instead. It exists only for internal usage by the builders.
- func (m *RedeemCodeMutation) UserIDs() (ids []int64) {
- if id := m.user; id != nil {
- ids = append(ids, *id)
- }
- return
- }
- // ResetUser resets all changes to the "user" edge.
- func (m *RedeemCodeMutation) ResetUser() {
- m.user = nil
- m.cleareduser = false
- }
- // ClearGroup clears the "group" edge to the Group entity.
- func (m *RedeemCodeMutation) ClearGroup() {
- m.clearedgroup = true
- m.clearedFields[redeemcode.FieldGroupID] = struct{}{}
- }
- // GroupCleared reports if the "group" edge to the Group entity was cleared.
- func (m *RedeemCodeMutation) GroupCleared() bool {
- return m.GroupIDCleared() || m.clearedgroup
- }
- // GroupIDs returns the "group" edge IDs in the mutation.
- // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
- // GroupID instead. It exists only for internal usage by the builders.
- func (m *RedeemCodeMutation) GroupIDs() (ids []int64) {
- if id := m.group; id != nil {
- ids = append(ids, *id)
- }
- return
- }
- // ResetGroup resets all changes to the "group" edge.
- func (m *RedeemCodeMutation) ResetGroup() {
- m.group = nil
- m.clearedgroup = false
- }
- // Where appends a list predicates to the RedeemCodeMutation builder.
- func (m *RedeemCodeMutation) Where(ps ...predicate.RedeemCode) {
- m.predicates = append(m.predicates, ps...)
- }
- // WhereP appends storage-level predicates to the RedeemCodeMutation builder. Using this method,
- // users can use type-assertion to append predicates that do not depend on any generated package.
- func (m *RedeemCodeMutation) WhereP(ps ...func(*sql.Selector)) {
- p := make([]predicate.RedeemCode, len(ps))
- for i := range ps {
- p[i] = ps[i]
- }
- m.Where(p...)
- }
- // Op returns the operation name.
- func (m *RedeemCodeMutation) Op() Op {
- return m.op
- }
- // SetOp allows setting the mutation operation.
- func (m *RedeemCodeMutation) SetOp(op Op) {
- m.op = op
- }
- // Type returns the node type of this mutation (RedeemCode).
- func (m *RedeemCodeMutation) Type() string {
- return m.typ
- }
- // Fields returns all fields that were changed during this mutation. Note that in
- // order to get all numeric fields that were incremented/decremented, call
- // AddedFields().
- func (m *RedeemCodeMutation) Fields() []string {
- fields := make([]string, 0, 11)
- if m.code != nil {
- fields = append(fields, redeemcode.FieldCode)
- }
- if m._type != nil {
- fields = append(fields, redeemcode.FieldType)
- }
- if m.value != nil {
- fields = append(fields, redeemcode.FieldValue)
- }
- if m.status != nil {
- fields = append(fields, redeemcode.FieldStatus)
- }
- if m.user != nil {
- fields = append(fields, redeemcode.FieldUsedBy)
- }
- if m.used_at != nil {
- fields = append(fields, redeemcode.FieldUsedAt)
- }
- if m.notes != nil {
- fields = append(fields, redeemcode.FieldNotes)
- }
- if m.created_at != nil {
- fields = append(fields, redeemcode.FieldCreatedAt)
- }
- if m.expires_at != nil {
- fields = append(fields, redeemcode.FieldExpiresAt)
- }
- if m.group != nil {
- fields = append(fields, redeemcode.FieldGroupID)
- }
- if m.validity_days != nil {
- fields = append(fields, redeemcode.FieldValidityDays)
- }
- return fields
- }
- // Field returns the value of a field with the given name. The second boolean
- // return value indicates that this field was not set, or was not defined in the
- // schema.
- func (m *RedeemCodeMutation) Field(name string) (ent.Value, bool) {
- switch name {
- case redeemcode.FieldCode:
- return m.Code()
- case redeemcode.FieldType:
- return m.GetType()
- case redeemcode.FieldValue:
- return m.Value()
- case redeemcode.FieldStatus:
- return m.Status()
- case redeemcode.FieldUsedBy:
- return m.UsedBy()
- case redeemcode.FieldUsedAt:
- return m.UsedAt()
- case redeemcode.FieldNotes:
- return m.Notes()
- case redeemcode.FieldCreatedAt:
- return m.CreatedAt()
- case redeemcode.FieldExpiresAt:
- return m.ExpiresAt()
- case redeemcode.FieldGroupID:
- return m.GroupID()
- case redeemcode.FieldValidityDays:
- return m.ValidityDays()
- }
- return nil, false
- }
- // OldField returns the old value of the field from the database. An error is
- // returned if the mutation operation is not UpdateOne, or the query to the
- // database failed.
- func (m *RedeemCodeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
- switch name {
- case redeemcode.FieldCode:
- return m.OldCode(ctx)
- case redeemcode.FieldType:
- return m.OldType(ctx)
- case redeemcode.FieldValue:
- return m.OldValue(ctx)
- case redeemcode.FieldStatus:
- return m.OldStatus(ctx)
- case redeemcode.FieldUsedBy:
- return m.OldUsedBy(ctx)
- case redeemcode.FieldUsedAt:
- return m.OldUsedAt(ctx)
- case redeemcode.FieldNotes:
- return m.OldNotes(ctx)
- case redeemcode.FieldCreatedAt:
- return m.OldCreatedAt(ctx)
- case redeemcode.FieldExpiresAt:
- return m.OldExpiresAt(ctx)
- case redeemcode.FieldGroupID:
- return m.OldGroupID(ctx)
- case redeemcode.FieldValidityDays:
- return m.OldValidityDays(ctx)
- }
- return nil, fmt.Errorf("unknown RedeemCode field %s", name)
- }
- // SetField sets the value of a field with the given name. It returns an error if
- // the field is not defined in the schema, or if the type mismatched the field
- // type.
- func (m *RedeemCodeMutation) SetField(name string, value ent.Value) error {
- switch name {
- case redeemcode.FieldCode:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetCode(v)
- return nil
- case redeemcode.FieldType:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetType(v)
- return nil
- case redeemcode.FieldValue:
- v, ok := value.(float64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetValue(v)
- return nil
- case redeemcode.FieldStatus:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetStatus(v)
- return nil
- case redeemcode.FieldUsedBy:
- v, ok := value.(int64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetUsedBy(v)
- return nil
- case redeemcode.FieldUsedAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetUsedAt(v)
- return nil
- case redeemcode.FieldNotes:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetNotes(v)
- return nil
- case redeemcode.FieldCreatedAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetCreatedAt(v)
- return nil
- case redeemcode.FieldExpiresAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetExpiresAt(v)
- return nil
- case redeemcode.FieldGroupID:
- v, ok := value.(int64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetGroupID(v)
- return nil
- case redeemcode.FieldValidityDays:
- v, ok := value.(int)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetValidityDays(v)
- return nil
- }
- return fmt.Errorf("unknown RedeemCode field %s", name)
- }
- // AddedFields returns all numeric fields that were incremented/decremented during
- // this mutation.
- func (m *RedeemCodeMutation) AddedFields() []string {
- var fields []string
- if m.addvalue != nil {
- fields = append(fields, redeemcode.FieldValue)
- }
- if m.addvalidity_days != nil {
- fields = append(fields, redeemcode.FieldValidityDays)
- }
- return fields
- }
- // AddedField returns the numeric value that was incremented/decremented on a field
- // with the given name. The second boolean return value indicates that this field
- // was not set, or was not defined in the schema.
- func (m *RedeemCodeMutation) AddedField(name string) (ent.Value, bool) {
- switch name {
- case redeemcode.FieldValue:
- return m.AddedValue()
- case redeemcode.FieldValidityDays:
- return m.AddedValidityDays()
- }
- return nil, false
- }
- // AddField adds the value to the field with the given name. It returns an error if
- // the field is not defined in the schema, or if the type mismatched the field
- // type.
- func (m *RedeemCodeMutation) AddField(name string, value ent.Value) error {
- switch name {
- case redeemcode.FieldValue:
- v, ok := value.(float64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.AddValue(v)
- return nil
- case redeemcode.FieldValidityDays:
- v, ok := value.(int)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.AddValidityDays(v)
- return nil
- }
- return fmt.Errorf("unknown RedeemCode numeric field %s", name)
- }
- // ClearedFields returns all nullable fields that were cleared during this
- // mutation.
- func (m *RedeemCodeMutation) ClearedFields() []string {
- var fields []string
- if m.FieldCleared(redeemcode.FieldUsedBy) {
- fields = append(fields, redeemcode.FieldUsedBy)
- }
- if m.FieldCleared(redeemcode.FieldUsedAt) {
- fields = append(fields, redeemcode.FieldUsedAt)
- }
- if m.FieldCleared(redeemcode.FieldNotes) {
- fields = append(fields, redeemcode.FieldNotes)
- }
- if m.FieldCleared(redeemcode.FieldExpiresAt) {
- fields = append(fields, redeemcode.FieldExpiresAt)
- }
- if m.FieldCleared(redeemcode.FieldGroupID) {
- fields = append(fields, redeemcode.FieldGroupID)
- }
- return fields
- }
- // FieldCleared returns a boolean indicating if a field with the given name was
- // cleared in this mutation.
- func (m *RedeemCodeMutation) FieldCleared(name string) bool {
- _, ok := m.clearedFields[name]
- return ok
- }
- // ClearField clears the value of the field with the given name. It returns an
- // error if the field is not defined in the schema.
- func (m *RedeemCodeMutation) ClearField(name string) error {
- switch name {
- case redeemcode.FieldUsedBy:
- m.ClearUsedBy()
- return nil
- case redeemcode.FieldUsedAt:
- m.ClearUsedAt()
- return nil
- case redeemcode.FieldNotes:
- m.ClearNotes()
- return nil
- case redeemcode.FieldExpiresAt:
- m.ClearExpiresAt()
- return nil
- case redeemcode.FieldGroupID:
- m.ClearGroupID()
- return nil
- }
- return fmt.Errorf("unknown RedeemCode nullable field %s", name)
- }
- // ResetField resets all changes in the mutation for the field with the given name.
- // It returns an error if the field is not defined in the schema.
- func (m *RedeemCodeMutation) ResetField(name string) error {
- switch name {
- case redeemcode.FieldCode:
- m.ResetCode()
- return nil
- case redeemcode.FieldType:
- m.ResetType()
- return nil
- case redeemcode.FieldValue:
- m.ResetValue()
- return nil
- case redeemcode.FieldStatus:
- m.ResetStatus()
- return nil
- case redeemcode.FieldUsedBy:
- m.ResetUsedBy()
- return nil
- case redeemcode.FieldUsedAt:
- m.ResetUsedAt()
- return nil
- case redeemcode.FieldNotes:
- m.ResetNotes()
- return nil
- case redeemcode.FieldCreatedAt:
- m.ResetCreatedAt()
- return nil
- case redeemcode.FieldExpiresAt:
- m.ResetExpiresAt()
- return nil
- case redeemcode.FieldGroupID:
- m.ResetGroupID()
- return nil
- case redeemcode.FieldValidityDays:
- m.ResetValidityDays()
- return nil
- }
- return fmt.Errorf("unknown RedeemCode field %s", name)
- }
- // AddedEdges returns all edge names that were set/added in this mutation.
- func (m *RedeemCodeMutation) AddedEdges() []string {
- edges := make([]string, 0, 2)
- if m.user != nil {
- edges = append(edges, redeemcode.EdgeUser)
- }
- if m.group != nil {
- edges = append(edges, redeemcode.EdgeGroup)
- }
- return edges
- }
- // AddedIDs returns all IDs (to other nodes) that were added for the given edge
- // name in this mutation.
- func (m *RedeemCodeMutation) AddedIDs(name string) []ent.Value {
- switch name {
- case redeemcode.EdgeUser:
- if id := m.user; id != nil {
- return []ent.Value{*id}
- }
- case redeemcode.EdgeGroup:
- if id := m.group; id != nil {
- return []ent.Value{*id}
- }
- }
- return nil
- }
- // RemovedEdges returns all edge names that were removed in this mutation.
- func (m *RedeemCodeMutation) RemovedEdges() []string {
- edges := make([]string, 0, 2)
- return edges
- }
- // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
- // the given name in this mutation.
- func (m *RedeemCodeMutation) RemovedIDs(name string) []ent.Value {
- return nil
- }
- // ClearedEdges returns all edge names that were cleared in this mutation.
- func (m *RedeemCodeMutation) ClearedEdges() []string {
- edges := make([]string, 0, 2)
- if m.cleareduser {
- edges = append(edges, redeemcode.EdgeUser)
- }
- if m.clearedgroup {
- edges = append(edges, redeemcode.EdgeGroup)
- }
- return edges
- }
- // EdgeCleared returns a boolean which indicates if the edge with the given name
- // was cleared in this mutation.
- func (m *RedeemCodeMutation) EdgeCleared(name string) bool {
- switch name {
- case redeemcode.EdgeUser:
- return m.cleareduser
- case redeemcode.EdgeGroup:
- return m.clearedgroup
- }
- return false
- }
- // ClearEdge clears the value of the edge with the given name. It returns an error
- // if that edge is not defined in the schema.
- func (m *RedeemCodeMutation) ClearEdge(name string) error {
- switch name {
- case redeemcode.EdgeUser:
- m.ClearUser()
- return nil
- case redeemcode.EdgeGroup:
- m.ClearGroup()
- return nil
- }
- return fmt.Errorf("unknown RedeemCode unique edge %s", name)
- }
- // ResetEdge resets all changes to the edge with the given name in this mutation.
- // It returns an error if the edge is not defined in the schema.
- func (m *RedeemCodeMutation) ResetEdge(name string) error {
- switch name {
- case redeemcode.EdgeUser:
- m.ResetUser()
- return nil
- case redeemcode.EdgeGroup:
- m.ResetGroup()
- return nil
- }
- return fmt.Errorf("unknown RedeemCode edge %s", name)
- }
- // SecurityPolicyKeywordMutation represents an operation that mutates the SecurityPolicyKeyword nodes in the graph.
- type SecurityPolicyKeywordMutation struct {
- config
- op Op
- typ string
- id *int64
- created_at *time.Time
- updated_at *time.Time
- deleted_at *time.Time
- keyword *string
- category *string
- enabled *bool
- clearedFields map[string]struct{}
- group *int64
- clearedgroup bool
- done bool
- oldValue func(context.Context) (*SecurityPolicyKeyword, error)
- predicates []predicate.SecurityPolicyKeyword
- }
- var _ ent.Mutation = (*SecurityPolicyKeywordMutation)(nil)
- // securitypolicykeywordOption allows management of the mutation configuration using functional options.
- type securitypolicykeywordOption func(*SecurityPolicyKeywordMutation)
- // newSecurityPolicyKeywordMutation creates new mutation for the SecurityPolicyKeyword entity.
- func newSecurityPolicyKeywordMutation(c config, op Op, opts ...securitypolicykeywordOption) *SecurityPolicyKeywordMutation {
- m := &SecurityPolicyKeywordMutation{
- config: c,
- op: op,
- typ: TypeSecurityPolicyKeyword,
- clearedFields: make(map[string]struct{}),
- }
- for _, opt := range opts {
- opt(m)
- }
- return m
- }
- // withSecurityPolicyKeywordID sets the ID field of the mutation.
- func withSecurityPolicyKeywordID(id int64) securitypolicykeywordOption {
- return func(m *SecurityPolicyKeywordMutation) {
- var (
- err error
- once sync.Once
- value *SecurityPolicyKeyword
- )
- m.oldValue = func(ctx context.Context) (*SecurityPolicyKeyword, error) {
- once.Do(func() {
- if m.done {
- err = errors.New("querying old values post mutation is not allowed")
- } else {
- value, err = m.Client().SecurityPolicyKeyword.Get(ctx, id)
- }
- })
- return value, err
- }
- m.id = &id
- }
- }
- // withSecurityPolicyKeyword sets the old SecurityPolicyKeyword of the mutation.
- func withSecurityPolicyKeyword(node *SecurityPolicyKeyword) securitypolicykeywordOption {
- return func(m *SecurityPolicyKeywordMutation) {
- m.oldValue = func(context.Context) (*SecurityPolicyKeyword, error) {
- return node, nil
- }
- m.id = &node.ID
- }
- }
- // Client returns a new `ent.Client` from the mutation. If the mutation was
- // executed in a transaction (ent.Tx), a transactional client is returned.
- func (m SecurityPolicyKeywordMutation) Client() *Client {
- client := &Client{config: m.config}
- client.init()
- return client
- }
- // Tx returns an `ent.Tx` for mutations that were executed in transactions;
- // it returns an error otherwise.
- func (m SecurityPolicyKeywordMutation) Tx() (*Tx, error) {
- if _, ok := m.driver.(*txDriver); !ok {
- return nil, errors.New("ent: mutation is not running in a transaction")
- }
- tx := &Tx{config: m.config}
- tx.init()
- return tx, nil
- }
- // ID returns the ID value in the mutation. Note that the ID is only available
- // if it was provided to the builder or after it was returned from the database.
- func (m *SecurityPolicyKeywordMutation) ID() (id int64, exists bool) {
- if m.id == nil {
- return
- }
- return *m.id, true
- }
- // IDs queries the database and returns the entity ids that match the mutation's predicate.
- // That means, if the mutation is applied within a transaction with an isolation level such
- // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
- // or updated by the mutation.
- func (m *SecurityPolicyKeywordMutation) IDs(ctx context.Context) ([]int64, error) {
- switch {
- case m.op.Is(OpUpdateOne | OpDeleteOne):
- id, exists := m.ID()
- if exists {
- return []int64{id}, nil
- }
- fallthrough
- case m.op.Is(OpUpdate | OpDelete):
- return m.Client().SecurityPolicyKeyword.Query().Where(m.predicates...).IDs(ctx)
- default:
- return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
- }
- }
- // SetCreatedAt sets the "created_at" field.
- func (m *SecurityPolicyKeywordMutation) SetCreatedAt(t time.Time) {
- m.created_at = &t
- }
- // CreatedAt returns the value of the "created_at" field in the mutation.
- func (m *SecurityPolicyKeywordMutation) CreatedAt() (r time.Time, exists bool) {
- v := m.created_at
- if v == nil {
- return
- }
- return *v, true
- }
- // OldCreatedAt returns the old "created_at" field's value of the SecurityPolicyKeyword entity.
- // If the SecurityPolicyKeyword object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *SecurityPolicyKeywordMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldCreatedAt requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
- }
- return oldValue.CreatedAt, nil
- }
- // ResetCreatedAt resets all changes to the "created_at" field.
- func (m *SecurityPolicyKeywordMutation) ResetCreatedAt() {
- m.created_at = nil
- }
- // SetUpdatedAt sets the "updated_at" field.
- func (m *SecurityPolicyKeywordMutation) SetUpdatedAt(t time.Time) {
- m.updated_at = &t
- }
- // UpdatedAt returns the value of the "updated_at" field in the mutation.
- func (m *SecurityPolicyKeywordMutation) UpdatedAt() (r time.Time, exists bool) {
- v := m.updated_at
- if v == nil {
- return
- }
- return *v, true
- }
- // OldUpdatedAt returns the old "updated_at" field's value of the SecurityPolicyKeyword entity.
- // If the SecurityPolicyKeyword object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *SecurityPolicyKeywordMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
- }
- return oldValue.UpdatedAt, nil
- }
- // ResetUpdatedAt resets all changes to the "updated_at" field.
- func (m *SecurityPolicyKeywordMutation) ResetUpdatedAt() {
- m.updated_at = nil
- }
- // SetDeletedAt sets the "deleted_at" field.
- func (m *SecurityPolicyKeywordMutation) SetDeletedAt(t time.Time) {
- m.deleted_at = &t
- }
- // DeletedAt returns the value of the "deleted_at" field in the mutation.
- func (m *SecurityPolicyKeywordMutation) DeletedAt() (r time.Time, exists bool) {
- v := m.deleted_at
- if v == nil {
- return
- }
- return *v, true
- }
- // OldDeletedAt returns the old "deleted_at" field's value of the SecurityPolicyKeyword entity.
- // If the SecurityPolicyKeyword object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *SecurityPolicyKeywordMutation) OldDeletedAt(ctx context.Context) (v *time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldDeletedAt requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
- }
- return oldValue.DeletedAt, nil
- }
- // ClearDeletedAt clears the value of the "deleted_at" field.
- func (m *SecurityPolicyKeywordMutation) ClearDeletedAt() {
- m.deleted_at = nil
- m.clearedFields[securitypolicykeyword.FieldDeletedAt] = struct{}{}
- }
- // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
- func (m *SecurityPolicyKeywordMutation) DeletedAtCleared() bool {
- _, ok := m.clearedFields[securitypolicykeyword.FieldDeletedAt]
- return ok
- }
- // ResetDeletedAt resets all changes to the "deleted_at" field.
- func (m *SecurityPolicyKeywordMutation) ResetDeletedAt() {
- m.deleted_at = nil
- delete(m.clearedFields, securitypolicykeyword.FieldDeletedAt)
- }
- // SetGroupID sets the "group_id" field.
- func (m *SecurityPolicyKeywordMutation) SetGroupID(i int64) {
- m.group = &i
- }
- // GroupID returns the value of the "group_id" field in the mutation.
- func (m *SecurityPolicyKeywordMutation) GroupID() (r int64, exists bool) {
- v := m.group
- if v == nil {
- return
- }
- return *v, true
- }
- // OldGroupID returns the old "group_id" field's value of the SecurityPolicyKeyword entity.
- // If the SecurityPolicyKeyword object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *SecurityPolicyKeywordMutation) OldGroupID(ctx context.Context) (v *int64, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldGroupID is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldGroupID requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldGroupID: %w", err)
- }
- return oldValue.GroupID, nil
- }
- // ClearGroupID clears the value of the "group_id" field.
- func (m *SecurityPolicyKeywordMutation) ClearGroupID() {
- m.group = nil
- m.clearedFields[securitypolicykeyword.FieldGroupID] = struct{}{}
- }
- // GroupIDCleared returns if the "group_id" field was cleared in this mutation.
- func (m *SecurityPolicyKeywordMutation) GroupIDCleared() bool {
- _, ok := m.clearedFields[securitypolicykeyword.FieldGroupID]
- return ok
- }
- // ResetGroupID resets all changes to the "group_id" field.
- func (m *SecurityPolicyKeywordMutation) ResetGroupID() {
- m.group = nil
- delete(m.clearedFields, securitypolicykeyword.FieldGroupID)
- }
- // SetKeyword sets the "keyword" field.
- func (m *SecurityPolicyKeywordMutation) SetKeyword(s string) {
- m.keyword = &s
- }
- // Keyword returns the value of the "keyword" field in the mutation.
- func (m *SecurityPolicyKeywordMutation) Keyword() (r string, exists bool) {
- v := m.keyword
- if v == nil {
- return
- }
- return *v, true
- }
- // OldKeyword returns the old "keyword" field's value of the SecurityPolicyKeyword entity.
- // If the SecurityPolicyKeyword object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *SecurityPolicyKeywordMutation) OldKeyword(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldKeyword is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldKeyword requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldKeyword: %w", err)
- }
- return oldValue.Keyword, nil
- }
- // ResetKeyword resets all changes to the "keyword" field.
- func (m *SecurityPolicyKeywordMutation) ResetKeyword() {
- m.keyword = nil
- }
- // SetCategory sets the "category" field.
- func (m *SecurityPolicyKeywordMutation) SetCategory(s string) {
- m.category = &s
- }
- // Category returns the value of the "category" field in the mutation.
- func (m *SecurityPolicyKeywordMutation) Category() (r string, exists bool) {
- v := m.category
- if v == nil {
- return
- }
- return *v, true
- }
- // OldCategory returns the old "category" field's value of the SecurityPolicyKeyword entity.
- // If the SecurityPolicyKeyword object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *SecurityPolicyKeywordMutation) OldCategory(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldCategory is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldCategory requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldCategory: %w", err)
- }
- return oldValue.Category, nil
- }
- // ResetCategory resets all changes to the "category" field.
- func (m *SecurityPolicyKeywordMutation) ResetCategory() {
- m.category = nil
- }
- // SetEnabled sets the "enabled" field.
- func (m *SecurityPolicyKeywordMutation) SetEnabled(b bool) {
- m.enabled = &b
- }
- // Enabled returns the value of the "enabled" field in the mutation.
- func (m *SecurityPolicyKeywordMutation) Enabled() (r bool, exists bool) {
- v := m.enabled
- if v == nil {
- return
- }
- return *v, true
- }
- // OldEnabled returns the old "enabled" field's value of the SecurityPolicyKeyword entity.
- // If the SecurityPolicyKeyword object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *SecurityPolicyKeywordMutation) OldEnabled(ctx context.Context) (v bool, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldEnabled is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldEnabled requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldEnabled: %w", err)
- }
- return oldValue.Enabled, nil
- }
- // ResetEnabled resets all changes to the "enabled" field.
- func (m *SecurityPolicyKeywordMutation) ResetEnabled() {
- m.enabled = nil
- }
- // ClearGroup clears the "group" edge to the Group entity.
- func (m *SecurityPolicyKeywordMutation) ClearGroup() {
- m.clearedgroup = true
- m.clearedFields[securitypolicykeyword.FieldGroupID] = struct{}{}
- }
- // GroupCleared reports if the "group" edge to the Group entity was cleared.
- func (m *SecurityPolicyKeywordMutation) GroupCleared() bool {
- return m.GroupIDCleared() || m.clearedgroup
- }
- // GroupIDs returns the "group" edge IDs in the mutation.
- // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
- // GroupID instead. It exists only for internal usage by the builders.
- func (m *SecurityPolicyKeywordMutation) GroupIDs() (ids []int64) {
- if id := m.group; id != nil {
- ids = append(ids, *id)
- }
- return
- }
- // ResetGroup resets all changes to the "group" edge.
- func (m *SecurityPolicyKeywordMutation) ResetGroup() {
- m.group = nil
- m.clearedgroup = false
- }
- // Where appends a list predicates to the SecurityPolicyKeywordMutation builder.
- func (m *SecurityPolicyKeywordMutation) Where(ps ...predicate.SecurityPolicyKeyword) {
- m.predicates = append(m.predicates, ps...)
- }
- // WhereP appends storage-level predicates to the SecurityPolicyKeywordMutation builder. Using this method,
- // users can use type-assertion to append predicates that do not depend on any generated package.
- func (m *SecurityPolicyKeywordMutation) WhereP(ps ...func(*sql.Selector)) {
- p := make([]predicate.SecurityPolicyKeyword, len(ps))
- for i := range ps {
- p[i] = ps[i]
- }
- m.Where(p...)
- }
- // Op returns the operation name.
- func (m *SecurityPolicyKeywordMutation) Op() Op {
- return m.op
- }
- // SetOp allows setting the mutation operation.
- func (m *SecurityPolicyKeywordMutation) SetOp(op Op) {
- m.op = op
- }
- // Type returns the node type of this mutation (SecurityPolicyKeyword).
- func (m *SecurityPolicyKeywordMutation) Type() string {
- return m.typ
- }
- // Fields returns all fields that were changed during this mutation. Note that in
- // order to get all numeric fields that were incremented/decremented, call
- // AddedFields().
- func (m *SecurityPolicyKeywordMutation) Fields() []string {
- fields := make([]string, 0, 7)
- if m.created_at != nil {
- fields = append(fields, securitypolicykeyword.FieldCreatedAt)
- }
- if m.updated_at != nil {
- fields = append(fields, securitypolicykeyword.FieldUpdatedAt)
- }
- if m.deleted_at != nil {
- fields = append(fields, securitypolicykeyword.FieldDeletedAt)
- }
- if m.group != nil {
- fields = append(fields, securitypolicykeyword.FieldGroupID)
- }
- if m.keyword != nil {
- fields = append(fields, securitypolicykeyword.FieldKeyword)
- }
- if m.category != nil {
- fields = append(fields, securitypolicykeyword.FieldCategory)
- }
- if m.enabled != nil {
- fields = append(fields, securitypolicykeyword.FieldEnabled)
- }
- return fields
- }
- // Field returns the value of a field with the given name. The second boolean
- // return value indicates that this field was not set, or was not defined in the
- // schema.
- func (m *SecurityPolicyKeywordMutation) Field(name string) (ent.Value, bool) {
- switch name {
- case securitypolicykeyword.FieldCreatedAt:
- return m.CreatedAt()
- case securitypolicykeyword.FieldUpdatedAt:
- return m.UpdatedAt()
- case securitypolicykeyword.FieldDeletedAt:
- return m.DeletedAt()
- case securitypolicykeyword.FieldGroupID:
- return m.GroupID()
- case securitypolicykeyword.FieldKeyword:
- return m.Keyword()
- case securitypolicykeyword.FieldCategory:
- return m.Category()
- case securitypolicykeyword.FieldEnabled:
- return m.Enabled()
- }
- return nil, false
- }
- // OldField returns the old value of the field from the database. An error is
- // returned if the mutation operation is not UpdateOne, or the query to the
- // database failed.
- func (m *SecurityPolicyKeywordMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
- switch name {
- case securitypolicykeyword.FieldCreatedAt:
- return m.OldCreatedAt(ctx)
- case securitypolicykeyword.FieldUpdatedAt:
- return m.OldUpdatedAt(ctx)
- case securitypolicykeyword.FieldDeletedAt:
- return m.OldDeletedAt(ctx)
- case securitypolicykeyword.FieldGroupID:
- return m.OldGroupID(ctx)
- case securitypolicykeyword.FieldKeyword:
- return m.OldKeyword(ctx)
- case securitypolicykeyword.FieldCategory:
- return m.OldCategory(ctx)
- case securitypolicykeyword.FieldEnabled:
- return m.OldEnabled(ctx)
- }
- return nil, fmt.Errorf("unknown SecurityPolicyKeyword field %s", name)
- }
- // SetField sets the value of a field with the given name. It returns an error if
- // the field is not defined in the schema, or if the type mismatched the field
- // type.
- func (m *SecurityPolicyKeywordMutation) SetField(name string, value ent.Value) error {
- switch name {
- case securitypolicykeyword.FieldCreatedAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetCreatedAt(v)
- return nil
- case securitypolicykeyword.FieldUpdatedAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetUpdatedAt(v)
- return nil
- case securitypolicykeyword.FieldDeletedAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetDeletedAt(v)
- return nil
- case securitypolicykeyword.FieldGroupID:
- v, ok := value.(int64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetGroupID(v)
- return nil
- case securitypolicykeyword.FieldKeyword:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetKeyword(v)
- return nil
- case securitypolicykeyword.FieldCategory:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetCategory(v)
- return nil
- case securitypolicykeyword.FieldEnabled:
- v, ok := value.(bool)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetEnabled(v)
- return nil
- }
- return fmt.Errorf("unknown SecurityPolicyKeyword field %s", name)
- }
- // AddedFields returns all numeric fields that were incremented/decremented during
- // this mutation.
- func (m *SecurityPolicyKeywordMutation) AddedFields() []string {
- var fields []string
- return fields
- }
- // AddedField returns the numeric value that was incremented/decremented on a field
- // with the given name. The second boolean return value indicates that this field
- // was not set, or was not defined in the schema.
- func (m *SecurityPolicyKeywordMutation) AddedField(name string) (ent.Value, bool) {
- switch name {
- }
- return nil, false
- }
- // AddField adds the value to the field with the given name. It returns an error if
- // the field is not defined in the schema, or if the type mismatched the field
- // type.
- func (m *SecurityPolicyKeywordMutation) AddField(name string, value ent.Value) error {
- switch name {
- }
- return fmt.Errorf("unknown SecurityPolicyKeyword numeric field %s", name)
- }
- // ClearedFields returns all nullable fields that were cleared during this
- // mutation.
- func (m *SecurityPolicyKeywordMutation) ClearedFields() []string {
- var fields []string
- if m.FieldCleared(securitypolicykeyword.FieldDeletedAt) {
- fields = append(fields, securitypolicykeyword.FieldDeletedAt)
- }
- if m.FieldCleared(securitypolicykeyword.FieldGroupID) {
- fields = append(fields, securitypolicykeyword.FieldGroupID)
- }
- return fields
- }
- // FieldCleared returns a boolean indicating if a field with the given name was
- // cleared in this mutation.
- func (m *SecurityPolicyKeywordMutation) FieldCleared(name string) bool {
- _, ok := m.clearedFields[name]
- return ok
- }
- // ClearField clears the value of the field with the given name. It returns an
- // error if the field is not defined in the schema.
- func (m *SecurityPolicyKeywordMutation) ClearField(name string) error {
- switch name {
- case securitypolicykeyword.FieldDeletedAt:
- m.ClearDeletedAt()
- return nil
- case securitypolicykeyword.FieldGroupID:
- m.ClearGroupID()
- return nil
- }
- return fmt.Errorf("unknown SecurityPolicyKeyword nullable field %s", name)
- }
- // ResetField resets all changes in the mutation for the field with the given name.
- // It returns an error if the field is not defined in the schema.
- func (m *SecurityPolicyKeywordMutation) ResetField(name string) error {
- switch name {
- case securitypolicykeyword.FieldCreatedAt:
- m.ResetCreatedAt()
- return nil
- case securitypolicykeyword.FieldUpdatedAt:
- m.ResetUpdatedAt()
- return nil
- case securitypolicykeyword.FieldDeletedAt:
- m.ResetDeletedAt()
- return nil
- case securitypolicykeyword.FieldGroupID:
- m.ResetGroupID()
- return nil
- case securitypolicykeyword.FieldKeyword:
- m.ResetKeyword()
- return nil
- case securitypolicykeyword.FieldCategory:
- m.ResetCategory()
- return nil
- case securitypolicykeyword.FieldEnabled:
- m.ResetEnabled()
- return nil
- }
- return fmt.Errorf("unknown SecurityPolicyKeyword field %s", name)
- }
- // AddedEdges returns all edge names that were set/added in this mutation.
- func (m *SecurityPolicyKeywordMutation) AddedEdges() []string {
- edges := make([]string, 0, 1)
- if m.group != nil {
- edges = append(edges, securitypolicykeyword.EdgeGroup)
- }
- return edges
- }
- // AddedIDs returns all IDs (to other nodes) that were added for the given edge
- // name in this mutation.
- func (m *SecurityPolicyKeywordMutation) AddedIDs(name string) []ent.Value {
- switch name {
- case securitypolicykeyword.EdgeGroup:
- if id := m.group; id != nil {
- return []ent.Value{*id}
- }
- }
- return nil
- }
- // RemovedEdges returns all edge names that were removed in this mutation.
- func (m *SecurityPolicyKeywordMutation) RemovedEdges() []string {
- edges := make([]string, 0, 1)
- return edges
- }
- // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
- // the given name in this mutation.
- func (m *SecurityPolicyKeywordMutation) RemovedIDs(name string) []ent.Value {
- return nil
- }
- // ClearedEdges returns all edge names that were cleared in this mutation.
- func (m *SecurityPolicyKeywordMutation) ClearedEdges() []string {
- edges := make([]string, 0, 1)
- if m.clearedgroup {
- edges = append(edges, securitypolicykeyword.EdgeGroup)
- }
- return edges
- }
- // EdgeCleared returns a boolean which indicates if the edge with the given name
- // was cleared in this mutation.
- func (m *SecurityPolicyKeywordMutation) EdgeCleared(name string) bool {
- switch name {
- case securitypolicykeyword.EdgeGroup:
- return m.clearedgroup
- }
- return false
- }
- // ClearEdge clears the value of the edge with the given name. It returns an error
- // if that edge is not defined in the schema.
- func (m *SecurityPolicyKeywordMutation) ClearEdge(name string) error {
- switch name {
- case securitypolicykeyword.EdgeGroup:
- m.ClearGroup()
- return nil
- }
- return fmt.Errorf("unknown SecurityPolicyKeyword unique edge %s", name)
- }
- // ResetEdge resets all changes to the edge with the given name in this mutation.
- // It returns an error if the edge is not defined in the schema.
- func (m *SecurityPolicyKeywordMutation) ResetEdge(name string) error {
- switch name {
- case securitypolicykeyword.EdgeGroup:
- m.ResetGroup()
- return nil
- }
- return fmt.Errorf("unknown SecurityPolicyKeyword edge %s", name)
- }
- // SecuritySecretMutation represents an operation that mutates the SecuritySecret nodes in the graph.
- type SecuritySecretMutation struct {
- config
- op Op
- typ string
- id *int64
- created_at *time.Time
- updated_at *time.Time
- key *string
- value *string
- clearedFields map[string]struct{}
- done bool
- oldValue func(context.Context) (*SecuritySecret, error)
- predicates []predicate.SecuritySecret
- }
- var _ ent.Mutation = (*SecuritySecretMutation)(nil)
- // securitysecretOption allows management of the mutation configuration using functional options.
- type securitysecretOption func(*SecuritySecretMutation)
- // newSecuritySecretMutation creates new mutation for the SecuritySecret entity.
- func newSecuritySecretMutation(c config, op Op, opts ...securitysecretOption) *SecuritySecretMutation {
- m := &SecuritySecretMutation{
- config: c,
- op: op,
- typ: TypeSecuritySecret,
- clearedFields: make(map[string]struct{}),
- }
- for _, opt := range opts {
- opt(m)
- }
- return m
- }
- // withSecuritySecretID sets the ID field of the mutation.
- func withSecuritySecretID(id int64) securitysecretOption {
- return func(m *SecuritySecretMutation) {
- var (
- err error
- once sync.Once
- value *SecuritySecret
- )
- m.oldValue = func(ctx context.Context) (*SecuritySecret, error) {
- once.Do(func() {
- if m.done {
- err = errors.New("querying old values post mutation is not allowed")
- } else {
- value, err = m.Client().SecuritySecret.Get(ctx, id)
- }
- })
- return value, err
- }
- m.id = &id
- }
- }
- // withSecuritySecret sets the old SecuritySecret of the mutation.
- func withSecuritySecret(node *SecuritySecret) securitysecretOption {
- return func(m *SecuritySecretMutation) {
- m.oldValue = func(context.Context) (*SecuritySecret, error) {
- return node, nil
- }
- m.id = &node.ID
- }
- }
- // Client returns a new `ent.Client` from the mutation. If the mutation was
- // executed in a transaction (ent.Tx), a transactional client is returned.
- func (m SecuritySecretMutation) Client() *Client {
- client := &Client{config: m.config}
- client.init()
- return client
- }
- // Tx returns an `ent.Tx` for mutations that were executed in transactions;
- // it returns an error otherwise.
- func (m SecuritySecretMutation) Tx() (*Tx, error) {
- if _, ok := m.driver.(*txDriver); !ok {
- return nil, errors.New("ent: mutation is not running in a transaction")
- }
- tx := &Tx{config: m.config}
- tx.init()
- return tx, nil
- }
- // ID returns the ID value in the mutation. Note that the ID is only available
- // if it was provided to the builder or after it was returned from the database.
- func (m *SecuritySecretMutation) ID() (id int64, exists bool) {
- if m.id == nil {
- return
- }
- return *m.id, true
- }
- // IDs queries the database and returns the entity ids that match the mutation's predicate.
- // That means, if the mutation is applied within a transaction with an isolation level such
- // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
- // or updated by the mutation.
- func (m *SecuritySecretMutation) IDs(ctx context.Context) ([]int64, error) {
- switch {
- case m.op.Is(OpUpdateOne | OpDeleteOne):
- id, exists := m.ID()
- if exists {
- return []int64{id}, nil
- }
- fallthrough
- case m.op.Is(OpUpdate | OpDelete):
- return m.Client().SecuritySecret.Query().Where(m.predicates...).IDs(ctx)
- default:
- return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
- }
- }
- // SetCreatedAt sets the "created_at" field.
- func (m *SecuritySecretMutation) SetCreatedAt(t time.Time) {
- m.created_at = &t
- }
- // CreatedAt returns the value of the "created_at" field in the mutation.
- func (m *SecuritySecretMutation) CreatedAt() (r time.Time, exists bool) {
- v := m.created_at
- if v == nil {
- return
- }
- return *v, true
- }
- // OldCreatedAt returns the old "created_at" field's value of the SecuritySecret entity.
- // If the SecuritySecret object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *SecuritySecretMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldCreatedAt requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
- }
- return oldValue.CreatedAt, nil
- }
- // ResetCreatedAt resets all changes to the "created_at" field.
- func (m *SecuritySecretMutation) ResetCreatedAt() {
- m.created_at = nil
- }
- // SetUpdatedAt sets the "updated_at" field.
- func (m *SecuritySecretMutation) SetUpdatedAt(t time.Time) {
- m.updated_at = &t
- }
- // UpdatedAt returns the value of the "updated_at" field in the mutation.
- func (m *SecuritySecretMutation) UpdatedAt() (r time.Time, exists bool) {
- v := m.updated_at
- if v == nil {
- return
- }
- return *v, true
- }
- // OldUpdatedAt returns the old "updated_at" field's value of the SecuritySecret entity.
- // If the SecuritySecret object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *SecuritySecretMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
- }
- return oldValue.UpdatedAt, nil
- }
- // ResetUpdatedAt resets all changes to the "updated_at" field.
- func (m *SecuritySecretMutation) ResetUpdatedAt() {
- m.updated_at = nil
- }
- // SetKey sets the "key" field.
- func (m *SecuritySecretMutation) SetKey(s string) {
- m.key = &s
- }
- // Key returns the value of the "key" field in the mutation.
- func (m *SecuritySecretMutation) Key() (r string, exists bool) {
- v := m.key
- if v == nil {
- return
- }
- return *v, true
- }
- // OldKey returns the old "key" field's value of the SecuritySecret entity.
- // If the SecuritySecret object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *SecuritySecretMutation) OldKey(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldKey is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldKey requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldKey: %w", err)
- }
- return oldValue.Key, nil
- }
- // ResetKey resets all changes to the "key" field.
- func (m *SecuritySecretMutation) ResetKey() {
- m.key = nil
- }
- // SetValue sets the "value" field.
- func (m *SecuritySecretMutation) SetValue(s string) {
- m.value = &s
- }
- // Value returns the value of the "value" field in the mutation.
- func (m *SecuritySecretMutation) Value() (r string, exists bool) {
- v := m.value
- if v == nil {
- return
- }
- return *v, true
- }
- // OldValue returns the old "value" field's value of the SecuritySecret entity.
- // If the SecuritySecret object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *SecuritySecretMutation) OldValue(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldValue is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldValue requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldValue: %w", err)
- }
- return oldValue.Value, nil
- }
- // ResetValue resets all changes to the "value" field.
- func (m *SecuritySecretMutation) ResetValue() {
- m.value = nil
- }
- // Where appends a list predicates to the SecuritySecretMutation builder.
- func (m *SecuritySecretMutation) Where(ps ...predicate.SecuritySecret) {
- m.predicates = append(m.predicates, ps...)
- }
- // WhereP appends storage-level predicates to the SecuritySecretMutation builder. Using this method,
- // users can use type-assertion to append predicates that do not depend on any generated package.
- func (m *SecuritySecretMutation) WhereP(ps ...func(*sql.Selector)) {
- p := make([]predicate.SecuritySecret, len(ps))
- for i := range ps {
- p[i] = ps[i]
- }
- m.Where(p...)
- }
- // Op returns the operation name.
- func (m *SecuritySecretMutation) Op() Op {
- return m.op
- }
- // SetOp allows setting the mutation operation.
- func (m *SecuritySecretMutation) SetOp(op Op) {
- m.op = op
- }
- // Type returns the node type of this mutation (SecuritySecret).
- func (m *SecuritySecretMutation) Type() string {
- return m.typ
- }
- // Fields returns all fields that were changed during this mutation. Note that in
- // order to get all numeric fields that were incremented/decremented, call
- // AddedFields().
- func (m *SecuritySecretMutation) Fields() []string {
- fields := make([]string, 0, 4)
- if m.created_at != nil {
- fields = append(fields, securitysecret.FieldCreatedAt)
- }
- if m.updated_at != nil {
- fields = append(fields, securitysecret.FieldUpdatedAt)
- }
- if m.key != nil {
- fields = append(fields, securitysecret.FieldKey)
- }
- if m.value != nil {
- fields = append(fields, securitysecret.FieldValue)
- }
- return fields
- }
- // Field returns the value of a field with the given name. The second boolean
- // return value indicates that this field was not set, or was not defined in the
- // schema.
- func (m *SecuritySecretMutation) Field(name string) (ent.Value, bool) {
- switch name {
- case securitysecret.FieldCreatedAt:
- return m.CreatedAt()
- case securitysecret.FieldUpdatedAt:
- return m.UpdatedAt()
- case securitysecret.FieldKey:
- return m.Key()
- case securitysecret.FieldValue:
- return m.Value()
- }
- return nil, false
- }
- // OldField returns the old value of the field from the database. An error is
- // returned if the mutation operation is not UpdateOne, or the query to the
- // database failed.
- func (m *SecuritySecretMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
- switch name {
- case securitysecret.FieldCreatedAt:
- return m.OldCreatedAt(ctx)
- case securitysecret.FieldUpdatedAt:
- return m.OldUpdatedAt(ctx)
- case securitysecret.FieldKey:
- return m.OldKey(ctx)
- case securitysecret.FieldValue:
- return m.OldValue(ctx)
- }
- return nil, fmt.Errorf("unknown SecuritySecret field %s", name)
- }
- // SetField sets the value of a field with the given name. It returns an error if
- // the field is not defined in the schema, or if the type mismatched the field
- // type.
- func (m *SecuritySecretMutation) SetField(name string, value ent.Value) error {
- switch name {
- case securitysecret.FieldCreatedAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetCreatedAt(v)
- return nil
- case securitysecret.FieldUpdatedAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetUpdatedAt(v)
- return nil
- case securitysecret.FieldKey:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetKey(v)
- return nil
- case securitysecret.FieldValue:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetValue(v)
- return nil
- }
- return fmt.Errorf("unknown SecuritySecret field %s", name)
- }
- // AddedFields returns all numeric fields that were incremented/decremented during
- // this mutation.
- func (m *SecuritySecretMutation) AddedFields() []string {
- return nil
- }
- // AddedField returns the numeric value that was incremented/decremented on a field
- // with the given name. The second boolean return value indicates that this field
- // was not set, or was not defined in the schema.
- func (m *SecuritySecretMutation) AddedField(name string) (ent.Value, bool) {
- return nil, false
- }
- // AddField adds the value to the field with the given name. It returns an error if
- // the field is not defined in the schema, or if the type mismatched the field
- // type.
- func (m *SecuritySecretMutation) AddField(name string, value ent.Value) error {
- switch name {
- }
- return fmt.Errorf("unknown SecuritySecret numeric field %s", name)
- }
- // ClearedFields returns all nullable fields that were cleared during this
- // mutation.
- func (m *SecuritySecretMutation) ClearedFields() []string {
- return nil
- }
- // FieldCleared returns a boolean indicating if a field with the given name was
- // cleared in this mutation.
- func (m *SecuritySecretMutation) FieldCleared(name string) bool {
- _, ok := m.clearedFields[name]
- return ok
- }
- // ClearField clears the value of the field with the given name. It returns an
- // error if the field is not defined in the schema.
- func (m *SecuritySecretMutation) ClearField(name string) error {
- return fmt.Errorf("unknown SecuritySecret nullable field %s", name)
- }
- // ResetField resets all changes in the mutation for the field with the given name.
- // It returns an error if the field is not defined in the schema.
- func (m *SecuritySecretMutation) ResetField(name string) error {
- switch name {
- case securitysecret.FieldCreatedAt:
- m.ResetCreatedAt()
- return nil
- case securitysecret.FieldUpdatedAt:
- m.ResetUpdatedAt()
- return nil
- case securitysecret.FieldKey:
- m.ResetKey()
- return nil
- case securitysecret.FieldValue:
- m.ResetValue()
- return nil
- }
- return fmt.Errorf("unknown SecuritySecret field %s", name)
- }
- // AddedEdges returns all edge names that were set/added in this mutation.
- func (m *SecuritySecretMutation) AddedEdges() []string {
- edges := make([]string, 0, 0)
- return edges
- }
- // AddedIDs returns all IDs (to other nodes) that were added for the given edge
- // name in this mutation.
- func (m *SecuritySecretMutation) AddedIDs(name string) []ent.Value {
- return nil
- }
- // RemovedEdges returns all edge names that were removed in this mutation.
- func (m *SecuritySecretMutation) RemovedEdges() []string {
- edges := make([]string, 0, 0)
- return edges
- }
- // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
- // the given name in this mutation.
- func (m *SecuritySecretMutation) RemovedIDs(name string) []ent.Value {
- return nil
- }
- // ClearedEdges returns all edge names that were cleared in this mutation.
- func (m *SecuritySecretMutation) ClearedEdges() []string {
- edges := make([]string, 0, 0)
- return edges
- }
- // EdgeCleared returns a boolean which indicates if the edge with the given name
- // was cleared in this mutation.
- func (m *SecuritySecretMutation) EdgeCleared(name string) bool {
- return false
- }
- // ClearEdge clears the value of the edge with the given name. It returns an error
- // if that edge is not defined in the schema.
- func (m *SecuritySecretMutation) ClearEdge(name string) error {
- return fmt.Errorf("unknown SecuritySecret unique edge %s", name)
- }
- // ResetEdge resets all changes to the edge with the given name in this mutation.
- // It returns an error if the edge is not defined in the schema.
- func (m *SecuritySecretMutation) ResetEdge(name string) error {
- return fmt.Errorf("unknown SecuritySecret edge %s", name)
- }
- // SettingMutation represents an operation that mutates the Setting nodes in the graph.
- type SettingMutation struct {
- config
- op Op
- typ string
- id *int64
- key *string
- value *string
- updated_at *time.Time
- clearedFields map[string]struct{}
- done bool
- oldValue func(context.Context) (*Setting, error)
- predicates []predicate.Setting
- }
- var _ ent.Mutation = (*SettingMutation)(nil)
- // settingOption allows management of the mutation configuration using functional options.
- type settingOption func(*SettingMutation)
- // newSettingMutation creates new mutation for the Setting entity.
- func newSettingMutation(c config, op Op, opts ...settingOption) *SettingMutation {
- m := &SettingMutation{
- config: c,
- op: op,
- typ: TypeSetting,
- clearedFields: make(map[string]struct{}),
- }
- for _, opt := range opts {
- opt(m)
- }
- return m
- }
- // withSettingID sets the ID field of the mutation.
- func withSettingID(id int64) settingOption {
- return func(m *SettingMutation) {
- var (
- err error
- once sync.Once
- value *Setting
- )
- m.oldValue = func(ctx context.Context) (*Setting, error) {
- once.Do(func() {
- if m.done {
- err = errors.New("querying old values post mutation is not allowed")
- } else {
- value, err = m.Client().Setting.Get(ctx, id)
- }
- })
- return value, err
- }
- m.id = &id
- }
- }
- // withSetting sets the old Setting of the mutation.
- func withSetting(node *Setting) settingOption {
- return func(m *SettingMutation) {
- m.oldValue = func(context.Context) (*Setting, error) {
- return node, nil
- }
- m.id = &node.ID
- }
- }
- // Client returns a new `ent.Client` from the mutation. If the mutation was
- // executed in a transaction (ent.Tx), a transactional client is returned.
- func (m SettingMutation) Client() *Client {
- client := &Client{config: m.config}
- client.init()
- return client
- }
- // Tx returns an `ent.Tx` for mutations that were executed in transactions;
- // it returns an error otherwise.
- func (m SettingMutation) Tx() (*Tx, error) {
- if _, ok := m.driver.(*txDriver); !ok {
- return nil, errors.New("ent: mutation is not running in a transaction")
- }
- tx := &Tx{config: m.config}
- tx.init()
- return tx, nil
- }
- // ID returns the ID value in the mutation. Note that the ID is only available
- // if it was provided to the builder or after it was returned from the database.
- func (m *SettingMutation) ID() (id int64, exists bool) {
- if m.id == nil {
- return
- }
- return *m.id, true
- }
- // IDs queries the database and returns the entity ids that match the mutation's predicate.
- // That means, if the mutation is applied within a transaction with an isolation level such
- // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
- // or updated by the mutation.
- func (m *SettingMutation) IDs(ctx context.Context) ([]int64, error) {
- switch {
- case m.op.Is(OpUpdateOne | OpDeleteOne):
- id, exists := m.ID()
- if exists {
- return []int64{id}, nil
- }
- fallthrough
- case m.op.Is(OpUpdate | OpDelete):
- return m.Client().Setting.Query().Where(m.predicates...).IDs(ctx)
- default:
- return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
- }
- }
- // SetKey sets the "key" field.
- func (m *SettingMutation) SetKey(s string) {
- m.key = &s
- }
- // Key returns the value of the "key" field in the mutation.
- func (m *SettingMutation) Key() (r string, exists bool) {
- v := m.key
- if v == nil {
- return
- }
- return *v, true
- }
- // OldKey returns the old "key" field's value of the Setting entity.
- // If the Setting object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *SettingMutation) OldKey(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldKey is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldKey requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldKey: %w", err)
- }
- return oldValue.Key, nil
- }
- // ResetKey resets all changes to the "key" field.
- func (m *SettingMutation) ResetKey() {
- m.key = nil
- }
- // SetValue sets the "value" field.
- func (m *SettingMutation) SetValue(s string) {
- m.value = &s
- }
- // Value returns the value of the "value" field in the mutation.
- func (m *SettingMutation) Value() (r string, exists bool) {
- v := m.value
- if v == nil {
- return
- }
- return *v, true
- }
- // OldValue returns the old "value" field's value of the Setting entity.
- // If the Setting object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *SettingMutation) OldValue(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldValue is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldValue requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldValue: %w", err)
- }
- return oldValue.Value, nil
- }
- // ResetValue resets all changes to the "value" field.
- func (m *SettingMutation) ResetValue() {
- m.value = nil
- }
- // SetUpdatedAt sets the "updated_at" field.
- func (m *SettingMutation) SetUpdatedAt(t time.Time) {
- m.updated_at = &t
- }
- // UpdatedAt returns the value of the "updated_at" field in the mutation.
- func (m *SettingMutation) UpdatedAt() (r time.Time, exists bool) {
- v := m.updated_at
- if v == nil {
- return
- }
- return *v, true
- }
- // OldUpdatedAt returns the old "updated_at" field's value of the Setting entity.
- // If the Setting object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *SettingMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
- }
- return oldValue.UpdatedAt, nil
- }
- // ResetUpdatedAt resets all changes to the "updated_at" field.
- func (m *SettingMutation) ResetUpdatedAt() {
- m.updated_at = nil
- }
- // Where appends a list predicates to the SettingMutation builder.
- func (m *SettingMutation) Where(ps ...predicate.Setting) {
- m.predicates = append(m.predicates, ps...)
- }
- // WhereP appends storage-level predicates to the SettingMutation builder. Using this method,
- // users can use type-assertion to append predicates that do not depend on any generated package.
- func (m *SettingMutation) WhereP(ps ...func(*sql.Selector)) {
- p := make([]predicate.Setting, len(ps))
- for i := range ps {
- p[i] = ps[i]
- }
- m.Where(p...)
- }
- // Op returns the operation name.
- func (m *SettingMutation) Op() Op {
- return m.op
- }
- // SetOp allows setting the mutation operation.
- func (m *SettingMutation) SetOp(op Op) {
- m.op = op
- }
- // Type returns the node type of this mutation (Setting).
- func (m *SettingMutation) Type() string {
- return m.typ
- }
- // Fields returns all fields that were changed during this mutation. Note that in
- // order to get all numeric fields that were incremented/decremented, call
- // AddedFields().
- func (m *SettingMutation) Fields() []string {
- fields := make([]string, 0, 3)
- if m.key != nil {
- fields = append(fields, setting.FieldKey)
- }
- if m.value != nil {
- fields = append(fields, setting.FieldValue)
- }
- if m.updated_at != nil {
- fields = append(fields, setting.FieldUpdatedAt)
- }
- return fields
- }
- // Field returns the value of a field with the given name. The second boolean
- // return value indicates that this field was not set, or was not defined in the
- // schema.
- func (m *SettingMutation) Field(name string) (ent.Value, bool) {
- switch name {
- case setting.FieldKey:
- return m.Key()
- case setting.FieldValue:
- return m.Value()
- case setting.FieldUpdatedAt:
- return m.UpdatedAt()
- }
- return nil, false
- }
- // OldField returns the old value of the field from the database. An error is
- // returned if the mutation operation is not UpdateOne, or the query to the
- // database failed.
- func (m *SettingMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
- switch name {
- case setting.FieldKey:
- return m.OldKey(ctx)
- case setting.FieldValue:
- return m.OldValue(ctx)
- case setting.FieldUpdatedAt:
- return m.OldUpdatedAt(ctx)
- }
- return nil, fmt.Errorf("unknown Setting field %s", name)
- }
- // SetField sets the value of a field with the given name. It returns an error if
- // the field is not defined in the schema, or if the type mismatched the field
- // type.
- func (m *SettingMutation) SetField(name string, value ent.Value) error {
- switch name {
- case setting.FieldKey:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetKey(v)
- return nil
- case setting.FieldValue:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetValue(v)
- return nil
- case setting.FieldUpdatedAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetUpdatedAt(v)
- return nil
- }
- return fmt.Errorf("unknown Setting field %s", name)
- }
- // AddedFields returns all numeric fields that were incremented/decremented during
- // this mutation.
- func (m *SettingMutation) AddedFields() []string {
- return nil
- }
- // AddedField returns the numeric value that was incremented/decremented on a field
- // with the given name. The second boolean return value indicates that this field
- // was not set, or was not defined in the schema.
- func (m *SettingMutation) AddedField(name string) (ent.Value, bool) {
- return nil, false
- }
- // AddField adds the value to the field with the given name. It returns an error if
- // the field is not defined in the schema, or if the type mismatched the field
- // type.
- func (m *SettingMutation) AddField(name string, value ent.Value) error {
- switch name {
- }
- return fmt.Errorf("unknown Setting numeric field %s", name)
- }
- // ClearedFields returns all nullable fields that were cleared during this
- // mutation.
- func (m *SettingMutation) ClearedFields() []string {
- return nil
- }
- // FieldCleared returns a boolean indicating if a field with the given name was
- // cleared in this mutation.
- func (m *SettingMutation) FieldCleared(name string) bool {
- _, ok := m.clearedFields[name]
- return ok
- }
- // ClearField clears the value of the field with the given name. It returns an
- // error if the field is not defined in the schema.
- func (m *SettingMutation) ClearField(name string) error {
- return fmt.Errorf("unknown Setting nullable field %s", name)
- }
- // ResetField resets all changes in the mutation for the field with the given name.
- // It returns an error if the field is not defined in the schema.
- func (m *SettingMutation) ResetField(name string) error {
- switch name {
- case setting.FieldKey:
- m.ResetKey()
- return nil
- case setting.FieldValue:
- m.ResetValue()
- return nil
- case setting.FieldUpdatedAt:
- m.ResetUpdatedAt()
- return nil
- }
- return fmt.Errorf("unknown Setting field %s", name)
- }
- // AddedEdges returns all edge names that were set/added in this mutation.
- func (m *SettingMutation) AddedEdges() []string {
- edges := make([]string, 0, 0)
- return edges
- }
- // AddedIDs returns all IDs (to other nodes) that were added for the given edge
- // name in this mutation.
- func (m *SettingMutation) AddedIDs(name string) []ent.Value {
- return nil
- }
- // RemovedEdges returns all edge names that were removed in this mutation.
- func (m *SettingMutation) RemovedEdges() []string {
- edges := make([]string, 0, 0)
- return edges
- }
- // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
- // the given name in this mutation.
- func (m *SettingMutation) RemovedIDs(name string) []ent.Value {
- return nil
- }
- // ClearedEdges returns all edge names that were cleared in this mutation.
- func (m *SettingMutation) ClearedEdges() []string {
- edges := make([]string, 0, 0)
- return edges
- }
- // EdgeCleared returns a boolean which indicates if the edge with the given name
- // was cleared in this mutation.
- func (m *SettingMutation) EdgeCleared(name string) bool {
- return false
- }
- // ClearEdge clears the value of the edge with the given name. It returns an error
- // if that edge is not defined in the schema.
- func (m *SettingMutation) ClearEdge(name string) error {
- return fmt.Errorf("unknown Setting unique edge %s", name)
- }
- // ResetEdge resets all changes to the edge with the given name in this mutation.
- // It returns an error if the edge is not defined in the schema.
- func (m *SettingMutation) ResetEdge(name string) error {
- return fmt.Errorf("unknown Setting edge %s", name)
- }
- // SubscriptionPlanMutation represents an operation that mutates the SubscriptionPlan nodes in the graph.
- type SubscriptionPlanMutation struct {
- config
- op Op
- typ string
- id *int64
- group_id *int64
- addgroup_id *int64
- name *string
- description *string
- price *float64
- addprice *float64
- original_price *float64
- addoriginal_price *float64
- currency *string
- validity_days *int
- addvalidity_days *int
- validity_unit *string
- features *string
- product_name *string
- for_sale *bool
- sort_order *int
- addsort_order *int
- created_at *time.Time
- updated_at *time.Time
- clearedFields map[string]struct{}
- done bool
- oldValue func(context.Context) (*SubscriptionPlan, error)
- predicates []predicate.SubscriptionPlan
- }
- var _ ent.Mutation = (*SubscriptionPlanMutation)(nil)
- // subscriptionplanOption allows management of the mutation configuration using functional options.
- type subscriptionplanOption func(*SubscriptionPlanMutation)
- // newSubscriptionPlanMutation creates new mutation for the SubscriptionPlan entity.
- func newSubscriptionPlanMutation(c config, op Op, opts ...subscriptionplanOption) *SubscriptionPlanMutation {
- m := &SubscriptionPlanMutation{
- config: c,
- op: op,
- typ: TypeSubscriptionPlan,
- clearedFields: make(map[string]struct{}),
- }
- for _, opt := range opts {
- opt(m)
- }
- return m
- }
- // withSubscriptionPlanID sets the ID field of the mutation.
- func withSubscriptionPlanID(id int64) subscriptionplanOption {
- return func(m *SubscriptionPlanMutation) {
- var (
- err error
- once sync.Once
- value *SubscriptionPlan
- )
- m.oldValue = func(ctx context.Context) (*SubscriptionPlan, error) {
- once.Do(func() {
- if m.done {
- err = errors.New("querying old values post mutation is not allowed")
- } else {
- value, err = m.Client().SubscriptionPlan.Get(ctx, id)
- }
- })
- return value, err
- }
- m.id = &id
- }
- }
- // withSubscriptionPlan sets the old SubscriptionPlan of the mutation.
- func withSubscriptionPlan(node *SubscriptionPlan) subscriptionplanOption {
- return func(m *SubscriptionPlanMutation) {
- m.oldValue = func(context.Context) (*SubscriptionPlan, error) {
- return node, nil
- }
- m.id = &node.ID
- }
- }
- // Client returns a new `ent.Client` from the mutation. If the mutation was
- // executed in a transaction (ent.Tx), a transactional client is returned.
- func (m SubscriptionPlanMutation) Client() *Client {
- client := &Client{config: m.config}
- client.init()
- return client
- }
- // Tx returns an `ent.Tx` for mutations that were executed in transactions;
- // it returns an error otherwise.
- func (m SubscriptionPlanMutation) Tx() (*Tx, error) {
- if _, ok := m.driver.(*txDriver); !ok {
- return nil, errors.New("ent: mutation is not running in a transaction")
- }
- tx := &Tx{config: m.config}
- tx.init()
- return tx, nil
- }
- // ID returns the ID value in the mutation. Note that the ID is only available
- // if it was provided to the builder or after it was returned from the database.
- func (m *SubscriptionPlanMutation) ID() (id int64, exists bool) {
- if m.id == nil {
- return
- }
- return *m.id, true
- }
- // IDs queries the database and returns the entity ids that match the mutation's predicate.
- // That means, if the mutation is applied within a transaction with an isolation level such
- // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
- // or updated by the mutation.
- func (m *SubscriptionPlanMutation) IDs(ctx context.Context) ([]int64, error) {
- switch {
- case m.op.Is(OpUpdateOne | OpDeleteOne):
- id, exists := m.ID()
- if exists {
- return []int64{id}, nil
- }
- fallthrough
- case m.op.Is(OpUpdate | OpDelete):
- return m.Client().SubscriptionPlan.Query().Where(m.predicates...).IDs(ctx)
- default:
- return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
- }
- }
- // SetGroupID sets the "group_id" field.
- func (m *SubscriptionPlanMutation) SetGroupID(i int64) {
- m.group_id = &i
- m.addgroup_id = nil
- }
- // GroupID returns the value of the "group_id" field in the mutation.
- func (m *SubscriptionPlanMutation) GroupID() (r int64, exists bool) {
- v := m.group_id
- if v == nil {
- return
- }
- return *v, true
- }
- // OldGroupID returns the old "group_id" field's value of the SubscriptionPlan entity.
- // If the SubscriptionPlan object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *SubscriptionPlanMutation) OldGroupID(ctx context.Context) (v int64, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldGroupID is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldGroupID requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldGroupID: %w", err)
- }
- return oldValue.GroupID, nil
- }
- // AddGroupID adds i to the "group_id" field.
- func (m *SubscriptionPlanMutation) AddGroupID(i int64) {
- if m.addgroup_id != nil {
- *m.addgroup_id += i
- } else {
- m.addgroup_id = &i
- }
- }
- // AddedGroupID returns the value that was added to the "group_id" field in this mutation.
- func (m *SubscriptionPlanMutation) AddedGroupID() (r int64, exists bool) {
- v := m.addgroup_id
- if v == nil {
- return
- }
- return *v, true
- }
- // ResetGroupID resets all changes to the "group_id" field.
- func (m *SubscriptionPlanMutation) ResetGroupID() {
- m.group_id = nil
- m.addgroup_id = nil
- }
- // SetName sets the "name" field.
- func (m *SubscriptionPlanMutation) SetName(s string) {
- m.name = &s
- }
- // Name returns the value of the "name" field in the mutation.
- func (m *SubscriptionPlanMutation) Name() (r string, exists bool) {
- v := m.name
- if v == nil {
- return
- }
- return *v, true
- }
- // OldName returns the old "name" field's value of the SubscriptionPlan entity.
- // If the SubscriptionPlan object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *SubscriptionPlanMutation) OldName(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldName is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldName requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldName: %w", err)
- }
- return oldValue.Name, nil
- }
- // ResetName resets all changes to the "name" field.
- func (m *SubscriptionPlanMutation) ResetName() {
- m.name = nil
- }
- // SetDescription sets the "description" field.
- func (m *SubscriptionPlanMutation) SetDescription(s string) {
- m.description = &s
- }
- // Description returns the value of the "description" field in the mutation.
- func (m *SubscriptionPlanMutation) Description() (r string, exists bool) {
- v := m.description
- if v == nil {
- return
- }
- return *v, true
- }
- // OldDescription returns the old "description" field's value of the SubscriptionPlan entity.
- // If the SubscriptionPlan object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *SubscriptionPlanMutation) OldDescription(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldDescription is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldDescription requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldDescription: %w", err)
- }
- return oldValue.Description, nil
- }
- // ResetDescription resets all changes to the "description" field.
- func (m *SubscriptionPlanMutation) ResetDescription() {
- m.description = nil
- }
- // SetPrice sets the "price" field.
- func (m *SubscriptionPlanMutation) SetPrice(f float64) {
- m.price = &f
- m.addprice = nil
- }
- // Price returns the value of the "price" field in the mutation.
- func (m *SubscriptionPlanMutation) Price() (r float64, exists bool) {
- v := m.price
- if v == nil {
- return
- }
- return *v, true
- }
- // OldPrice returns the old "price" field's value of the SubscriptionPlan entity.
- // If the SubscriptionPlan object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *SubscriptionPlanMutation) OldPrice(ctx context.Context) (v float64, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldPrice is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldPrice requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldPrice: %w", err)
- }
- return oldValue.Price, nil
- }
- // AddPrice adds f to the "price" field.
- func (m *SubscriptionPlanMutation) AddPrice(f float64) {
- if m.addprice != nil {
- *m.addprice += f
- } else {
- m.addprice = &f
- }
- }
- // AddedPrice returns the value that was added to the "price" field in this mutation.
- func (m *SubscriptionPlanMutation) AddedPrice() (r float64, exists bool) {
- v := m.addprice
- if v == nil {
- return
- }
- return *v, true
- }
- // ResetPrice resets all changes to the "price" field.
- func (m *SubscriptionPlanMutation) ResetPrice() {
- m.price = nil
- m.addprice = nil
- }
- // SetOriginalPrice sets the "original_price" field.
- func (m *SubscriptionPlanMutation) SetOriginalPrice(f float64) {
- m.original_price = &f
- m.addoriginal_price = nil
- }
- // OriginalPrice returns the value of the "original_price" field in the mutation.
- func (m *SubscriptionPlanMutation) OriginalPrice() (r float64, exists bool) {
- v := m.original_price
- if v == nil {
- return
- }
- return *v, true
- }
- // OldOriginalPrice returns the old "original_price" field's value of the SubscriptionPlan entity.
- // If the SubscriptionPlan object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *SubscriptionPlanMutation) OldOriginalPrice(ctx context.Context) (v *float64, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldOriginalPrice is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldOriginalPrice requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldOriginalPrice: %w", err)
- }
- return oldValue.OriginalPrice, nil
- }
- // AddOriginalPrice adds f to the "original_price" field.
- func (m *SubscriptionPlanMutation) AddOriginalPrice(f float64) {
- if m.addoriginal_price != nil {
- *m.addoriginal_price += f
- } else {
- m.addoriginal_price = &f
- }
- }
- // AddedOriginalPrice returns the value that was added to the "original_price" field in this mutation.
- func (m *SubscriptionPlanMutation) AddedOriginalPrice() (r float64, exists bool) {
- v := m.addoriginal_price
- if v == nil {
- return
- }
- return *v, true
- }
- // ClearOriginalPrice clears the value of the "original_price" field.
- func (m *SubscriptionPlanMutation) ClearOriginalPrice() {
- m.original_price = nil
- m.addoriginal_price = nil
- m.clearedFields[subscriptionplan.FieldOriginalPrice] = struct{}{}
- }
- // OriginalPriceCleared returns if the "original_price" field was cleared in this mutation.
- func (m *SubscriptionPlanMutation) OriginalPriceCleared() bool {
- _, ok := m.clearedFields[subscriptionplan.FieldOriginalPrice]
- return ok
- }
- // ResetOriginalPrice resets all changes to the "original_price" field.
- func (m *SubscriptionPlanMutation) ResetOriginalPrice() {
- m.original_price = nil
- m.addoriginal_price = nil
- delete(m.clearedFields, subscriptionplan.FieldOriginalPrice)
- }
- // SetCurrency sets the "currency" field.
- func (m *SubscriptionPlanMutation) SetCurrency(s string) {
- m.currency = &s
- }
- // Currency returns the value of the "currency" field in the mutation.
- func (m *SubscriptionPlanMutation) Currency() (r string, exists bool) {
- v := m.currency
- if v == nil {
- return
- }
- return *v, true
- }
- // OldCurrency returns the old "currency" field's value of the SubscriptionPlan entity.
- // If the SubscriptionPlan object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *SubscriptionPlanMutation) OldCurrency(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldCurrency is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldCurrency requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldCurrency: %w", err)
- }
- return oldValue.Currency, nil
- }
- // ResetCurrency resets all changes to the "currency" field.
- func (m *SubscriptionPlanMutation) ResetCurrency() {
- m.currency = nil
- }
- // SetValidityDays sets the "validity_days" field.
- func (m *SubscriptionPlanMutation) SetValidityDays(i int) {
- m.validity_days = &i
- m.addvalidity_days = nil
- }
- // ValidityDays returns the value of the "validity_days" field in the mutation.
- func (m *SubscriptionPlanMutation) ValidityDays() (r int, exists bool) {
- v := m.validity_days
- if v == nil {
- return
- }
- return *v, true
- }
- // OldValidityDays returns the old "validity_days" field's value of the SubscriptionPlan entity.
- // If the SubscriptionPlan object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *SubscriptionPlanMutation) OldValidityDays(ctx context.Context) (v int, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldValidityDays is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldValidityDays requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldValidityDays: %w", err)
- }
- return oldValue.ValidityDays, nil
- }
- // AddValidityDays adds i to the "validity_days" field.
- func (m *SubscriptionPlanMutation) AddValidityDays(i int) {
- if m.addvalidity_days != nil {
- *m.addvalidity_days += i
- } else {
- m.addvalidity_days = &i
- }
- }
- // AddedValidityDays returns the value that was added to the "validity_days" field in this mutation.
- func (m *SubscriptionPlanMutation) AddedValidityDays() (r int, exists bool) {
- v := m.addvalidity_days
- if v == nil {
- return
- }
- return *v, true
- }
- // ResetValidityDays resets all changes to the "validity_days" field.
- func (m *SubscriptionPlanMutation) ResetValidityDays() {
- m.validity_days = nil
- m.addvalidity_days = nil
- }
- // SetValidityUnit sets the "validity_unit" field.
- func (m *SubscriptionPlanMutation) SetValidityUnit(s string) {
- m.validity_unit = &s
- }
- // ValidityUnit returns the value of the "validity_unit" field in the mutation.
- func (m *SubscriptionPlanMutation) ValidityUnit() (r string, exists bool) {
- v := m.validity_unit
- if v == nil {
- return
- }
- return *v, true
- }
- // OldValidityUnit returns the old "validity_unit" field's value of the SubscriptionPlan entity.
- // If the SubscriptionPlan object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *SubscriptionPlanMutation) OldValidityUnit(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldValidityUnit is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldValidityUnit requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldValidityUnit: %w", err)
- }
- return oldValue.ValidityUnit, nil
- }
- // ResetValidityUnit resets all changes to the "validity_unit" field.
- func (m *SubscriptionPlanMutation) ResetValidityUnit() {
- m.validity_unit = nil
- }
- // SetFeatures sets the "features" field.
- func (m *SubscriptionPlanMutation) SetFeatures(s string) {
- m.features = &s
- }
- // Features returns the value of the "features" field in the mutation.
- func (m *SubscriptionPlanMutation) Features() (r string, exists bool) {
- v := m.features
- if v == nil {
- return
- }
- return *v, true
- }
- // OldFeatures returns the old "features" field's value of the SubscriptionPlan entity.
- // If the SubscriptionPlan object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *SubscriptionPlanMutation) OldFeatures(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldFeatures is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldFeatures requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldFeatures: %w", err)
- }
- return oldValue.Features, nil
- }
- // ResetFeatures resets all changes to the "features" field.
- func (m *SubscriptionPlanMutation) ResetFeatures() {
- m.features = nil
- }
- // SetProductName sets the "product_name" field.
- func (m *SubscriptionPlanMutation) SetProductName(s string) {
- m.product_name = &s
- }
- // ProductName returns the value of the "product_name" field in the mutation.
- func (m *SubscriptionPlanMutation) ProductName() (r string, exists bool) {
- v := m.product_name
- if v == nil {
- return
- }
- return *v, true
- }
- // OldProductName returns the old "product_name" field's value of the SubscriptionPlan entity.
- // If the SubscriptionPlan object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *SubscriptionPlanMutation) OldProductName(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldProductName is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldProductName requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldProductName: %w", err)
- }
- return oldValue.ProductName, nil
- }
- // ResetProductName resets all changes to the "product_name" field.
- func (m *SubscriptionPlanMutation) ResetProductName() {
- m.product_name = nil
- }
- // SetForSale sets the "for_sale" field.
- func (m *SubscriptionPlanMutation) SetForSale(b bool) {
- m.for_sale = &b
- }
- // ForSale returns the value of the "for_sale" field in the mutation.
- func (m *SubscriptionPlanMutation) ForSale() (r bool, exists bool) {
- v := m.for_sale
- if v == nil {
- return
- }
- return *v, true
- }
- // OldForSale returns the old "for_sale" field's value of the SubscriptionPlan entity.
- // If the SubscriptionPlan object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *SubscriptionPlanMutation) OldForSale(ctx context.Context) (v bool, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldForSale is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldForSale requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldForSale: %w", err)
- }
- return oldValue.ForSale, nil
- }
- // ResetForSale resets all changes to the "for_sale" field.
- func (m *SubscriptionPlanMutation) ResetForSale() {
- m.for_sale = nil
- }
- // SetSortOrder sets the "sort_order" field.
- func (m *SubscriptionPlanMutation) SetSortOrder(i int) {
- m.sort_order = &i
- m.addsort_order = nil
- }
- // SortOrder returns the value of the "sort_order" field in the mutation.
- func (m *SubscriptionPlanMutation) SortOrder() (r int, exists bool) {
- v := m.sort_order
- if v == nil {
- return
- }
- return *v, true
- }
- // OldSortOrder returns the old "sort_order" field's value of the SubscriptionPlan entity.
- // If the SubscriptionPlan object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *SubscriptionPlanMutation) OldSortOrder(ctx context.Context) (v int, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldSortOrder is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldSortOrder requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldSortOrder: %w", err)
- }
- return oldValue.SortOrder, nil
- }
- // AddSortOrder adds i to the "sort_order" field.
- func (m *SubscriptionPlanMutation) AddSortOrder(i int) {
- if m.addsort_order != nil {
- *m.addsort_order += i
- } else {
- m.addsort_order = &i
- }
- }
- // AddedSortOrder returns the value that was added to the "sort_order" field in this mutation.
- func (m *SubscriptionPlanMutation) AddedSortOrder() (r int, exists bool) {
- v := m.addsort_order
- if v == nil {
- return
- }
- return *v, true
- }
- // ResetSortOrder resets all changes to the "sort_order" field.
- func (m *SubscriptionPlanMutation) ResetSortOrder() {
- m.sort_order = nil
- m.addsort_order = nil
- }
- // SetCreatedAt sets the "created_at" field.
- func (m *SubscriptionPlanMutation) SetCreatedAt(t time.Time) {
- m.created_at = &t
- }
- // CreatedAt returns the value of the "created_at" field in the mutation.
- func (m *SubscriptionPlanMutation) CreatedAt() (r time.Time, exists bool) {
- v := m.created_at
- if v == nil {
- return
- }
- return *v, true
- }
- // OldCreatedAt returns the old "created_at" field's value of the SubscriptionPlan entity.
- // If the SubscriptionPlan object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *SubscriptionPlanMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldCreatedAt requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
- }
- return oldValue.CreatedAt, nil
- }
- // ResetCreatedAt resets all changes to the "created_at" field.
- func (m *SubscriptionPlanMutation) ResetCreatedAt() {
- m.created_at = nil
- }
- // SetUpdatedAt sets the "updated_at" field.
- func (m *SubscriptionPlanMutation) SetUpdatedAt(t time.Time) {
- m.updated_at = &t
- }
- // UpdatedAt returns the value of the "updated_at" field in the mutation.
- func (m *SubscriptionPlanMutation) UpdatedAt() (r time.Time, exists bool) {
- v := m.updated_at
- if v == nil {
- return
- }
- return *v, true
- }
- // OldUpdatedAt returns the old "updated_at" field's value of the SubscriptionPlan entity.
- // If the SubscriptionPlan object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *SubscriptionPlanMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
- }
- return oldValue.UpdatedAt, nil
- }
- // ResetUpdatedAt resets all changes to the "updated_at" field.
- func (m *SubscriptionPlanMutation) ResetUpdatedAt() {
- m.updated_at = nil
- }
- // Where appends a list predicates to the SubscriptionPlanMutation builder.
- func (m *SubscriptionPlanMutation) Where(ps ...predicate.SubscriptionPlan) {
- m.predicates = append(m.predicates, ps...)
- }
- // WhereP appends storage-level predicates to the SubscriptionPlanMutation builder. Using this method,
- // users can use type-assertion to append predicates that do not depend on any generated package.
- func (m *SubscriptionPlanMutation) WhereP(ps ...func(*sql.Selector)) {
- p := make([]predicate.SubscriptionPlan, len(ps))
- for i := range ps {
- p[i] = ps[i]
- }
- m.Where(p...)
- }
- // Op returns the operation name.
- func (m *SubscriptionPlanMutation) Op() Op {
- return m.op
- }
- // SetOp allows setting the mutation operation.
- func (m *SubscriptionPlanMutation) SetOp(op Op) {
- m.op = op
- }
- // Type returns the node type of this mutation (SubscriptionPlan).
- func (m *SubscriptionPlanMutation) Type() string {
- return m.typ
- }
- // Fields returns all fields that were changed during this mutation. Note that in
- // order to get all numeric fields that were incremented/decremented, call
- // AddedFields().
- func (m *SubscriptionPlanMutation) Fields() []string {
- fields := make([]string, 0, 14)
- if m.group_id != nil {
- fields = append(fields, subscriptionplan.FieldGroupID)
- }
- if m.name != nil {
- fields = append(fields, subscriptionplan.FieldName)
- }
- if m.description != nil {
- fields = append(fields, subscriptionplan.FieldDescription)
- }
- if m.price != nil {
- fields = append(fields, subscriptionplan.FieldPrice)
- }
- if m.original_price != nil {
- fields = append(fields, subscriptionplan.FieldOriginalPrice)
- }
- if m.currency != nil {
- fields = append(fields, subscriptionplan.FieldCurrency)
- }
- if m.validity_days != nil {
- fields = append(fields, subscriptionplan.FieldValidityDays)
- }
- if m.validity_unit != nil {
- fields = append(fields, subscriptionplan.FieldValidityUnit)
- }
- if m.features != nil {
- fields = append(fields, subscriptionplan.FieldFeatures)
- }
- if m.product_name != nil {
- fields = append(fields, subscriptionplan.FieldProductName)
- }
- if m.for_sale != nil {
- fields = append(fields, subscriptionplan.FieldForSale)
- }
- if m.sort_order != nil {
- fields = append(fields, subscriptionplan.FieldSortOrder)
- }
- if m.created_at != nil {
- fields = append(fields, subscriptionplan.FieldCreatedAt)
- }
- if m.updated_at != nil {
- fields = append(fields, subscriptionplan.FieldUpdatedAt)
- }
- return fields
- }
- // Field returns the value of a field with the given name. The second boolean
- // return value indicates that this field was not set, or was not defined in the
- // schema.
- func (m *SubscriptionPlanMutation) Field(name string) (ent.Value, bool) {
- switch name {
- case subscriptionplan.FieldGroupID:
- return m.GroupID()
- case subscriptionplan.FieldName:
- return m.Name()
- case subscriptionplan.FieldDescription:
- return m.Description()
- case subscriptionplan.FieldPrice:
- return m.Price()
- case subscriptionplan.FieldOriginalPrice:
- return m.OriginalPrice()
- case subscriptionplan.FieldCurrency:
- return m.Currency()
- case subscriptionplan.FieldValidityDays:
- return m.ValidityDays()
- case subscriptionplan.FieldValidityUnit:
- return m.ValidityUnit()
- case subscriptionplan.FieldFeatures:
- return m.Features()
- case subscriptionplan.FieldProductName:
- return m.ProductName()
- case subscriptionplan.FieldForSale:
- return m.ForSale()
- case subscriptionplan.FieldSortOrder:
- return m.SortOrder()
- case subscriptionplan.FieldCreatedAt:
- return m.CreatedAt()
- case subscriptionplan.FieldUpdatedAt:
- return m.UpdatedAt()
- }
- return nil, false
- }
- // OldField returns the old value of the field from the database. An error is
- // returned if the mutation operation is not UpdateOne, or the query to the
- // database failed.
- func (m *SubscriptionPlanMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
- switch name {
- case subscriptionplan.FieldGroupID:
- return m.OldGroupID(ctx)
- case subscriptionplan.FieldName:
- return m.OldName(ctx)
- case subscriptionplan.FieldDescription:
- return m.OldDescription(ctx)
- case subscriptionplan.FieldPrice:
- return m.OldPrice(ctx)
- case subscriptionplan.FieldOriginalPrice:
- return m.OldOriginalPrice(ctx)
- case subscriptionplan.FieldCurrency:
- return m.OldCurrency(ctx)
- case subscriptionplan.FieldValidityDays:
- return m.OldValidityDays(ctx)
- case subscriptionplan.FieldValidityUnit:
- return m.OldValidityUnit(ctx)
- case subscriptionplan.FieldFeatures:
- return m.OldFeatures(ctx)
- case subscriptionplan.FieldProductName:
- return m.OldProductName(ctx)
- case subscriptionplan.FieldForSale:
- return m.OldForSale(ctx)
- case subscriptionplan.FieldSortOrder:
- return m.OldSortOrder(ctx)
- case subscriptionplan.FieldCreatedAt:
- return m.OldCreatedAt(ctx)
- case subscriptionplan.FieldUpdatedAt:
- return m.OldUpdatedAt(ctx)
- }
- return nil, fmt.Errorf("unknown SubscriptionPlan field %s", name)
- }
- // SetField sets the value of a field with the given name. It returns an error if
- // the field is not defined in the schema, or if the type mismatched the field
- // type.
- func (m *SubscriptionPlanMutation) SetField(name string, value ent.Value) error {
- switch name {
- case subscriptionplan.FieldGroupID:
- v, ok := value.(int64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetGroupID(v)
- return nil
- case subscriptionplan.FieldName:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetName(v)
- return nil
- case subscriptionplan.FieldDescription:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetDescription(v)
- return nil
- case subscriptionplan.FieldPrice:
- v, ok := value.(float64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetPrice(v)
- return nil
- case subscriptionplan.FieldOriginalPrice:
- v, ok := value.(float64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetOriginalPrice(v)
- return nil
- case subscriptionplan.FieldCurrency:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetCurrency(v)
- return nil
- case subscriptionplan.FieldValidityDays:
- v, ok := value.(int)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetValidityDays(v)
- return nil
- case subscriptionplan.FieldValidityUnit:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetValidityUnit(v)
- return nil
- case subscriptionplan.FieldFeatures:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetFeatures(v)
- return nil
- case subscriptionplan.FieldProductName:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetProductName(v)
- return nil
- case subscriptionplan.FieldForSale:
- v, ok := value.(bool)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetForSale(v)
- return nil
- case subscriptionplan.FieldSortOrder:
- v, ok := value.(int)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetSortOrder(v)
- return nil
- case subscriptionplan.FieldCreatedAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetCreatedAt(v)
- return nil
- case subscriptionplan.FieldUpdatedAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetUpdatedAt(v)
- return nil
- }
- return fmt.Errorf("unknown SubscriptionPlan field %s", name)
- }
- // AddedFields returns all numeric fields that were incremented/decremented during
- // this mutation.
- func (m *SubscriptionPlanMutation) AddedFields() []string {
- var fields []string
- if m.addgroup_id != nil {
- fields = append(fields, subscriptionplan.FieldGroupID)
- }
- if m.addprice != nil {
- fields = append(fields, subscriptionplan.FieldPrice)
- }
- if m.addoriginal_price != nil {
- fields = append(fields, subscriptionplan.FieldOriginalPrice)
- }
- if m.addvalidity_days != nil {
- fields = append(fields, subscriptionplan.FieldValidityDays)
- }
- if m.addsort_order != nil {
- fields = append(fields, subscriptionplan.FieldSortOrder)
- }
- return fields
- }
- // AddedField returns the numeric value that was incremented/decremented on a field
- // with the given name. The second boolean return value indicates that this field
- // was not set, or was not defined in the schema.
- func (m *SubscriptionPlanMutation) AddedField(name string) (ent.Value, bool) {
- switch name {
- case subscriptionplan.FieldGroupID:
- return m.AddedGroupID()
- case subscriptionplan.FieldPrice:
- return m.AddedPrice()
- case subscriptionplan.FieldOriginalPrice:
- return m.AddedOriginalPrice()
- case subscriptionplan.FieldValidityDays:
- return m.AddedValidityDays()
- case subscriptionplan.FieldSortOrder:
- return m.AddedSortOrder()
- }
- return nil, false
- }
- // AddField adds the value to the field with the given name. It returns an error if
- // the field is not defined in the schema, or if the type mismatched the field
- // type.
- func (m *SubscriptionPlanMutation) AddField(name string, value ent.Value) error {
- switch name {
- case subscriptionplan.FieldGroupID:
- v, ok := value.(int64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.AddGroupID(v)
- return nil
- case subscriptionplan.FieldPrice:
- v, ok := value.(float64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.AddPrice(v)
- return nil
- case subscriptionplan.FieldOriginalPrice:
- v, ok := value.(float64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.AddOriginalPrice(v)
- return nil
- case subscriptionplan.FieldValidityDays:
- v, ok := value.(int)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.AddValidityDays(v)
- return nil
- case subscriptionplan.FieldSortOrder:
- v, ok := value.(int)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.AddSortOrder(v)
- return nil
- }
- return fmt.Errorf("unknown SubscriptionPlan numeric field %s", name)
- }
- // ClearedFields returns all nullable fields that were cleared during this
- // mutation.
- func (m *SubscriptionPlanMutation) ClearedFields() []string {
- var fields []string
- if m.FieldCleared(subscriptionplan.FieldOriginalPrice) {
- fields = append(fields, subscriptionplan.FieldOriginalPrice)
- }
- return fields
- }
- // FieldCleared returns a boolean indicating if a field with the given name was
- // cleared in this mutation.
- func (m *SubscriptionPlanMutation) FieldCleared(name string) bool {
- _, ok := m.clearedFields[name]
- return ok
- }
- // ClearField clears the value of the field with the given name. It returns an
- // error if the field is not defined in the schema.
- func (m *SubscriptionPlanMutation) ClearField(name string) error {
- switch name {
- case subscriptionplan.FieldOriginalPrice:
- m.ClearOriginalPrice()
- return nil
- }
- return fmt.Errorf("unknown SubscriptionPlan nullable field %s", name)
- }
- // ResetField resets all changes in the mutation for the field with the given name.
- // It returns an error if the field is not defined in the schema.
- func (m *SubscriptionPlanMutation) ResetField(name string) error {
- switch name {
- case subscriptionplan.FieldGroupID:
- m.ResetGroupID()
- return nil
- case subscriptionplan.FieldName:
- m.ResetName()
- return nil
- case subscriptionplan.FieldDescription:
- m.ResetDescription()
- return nil
- case subscriptionplan.FieldPrice:
- m.ResetPrice()
- return nil
- case subscriptionplan.FieldOriginalPrice:
- m.ResetOriginalPrice()
- return nil
- case subscriptionplan.FieldCurrency:
- m.ResetCurrency()
- return nil
- case subscriptionplan.FieldValidityDays:
- m.ResetValidityDays()
- return nil
- case subscriptionplan.FieldValidityUnit:
- m.ResetValidityUnit()
- return nil
- case subscriptionplan.FieldFeatures:
- m.ResetFeatures()
- return nil
- case subscriptionplan.FieldProductName:
- m.ResetProductName()
- return nil
- case subscriptionplan.FieldForSale:
- m.ResetForSale()
- return nil
- case subscriptionplan.FieldSortOrder:
- m.ResetSortOrder()
- return nil
- case subscriptionplan.FieldCreatedAt:
- m.ResetCreatedAt()
- return nil
- case subscriptionplan.FieldUpdatedAt:
- m.ResetUpdatedAt()
- return nil
- }
- return fmt.Errorf("unknown SubscriptionPlan field %s", name)
- }
- // AddedEdges returns all edge names that were set/added in this mutation.
- func (m *SubscriptionPlanMutation) AddedEdges() []string {
- edges := make([]string, 0, 0)
- return edges
- }
- // AddedIDs returns all IDs (to other nodes) that were added for the given edge
- // name in this mutation.
- func (m *SubscriptionPlanMutation) AddedIDs(name string) []ent.Value {
- return nil
- }
- // RemovedEdges returns all edge names that were removed in this mutation.
- func (m *SubscriptionPlanMutation) RemovedEdges() []string {
- edges := make([]string, 0, 0)
- return edges
- }
- // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
- // the given name in this mutation.
- func (m *SubscriptionPlanMutation) RemovedIDs(name string) []ent.Value {
- return nil
- }
- // ClearedEdges returns all edge names that were cleared in this mutation.
- func (m *SubscriptionPlanMutation) ClearedEdges() []string {
- edges := make([]string, 0, 0)
- return edges
- }
- // EdgeCleared returns a boolean which indicates if the edge with the given name
- // was cleared in this mutation.
- func (m *SubscriptionPlanMutation) EdgeCleared(name string) bool {
- return false
- }
- // ClearEdge clears the value of the edge with the given name. It returns an error
- // if that edge is not defined in the schema.
- func (m *SubscriptionPlanMutation) ClearEdge(name string) error {
- return fmt.Errorf("unknown SubscriptionPlan unique edge %s", name)
- }
- // ResetEdge resets all changes to the edge with the given name in this mutation.
- // It returns an error if the edge is not defined in the schema.
- func (m *SubscriptionPlanMutation) ResetEdge(name string) error {
- return fmt.Errorf("unknown SubscriptionPlan edge %s", name)
- }
- // TLSFingerprintProfileMutation represents an operation that mutates the TLSFingerprintProfile nodes in the graph.
- type TLSFingerprintProfileMutation struct {
- config
- op Op
- typ string
- id *int64
- created_at *time.Time
- updated_at *time.Time
- name *string
- description *string
- enable_grease *bool
- cipher_suites *[]uint16
- appendcipher_suites []uint16
- curves *[]uint16
- appendcurves []uint16
- point_formats *[]uint16
- appendpoint_formats []uint16
- signature_algorithms *[]uint16
- appendsignature_algorithms []uint16
- alpn_protocols *[]string
- appendalpn_protocols []string
- supported_versions *[]uint16
- appendsupported_versions []uint16
- key_share_groups *[]uint16
- appendkey_share_groups []uint16
- psk_modes *[]uint16
- appendpsk_modes []uint16
- extensions *[]uint16
- appendextensions []uint16
- clearedFields map[string]struct{}
- done bool
- oldValue func(context.Context) (*TLSFingerprintProfile, error)
- predicates []predicate.TLSFingerprintProfile
- }
- var _ ent.Mutation = (*TLSFingerprintProfileMutation)(nil)
- // tlsfingerprintprofileOption allows management of the mutation configuration using functional options.
- type tlsfingerprintprofileOption func(*TLSFingerprintProfileMutation)
- // newTLSFingerprintProfileMutation creates new mutation for the TLSFingerprintProfile entity.
- func newTLSFingerprintProfileMutation(c config, op Op, opts ...tlsfingerprintprofileOption) *TLSFingerprintProfileMutation {
- m := &TLSFingerprintProfileMutation{
- config: c,
- op: op,
- typ: TypeTLSFingerprintProfile,
- clearedFields: make(map[string]struct{}),
- }
- for _, opt := range opts {
- opt(m)
- }
- return m
- }
- // withTLSFingerprintProfileID sets the ID field of the mutation.
- func withTLSFingerprintProfileID(id int64) tlsfingerprintprofileOption {
- return func(m *TLSFingerprintProfileMutation) {
- var (
- err error
- once sync.Once
- value *TLSFingerprintProfile
- )
- m.oldValue = func(ctx context.Context) (*TLSFingerprintProfile, error) {
- once.Do(func() {
- if m.done {
- err = errors.New("querying old values post mutation is not allowed")
- } else {
- value, err = m.Client().TLSFingerprintProfile.Get(ctx, id)
- }
- })
- return value, err
- }
- m.id = &id
- }
- }
- // withTLSFingerprintProfile sets the old TLSFingerprintProfile of the mutation.
- func withTLSFingerprintProfile(node *TLSFingerprintProfile) tlsfingerprintprofileOption {
- return func(m *TLSFingerprintProfileMutation) {
- m.oldValue = func(context.Context) (*TLSFingerprintProfile, error) {
- return node, nil
- }
- m.id = &node.ID
- }
- }
- // Client returns a new `ent.Client` from the mutation. If the mutation was
- // executed in a transaction (ent.Tx), a transactional client is returned.
- func (m TLSFingerprintProfileMutation) Client() *Client {
- client := &Client{config: m.config}
- client.init()
- return client
- }
- // Tx returns an `ent.Tx` for mutations that were executed in transactions;
- // it returns an error otherwise.
- func (m TLSFingerprintProfileMutation) Tx() (*Tx, error) {
- if _, ok := m.driver.(*txDriver); !ok {
- return nil, errors.New("ent: mutation is not running in a transaction")
- }
- tx := &Tx{config: m.config}
- tx.init()
- return tx, nil
- }
- // ID returns the ID value in the mutation. Note that the ID is only available
- // if it was provided to the builder or after it was returned from the database.
- func (m *TLSFingerprintProfileMutation) ID() (id int64, exists bool) {
- if m.id == nil {
- return
- }
- return *m.id, true
- }
- // IDs queries the database and returns the entity ids that match the mutation's predicate.
- // That means, if the mutation is applied within a transaction with an isolation level such
- // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
- // or updated by the mutation.
- func (m *TLSFingerprintProfileMutation) IDs(ctx context.Context) ([]int64, error) {
- switch {
- case m.op.Is(OpUpdateOne | OpDeleteOne):
- id, exists := m.ID()
- if exists {
- return []int64{id}, nil
- }
- fallthrough
- case m.op.Is(OpUpdate | OpDelete):
- return m.Client().TLSFingerprintProfile.Query().Where(m.predicates...).IDs(ctx)
- default:
- return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
- }
- }
- // SetCreatedAt sets the "created_at" field.
- func (m *TLSFingerprintProfileMutation) SetCreatedAt(t time.Time) {
- m.created_at = &t
- }
- // CreatedAt returns the value of the "created_at" field in the mutation.
- func (m *TLSFingerprintProfileMutation) CreatedAt() (r time.Time, exists bool) {
- v := m.created_at
- if v == nil {
- return
- }
- return *v, true
- }
- // OldCreatedAt returns the old "created_at" field's value of the TLSFingerprintProfile entity.
- // If the TLSFingerprintProfile object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *TLSFingerprintProfileMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldCreatedAt requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
- }
- return oldValue.CreatedAt, nil
- }
- // ResetCreatedAt resets all changes to the "created_at" field.
- func (m *TLSFingerprintProfileMutation) ResetCreatedAt() {
- m.created_at = nil
- }
- // SetUpdatedAt sets the "updated_at" field.
- func (m *TLSFingerprintProfileMutation) SetUpdatedAt(t time.Time) {
- m.updated_at = &t
- }
- // UpdatedAt returns the value of the "updated_at" field in the mutation.
- func (m *TLSFingerprintProfileMutation) UpdatedAt() (r time.Time, exists bool) {
- v := m.updated_at
- if v == nil {
- return
- }
- return *v, true
- }
- // OldUpdatedAt returns the old "updated_at" field's value of the TLSFingerprintProfile entity.
- // If the TLSFingerprintProfile object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *TLSFingerprintProfileMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
- }
- return oldValue.UpdatedAt, nil
- }
- // ResetUpdatedAt resets all changes to the "updated_at" field.
- func (m *TLSFingerprintProfileMutation) ResetUpdatedAt() {
- m.updated_at = nil
- }
- // SetName sets the "name" field.
- func (m *TLSFingerprintProfileMutation) SetName(s string) {
- m.name = &s
- }
- // Name returns the value of the "name" field in the mutation.
- func (m *TLSFingerprintProfileMutation) Name() (r string, exists bool) {
- v := m.name
- if v == nil {
- return
- }
- return *v, true
- }
- // OldName returns the old "name" field's value of the TLSFingerprintProfile entity.
- // If the TLSFingerprintProfile object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *TLSFingerprintProfileMutation) OldName(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldName is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldName requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldName: %w", err)
- }
- return oldValue.Name, nil
- }
- // ResetName resets all changes to the "name" field.
- func (m *TLSFingerprintProfileMutation) ResetName() {
- m.name = nil
- }
- // SetDescription sets the "description" field.
- func (m *TLSFingerprintProfileMutation) SetDescription(s string) {
- m.description = &s
- }
- // Description returns the value of the "description" field in the mutation.
- func (m *TLSFingerprintProfileMutation) Description() (r string, exists bool) {
- v := m.description
- if v == nil {
- return
- }
- return *v, true
- }
- // OldDescription returns the old "description" field's value of the TLSFingerprintProfile entity.
- // If the TLSFingerprintProfile object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *TLSFingerprintProfileMutation) OldDescription(ctx context.Context) (v *string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldDescription is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldDescription requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldDescription: %w", err)
- }
- return oldValue.Description, nil
- }
- // ClearDescription clears the value of the "description" field.
- func (m *TLSFingerprintProfileMutation) ClearDescription() {
- m.description = nil
- m.clearedFields[tlsfingerprintprofile.FieldDescription] = struct{}{}
- }
- // DescriptionCleared returns if the "description" field was cleared in this mutation.
- func (m *TLSFingerprintProfileMutation) DescriptionCleared() bool {
- _, ok := m.clearedFields[tlsfingerprintprofile.FieldDescription]
- return ok
- }
- // ResetDescription resets all changes to the "description" field.
- func (m *TLSFingerprintProfileMutation) ResetDescription() {
- m.description = nil
- delete(m.clearedFields, tlsfingerprintprofile.FieldDescription)
- }
- // SetEnableGrease sets the "enable_grease" field.
- func (m *TLSFingerprintProfileMutation) SetEnableGrease(b bool) {
- m.enable_grease = &b
- }
- // EnableGrease returns the value of the "enable_grease" field in the mutation.
- func (m *TLSFingerprintProfileMutation) EnableGrease() (r bool, exists bool) {
- v := m.enable_grease
- if v == nil {
- return
- }
- return *v, true
- }
- // OldEnableGrease returns the old "enable_grease" field's value of the TLSFingerprintProfile entity.
- // If the TLSFingerprintProfile object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *TLSFingerprintProfileMutation) OldEnableGrease(ctx context.Context) (v bool, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldEnableGrease is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldEnableGrease requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldEnableGrease: %w", err)
- }
- return oldValue.EnableGrease, nil
- }
- // ResetEnableGrease resets all changes to the "enable_grease" field.
- func (m *TLSFingerprintProfileMutation) ResetEnableGrease() {
- m.enable_grease = nil
- }
- // SetCipherSuites sets the "cipher_suites" field.
- func (m *TLSFingerprintProfileMutation) SetCipherSuites(u []uint16) {
- m.cipher_suites = &u
- m.appendcipher_suites = nil
- }
- // CipherSuites returns the value of the "cipher_suites" field in the mutation.
- func (m *TLSFingerprintProfileMutation) CipherSuites() (r []uint16, exists bool) {
- v := m.cipher_suites
- if v == nil {
- return
- }
- return *v, true
- }
- // OldCipherSuites returns the old "cipher_suites" field's value of the TLSFingerprintProfile entity.
- // If the TLSFingerprintProfile object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *TLSFingerprintProfileMutation) OldCipherSuites(ctx context.Context) (v []uint16, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldCipherSuites is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldCipherSuites requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldCipherSuites: %w", err)
- }
- return oldValue.CipherSuites, nil
- }
- // AppendCipherSuites adds u to the "cipher_suites" field.
- func (m *TLSFingerprintProfileMutation) AppendCipherSuites(u []uint16) {
- m.appendcipher_suites = append(m.appendcipher_suites, u...)
- }
- // AppendedCipherSuites returns the list of values that were appended to the "cipher_suites" field in this mutation.
- func (m *TLSFingerprintProfileMutation) AppendedCipherSuites() ([]uint16, bool) {
- if len(m.appendcipher_suites) == 0 {
- return nil, false
- }
- return m.appendcipher_suites, true
- }
- // ClearCipherSuites clears the value of the "cipher_suites" field.
- func (m *TLSFingerprintProfileMutation) ClearCipherSuites() {
- m.cipher_suites = nil
- m.appendcipher_suites = nil
- m.clearedFields[tlsfingerprintprofile.FieldCipherSuites] = struct{}{}
- }
- // CipherSuitesCleared returns if the "cipher_suites" field was cleared in this mutation.
- func (m *TLSFingerprintProfileMutation) CipherSuitesCleared() bool {
- _, ok := m.clearedFields[tlsfingerprintprofile.FieldCipherSuites]
- return ok
- }
- // ResetCipherSuites resets all changes to the "cipher_suites" field.
- func (m *TLSFingerprintProfileMutation) ResetCipherSuites() {
- m.cipher_suites = nil
- m.appendcipher_suites = nil
- delete(m.clearedFields, tlsfingerprintprofile.FieldCipherSuites)
- }
- // SetCurves sets the "curves" field.
- func (m *TLSFingerprintProfileMutation) SetCurves(u []uint16) {
- m.curves = &u
- m.appendcurves = nil
- }
- // Curves returns the value of the "curves" field in the mutation.
- func (m *TLSFingerprintProfileMutation) Curves() (r []uint16, exists bool) {
- v := m.curves
- if v == nil {
- return
- }
- return *v, true
- }
- // OldCurves returns the old "curves" field's value of the TLSFingerprintProfile entity.
- // If the TLSFingerprintProfile object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *TLSFingerprintProfileMutation) OldCurves(ctx context.Context) (v []uint16, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldCurves is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldCurves requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldCurves: %w", err)
- }
- return oldValue.Curves, nil
- }
- // AppendCurves adds u to the "curves" field.
- func (m *TLSFingerprintProfileMutation) AppendCurves(u []uint16) {
- m.appendcurves = append(m.appendcurves, u...)
- }
- // AppendedCurves returns the list of values that were appended to the "curves" field in this mutation.
- func (m *TLSFingerprintProfileMutation) AppendedCurves() ([]uint16, bool) {
- if len(m.appendcurves) == 0 {
- return nil, false
- }
- return m.appendcurves, true
- }
- // ClearCurves clears the value of the "curves" field.
- func (m *TLSFingerprintProfileMutation) ClearCurves() {
- m.curves = nil
- m.appendcurves = nil
- m.clearedFields[tlsfingerprintprofile.FieldCurves] = struct{}{}
- }
- // CurvesCleared returns if the "curves" field was cleared in this mutation.
- func (m *TLSFingerprintProfileMutation) CurvesCleared() bool {
- _, ok := m.clearedFields[tlsfingerprintprofile.FieldCurves]
- return ok
- }
- // ResetCurves resets all changes to the "curves" field.
- func (m *TLSFingerprintProfileMutation) ResetCurves() {
- m.curves = nil
- m.appendcurves = nil
- delete(m.clearedFields, tlsfingerprintprofile.FieldCurves)
- }
- // SetPointFormats sets the "point_formats" field.
- func (m *TLSFingerprintProfileMutation) SetPointFormats(u []uint16) {
- m.point_formats = &u
- m.appendpoint_formats = nil
- }
- // PointFormats returns the value of the "point_formats" field in the mutation.
- func (m *TLSFingerprintProfileMutation) PointFormats() (r []uint16, exists bool) {
- v := m.point_formats
- if v == nil {
- return
- }
- return *v, true
- }
- // OldPointFormats returns the old "point_formats" field's value of the TLSFingerprintProfile entity.
- // If the TLSFingerprintProfile object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *TLSFingerprintProfileMutation) OldPointFormats(ctx context.Context) (v []uint16, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldPointFormats is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldPointFormats requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldPointFormats: %w", err)
- }
- return oldValue.PointFormats, nil
- }
- // AppendPointFormats adds u to the "point_formats" field.
- func (m *TLSFingerprintProfileMutation) AppendPointFormats(u []uint16) {
- m.appendpoint_formats = append(m.appendpoint_formats, u...)
- }
- // AppendedPointFormats returns the list of values that were appended to the "point_formats" field in this mutation.
- func (m *TLSFingerprintProfileMutation) AppendedPointFormats() ([]uint16, bool) {
- if len(m.appendpoint_formats) == 0 {
- return nil, false
- }
- return m.appendpoint_formats, true
- }
- // ClearPointFormats clears the value of the "point_formats" field.
- func (m *TLSFingerprintProfileMutation) ClearPointFormats() {
- m.point_formats = nil
- m.appendpoint_formats = nil
- m.clearedFields[tlsfingerprintprofile.FieldPointFormats] = struct{}{}
- }
- // PointFormatsCleared returns if the "point_formats" field was cleared in this mutation.
- func (m *TLSFingerprintProfileMutation) PointFormatsCleared() bool {
- _, ok := m.clearedFields[tlsfingerprintprofile.FieldPointFormats]
- return ok
- }
- // ResetPointFormats resets all changes to the "point_formats" field.
- func (m *TLSFingerprintProfileMutation) ResetPointFormats() {
- m.point_formats = nil
- m.appendpoint_formats = nil
- delete(m.clearedFields, tlsfingerprintprofile.FieldPointFormats)
- }
- // SetSignatureAlgorithms sets the "signature_algorithms" field.
- func (m *TLSFingerprintProfileMutation) SetSignatureAlgorithms(u []uint16) {
- m.signature_algorithms = &u
- m.appendsignature_algorithms = nil
- }
- // SignatureAlgorithms returns the value of the "signature_algorithms" field in the mutation.
- func (m *TLSFingerprintProfileMutation) SignatureAlgorithms() (r []uint16, exists bool) {
- v := m.signature_algorithms
- if v == nil {
- return
- }
- return *v, true
- }
- // OldSignatureAlgorithms returns the old "signature_algorithms" field's value of the TLSFingerprintProfile entity.
- // If the TLSFingerprintProfile object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *TLSFingerprintProfileMutation) OldSignatureAlgorithms(ctx context.Context) (v []uint16, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldSignatureAlgorithms is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldSignatureAlgorithms requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldSignatureAlgorithms: %w", err)
- }
- return oldValue.SignatureAlgorithms, nil
- }
- // AppendSignatureAlgorithms adds u to the "signature_algorithms" field.
- func (m *TLSFingerprintProfileMutation) AppendSignatureAlgorithms(u []uint16) {
- m.appendsignature_algorithms = append(m.appendsignature_algorithms, u...)
- }
- // AppendedSignatureAlgorithms returns the list of values that were appended to the "signature_algorithms" field in this mutation.
- func (m *TLSFingerprintProfileMutation) AppendedSignatureAlgorithms() ([]uint16, bool) {
- if len(m.appendsignature_algorithms) == 0 {
- return nil, false
- }
- return m.appendsignature_algorithms, true
- }
- // ClearSignatureAlgorithms clears the value of the "signature_algorithms" field.
- func (m *TLSFingerprintProfileMutation) ClearSignatureAlgorithms() {
- m.signature_algorithms = nil
- m.appendsignature_algorithms = nil
- m.clearedFields[tlsfingerprintprofile.FieldSignatureAlgorithms] = struct{}{}
- }
- // SignatureAlgorithmsCleared returns if the "signature_algorithms" field was cleared in this mutation.
- func (m *TLSFingerprintProfileMutation) SignatureAlgorithmsCleared() bool {
- _, ok := m.clearedFields[tlsfingerprintprofile.FieldSignatureAlgorithms]
- return ok
- }
- // ResetSignatureAlgorithms resets all changes to the "signature_algorithms" field.
- func (m *TLSFingerprintProfileMutation) ResetSignatureAlgorithms() {
- m.signature_algorithms = nil
- m.appendsignature_algorithms = nil
- delete(m.clearedFields, tlsfingerprintprofile.FieldSignatureAlgorithms)
- }
- // SetAlpnProtocols sets the "alpn_protocols" field.
- func (m *TLSFingerprintProfileMutation) SetAlpnProtocols(s []string) {
- m.alpn_protocols = &s
- m.appendalpn_protocols = nil
- }
- // AlpnProtocols returns the value of the "alpn_protocols" field in the mutation.
- func (m *TLSFingerprintProfileMutation) AlpnProtocols() (r []string, exists bool) {
- v := m.alpn_protocols
- if v == nil {
- return
- }
- return *v, true
- }
- // OldAlpnProtocols returns the old "alpn_protocols" field's value of the TLSFingerprintProfile entity.
- // If the TLSFingerprintProfile object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *TLSFingerprintProfileMutation) OldAlpnProtocols(ctx context.Context) (v []string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldAlpnProtocols is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldAlpnProtocols requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldAlpnProtocols: %w", err)
- }
- return oldValue.AlpnProtocols, nil
- }
- // AppendAlpnProtocols adds s to the "alpn_protocols" field.
- func (m *TLSFingerprintProfileMutation) AppendAlpnProtocols(s []string) {
- m.appendalpn_protocols = append(m.appendalpn_protocols, s...)
- }
- // AppendedAlpnProtocols returns the list of values that were appended to the "alpn_protocols" field in this mutation.
- func (m *TLSFingerprintProfileMutation) AppendedAlpnProtocols() ([]string, bool) {
- if len(m.appendalpn_protocols) == 0 {
- return nil, false
- }
- return m.appendalpn_protocols, true
- }
- // ClearAlpnProtocols clears the value of the "alpn_protocols" field.
- func (m *TLSFingerprintProfileMutation) ClearAlpnProtocols() {
- m.alpn_protocols = nil
- m.appendalpn_protocols = nil
- m.clearedFields[tlsfingerprintprofile.FieldAlpnProtocols] = struct{}{}
- }
- // AlpnProtocolsCleared returns if the "alpn_protocols" field was cleared in this mutation.
- func (m *TLSFingerprintProfileMutation) AlpnProtocolsCleared() bool {
- _, ok := m.clearedFields[tlsfingerprintprofile.FieldAlpnProtocols]
- return ok
- }
- // ResetAlpnProtocols resets all changes to the "alpn_protocols" field.
- func (m *TLSFingerprintProfileMutation) ResetAlpnProtocols() {
- m.alpn_protocols = nil
- m.appendalpn_protocols = nil
- delete(m.clearedFields, tlsfingerprintprofile.FieldAlpnProtocols)
- }
- // SetSupportedVersions sets the "supported_versions" field.
- func (m *TLSFingerprintProfileMutation) SetSupportedVersions(u []uint16) {
- m.supported_versions = &u
- m.appendsupported_versions = nil
- }
- // SupportedVersions returns the value of the "supported_versions" field in the mutation.
- func (m *TLSFingerprintProfileMutation) SupportedVersions() (r []uint16, exists bool) {
- v := m.supported_versions
- if v == nil {
- return
- }
- return *v, true
- }
- // OldSupportedVersions returns the old "supported_versions" field's value of the TLSFingerprintProfile entity.
- // If the TLSFingerprintProfile object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *TLSFingerprintProfileMutation) OldSupportedVersions(ctx context.Context) (v []uint16, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldSupportedVersions is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldSupportedVersions requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldSupportedVersions: %w", err)
- }
- return oldValue.SupportedVersions, nil
- }
- // AppendSupportedVersions adds u to the "supported_versions" field.
- func (m *TLSFingerprintProfileMutation) AppendSupportedVersions(u []uint16) {
- m.appendsupported_versions = append(m.appendsupported_versions, u...)
- }
- // AppendedSupportedVersions returns the list of values that were appended to the "supported_versions" field in this mutation.
- func (m *TLSFingerprintProfileMutation) AppendedSupportedVersions() ([]uint16, bool) {
- if len(m.appendsupported_versions) == 0 {
- return nil, false
- }
- return m.appendsupported_versions, true
- }
- // ClearSupportedVersions clears the value of the "supported_versions" field.
- func (m *TLSFingerprintProfileMutation) ClearSupportedVersions() {
- m.supported_versions = nil
- m.appendsupported_versions = nil
- m.clearedFields[tlsfingerprintprofile.FieldSupportedVersions] = struct{}{}
- }
- // SupportedVersionsCleared returns if the "supported_versions" field was cleared in this mutation.
- func (m *TLSFingerprintProfileMutation) SupportedVersionsCleared() bool {
- _, ok := m.clearedFields[tlsfingerprintprofile.FieldSupportedVersions]
- return ok
- }
- // ResetSupportedVersions resets all changes to the "supported_versions" field.
- func (m *TLSFingerprintProfileMutation) ResetSupportedVersions() {
- m.supported_versions = nil
- m.appendsupported_versions = nil
- delete(m.clearedFields, tlsfingerprintprofile.FieldSupportedVersions)
- }
- // SetKeyShareGroups sets the "key_share_groups" field.
- func (m *TLSFingerprintProfileMutation) SetKeyShareGroups(u []uint16) {
- m.key_share_groups = &u
- m.appendkey_share_groups = nil
- }
- // KeyShareGroups returns the value of the "key_share_groups" field in the mutation.
- func (m *TLSFingerprintProfileMutation) KeyShareGroups() (r []uint16, exists bool) {
- v := m.key_share_groups
- if v == nil {
- return
- }
- return *v, true
- }
- // OldKeyShareGroups returns the old "key_share_groups" field's value of the TLSFingerprintProfile entity.
- // If the TLSFingerprintProfile object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *TLSFingerprintProfileMutation) OldKeyShareGroups(ctx context.Context) (v []uint16, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldKeyShareGroups is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldKeyShareGroups requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldKeyShareGroups: %w", err)
- }
- return oldValue.KeyShareGroups, nil
- }
- // AppendKeyShareGroups adds u to the "key_share_groups" field.
- func (m *TLSFingerprintProfileMutation) AppendKeyShareGroups(u []uint16) {
- m.appendkey_share_groups = append(m.appendkey_share_groups, u...)
- }
- // AppendedKeyShareGroups returns the list of values that were appended to the "key_share_groups" field in this mutation.
- func (m *TLSFingerprintProfileMutation) AppendedKeyShareGroups() ([]uint16, bool) {
- if len(m.appendkey_share_groups) == 0 {
- return nil, false
- }
- return m.appendkey_share_groups, true
- }
- // ClearKeyShareGroups clears the value of the "key_share_groups" field.
- func (m *TLSFingerprintProfileMutation) ClearKeyShareGroups() {
- m.key_share_groups = nil
- m.appendkey_share_groups = nil
- m.clearedFields[tlsfingerprintprofile.FieldKeyShareGroups] = struct{}{}
- }
- // KeyShareGroupsCleared returns if the "key_share_groups" field was cleared in this mutation.
- func (m *TLSFingerprintProfileMutation) KeyShareGroupsCleared() bool {
- _, ok := m.clearedFields[tlsfingerprintprofile.FieldKeyShareGroups]
- return ok
- }
- // ResetKeyShareGroups resets all changes to the "key_share_groups" field.
- func (m *TLSFingerprintProfileMutation) ResetKeyShareGroups() {
- m.key_share_groups = nil
- m.appendkey_share_groups = nil
- delete(m.clearedFields, tlsfingerprintprofile.FieldKeyShareGroups)
- }
- // SetPskModes sets the "psk_modes" field.
- func (m *TLSFingerprintProfileMutation) SetPskModes(u []uint16) {
- m.psk_modes = &u
- m.appendpsk_modes = nil
- }
- // PskModes returns the value of the "psk_modes" field in the mutation.
- func (m *TLSFingerprintProfileMutation) PskModes() (r []uint16, exists bool) {
- v := m.psk_modes
- if v == nil {
- return
- }
- return *v, true
- }
- // OldPskModes returns the old "psk_modes" field's value of the TLSFingerprintProfile entity.
- // If the TLSFingerprintProfile object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *TLSFingerprintProfileMutation) OldPskModes(ctx context.Context) (v []uint16, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldPskModes is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldPskModes requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldPskModes: %w", err)
- }
- return oldValue.PskModes, nil
- }
- // AppendPskModes adds u to the "psk_modes" field.
- func (m *TLSFingerprintProfileMutation) AppendPskModes(u []uint16) {
- m.appendpsk_modes = append(m.appendpsk_modes, u...)
- }
- // AppendedPskModes returns the list of values that were appended to the "psk_modes" field in this mutation.
- func (m *TLSFingerprintProfileMutation) AppendedPskModes() ([]uint16, bool) {
- if len(m.appendpsk_modes) == 0 {
- return nil, false
- }
- return m.appendpsk_modes, true
- }
- // ClearPskModes clears the value of the "psk_modes" field.
- func (m *TLSFingerprintProfileMutation) ClearPskModes() {
- m.psk_modes = nil
- m.appendpsk_modes = nil
- m.clearedFields[tlsfingerprintprofile.FieldPskModes] = struct{}{}
- }
- // PskModesCleared returns if the "psk_modes" field was cleared in this mutation.
- func (m *TLSFingerprintProfileMutation) PskModesCleared() bool {
- _, ok := m.clearedFields[tlsfingerprintprofile.FieldPskModes]
- return ok
- }
- // ResetPskModes resets all changes to the "psk_modes" field.
- func (m *TLSFingerprintProfileMutation) ResetPskModes() {
- m.psk_modes = nil
- m.appendpsk_modes = nil
- delete(m.clearedFields, tlsfingerprintprofile.FieldPskModes)
- }
- // SetExtensions sets the "extensions" field.
- func (m *TLSFingerprintProfileMutation) SetExtensions(u []uint16) {
- m.extensions = &u
- m.appendextensions = nil
- }
- // Extensions returns the value of the "extensions" field in the mutation.
- func (m *TLSFingerprintProfileMutation) Extensions() (r []uint16, exists bool) {
- v := m.extensions
- if v == nil {
- return
- }
- return *v, true
- }
- // OldExtensions returns the old "extensions" field's value of the TLSFingerprintProfile entity.
- // If the TLSFingerprintProfile object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *TLSFingerprintProfileMutation) OldExtensions(ctx context.Context) (v []uint16, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldExtensions is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldExtensions requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldExtensions: %w", err)
- }
- return oldValue.Extensions, nil
- }
- // AppendExtensions adds u to the "extensions" field.
- func (m *TLSFingerprintProfileMutation) AppendExtensions(u []uint16) {
- m.appendextensions = append(m.appendextensions, u...)
- }
- // AppendedExtensions returns the list of values that were appended to the "extensions" field in this mutation.
- func (m *TLSFingerprintProfileMutation) AppendedExtensions() ([]uint16, bool) {
- if len(m.appendextensions) == 0 {
- return nil, false
- }
- return m.appendextensions, true
- }
- // ClearExtensions clears the value of the "extensions" field.
- func (m *TLSFingerprintProfileMutation) ClearExtensions() {
- m.extensions = nil
- m.appendextensions = nil
- m.clearedFields[tlsfingerprintprofile.FieldExtensions] = struct{}{}
- }
- // ExtensionsCleared returns if the "extensions" field was cleared in this mutation.
- func (m *TLSFingerprintProfileMutation) ExtensionsCleared() bool {
- _, ok := m.clearedFields[tlsfingerprintprofile.FieldExtensions]
- return ok
- }
- // ResetExtensions resets all changes to the "extensions" field.
- func (m *TLSFingerprintProfileMutation) ResetExtensions() {
- m.extensions = nil
- m.appendextensions = nil
- delete(m.clearedFields, tlsfingerprintprofile.FieldExtensions)
- }
- // Where appends a list predicates to the TLSFingerprintProfileMutation builder.
- func (m *TLSFingerprintProfileMutation) Where(ps ...predicate.TLSFingerprintProfile) {
- m.predicates = append(m.predicates, ps...)
- }
- // WhereP appends storage-level predicates to the TLSFingerprintProfileMutation builder. Using this method,
- // users can use type-assertion to append predicates that do not depend on any generated package.
- func (m *TLSFingerprintProfileMutation) WhereP(ps ...func(*sql.Selector)) {
- p := make([]predicate.TLSFingerprintProfile, len(ps))
- for i := range ps {
- p[i] = ps[i]
- }
- m.Where(p...)
- }
- // Op returns the operation name.
- func (m *TLSFingerprintProfileMutation) Op() Op {
- return m.op
- }
- // SetOp allows setting the mutation operation.
- func (m *TLSFingerprintProfileMutation) SetOp(op Op) {
- m.op = op
- }
- // Type returns the node type of this mutation (TLSFingerprintProfile).
- func (m *TLSFingerprintProfileMutation) Type() string {
- return m.typ
- }
- // Fields returns all fields that were changed during this mutation. Note that in
- // order to get all numeric fields that were incremented/decremented, call
- // AddedFields().
- func (m *TLSFingerprintProfileMutation) Fields() []string {
- fields := make([]string, 0, 14)
- if m.created_at != nil {
- fields = append(fields, tlsfingerprintprofile.FieldCreatedAt)
- }
- if m.updated_at != nil {
- fields = append(fields, tlsfingerprintprofile.FieldUpdatedAt)
- }
- if m.name != nil {
- fields = append(fields, tlsfingerprintprofile.FieldName)
- }
- if m.description != nil {
- fields = append(fields, tlsfingerprintprofile.FieldDescription)
- }
- if m.enable_grease != nil {
- fields = append(fields, tlsfingerprintprofile.FieldEnableGrease)
- }
- if m.cipher_suites != nil {
- fields = append(fields, tlsfingerprintprofile.FieldCipherSuites)
- }
- if m.curves != nil {
- fields = append(fields, tlsfingerprintprofile.FieldCurves)
- }
- if m.point_formats != nil {
- fields = append(fields, tlsfingerprintprofile.FieldPointFormats)
- }
- if m.signature_algorithms != nil {
- fields = append(fields, tlsfingerprintprofile.FieldSignatureAlgorithms)
- }
- if m.alpn_protocols != nil {
- fields = append(fields, tlsfingerprintprofile.FieldAlpnProtocols)
- }
- if m.supported_versions != nil {
- fields = append(fields, tlsfingerprintprofile.FieldSupportedVersions)
- }
- if m.key_share_groups != nil {
- fields = append(fields, tlsfingerprintprofile.FieldKeyShareGroups)
- }
- if m.psk_modes != nil {
- fields = append(fields, tlsfingerprintprofile.FieldPskModes)
- }
- if m.extensions != nil {
- fields = append(fields, tlsfingerprintprofile.FieldExtensions)
- }
- return fields
- }
- // Field returns the value of a field with the given name. The second boolean
- // return value indicates that this field was not set, or was not defined in the
- // schema.
- func (m *TLSFingerprintProfileMutation) Field(name string) (ent.Value, bool) {
- switch name {
- case tlsfingerprintprofile.FieldCreatedAt:
- return m.CreatedAt()
- case tlsfingerprintprofile.FieldUpdatedAt:
- return m.UpdatedAt()
- case tlsfingerprintprofile.FieldName:
- return m.Name()
- case tlsfingerprintprofile.FieldDescription:
- return m.Description()
- case tlsfingerprintprofile.FieldEnableGrease:
- return m.EnableGrease()
- case tlsfingerprintprofile.FieldCipherSuites:
- return m.CipherSuites()
- case tlsfingerprintprofile.FieldCurves:
- return m.Curves()
- case tlsfingerprintprofile.FieldPointFormats:
- return m.PointFormats()
- case tlsfingerprintprofile.FieldSignatureAlgorithms:
- return m.SignatureAlgorithms()
- case tlsfingerprintprofile.FieldAlpnProtocols:
- return m.AlpnProtocols()
- case tlsfingerprintprofile.FieldSupportedVersions:
- return m.SupportedVersions()
- case tlsfingerprintprofile.FieldKeyShareGroups:
- return m.KeyShareGroups()
- case tlsfingerprintprofile.FieldPskModes:
- return m.PskModes()
- case tlsfingerprintprofile.FieldExtensions:
- return m.Extensions()
- }
- return nil, false
- }
- // OldField returns the old value of the field from the database. An error is
- // returned if the mutation operation is not UpdateOne, or the query to the
- // database failed.
- func (m *TLSFingerprintProfileMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
- switch name {
- case tlsfingerprintprofile.FieldCreatedAt:
- return m.OldCreatedAt(ctx)
- case tlsfingerprintprofile.FieldUpdatedAt:
- return m.OldUpdatedAt(ctx)
- case tlsfingerprintprofile.FieldName:
- return m.OldName(ctx)
- case tlsfingerprintprofile.FieldDescription:
- return m.OldDescription(ctx)
- case tlsfingerprintprofile.FieldEnableGrease:
- return m.OldEnableGrease(ctx)
- case tlsfingerprintprofile.FieldCipherSuites:
- return m.OldCipherSuites(ctx)
- case tlsfingerprintprofile.FieldCurves:
- return m.OldCurves(ctx)
- case tlsfingerprintprofile.FieldPointFormats:
- return m.OldPointFormats(ctx)
- case tlsfingerprintprofile.FieldSignatureAlgorithms:
- return m.OldSignatureAlgorithms(ctx)
- case tlsfingerprintprofile.FieldAlpnProtocols:
- return m.OldAlpnProtocols(ctx)
- case tlsfingerprintprofile.FieldSupportedVersions:
- return m.OldSupportedVersions(ctx)
- case tlsfingerprintprofile.FieldKeyShareGroups:
- return m.OldKeyShareGroups(ctx)
- case tlsfingerprintprofile.FieldPskModes:
- return m.OldPskModes(ctx)
- case tlsfingerprintprofile.FieldExtensions:
- return m.OldExtensions(ctx)
- }
- return nil, fmt.Errorf("unknown TLSFingerprintProfile field %s", name)
- }
- // SetField sets the value of a field with the given name. It returns an error if
- // the field is not defined in the schema, or if the type mismatched the field
- // type.
- func (m *TLSFingerprintProfileMutation) SetField(name string, value ent.Value) error {
- switch name {
- case tlsfingerprintprofile.FieldCreatedAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetCreatedAt(v)
- return nil
- case tlsfingerprintprofile.FieldUpdatedAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetUpdatedAt(v)
- return nil
- case tlsfingerprintprofile.FieldName:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetName(v)
- return nil
- case tlsfingerprintprofile.FieldDescription:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetDescription(v)
- return nil
- case tlsfingerprintprofile.FieldEnableGrease:
- v, ok := value.(bool)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetEnableGrease(v)
- return nil
- case tlsfingerprintprofile.FieldCipherSuites:
- v, ok := value.([]uint16)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetCipherSuites(v)
- return nil
- case tlsfingerprintprofile.FieldCurves:
- v, ok := value.([]uint16)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetCurves(v)
- return nil
- case tlsfingerprintprofile.FieldPointFormats:
- v, ok := value.([]uint16)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetPointFormats(v)
- return nil
- case tlsfingerprintprofile.FieldSignatureAlgorithms:
- v, ok := value.([]uint16)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetSignatureAlgorithms(v)
- return nil
- case tlsfingerprintprofile.FieldAlpnProtocols:
- v, ok := value.([]string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetAlpnProtocols(v)
- return nil
- case tlsfingerprintprofile.FieldSupportedVersions:
- v, ok := value.([]uint16)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetSupportedVersions(v)
- return nil
- case tlsfingerprintprofile.FieldKeyShareGroups:
- v, ok := value.([]uint16)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetKeyShareGroups(v)
- return nil
- case tlsfingerprintprofile.FieldPskModes:
- v, ok := value.([]uint16)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetPskModes(v)
- return nil
- case tlsfingerprintprofile.FieldExtensions:
- v, ok := value.([]uint16)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetExtensions(v)
- return nil
- }
- return fmt.Errorf("unknown TLSFingerprintProfile field %s", name)
- }
- // AddedFields returns all numeric fields that were incremented/decremented during
- // this mutation.
- func (m *TLSFingerprintProfileMutation) AddedFields() []string {
- return nil
- }
- // AddedField returns the numeric value that was incremented/decremented on a field
- // with the given name. The second boolean return value indicates that this field
- // was not set, or was not defined in the schema.
- func (m *TLSFingerprintProfileMutation) AddedField(name string) (ent.Value, bool) {
- return nil, false
- }
- // AddField adds the value to the field with the given name. It returns an error if
- // the field is not defined in the schema, or if the type mismatched the field
- // type.
- func (m *TLSFingerprintProfileMutation) AddField(name string, value ent.Value) error {
- switch name {
- }
- return fmt.Errorf("unknown TLSFingerprintProfile numeric field %s", name)
- }
- // ClearedFields returns all nullable fields that were cleared during this
- // mutation.
- func (m *TLSFingerprintProfileMutation) ClearedFields() []string {
- var fields []string
- if m.FieldCleared(tlsfingerprintprofile.FieldDescription) {
- fields = append(fields, tlsfingerprintprofile.FieldDescription)
- }
- if m.FieldCleared(tlsfingerprintprofile.FieldCipherSuites) {
- fields = append(fields, tlsfingerprintprofile.FieldCipherSuites)
- }
- if m.FieldCleared(tlsfingerprintprofile.FieldCurves) {
- fields = append(fields, tlsfingerprintprofile.FieldCurves)
- }
- if m.FieldCleared(tlsfingerprintprofile.FieldPointFormats) {
- fields = append(fields, tlsfingerprintprofile.FieldPointFormats)
- }
- if m.FieldCleared(tlsfingerprintprofile.FieldSignatureAlgorithms) {
- fields = append(fields, tlsfingerprintprofile.FieldSignatureAlgorithms)
- }
- if m.FieldCleared(tlsfingerprintprofile.FieldAlpnProtocols) {
- fields = append(fields, tlsfingerprintprofile.FieldAlpnProtocols)
- }
- if m.FieldCleared(tlsfingerprintprofile.FieldSupportedVersions) {
- fields = append(fields, tlsfingerprintprofile.FieldSupportedVersions)
- }
- if m.FieldCleared(tlsfingerprintprofile.FieldKeyShareGroups) {
- fields = append(fields, tlsfingerprintprofile.FieldKeyShareGroups)
- }
- if m.FieldCleared(tlsfingerprintprofile.FieldPskModes) {
- fields = append(fields, tlsfingerprintprofile.FieldPskModes)
- }
- if m.FieldCleared(tlsfingerprintprofile.FieldExtensions) {
- fields = append(fields, tlsfingerprintprofile.FieldExtensions)
- }
- return fields
- }
- // FieldCleared returns a boolean indicating if a field with the given name was
- // cleared in this mutation.
- func (m *TLSFingerprintProfileMutation) FieldCleared(name string) bool {
- _, ok := m.clearedFields[name]
- return ok
- }
- // ClearField clears the value of the field with the given name. It returns an
- // error if the field is not defined in the schema.
- func (m *TLSFingerprintProfileMutation) ClearField(name string) error {
- switch name {
- case tlsfingerprintprofile.FieldDescription:
- m.ClearDescription()
- return nil
- case tlsfingerprintprofile.FieldCipherSuites:
- m.ClearCipherSuites()
- return nil
- case tlsfingerprintprofile.FieldCurves:
- m.ClearCurves()
- return nil
- case tlsfingerprintprofile.FieldPointFormats:
- m.ClearPointFormats()
- return nil
- case tlsfingerprintprofile.FieldSignatureAlgorithms:
- m.ClearSignatureAlgorithms()
- return nil
- case tlsfingerprintprofile.FieldAlpnProtocols:
- m.ClearAlpnProtocols()
- return nil
- case tlsfingerprintprofile.FieldSupportedVersions:
- m.ClearSupportedVersions()
- return nil
- case tlsfingerprintprofile.FieldKeyShareGroups:
- m.ClearKeyShareGroups()
- return nil
- case tlsfingerprintprofile.FieldPskModes:
- m.ClearPskModes()
- return nil
- case tlsfingerprintprofile.FieldExtensions:
- m.ClearExtensions()
- return nil
- }
- return fmt.Errorf("unknown TLSFingerprintProfile nullable field %s", name)
- }
- // ResetField resets all changes in the mutation for the field with the given name.
- // It returns an error if the field is not defined in the schema.
- func (m *TLSFingerprintProfileMutation) ResetField(name string) error {
- switch name {
- case tlsfingerprintprofile.FieldCreatedAt:
- m.ResetCreatedAt()
- return nil
- case tlsfingerprintprofile.FieldUpdatedAt:
- m.ResetUpdatedAt()
- return nil
- case tlsfingerprintprofile.FieldName:
- m.ResetName()
- return nil
- case tlsfingerprintprofile.FieldDescription:
- m.ResetDescription()
- return nil
- case tlsfingerprintprofile.FieldEnableGrease:
- m.ResetEnableGrease()
- return nil
- case tlsfingerprintprofile.FieldCipherSuites:
- m.ResetCipherSuites()
- return nil
- case tlsfingerprintprofile.FieldCurves:
- m.ResetCurves()
- return nil
- case tlsfingerprintprofile.FieldPointFormats:
- m.ResetPointFormats()
- return nil
- case tlsfingerprintprofile.FieldSignatureAlgorithms:
- m.ResetSignatureAlgorithms()
- return nil
- case tlsfingerprintprofile.FieldAlpnProtocols:
- m.ResetAlpnProtocols()
- return nil
- case tlsfingerprintprofile.FieldSupportedVersions:
- m.ResetSupportedVersions()
- return nil
- case tlsfingerprintprofile.FieldKeyShareGroups:
- m.ResetKeyShareGroups()
- return nil
- case tlsfingerprintprofile.FieldPskModes:
- m.ResetPskModes()
- return nil
- case tlsfingerprintprofile.FieldExtensions:
- m.ResetExtensions()
- return nil
- }
- return fmt.Errorf("unknown TLSFingerprintProfile field %s", name)
- }
- // AddedEdges returns all edge names that were set/added in this mutation.
- func (m *TLSFingerprintProfileMutation) AddedEdges() []string {
- edges := make([]string, 0, 0)
- return edges
- }
- // AddedIDs returns all IDs (to other nodes) that were added for the given edge
- // name in this mutation.
- func (m *TLSFingerprintProfileMutation) AddedIDs(name string) []ent.Value {
- return nil
- }
- // RemovedEdges returns all edge names that were removed in this mutation.
- func (m *TLSFingerprintProfileMutation) RemovedEdges() []string {
- edges := make([]string, 0, 0)
- return edges
- }
- // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
- // the given name in this mutation.
- func (m *TLSFingerprintProfileMutation) RemovedIDs(name string) []ent.Value {
- return nil
- }
- // ClearedEdges returns all edge names that were cleared in this mutation.
- func (m *TLSFingerprintProfileMutation) ClearedEdges() []string {
- edges := make([]string, 0, 0)
- return edges
- }
- // EdgeCleared returns a boolean which indicates if the edge with the given name
- // was cleared in this mutation.
- func (m *TLSFingerprintProfileMutation) EdgeCleared(name string) bool {
- return false
- }
- // ClearEdge clears the value of the edge with the given name. It returns an error
- // if that edge is not defined in the schema.
- func (m *TLSFingerprintProfileMutation) ClearEdge(name string) error {
- return fmt.Errorf("unknown TLSFingerprintProfile unique edge %s", name)
- }
- // ResetEdge resets all changes to the edge with the given name in this mutation.
- // It returns an error if the edge is not defined in the schema.
- func (m *TLSFingerprintProfileMutation) ResetEdge(name string) error {
- return fmt.Errorf("unknown TLSFingerprintProfile edge %s", name)
- }
- // UsageCleanupTaskMutation represents an operation that mutates the UsageCleanupTask nodes in the graph.
- type UsageCleanupTaskMutation struct {
- config
- op Op
- typ string
- id *int64
- created_at *time.Time
- updated_at *time.Time
- status *string
- filters *jsontext.Value
- appendfilters jsontext.Value
- created_by *int64
- addcreated_by *int64
- deleted_rows *int64
- adddeleted_rows *int64
- error_message *string
- canceled_by *int64
- addcanceled_by *int64
- canceled_at *time.Time
- started_at *time.Time
- finished_at *time.Time
- clearedFields map[string]struct{}
- done bool
- oldValue func(context.Context) (*UsageCleanupTask, error)
- predicates []predicate.UsageCleanupTask
- }
- var _ ent.Mutation = (*UsageCleanupTaskMutation)(nil)
- // usagecleanuptaskOption allows management of the mutation configuration using functional options.
- type usagecleanuptaskOption func(*UsageCleanupTaskMutation)
- // newUsageCleanupTaskMutation creates new mutation for the UsageCleanupTask entity.
- func newUsageCleanupTaskMutation(c config, op Op, opts ...usagecleanuptaskOption) *UsageCleanupTaskMutation {
- m := &UsageCleanupTaskMutation{
- config: c,
- op: op,
- typ: TypeUsageCleanupTask,
- clearedFields: make(map[string]struct{}),
- }
- for _, opt := range opts {
- opt(m)
- }
- return m
- }
- // withUsageCleanupTaskID sets the ID field of the mutation.
- func withUsageCleanupTaskID(id int64) usagecleanuptaskOption {
- return func(m *UsageCleanupTaskMutation) {
- var (
- err error
- once sync.Once
- value *UsageCleanupTask
- )
- m.oldValue = func(ctx context.Context) (*UsageCleanupTask, error) {
- once.Do(func() {
- if m.done {
- err = errors.New("querying old values post mutation is not allowed")
- } else {
- value, err = m.Client().UsageCleanupTask.Get(ctx, id)
- }
- })
- return value, err
- }
- m.id = &id
- }
- }
- // withUsageCleanupTask sets the old UsageCleanupTask of the mutation.
- func withUsageCleanupTask(node *UsageCleanupTask) usagecleanuptaskOption {
- return func(m *UsageCleanupTaskMutation) {
- m.oldValue = func(context.Context) (*UsageCleanupTask, error) {
- return node, nil
- }
- m.id = &node.ID
- }
- }
- // Client returns a new `ent.Client` from the mutation. If the mutation was
- // executed in a transaction (ent.Tx), a transactional client is returned.
- func (m UsageCleanupTaskMutation) Client() *Client {
- client := &Client{config: m.config}
- client.init()
- return client
- }
- // Tx returns an `ent.Tx` for mutations that were executed in transactions;
- // it returns an error otherwise.
- func (m UsageCleanupTaskMutation) Tx() (*Tx, error) {
- if _, ok := m.driver.(*txDriver); !ok {
- return nil, errors.New("ent: mutation is not running in a transaction")
- }
- tx := &Tx{config: m.config}
- tx.init()
- return tx, nil
- }
- // ID returns the ID value in the mutation. Note that the ID is only available
- // if it was provided to the builder or after it was returned from the database.
- func (m *UsageCleanupTaskMutation) ID() (id int64, exists bool) {
- if m.id == nil {
- return
- }
- return *m.id, true
- }
- // IDs queries the database and returns the entity ids that match the mutation's predicate.
- // That means, if the mutation is applied within a transaction with an isolation level such
- // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
- // or updated by the mutation.
- func (m *UsageCleanupTaskMutation) IDs(ctx context.Context) ([]int64, error) {
- switch {
- case m.op.Is(OpUpdateOne | OpDeleteOne):
- id, exists := m.ID()
- if exists {
- return []int64{id}, nil
- }
- fallthrough
- case m.op.Is(OpUpdate | OpDelete):
- return m.Client().UsageCleanupTask.Query().Where(m.predicates...).IDs(ctx)
- default:
- return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
- }
- }
- // SetCreatedAt sets the "created_at" field.
- func (m *UsageCleanupTaskMutation) SetCreatedAt(t time.Time) {
- m.created_at = &t
- }
- // CreatedAt returns the value of the "created_at" field in the mutation.
- func (m *UsageCleanupTaskMutation) CreatedAt() (r time.Time, exists bool) {
- v := m.created_at
- if v == nil {
- return
- }
- return *v, true
- }
- // OldCreatedAt returns the old "created_at" field's value of the UsageCleanupTask entity.
- // If the UsageCleanupTask object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *UsageCleanupTaskMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldCreatedAt requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
- }
- return oldValue.CreatedAt, nil
- }
- // ResetCreatedAt resets all changes to the "created_at" field.
- func (m *UsageCleanupTaskMutation) ResetCreatedAt() {
- m.created_at = nil
- }
- // SetUpdatedAt sets the "updated_at" field.
- func (m *UsageCleanupTaskMutation) SetUpdatedAt(t time.Time) {
- m.updated_at = &t
- }
- // UpdatedAt returns the value of the "updated_at" field in the mutation.
- func (m *UsageCleanupTaskMutation) UpdatedAt() (r time.Time, exists bool) {
- v := m.updated_at
- if v == nil {
- return
- }
- return *v, true
- }
- // OldUpdatedAt returns the old "updated_at" field's value of the UsageCleanupTask entity.
- // If the UsageCleanupTask object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *UsageCleanupTaskMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
- }
- return oldValue.UpdatedAt, nil
- }
- // ResetUpdatedAt resets all changes to the "updated_at" field.
- func (m *UsageCleanupTaskMutation) ResetUpdatedAt() {
- m.updated_at = nil
- }
- // SetStatus sets the "status" field.
- func (m *UsageCleanupTaskMutation) SetStatus(s string) {
- m.status = &s
- }
- // Status returns the value of the "status" field in the mutation.
- func (m *UsageCleanupTaskMutation) Status() (r string, exists bool) {
- v := m.status
- if v == nil {
- return
- }
- return *v, true
- }
- // OldStatus returns the old "status" field's value of the UsageCleanupTask entity.
- // If the UsageCleanupTask object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *UsageCleanupTaskMutation) OldStatus(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldStatus is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldStatus requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldStatus: %w", err)
- }
- return oldValue.Status, nil
- }
- // ResetStatus resets all changes to the "status" field.
- func (m *UsageCleanupTaskMutation) ResetStatus() {
- m.status = nil
- }
- // SetFilters sets the "filters" field.
- func (m *UsageCleanupTaskMutation) SetFilters(j jsontext.Value) {
- m.filters = &j
- m.appendfilters = nil
- }
- // Filters returns the value of the "filters" field in the mutation.
- func (m *UsageCleanupTaskMutation) Filters() (r jsontext.Value, exists bool) {
- v := m.filters
- if v == nil {
- return
- }
- return *v, true
- }
- // OldFilters returns the old "filters" field's value of the UsageCleanupTask entity.
- // If the UsageCleanupTask object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *UsageCleanupTaskMutation) OldFilters(ctx context.Context) (v jsontext.Value, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldFilters is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldFilters requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldFilters: %w", err)
- }
- return oldValue.Filters, nil
- }
- // AppendFilters adds j to the "filters" field.
- func (m *UsageCleanupTaskMutation) AppendFilters(j jsontext.Value) {
- m.appendfilters = append(m.appendfilters, j...)
- }
- // AppendedFilters returns the list of values that were appended to the "filters" field in this mutation.
- func (m *UsageCleanupTaskMutation) AppendedFilters() (jsontext.Value, bool) {
- if len(m.appendfilters) == 0 {
- return nil, false
- }
- return m.appendfilters, true
- }
- // ResetFilters resets all changes to the "filters" field.
- func (m *UsageCleanupTaskMutation) ResetFilters() {
- m.filters = nil
- m.appendfilters = nil
- }
- // SetCreatedBy sets the "created_by" field.
- func (m *UsageCleanupTaskMutation) SetCreatedBy(i int64) {
- m.created_by = &i
- m.addcreated_by = nil
- }
- // CreatedBy returns the value of the "created_by" field in the mutation.
- func (m *UsageCleanupTaskMutation) CreatedBy() (r int64, exists bool) {
- v := m.created_by
- if v == nil {
- return
- }
- return *v, true
- }
- // OldCreatedBy returns the old "created_by" field's value of the UsageCleanupTask entity.
- // If the UsageCleanupTask object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *UsageCleanupTaskMutation) OldCreatedBy(ctx context.Context) (v int64, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldCreatedBy is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldCreatedBy requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldCreatedBy: %w", err)
- }
- return oldValue.CreatedBy, nil
- }
- // AddCreatedBy adds i to the "created_by" field.
- func (m *UsageCleanupTaskMutation) AddCreatedBy(i int64) {
- if m.addcreated_by != nil {
- *m.addcreated_by += i
- } else {
- m.addcreated_by = &i
- }
- }
- // AddedCreatedBy returns the value that was added to the "created_by" field in this mutation.
- func (m *UsageCleanupTaskMutation) AddedCreatedBy() (r int64, exists bool) {
- v := m.addcreated_by
- if v == nil {
- return
- }
- return *v, true
- }
- // ResetCreatedBy resets all changes to the "created_by" field.
- func (m *UsageCleanupTaskMutation) ResetCreatedBy() {
- m.created_by = nil
- m.addcreated_by = nil
- }
- // SetDeletedRows sets the "deleted_rows" field.
- func (m *UsageCleanupTaskMutation) SetDeletedRows(i int64) {
- m.deleted_rows = &i
- m.adddeleted_rows = nil
- }
- // DeletedRows returns the value of the "deleted_rows" field in the mutation.
- func (m *UsageCleanupTaskMutation) DeletedRows() (r int64, exists bool) {
- v := m.deleted_rows
- if v == nil {
- return
- }
- return *v, true
- }
- // OldDeletedRows returns the old "deleted_rows" field's value of the UsageCleanupTask entity.
- // If the UsageCleanupTask object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *UsageCleanupTaskMutation) OldDeletedRows(ctx context.Context) (v int64, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldDeletedRows is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldDeletedRows requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldDeletedRows: %w", err)
- }
- return oldValue.DeletedRows, nil
- }
- // AddDeletedRows adds i to the "deleted_rows" field.
- func (m *UsageCleanupTaskMutation) AddDeletedRows(i int64) {
- if m.adddeleted_rows != nil {
- *m.adddeleted_rows += i
- } else {
- m.adddeleted_rows = &i
- }
- }
- // AddedDeletedRows returns the value that was added to the "deleted_rows" field in this mutation.
- func (m *UsageCleanupTaskMutation) AddedDeletedRows() (r int64, exists bool) {
- v := m.adddeleted_rows
- if v == nil {
- return
- }
- return *v, true
- }
- // ResetDeletedRows resets all changes to the "deleted_rows" field.
- func (m *UsageCleanupTaskMutation) ResetDeletedRows() {
- m.deleted_rows = nil
- m.adddeleted_rows = nil
- }
- // SetErrorMessage sets the "error_message" field.
- func (m *UsageCleanupTaskMutation) SetErrorMessage(s string) {
- m.error_message = &s
- }
- // ErrorMessage returns the value of the "error_message" field in the mutation.
- func (m *UsageCleanupTaskMutation) ErrorMessage() (r string, exists bool) {
- v := m.error_message
- if v == nil {
- return
- }
- return *v, true
- }
- // OldErrorMessage returns the old "error_message" field's value of the UsageCleanupTask entity.
- // If the UsageCleanupTask object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *UsageCleanupTaskMutation) OldErrorMessage(ctx context.Context) (v *string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldErrorMessage is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldErrorMessage requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldErrorMessage: %w", err)
- }
- return oldValue.ErrorMessage, nil
- }
- // ClearErrorMessage clears the value of the "error_message" field.
- func (m *UsageCleanupTaskMutation) ClearErrorMessage() {
- m.error_message = nil
- m.clearedFields[usagecleanuptask.FieldErrorMessage] = struct{}{}
- }
- // ErrorMessageCleared returns if the "error_message" field was cleared in this mutation.
- func (m *UsageCleanupTaskMutation) ErrorMessageCleared() bool {
- _, ok := m.clearedFields[usagecleanuptask.FieldErrorMessage]
- return ok
- }
- // ResetErrorMessage resets all changes to the "error_message" field.
- func (m *UsageCleanupTaskMutation) ResetErrorMessage() {
- m.error_message = nil
- delete(m.clearedFields, usagecleanuptask.FieldErrorMessage)
- }
- // SetCanceledBy sets the "canceled_by" field.
- func (m *UsageCleanupTaskMutation) SetCanceledBy(i int64) {
- m.canceled_by = &i
- m.addcanceled_by = nil
- }
- // CanceledBy returns the value of the "canceled_by" field in the mutation.
- func (m *UsageCleanupTaskMutation) CanceledBy() (r int64, exists bool) {
- v := m.canceled_by
- if v == nil {
- return
- }
- return *v, true
- }
- // OldCanceledBy returns the old "canceled_by" field's value of the UsageCleanupTask entity.
- // If the UsageCleanupTask object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *UsageCleanupTaskMutation) OldCanceledBy(ctx context.Context) (v *int64, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldCanceledBy is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldCanceledBy requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldCanceledBy: %w", err)
- }
- return oldValue.CanceledBy, nil
- }
- // AddCanceledBy adds i to the "canceled_by" field.
- func (m *UsageCleanupTaskMutation) AddCanceledBy(i int64) {
- if m.addcanceled_by != nil {
- *m.addcanceled_by += i
- } else {
- m.addcanceled_by = &i
- }
- }
- // AddedCanceledBy returns the value that was added to the "canceled_by" field in this mutation.
- func (m *UsageCleanupTaskMutation) AddedCanceledBy() (r int64, exists bool) {
- v := m.addcanceled_by
- if v == nil {
- return
- }
- return *v, true
- }
- // ClearCanceledBy clears the value of the "canceled_by" field.
- func (m *UsageCleanupTaskMutation) ClearCanceledBy() {
- m.canceled_by = nil
- m.addcanceled_by = nil
- m.clearedFields[usagecleanuptask.FieldCanceledBy] = struct{}{}
- }
- // CanceledByCleared returns if the "canceled_by" field was cleared in this mutation.
- func (m *UsageCleanupTaskMutation) CanceledByCleared() bool {
- _, ok := m.clearedFields[usagecleanuptask.FieldCanceledBy]
- return ok
- }
- // ResetCanceledBy resets all changes to the "canceled_by" field.
- func (m *UsageCleanupTaskMutation) ResetCanceledBy() {
- m.canceled_by = nil
- m.addcanceled_by = nil
- delete(m.clearedFields, usagecleanuptask.FieldCanceledBy)
- }
- // SetCanceledAt sets the "canceled_at" field.
- func (m *UsageCleanupTaskMutation) SetCanceledAt(t time.Time) {
- m.canceled_at = &t
- }
- // CanceledAt returns the value of the "canceled_at" field in the mutation.
- func (m *UsageCleanupTaskMutation) CanceledAt() (r time.Time, exists bool) {
- v := m.canceled_at
- if v == nil {
- return
- }
- return *v, true
- }
- // OldCanceledAt returns the old "canceled_at" field's value of the UsageCleanupTask entity.
- // If the UsageCleanupTask object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *UsageCleanupTaskMutation) OldCanceledAt(ctx context.Context) (v *time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldCanceledAt is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldCanceledAt requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldCanceledAt: %w", err)
- }
- return oldValue.CanceledAt, nil
- }
- // ClearCanceledAt clears the value of the "canceled_at" field.
- func (m *UsageCleanupTaskMutation) ClearCanceledAt() {
- m.canceled_at = nil
- m.clearedFields[usagecleanuptask.FieldCanceledAt] = struct{}{}
- }
- // CanceledAtCleared returns if the "canceled_at" field was cleared in this mutation.
- func (m *UsageCleanupTaskMutation) CanceledAtCleared() bool {
- _, ok := m.clearedFields[usagecleanuptask.FieldCanceledAt]
- return ok
- }
- // ResetCanceledAt resets all changes to the "canceled_at" field.
- func (m *UsageCleanupTaskMutation) ResetCanceledAt() {
- m.canceled_at = nil
- delete(m.clearedFields, usagecleanuptask.FieldCanceledAt)
- }
- // SetStartedAt sets the "started_at" field.
- func (m *UsageCleanupTaskMutation) SetStartedAt(t time.Time) {
- m.started_at = &t
- }
- // StartedAt returns the value of the "started_at" field in the mutation.
- func (m *UsageCleanupTaskMutation) StartedAt() (r time.Time, exists bool) {
- v := m.started_at
- if v == nil {
- return
- }
- return *v, true
- }
- // OldStartedAt returns the old "started_at" field's value of the UsageCleanupTask entity.
- // If the UsageCleanupTask object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *UsageCleanupTaskMutation) OldStartedAt(ctx context.Context) (v *time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldStartedAt is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldStartedAt requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldStartedAt: %w", err)
- }
- return oldValue.StartedAt, nil
- }
- // ClearStartedAt clears the value of the "started_at" field.
- func (m *UsageCleanupTaskMutation) ClearStartedAt() {
- m.started_at = nil
- m.clearedFields[usagecleanuptask.FieldStartedAt] = struct{}{}
- }
- // StartedAtCleared returns if the "started_at" field was cleared in this mutation.
- func (m *UsageCleanupTaskMutation) StartedAtCleared() bool {
- _, ok := m.clearedFields[usagecleanuptask.FieldStartedAt]
- return ok
- }
- // ResetStartedAt resets all changes to the "started_at" field.
- func (m *UsageCleanupTaskMutation) ResetStartedAt() {
- m.started_at = nil
- delete(m.clearedFields, usagecleanuptask.FieldStartedAt)
- }
- // SetFinishedAt sets the "finished_at" field.
- func (m *UsageCleanupTaskMutation) SetFinishedAt(t time.Time) {
- m.finished_at = &t
- }
- // FinishedAt returns the value of the "finished_at" field in the mutation.
- func (m *UsageCleanupTaskMutation) FinishedAt() (r time.Time, exists bool) {
- v := m.finished_at
- if v == nil {
- return
- }
- return *v, true
- }
- // OldFinishedAt returns the old "finished_at" field's value of the UsageCleanupTask entity.
- // If the UsageCleanupTask object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *UsageCleanupTaskMutation) OldFinishedAt(ctx context.Context) (v *time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldFinishedAt is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldFinishedAt requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldFinishedAt: %w", err)
- }
- return oldValue.FinishedAt, nil
- }
- // ClearFinishedAt clears the value of the "finished_at" field.
- func (m *UsageCleanupTaskMutation) ClearFinishedAt() {
- m.finished_at = nil
- m.clearedFields[usagecleanuptask.FieldFinishedAt] = struct{}{}
- }
- // FinishedAtCleared returns if the "finished_at" field was cleared in this mutation.
- func (m *UsageCleanupTaskMutation) FinishedAtCleared() bool {
- _, ok := m.clearedFields[usagecleanuptask.FieldFinishedAt]
- return ok
- }
- // ResetFinishedAt resets all changes to the "finished_at" field.
- func (m *UsageCleanupTaskMutation) ResetFinishedAt() {
- m.finished_at = nil
- delete(m.clearedFields, usagecleanuptask.FieldFinishedAt)
- }
- // Where appends a list predicates to the UsageCleanupTaskMutation builder.
- func (m *UsageCleanupTaskMutation) Where(ps ...predicate.UsageCleanupTask) {
- m.predicates = append(m.predicates, ps...)
- }
- // WhereP appends storage-level predicates to the UsageCleanupTaskMutation builder. Using this method,
- // users can use type-assertion to append predicates that do not depend on any generated package.
- func (m *UsageCleanupTaskMutation) WhereP(ps ...func(*sql.Selector)) {
- p := make([]predicate.UsageCleanupTask, len(ps))
- for i := range ps {
- p[i] = ps[i]
- }
- m.Where(p...)
- }
- // Op returns the operation name.
- func (m *UsageCleanupTaskMutation) Op() Op {
- return m.op
- }
- // SetOp allows setting the mutation operation.
- func (m *UsageCleanupTaskMutation) SetOp(op Op) {
- m.op = op
- }
- // Type returns the node type of this mutation (UsageCleanupTask).
- func (m *UsageCleanupTaskMutation) Type() string {
- return m.typ
- }
- // Fields returns all fields that were changed during this mutation. Note that in
- // order to get all numeric fields that were incremented/decremented, call
- // AddedFields().
- func (m *UsageCleanupTaskMutation) Fields() []string {
- fields := make([]string, 0, 11)
- if m.created_at != nil {
- fields = append(fields, usagecleanuptask.FieldCreatedAt)
- }
- if m.updated_at != nil {
- fields = append(fields, usagecleanuptask.FieldUpdatedAt)
- }
- if m.status != nil {
- fields = append(fields, usagecleanuptask.FieldStatus)
- }
- if m.filters != nil {
- fields = append(fields, usagecleanuptask.FieldFilters)
- }
- if m.created_by != nil {
- fields = append(fields, usagecleanuptask.FieldCreatedBy)
- }
- if m.deleted_rows != nil {
- fields = append(fields, usagecleanuptask.FieldDeletedRows)
- }
- if m.error_message != nil {
- fields = append(fields, usagecleanuptask.FieldErrorMessage)
- }
- if m.canceled_by != nil {
- fields = append(fields, usagecleanuptask.FieldCanceledBy)
- }
- if m.canceled_at != nil {
- fields = append(fields, usagecleanuptask.FieldCanceledAt)
- }
- if m.started_at != nil {
- fields = append(fields, usagecleanuptask.FieldStartedAt)
- }
- if m.finished_at != nil {
- fields = append(fields, usagecleanuptask.FieldFinishedAt)
- }
- return fields
- }
- // Field returns the value of a field with the given name. The second boolean
- // return value indicates that this field was not set, or was not defined in the
- // schema.
- func (m *UsageCleanupTaskMutation) Field(name string) (ent.Value, bool) {
- switch name {
- case usagecleanuptask.FieldCreatedAt:
- return m.CreatedAt()
- case usagecleanuptask.FieldUpdatedAt:
- return m.UpdatedAt()
- case usagecleanuptask.FieldStatus:
- return m.Status()
- case usagecleanuptask.FieldFilters:
- return m.Filters()
- case usagecleanuptask.FieldCreatedBy:
- return m.CreatedBy()
- case usagecleanuptask.FieldDeletedRows:
- return m.DeletedRows()
- case usagecleanuptask.FieldErrorMessage:
- return m.ErrorMessage()
- case usagecleanuptask.FieldCanceledBy:
- return m.CanceledBy()
- case usagecleanuptask.FieldCanceledAt:
- return m.CanceledAt()
- case usagecleanuptask.FieldStartedAt:
- return m.StartedAt()
- case usagecleanuptask.FieldFinishedAt:
- return m.FinishedAt()
- }
- return nil, false
- }
- // OldField returns the old value of the field from the database. An error is
- // returned if the mutation operation is not UpdateOne, or the query to the
- // database failed.
- func (m *UsageCleanupTaskMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
- switch name {
- case usagecleanuptask.FieldCreatedAt:
- return m.OldCreatedAt(ctx)
- case usagecleanuptask.FieldUpdatedAt:
- return m.OldUpdatedAt(ctx)
- case usagecleanuptask.FieldStatus:
- return m.OldStatus(ctx)
- case usagecleanuptask.FieldFilters:
- return m.OldFilters(ctx)
- case usagecleanuptask.FieldCreatedBy:
- return m.OldCreatedBy(ctx)
- case usagecleanuptask.FieldDeletedRows:
- return m.OldDeletedRows(ctx)
- case usagecleanuptask.FieldErrorMessage:
- return m.OldErrorMessage(ctx)
- case usagecleanuptask.FieldCanceledBy:
- return m.OldCanceledBy(ctx)
- case usagecleanuptask.FieldCanceledAt:
- return m.OldCanceledAt(ctx)
- case usagecleanuptask.FieldStartedAt:
- return m.OldStartedAt(ctx)
- case usagecleanuptask.FieldFinishedAt:
- return m.OldFinishedAt(ctx)
- }
- return nil, fmt.Errorf("unknown UsageCleanupTask field %s", name)
- }
- // SetField sets the value of a field with the given name. It returns an error if
- // the field is not defined in the schema, or if the type mismatched the field
- // type.
- func (m *UsageCleanupTaskMutation) SetField(name string, value ent.Value) error {
- switch name {
- case usagecleanuptask.FieldCreatedAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetCreatedAt(v)
- return nil
- case usagecleanuptask.FieldUpdatedAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetUpdatedAt(v)
- return nil
- case usagecleanuptask.FieldStatus:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetStatus(v)
- return nil
- case usagecleanuptask.FieldFilters:
- v, ok := value.(jsontext.Value)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetFilters(v)
- return nil
- case usagecleanuptask.FieldCreatedBy:
- v, ok := value.(int64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetCreatedBy(v)
- return nil
- case usagecleanuptask.FieldDeletedRows:
- v, ok := value.(int64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetDeletedRows(v)
- return nil
- case usagecleanuptask.FieldErrorMessage:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetErrorMessage(v)
- return nil
- case usagecleanuptask.FieldCanceledBy:
- v, ok := value.(int64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetCanceledBy(v)
- return nil
- case usagecleanuptask.FieldCanceledAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetCanceledAt(v)
- return nil
- case usagecleanuptask.FieldStartedAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetStartedAt(v)
- return nil
- case usagecleanuptask.FieldFinishedAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetFinishedAt(v)
- return nil
- }
- return fmt.Errorf("unknown UsageCleanupTask field %s", name)
- }
- // AddedFields returns all numeric fields that were incremented/decremented during
- // this mutation.
- func (m *UsageCleanupTaskMutation) AddedFields() []string {
- var fields []string
- if m.addcreated_by != nil {
- fields = append(fields, usagecleanuptask.FieldCreatedBy)
- }
- if m.adddeleted_rows != nil {
- fields = append(fields, usagecleanuptask.FieldDeletedRows)
- }
- if m.addcanceled_by != nil {
- fields = append(fields, usagecleanuptask.FieldCanceledBy)
- }
- return fields
- }
- // AddedField returns the numeric value that was incremented/decremented on a field
- // with the given name. The second boolean return value indicates that this field
- // was not set, or was not defined in the schema.
- func (m *UsageCleanupTaskMutation) AddedField(name string) (ent.Value, bool) {
- switch name {
- case usagecleanuptask.FieldCreatedBy:
- return m.AddedCreatedBy()
- case usagecleanuptask.FieldDeletedRows:
- return m.AddedDeletedRows()
- case usagecleanuptask.FieldCanceledBy:
- return m.AddedCanceledBy()
- }
- return nil, false
- }
- // AddField adds the value to the field with the given name. It returns an error if
- // the field is not defined in the schema, or if the type mismatched the field
- // type.
- func (m *UsageCleanupTaskMutation) AddField(name string, value ent.Value) error {
- switch name {
- case usagecleanuptask.FieldCreatedBy:
- v, ok := value.(int64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.AddCreatedBy(v)
- return nil
- case usagecleanuptask.FieldDeletedRows:
- v, ok := value.(int64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.AddDeletedRows(v)
- return nil
- case usagecleanuptask.FieldCanceledBy:
- v, ok := value.(int64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.AddCanceledBy(v)
- return nil
- }
- return fmt.Errorf("unknown UsageCleanupTask numeric field %s", name)
- }
- // ClearedFields returns all nullable fields that were cleared during this
- // mutation.
- func (m *UsageCleanupTaskMutation) ClearedFields() []string {
- var fields []string
- if m.FieldCleared(usagecleanuptask.FieldErrorMessage) {
- fields = append(fields, usagecleanuptask.FieldErrorMessage)
- }
- if m.FieldCleared(usagecleanuptask.FieldCanceledBy) {
- fields = append(fields, usagecleanuptask.FieldCanceledBy)
- }
- if m.FieldCleared(usagecleanuptask.FieldCanceledAt) {
- fields = append(fields, usagecleanuptask.FieldCanceledAt)
- }
- if m.FieldCleared(usagecleanuptask.FieldStartedAt) {
- fields = append(fields, usagecleanuptask.FieldStartedAt)
- }
- if m.FieldCleared(usagecleanuptask.FieldFinishedAt) {
- fields = append(fields, usagecleanuptask.FieldFinishedAt)
- }
- return fields
- }
- // FieldCleared returns a boolean indicating if a field with the given name was
- // cleared in this mutation.
- func (m *UsageCleanupTaskMutation) FieldCleared(name string) bool {
- _, ok := m.clearedFields[name]
- return ok
- }
- // ClearField clears the value of the field with the given name. It returns an
- // error if the field is not defined in the schema.
- func (m *UsageCleanupTaskMutation) ClearField(name string) error {
- switch name {
- case usagecleanuptask.FieldErrorMessage:
- m.ClearErrorMessage()
- return nil
- case usagecleanuptask.FieldCanceledBy:
- m.ClearCanceledBy()
- return nil
- case usagecleanuptask.FieldCanceledAt:
- m.ClearCanceledAt()
- return nil
- case usagecleanuptask.FieldStartedAt:
- m.ClearStartedAt()
- return nil
- case usagecleanuptask.FieldFinishedAt:
- m.ClearFinishedAt()
- return nil
- }
- return fmt.Errorf("unknown UsageCleanupTask nullable field %s", name)
- }
- // ResetField resets all changes in the mutation for the field with the given name.
- // It returns an error if the field is not defined in the schema.
- func (m *UsageCleanupTaskMutation) ResetField(name string) error {
- switch name {
- case usagecleanuptask.FieldCreatedAt:
- m.ResetCreatedAt()
- return nil
- case usagecleanuptask.FieldUpdatedAt:
- m.ResetUpdatedAt()
- return nil
- case usagecleanuptask.FieldStatus:
- m.ResetStatus()
- return nil
- case usagecleanuptask.FieldFilters:
- m.ResetFilters()
- return nil
- case usagecleanuptask.FieldCreatedBy:
- m.ResetCreatedBy()
- return nil
- case usagecleanuptask.FieldDeletedRows:
- m.ResetDeletedRows()
- return nil
- case usagecleanuptask.FieldErrorMessage:
- m.ResetErrorMessage()
- return nil
- case usagecleanuptask.FieldCanceledBy:
- m.ResetCanceledBy()
- return nil
- case usagecleanuptask.FieldCanceledAt:
- m.ResetCanceledAt()
- return nil
- case usagecleanuptask.FieldStartedAt:
- m.ResetStartedAt()
- return nil
- case usagecleanuptask.FieldFinishedAt:
- m.ResetFinishedAt()
- return nil
- }
- return fmt.Errorf("unknown UsageCleanupTask field %s", name)
- }
- // AddedEdges returns all edge names that were set/added in this mutation.
- func (m *UsageCleanupTaskMutation) AddedEdges() []string {
- edges := make([]string, 0, 0)
- return edges
- }
- // AddedIDs returns all IDs (to other nodes) that were added for the given edge
- // name in this mutation.
- func (m *UsageCleanupTaskMutation) AddedIDs(name string) []ent.Value {
- return nil
- }
- // RemovedEdges returns all edge names that were removed in this mutation.
- func (m *UsageCleanupTaskMutation) RemovedEdges() []string {
- edges := make([]string, 0, 0)
- return edges
- }
- // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
- // the given name in this mutation.
- func (m *UsageCleanupTaskMutation) RemovedIDs(name string) []ent.Value {
- return nil
- }
- // ClearedEdges returns all edge names that were cleared in this mutation.
- func (m *UsageCleanupTaskMutation) ClearedEdges() []string {
- edges := make([]string, 0, 0)
- return edges
- }
- // EdgeCleared returns a boolean which indicates if the edge with the given name
- // was cleared in this mutation.
- func (m *UsageCleanupTaskMutation) EdgeCleared(name string) bool {
- return false
- }
- // ClearEdge clears the value of the edge with the given name. It returns an error
- // if that edge is not defined in the schema.
- func (m *UsageCleanupTaskMutation) ClearEdge(name string) error {
- return fmt.Errorf("unknown UsageCleanupTask unique edge %s", name)
- }
- // ResetEdge resets all changes to the edge with the given name in this mutation.
- // It returns an error if the edge is not defined in the schema.
- func (m *UsageCleanupTaskMutation) ResetEdge(name string) error {
- return fmt.Errorf("unknown UsageCleanupTask edge %s", name)
- }
- // UsageLogMutation represents an operation that mutates the UsageLog nodes in the graph.
- type UsageLogMutation struct {
- config
- op Op
- typ string
- id *int64
- request_id *string
- model *string
- requested_model *string
- upstream_model *string
- upstream_response_model *string
- upstream_model_mismatch *bool
- channel_id *int64
- addchannel_id *int64
- model_mapping_chain *string
- billing_tier *string
- billing_mode *string
- input_tokens *int
- addinput_tokens *int
- output_tokens *int
- addoutput_tokens *int
- cache_creation_tokens *int
- addcache_creation_tokens *int
- cache_read_tokens *int
- addcache_read_tokens *int
- cache_creation_5m_tokens *int
- addcache_creation_5m_tokens *int
- cache_creation_1h_tokens *int
- addcache_creation_1h_tokens *int
- input_cost *float64
- addinput_cost *float64
- output_cost *float64
- addoutput_cost *float64
- cache_creation_cost *float64
- addcache_creation_cost *float64
- cache_read_cost *float64
- addcache_read_cost *float64
- total_cost *float64
- addtotal_cost *float64
- actual_cost *float64
- addactual_cost *float64
- rate_multiplier *float64
- addrate_multiplier *float64
- long_context_billing_applied *bool
- account_rate_multiplier *float64
- addaccount_rate_multiplier *float64
- billing_type *int8
- addbilling_type *int8
- stream *bool
- duration_ms *int
- addduration_ms *int
- first_token_ms *int
- addfirst_token_ms *int
- user_agent *string
- ip_address *string
- image_count *int
- addimage_count *int
- image_size *string
- image_input_size *string
- image_output_size *string
- image_size_source *string
- image_size_breakdown *map[string]int
- video_count *int
- addvideo_count *int
- video_resolution *string
- video_duration_seconds *int
- addvideo_duration_seconds *int
- cache_ttl_overridden *bool
- created_at *time.Time
- clearedFields map[string]struct{}
- user *int64
- cleareduser bool
- api_key *int64
- clearedapi_key bool
- account *int64
- clearedaccount bool
- group *int64
- clearedgroup bool
- subscription *int64
- clearedsubscription bool
- done bool
- oldValue func(context.Context) (*UsageLog, error)
- predicates []predicate.UsageLog
- }
- var _ ent.Mutation = (*UsageLogMutation)(nil)
- // usagelogOption allows management of the mutation configuration using functional options.
- type usagelogOption func(*UsageLogMutation)
- // newUsageLogMutation creates new mutation for the UsageLog entity.
- func newUsageLogMutation(c config, op Op, opts ...usagelogOption) *UsageLogMutation {
- m := &UsageLogMutation{
- config: c,
- op: op,
- typ: TypeUsageLog,
- clearedFields: make(map[string]struct{}),
- }
- for _, opt := range opts {
- opt(m)
- }
- return m
- }
- // withUsageLogID sets the ID field of the mutation.
- func withUsageLogID(id int64) usagelogOption {
- return func(m *UsageLogMutation) {
- var (
- err error
- once sync.Once
- value *UsageLog
- )
- m.oldValue = func(ctx context.Context) (*UsageLog, error) {
- once.Do(func() {
- if m.done {
- err = errors.New("querying old values post mutation is not allowed")
- } else {
- value, err = m.Client().UsageLog.Get(ctx, id)
- }
- })
- return value, err
- }
- m.id = &id
- }
- }
- // withUsageLog sets the old UsageLog of the mutation.
- func withUsageLog(node *UsageLog) usagelogOption {
- return func(m *UsageLogMutation) {
- m.oldValue = func(context.Context) (*UsageLog, error) {
- return node, nil
- }
- m.id = &node.ID
- }
- }
- // Client returns a new `ent.Client` from the mutation. If the mutation was
- // executed in a transaction (ent.Tx), a transactional client is returned.
- func (m UsageLogMutation) Client() *Client {
- client := &Client{config: m.config}
- client.init()
- return client
- }
- // Tx returns an `ent.Tx` for mutations that were executed in transactions;
- // it returns an error otherwise.
- func (m UsageLogMutation) Tx() (*Tx, error) {
- if _, ok := m.driver.(*txDriver); !ok {
- return nil, errors.New("ent: mutation is not running in a transaction")
- }
- tx := &Tx{config: m.config}
- tx.init()
- return tx, nil
- }
- // ID returns the ID value in the mutation. Note that the ID is only available
- // if it was provided to the builder or after it was returned from the database.
- func (m *UsageLogMutation) ID() (id int64, exists bool) {
- if m.id == nil {
- return
- }
- return *m.id, true
- }
- // IDs queries the database and returns the entity ids that match the mutation's predicate.
- // That means, if the mutation is applied within a transaction with an isolation level such
- // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
- // or updated by the mutation.
- func (m *UsageLogMutation) IDs(ctx context.Context) ([]int64, error) {
- switch {
- case m.op.Is(OpUpdateOne | OpDeleteOne):
- id, exists := m.ID()
- if exists {
- return []int64{id}, nil
- }
- fallthrough
- case m.op.Is(OpUpdate | OpDelete):
- return m.Client().UsageLog.Query().Where(m.predicates...).IDs(ctx)
- default:
- return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
- }
- }
- // SetUserID sets the "user_id" field.
- func (m *UsageLogMutation) SetUserID(i int64) {
- m.user = &i
- }
- // UserID returns the value of the "user_id" field in the mutation.
- func (m *UsageLogMutation) UserID() (r int64, exists bool) {
- v := m.user
- if v == nil {
- return
- }
- return *v, true
- }
- // OldUserID returns the old "user_id" field's value of the UsageLog entity.
- // If the UsageLog object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *UsageLogMutation) OldUserID(ctx context.Context) (v int64, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldUserID is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldUserID requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldUserID: %w", err)
- }
- return oldValue.UserID, nil
- }
- // ResetUserID resets all changes to the "user_id" field.
- func (m *UsageLogMutation) ResetUserID() {
- m.user = nil
- }
- // SetAPIKeyID sets the "api_key_id" field.
- func (m *UsageLogMutation) SetAPIKeyID(i int64) {
- m.api_key = &i
- }
- // APIKeyID returns the value of the "api_key_id" field in the mutation.
- func (m *UsageLogMutation) APIKeyID() (r int64, exists bool) {
- v := m.api_key
- if v == nil {
- return
- }
- return *v, true
- }
- // OldAPIKeyID returns the old "api_key_id" field's value of the UsageLog entity.
- // If the UsageLog object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *UsageLogMutation) OldAPIKeyID(ctx context.Context) (v int64, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldAPIKeyID is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldAPIKeyID requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldAPIKeyID: %w", err)
- }
- return oldValue.APIKeyID, nil
- }
- // ResetAPIKeyID resets all changes to the "api_key_id" field.
- func (m *UsageLogMutation) ResetAPIKeyID() {
- m.api_key = nil
- }
- // SetAccountID sets the "account_id" field.
- func (m *UsageLogMutation) SetAccountID(i int64) {
- m.account = &i
- }
- // AccountID returns the value of the "account_id" field in the mutation.
- func (m *UsageLogMutation) AccountID() (r int64, exists bool) {
- v := m.account
- if v == nil {
- return
- }
- return *v, true
- }
- // OldAccountID returns the old "account_id" field's value of the UsageLog entity.
- // If the UsageLog object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *UsageLogMutation) OldAccountID(ctx context.Context) (v int64, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldAccountID is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldAccountID requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldAccountID: %w", err)
- }
- return oldValue.AccountID, nil
- }
- // ResetAccountID resets all changes to the "account_id" field.
- func (m *UsageLogMutation) ResetAccountID() {
- m.account = nil
- }
- // SetRequestID sets the "request_id" field.
- func (m *UsageLogMutation) SetRequestID(s string) {
- m.request_id = &s
- }
- // RequestID returns the value of the "request_id" field in the mutation.
- func (m *UsageLogMutation) RequestID() (r string, exists bool) {
- v := m.request_id
- if v == nil {
- return
- }
- return *v, true
- }
- // OldRequestID returns the old "request_id" field's value of the UsageLog entity.
- // If the UsageLog object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *UsageLogMutation) OldRequestID(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldRequestID is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldRequestID requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldRequestID: %w", err)
- }
- return oldValue.RequestID, nil
- }
- // ResetRequestID resets all changes to the "request_id" field.
- func (m *UsageLogMutation) ResetRequestID() {
- m.request_id = nil
- }
- // SetModel sets the "model" field.
- func (m *UsageLogMutation) SetModel(s string) {
- m.model = &s
- }
- // Model returns the value of the "model" field in the mutation.
- func (m *UsageLogMutation) Model() (r string, exists bool) {
- v := m.model
- if v == nil {
- return
- }
- return *v, true
- }
- // OldModel returns the old "model" field's value of the UsageLog entity.
- // If the UsageLog object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *UsageLogMutation) OldModel(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldModel is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldModel requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldModel: %w", err)
- }
- return oldValue.Model, nil
- }
- // ResetModel resets all changes to the "model" field.
- func (m *UsageLogMutation) ResetModel() {
- m.model = nil
- }
- // SetRequestedModel sets the "requested_model" field.
- func (m *UsageLogMutation) SetRequestedModel(s string) {
- m.requested_model = &s
- }
- // RequestedModel returns the value of the "requested_model" field in the mutation.
- func (m *UsageLogMutation) RequestedModel() (r string, exists bool) {
- v := m.requested_model
- if v == nil {
- return
- }
- return *v, true
- }
- // OldRequestedModel returns the old "requested_model" field's value of the UsageLog entity.
- // If the UsageLog object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *UsageLogMutation) OldRequestedModel(ctx context.Context) (v *string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldRequestedModel is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldRequestedModel requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldRequestedModel: %w", err)
- }
- return oldValue.RequestedModel, nil
- }
- // ClearRequestedModel clears the value of the "requested_model" field.
- func (m *UsageLogMutation) ClearRequestedModel() {
- m.requested_model = nil
- m.clearedFields[usagelog.FieldRequestedModel] = struct{}{}
- }
- // RequestedModelCleared returns if the "requested_model" field was cleared in this mutation.
- func (m *UsageLogMutation) RequestedModelCleared() bool {
- _, ok := m.clearedFields[usagelog.FieldRequestedModel]
- return ok
- }
- // ResetRequestedModel resets all changes to the "requested_model" field.
- func (m *UsageLogMutation) ResetRequestedModel() {
- m.requested_model = nil
- delete(m.clearedFields, usagelog.FieldRequestedModel)
- }
- // SetUpstreamModel sets the "upstream_model" field.
- func (m *UsageLogMutation) SetUpstreamModel(s string) {
- m.upstream_model = &s
- }
- // UpstreamModel returns the value of the "upstream_model" field in the mutation.
- func (m *UsageLogMutation) UpstreamModel() (r string, exists bool) {
- v := m.upstream_model
- if v == nil {
- return
- }
- return *v, true
- }
- // OldUpstreamModel returns the old "upstream_model" field's value of the UsageLog entity.
- // If the UsageLog object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *UsageLogMutation) OldUpstreamModel(ctx context.Context) (v *string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldUpstreamModel is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldUpstreamModel requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldUpstreamModel: %w", err)
- }
- return oldValue.UpstreamModel, nil
- }
- // ClearUpstreamModel clears the value of the "upstream_model" field.
- func (m *UsageLogMutation) ClearUpstreamModel() {
- m.upstream_model = nil
- m.clearedFields[usagelog.FieldUpstreamModel] = struct{}{}
- }
- // UpstreamModelCleared returns if the "upstream_model" field was cleared in this mutation.
- func (m *UsageLogMutation) UpstreamModelCleared() bool {
- _, ok := m.clearedFields[usagelog.FieldUpstreamModel]
- return ok
- }
- // ResetUpstreamModel resets all changes to the "upstream_model" field.
- func (m *UsageLogMutation) ResetUpstreamModel() {
- m.upstream_model = nil
- delete(m.clearedFields, usagelog.FieldUpstreamModel)
- }
- // SetUpstreamResponseModel sets the "upstream_response_model" field.
- func (m *UsageLogMutation) SetUpstreamResponseModel(s string) {
- m.upstream_response_model = &s
- }
- // UpstreamResponseModel returns the value of the "upstream_response_model" field in the mutation.
- func (m *UsageLogMutation) UpstreamResponseModel() (r string, exists bool) {
- v := m.upstream_response_model
- if v == nil {
- return
- }
- return *v, true
- }
- // OldUpstreamResponseModel returns the old "upstream_response_model" field's value of the UsageLog entity.
- // If the UsageLog object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *UsageLogMutation) OldUpstreamResponseModel(ctx context.Context) (v *string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldUpstreamResponseModel is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldUpstreamResponseModel requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldUpstreamResponseModel: %w", err)
- }
- return oldValue.UpstreamResponseModel, nil
- }
- // ClearUpstreamResponseModel clears the value of the "upstream_response_model" field.
- func (m *UsageLogMutation) ClearUpstreamResponseModel() {
- m.upstream_response_model = nil
- m.clearedFields[usagelog.FieldUpstreamResponseModel] = struct{}{}
- }
- // UpstreamResponseModelCleared returns if the "upstream_response_model" field was cleared in this mutation.
- func (m *UsageLogMutation) UpstreamResponseModelCleared() bool {
- _, ok := m.clearedFields[usagelog.FieldUpstreamResponseModel]
- return ok
- }
- // ResetUpstreamResponseModel resets all changes to the "upstream_response_model" field.
- func (m *UsageLogMutation) ResetUpstreamResponseModel() {
- m.upstream_response_model = nil
- delete(m.clearedFields, usagelog.FieldUpstreamResponseModel)
- }
- // SetUpstreamModelMismatch sets the "upstream_model_mismatch" field.
- func (m *UsageLogMutation) SetUpstreamModelMismatch(b bool) {
- m.upstream_model_mismatch = &b
- }
- // UpstreamModelMismatch returns the value of the "upstream_model_mismatch" field in the mutation.
- func (m *UsageLogMutation) UpstreamModelMismatch() (r bool, exists bool) {
- v := m.upstream_model_mismatch
- if v == nil {
- return
- }
- return *v, true
- }
- // OldUpstreamModelMismatch returns the old "upstream_model_mismatch" field's value of the UsageLog entity.
- // If the UsageLog object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *UsageLogMutation) OldUpstreamModelMismatch(ctx context.Context) (v *bool, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldUpstreamModelMismatch is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldUpstreamModelMismatch requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldUpstreamModelMismatch: %w", err)
- }
- return oldValue.UpstreamModelMismatch, nil
- }
- // ClearUpstreamModelMismatch clears the value of the "upstream_model_mismatch" field.
- func (m *UsageLogMutation) ClearUpstreamModelMismatch() {
- m.upstream_model_mismatch = nil
- m.clearedFields[usagelog.FieldUpstreamModelMismatch] = struct{}{}
- }
- // UpstreamModelMismatchCleared returns if the "upstream_model_mismatch" field was cleared in this mutation.
- func (m *UsageLogMutation) UpstreamModelMismatchCleared() bool {
- _, ok := m.clearedFields[usagelog.FieldUpstreamModelMismatch]
- return ok
- }
- // ResetUpstreamModelMismatch resets all changes to the "upstream_model_mismatch" field.
- func (m *UsageLogMutation) ResetUpstreamModelMismatch() {
- m.upstream_model_mismatch = nil
- delete(m.clearedFields, usagelog.FieldUpstreamModelMismatch)
- }
- // SetChannelID sets the "channel_id" field.
- func (m *UsageLogMutation) SetChannelID(i int64) {
- m.channel_id = &i
- m.addchannel_id = nil
- }
- // ChannelID returns the value of the "channel_id" field in the mutation.
- func (m *UsageLogMutation) ChannelID() (r int64, exists bool) {
- v := m.channel_id
- if v == nil {
- return
- }
- return *v, true
- }
- // OldChannelID returns the old "channel_id" field's value of the UsageLog entity.
- // If the UsageLog object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *UsageLogMutation) OldChannelID(ctx context.Context) (v *int64, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldChannelID is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldChannelID requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldChannelID: %w", err)
- }
- return oldValue.ChannelID, nil
- }
- // AddChannelID adds i to the "channel_id" field.
- func (m *UsageLogMutation) AddChannelID(i int64) {
- if m.addchannel_id != nil {
- *m.addchannel_id += i
- } else {
- m.addchannel_id = &i
- }
- }
- // AddedChannelID returns the value that was added to the "channel_id" field in this mutation.
- func (m *UsageLogMutation) AddedChannelID() (r int64, exists bool) {
- v := m.addchannel_id
- if v == nil {
- return
- }
- return *v, true
- }
- // ClearChannelID clears the value of the "channel_id" field.
- func (m *UsageLogMutation) ClearChannelID() {
- m.channel_id = nil
- m.addchannel_id = nil
- m.clearedFields[usagelog.FieldChannelID] = struct{}{}
- }
- // ChannelIDCleared returns if the "channel_id" field was cleared in this mutation.
- func (m *UsageLogMutation) ChannelIDCleared() bool {
- _, ok := m.clearedFields[usagelog.FieldChannelID]
- return ok
- }
- // ResetChannelID resets all changes to the "channel_id" field.
- func (m *UsageLogMutation) ResetChannelID() {
- m.channel_id = nil
- m.addchannel_id = nil
- delete(m.clearedFields, usagelog.FieldChannelID)
- }
- // SetModelMappingChain sets the "model_mapping_chain" field.
- func (m *UsageLogMutation) SetModelMappingChain(s string) {
- m.model_mapping_chain = &s
- }
- // ModelMappingChain returns the value of the "model_mapping_chain" field in the mutation.
- func (m *UsageLogMutation) ModelMappingChain() (r string, exists bool) {
- v := m.model_mapping_chain
- if v == nil {
- return
- }
- return *v, true
- }
- // OldModelMappingChain returns the old "model_mapping_chain" field's value of the UsageLog entity.
- // If the UsageLog object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *UsageLogMutation) OldModelMappingChain(ctx context.Context) (v *string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldModelMappingChain is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldModelMappingChain requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldModelMappingChain: %w", err)
- }
- return oldValue.ModelMappingChain, nil
- }
- // ClearModelMappingChain clears the value of the "model_mapping_chain" field.
- func (m *UsageLogMutation) ClearModelMappingChain() {
- m.model_mapping_chain = nil
- m.clearedFields[usagelog.FieldModelMappingChain] = struct{}{}
- }
- // ModelMappingChainCleared returns if the "model_mapping_chain" field was cleared in this mutation.
- func (m *UsageLogMutation) ModelMappingChainCleared() bool {
- _, ok := m.clearedFields[usagelog.FieldModelMappingChain]
- return ok
- }
- // ResetModelMappingChain resets all changes to the "model_mapping_chain" field.
- func (m *UsageLogMutation) ResetModelMappingChain() {
- m.model_mapping_chain = nil
- delete(m.clearedFields, usagelog.FieldModelMappingChain)
- }
- // SetBillingTier sets the "billing_tier" field.
- func (m *UsageLogMutation) SetBillingTier(s string) {
- m.billing_tier = &s
- }
- // BillingTier returns the value of the "billing_tier" field in the mutation.
- func (m *UsageLogMutation) BillingTier() (r string, exists bool) {
- v := m.billing_tier
- if v == nil {
- return
- }
- return *v, true
- }
- // OldBillingTier returns the old "billing_tier" field's value of the UsageLog entity.
- // If the UsageLog object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *UsageLogMutation) OldBillingTier(ctx context.Context) (v *string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldBillingTier is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldBillingTier requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldBillingTier: %w", err)
- }
- return oldValue.BillingTier, nil
- }
- // ClearBillingTier clears the value of the "billing_tier" field.
- func (m *UsageLogMutation) ClearBillingTier() {
- m.billing_tier = nil
- m.clearedFields[usagelog.FieldBillingTier] = struct{}{}
- }
- // BillingTierCleared returns if the "billing_tier" field was cleared in this mutation.
- func (m *UsageLogMutation) BillingTierCleared() bool {
- _, ok := m.clearedFields[usagelog.FieldBillingTier]
- return ok
- }
- // ResetBillingTier resets all changes to the "billing_tier" field.
- func (m *UsageLogMutation) ResetBillingTier() {
- m.billing_tier = nil
- delete(m.clearedFields, usagelog.FieldBillingTier)
- }
- // SetBillingMode sets the "billing_mode" field.
- func (m *UsageLogMutation) SetBillingMode(s string) {
- m.billing_mode = &s
- }
- // BillingMode returns the value of the "billing_mode" field in the mutation.
- func (m *UsageLogMutation) BillingMode() (r string, exists bool) {
- v := m.billing_mode
- if v == nil {
- return
- }
- return *v, true
- }
- // OldBillingMode returns the old "billing_mode" field's value of the UsageLog entity.
- // If the UsageLog object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *UsageLogMutation) OldBillingMode(ctx context.Context) (v *string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldBillingMode is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldBillingMode requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldBillingMode: %w", err)
- }
- return oldValue.BillingMode, nil
- }
- // ClearBillingMode clears the value of the "billing_mode" field.
- func (m *UsageLogMutation) ClearBillingMode() {
- m.billing_mode = nil
- m.clearedFields[usagelog.FieldBillingMode] = struct{}{}
- }
- // BillingModeCleared returns if the "billing_mode" field was cleared in this mutation.
- func (m *UsageLogMutation) BillingModeCleared() bool {
- _, ok := m.clearedFields[usagelog.FieldBillingMode]
- return ok
- }
- // ResetBillingMode resets all changes to the "billing_mode" field.
- func (m *UsageLogMutation) ResetBillingMode() {
- m.billing_mode = nil
- delete(m.clearedFields, usagelog.FieldBillingMode)
- }
- // SetGroupID sets the "group_id" field.
- func (m *UsageLogMutation) SetGroupID(i int64) {
- m.group = &i
- }
- // GroupID returns the value of the "group_id" field in the mutation.
- func (m *UsageLogMutation) GroupID() (r int64, exists bool) {
- v := m.group
- if v == nil {
- return
- }
- return *v, true
- }
- // OldGroupID returns the old "group_id" field's value of the UsageLog entity.
- // If the UsageLog object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *UsageLogMutation) OldGroupID(ctx context.Context) (v *int64, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldGroupID is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldGroupID requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldGroupID: %w", err)
- }
- return oldValue.GroupID, nil
- }
- // ClearGroupID clears the value of the "group_id" field.
- func (m *UsageLogMutation) ClearGroupID() {
- m.group = nil
- m.clearedFields[usagelog.FieldGroupID] = struct{}{}
- }
- // GroupIDCleared returns if the "group_id" field was cleared in this mutation.
- func (m *UsageLogMutation) GroupIDCleared() bool {
- _, ok := m.clearedFields[usagelog.FieldGroupID]
- return ok
- }
- // ResetGroupID resets all changes to the "group_id" field.
- func (m *UsageLogMutation) ResetGroupID() {
- m.group = nil
- delete(m.clearedFields, usagelog.FieldGroupID)
- }
- // SetSubscriptionID sets the "subscription_id" field.
- func (m *UsageLogMutation) SetSubscriptionID(i int64) {
- m.subscription = &i
- }
- // SubscriptionID returns the value of the "subscription_id" field in the mutation.
- func (m *UsageLogMutation) SubscriptionID() (r int64, exists bool) {
- v := m.subscription
- if v == nil {
- return
- }
- return *v, true
- }
- // OldSubscriptionID returns the old "subscription_id" field's value of the UsageLog entity.
- // If the UsageLog object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *UsageLogMutation) OldSubscriptionID(ctx context.Context) (v *int64, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldSubscriptionID is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldSubscriptionID requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldSubscriptionID: %w", err)
- }
- return oldValue.SubscriptionID, nil
- }
- // ClearSubscriptionID clears the value of the "subscription_id" field.
- func (m *UsageLogMutation) ClearSubscriptionID() {
- m.subscription = nil
- m.clearedFields[usagelog.FieldSubscriptionID] = struct{}{}
- }
- // SubscriptionIDCleared returns if the "subscription_id" field was cleared in this mutation.
- func (m *UsageLogMutation) SubscriptionIDCleared() bool {
- _, ok := m.clearedFields[usagelog.FieldSubscriptionID]
- return ok
- }
- // ResetSubscriptionID resets all changes to the "subscription_id" field.
- func (m *UsageLogMutation) ResetSubscriptionID() {
- m.subscription = nil
- delete(m.clearedFields, usagelog.FieldSubscriptionID)
- }
- // SetInputTokens sets the "input_tokens" field.
- func (m *UsageLogMutation) SetInputTokens(i int) {
- m.input_tokens = &i
- m.addinput_tokens = nil
- }
- // InputTokens returns the value of the "input_tokens" field in the mutation.
- func (m *UsageLogMutation) InputTokens() (r int, exists bool) {
- v := m.input_tokens
- if v == nil {
- return
- }
- return *v, true
- }
- // OldInputTokens returns the old "input_tokens" field's value of the UsageLog entity.
- // If the UsageLog object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *UsageLogMutation) OldInputTokens(ctx context.Context) (v int, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldInputTokens is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldInputTokens requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldInputTokens: %w", err)
- }
- return oldValue.InputTokens, nil
- }
- // AddInputTokens adds i to the "input_tokens" field.
- func (m *UsageLogMutation) AddInputTokens(i int) {
- if m.addinput_tokens != nil {
- *m.addinput_tokens += i
- } else {
- m.addinput_tokens = &i
- }
- }
- // AddedInputTokens returns the value that was added to the "input_tokens" field in this mutation.
- func (m *UsageLogMutation) AddedInputTokens() (r int, exists bool) {
- v := m.addinput_tokens
- if v == nil {
- return
- }
- return *v, true
- }
- // ResetInputTokens resets all changes to the "input_tokens" field.
- func (m *UsageLogMutation) ResetInputTokens() {
- m.input_tokens = nil
- m.addinput_tokens = nil
- }
- // SetOutputTokens sets the "output_tokens" field.
- func (m *UsageLogMutation) SetOutputTokens(i int) {
- m.output_tokens = &i
- m.addoutput_tokens = nil
- }
- // OutputTokens returns the value of the "output_tokens" field in the mutation.
- func (m *UsageLogMutation) OutputTokens() (r int, exists bool) {
- v := m.output_tokens
- if v == nil {
- return
- }
- return *v, true
- }
- // OldOutputTokens returns the old "output_tokens" field's value of the UsageLog entity.
- // If the UsageLog object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *UsageLogMutation) OldOutputTokens(ctx context.Context) (v int, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldOutputTokens is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldOutputTokens requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldOutputTokens: %w", err)
- }
- return oldValue.OutputTokens, nil
- }
- // AddOutputTokens adds i to the "output_tokens" field.
- func (m *UsageLogMutation) AddOutputTokens(i int) {
- if m.addoutput_tokens != nil {
- *m.addoutput_tokens += i
- } else {
- m.addoutput_tokens = &i
- }
- }
- // AddedOutputTokens returns the value that was added to the "output_tokens" field in this mutation.
- func (m *UsageLogMutation) AddedOutputTokens() (r int, exists bool) {
- v := m.addoutput_tokens
- if v == nil {
- return
- }
- return *v, true
- }
- // ResetOutputTokens resets all changes to the "output_tokens" field.
- func (m *UsageLogMutation) ResetOutputTokens() {
- m.output_tokens = nil
- m.addoutput_tokens = nil
- }
- // SetCacheCreationTokens sets the "cache_creation_tokens" field.
- func (m *UsageLogMutation) SetCacheCreationTokens(i int) {
- m.cache_creation_tokens = &i
- m.addcache_creation_tokens = nil
- }
- // CacheCreationTokens returns the value of the "cache_creation_tokens" field in the mutation.
- func (m *UsageLogMutation) CacheCreationTokens() (r int, exists bool) {
- v := m.cache_creation_tokens
- if v == nil {
- return
- }
- return *v, true
- }
- // OldCacheCreationTokens returns the old "cache_creation_tokens" field's value of the UsageLog entity.
- // If the UsageLog object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *UsageLogMutation) OldCacheCreationTokens(ctx context.Context) (v int, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldCacheCreationTokens is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldCacheCreationTokens requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldCacheCreationTokens: %w", err)
- }
- return oldValue.CacheCreationTokens, nil
- }
- // AddCacheCreationTokens adds i to the "cache_creation_tokens" field.
- func (m *UsageLogMutation) AddCacheCreationTokens(i int) {
- if m.addcache_creation_tokens != nil {
- *m.addcache_creation_tokens += i
- } else {
- m.addcache_creation_tokens = &i
- }
- }
- // AddedCacheCreationTokens returns the value that was added to the "cache_creation_tokens" field in this mutation.
- func (m *UsageLogMutation) AddedCacheCreationTokens() (r int, exists bool) {
- v := m.addcache_creation_tokens
- if v == nil {
- return
- }
- return *v, true
- }
- // ResetCacheCreationTokens resets all changes to the "cache_creation_tokens" field.
- func (m *UsageLogMutation) ResetCacheCreationTokens() {
- m.cache_creation_tokens = nil
- m.addcache_creation_tokens = nil
- }
- // SetCacheReadTokens sets the "cache_read_tokens" field.
- func (m *UsageLogMutation) SetCacheReadTokens(i int) {
- m.cache_read_tokens = &i
- m.addcache_read_tokens = nil
- }
- // CacheReadTokens returns the value of the "cache_read_tokens" field in the mutation.
- func (m *UsageLogMutation) CacheReadTokens() (r int, exists bool) {
- v := m.cache_read_tokens
- if v == nil {
- return
- }
- return *v, true
- }
- // OldCacheReadTokens returns the old "cache_read_tokens" field's value of the UsageLog entity.
- // If the UsageLog object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *UsageLogMutation) OldCacheReadTokens(ctx context.Context) (v int, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldCacheReadTokens is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldCacheReadTokens requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldCacheReadTokens: %w", err)
- }
- return oldValue.CacheReadTokens, nil
- }
- // AddCacheReadTokens adds i to the "cache_read_tokens" field.
- func (m *UsageLogMutation) AddCacheReadTokens(i int) {
- if m.addcache_read_tokens != nil {
- *m.addcache_read_tokens += i
- } else {
- m.addcache_read_tokens = &i
- }
- }
- // AddedCacheReadTokens returns the value that was added to the "cache_read_tokens" field in this mutation.
- func (m *UsageLogMutation) AddedCacheReadTokens() (r int, exists bool) {
- v := m.addcache_read_tokens
- if v == nil {
- return
- }
- return *v, true
- }
- // ResetCacheReadTokens resets all changes to the "cache_read_tokens" field.
- func (m *UsageLogMutation) ResetCacheReadTokens() {
- m.cache_read_tokens = nil
- m.addcache_read_tokens = nil
- }
- // SetCacheCreation5mTokens sets the "cache_creation_5m_tokens" field.
- func (m *UsageLogMutation) SetCacheCreation5mTokens(i int) {
- m.cache_creation_5m_tokens = &i
- m.addcache_creation_5m_tokens = nil
- }
- // CacheCreation5mTokens returns the value of the "cache_creation_5m_tokens" field in the mutation.
- func (m *UsageLogMutation) CacheCreation5mTokens() (r int, exists bool) {
- v := m.cache_creation_5m_tokens
- if v == nil {
- return
- }
- return *v, true
- }
- // OldCacheCreation5mTokens returns the old "cache_creation_5m_tokens" field's value of the UsageLog entity.
- // If the UsageLog object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *UsageLogMutation) OldCacheCreation5mTokens(ctx context.Context) (v int, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldCacheCreation5mTokens is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldCacheCreation5mTokens requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldCacheCreation5mTokens: %w", err)
- }
- return oldValue.CacheCreation5mTokens, nil
- }
- // AddCacheCreation5mTokens adds i to the "cache_creation_5m_tokens" field.
- func (m *UsageLogMutation) AddCacheCreation5mTokens(i int) {
- if m.addcache_creation_5m_tokens != nil {
- *m.addcache_creation_5m_tokens += i
- } else {
- m.addcache_creation_5m_tokens = &i
- }
- }
- // AddedCacheCreation5mTokens returns the value that was added to the "cache_creation_5m_tokens" field in this mutation.
- func (m *UsageLogMutation) AddedCacheCreation5mTokens() (r int, exists bool) {
- v := m.addcache_creation_5m_tokens
- if v == nil {
- return
- }
- return *v, true
- }
- // ResetCacheCreation5mTokens resets all changes to the "cache_creation_5m_tokens" field.
- func (m *UsageLogMutation) ResetCacheCreation5mTokens() {
- m.cache_creation_5m_tokens = nil
- m.addcache_creation_5m_tokens = nil
- }
- // SetCacheCreation1hTokens sets the "cache_creation_1h_tokens" field.
- func (m *UsageLogMutation) SetCacheCreation1hTokens(i int) {
- m.cache_creation_1h_tokens = &i
- m.addcache_creation_1h_tokens = nil
- }
- // CacheCreation1hTokens returns the value of the "cache_creation_1h_tokens" field in the mutation.
- func (m *UsageLogMutation) CacheCreation1hTokens() (r int, exists bool) {
- v := m.cache_creation_1h_tokens
- if v == nil {
- return
- }
- return *v, true
- }
- // OldCacheCreation1hTokens returns the old "cache_creation_1h_tokens" field's value of the UsageLog entity.
- // If the UsageLog object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *UsageLogMutation) OldCacheCreation1hTokens(ctx context.Context) (v int, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldCacheCreation1hTokens is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldCacheCreation1hTokens requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldCacheCreation1hTokens: %w", err)
- }
- return oldValue.CacheCreation1hTokens, nil
- }
- // AddCacheCreation1hTokens adds i to the "cache_creation_1h_tokens" field.
- func (m *UsageLogMutation) AddCacheCreation1hTokens(i int) {
- if m.addcache_creation_1h_tokens != nil {
- *m.addcache_creation_1h_tokens += i
- } else {
- m.addcache_creation_1h_tokens = &i
- }
- }
- // AddedCacheCreation1hTokens returns the value that was added to the "cache_creation_1h_tokens" field in this mutation.
- func (m *UsageLogMutation) AddedCacheCreation1hTokens() (r int, exists bool) {
- v := m.addcache_creation_1h_tokens
- if v == nil {
- return
- }
- return *v, true
- }
- // ResetCacheCreation1hTokens resets all changes to the "cache_creation_1h_tokens" field.
- func (m *UsageLogMutation) ResetCacheCreation1hTokens() {
- m.cache_creation_1h_tokens = nil
- m.addcache_creation_1h_tokens = nil
- }
- // SetInputCost sets the "input_cost" field.
- func (m *UsageLogMutation) SetInputCost(f float64) {
- m.input_cost = &f
- m.addinput_cost = nil
- }
- // InputCost returns the value of the "input_cost" field in the mutation.
- func (m *UsageLogMutation) InputCost() (r float64, exists bool) {
- v := m.input_cost
- if v == nil {
- return
- }
- return *v, true
- }
- // OldInputCost returns the old "input_cost" field's value of the UsageLog entity.
- // If the UsageLog object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *UsageLogMutation) OldInputCost(ctx context.Context) (v float64, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldInputCost is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldInputCost requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldInputCost: %w", err)
- }
- return oldValue.InputCost, nil
- }
- // AddInputCost adds f to the "input_cost" field.
- func (m *UsageLogMutation) AddInputCost(f float64) {
- if m.addinput_cost != nil {
- *m.addinput_cost += f
- } else {
- m.addinput_cost = &f
- }
- }
- // AddedInputCost returns the value that was added to the "input_cost" field in this mutation.
- func (m *UsageLogMutation) AddedInputCost() (r float64, exists bool) {
- v := m.addinput_cost
- if v == nil {
- return
- }
- return *v, true
- }
- // ResetInputCost resets all changes to the "input_cost" field.
- func (m *UsageLogMutation) ResetInputCost() {
- m.input_cost = nil
- m.addinput_cost = nil
- }
- // SetOutputCost sets the "output_cost" field.
- func (m *UsageLogMutation) SetOutputCost(f float64) {
- m.output_cost = &f
- m.addoutput_cost = nil
- }
- // OutputCost returns the value of the "output_cost" field in the mutation.
- func (m *UsageLogMutation) OutputCost() (r float64, exists bool) {
- v := m.output_cost
- if v == nil {
- return
- }
- return *v, true
- }
- // OldOutputCost returns the old "output_cost" field's value of the UsageLog entity.
- // If the UsageLog object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *UsageLogMutation) OldOutputCost(ctx context.Context) (v float64, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldOutputCost is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldOutputCost requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldOutputCost: %w", err)
- }
- return oldValue.OutputCost, nil
- }
- // AddOutputCost adds f to the "output_cost" field.
- func (m *UsageLogMutation) AddOutputCost(f float64) {
- if m.addoutput_cost != nil {
- *m.addoutput_cost += f
- } else {
- m.addoutput_cost = &f
- }
- }
- // AddedOutputCost returns the value that was added to the "output_cost" field in this mutation.
- func (m *UsageLogMutation) AddedOutputCost() (r float64, exists bool) {
- v := m.addoutput_cost
- if v == nil {
- return
- }
- return *v, true
- }
- // ResetOutputCost resets all changes to the "output_cost" field.
- func (m *UsageLogMutation) ResetOutputCost() {
- m.output_cost = nil
- m.addoutput_cost = nil
- }
- // SetCacheCreationCost sets the "cache_creation_cost" field.
- func (m *UsageLogMutation) SetCacheCreationCost(f float64) {
- m.cache_creation_cost = &f
- m.addcache_creation_cost = nil
- }
- // CacheCreationCost returns the value of the "cache_creation_cost" field in the mutation.
- func (m *UsageLogMutation) CacheCreationCost() (r float64, exists bool) {
- v := m.cache_creation_cost
- if v == nil {
- return
- }
- return *v, true
- }
- // OldCacheCreationCost returns the old "cache_creation_cost" field's value of the UsageLog entity.
- // If the UsageLog object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *UsageLogMutation) OldCacheCreationCost(ctx context.Context) (v float64, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldCacheCreationCost is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldCacheCreationCost requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldCacheCreationCost: %w", err)
- }
- return oldValue.CacheCreationCost, nil
- }
- // AddCacheCreationCost adds f to the "cache_creation_cost" field.
- func (m *UsageLogMutation) AddCacheCreationCost(f float64) {
- if m.addcache_creation_cost != nil {
- *m.addcache_creation_cost += f
- } else {
- m.addcache_creation_cost = &f
- }
- }
- // AddedCacheCreationCost returns the value that was added to the "cache_creation_cost" field in this mutation.
- func (m *UsageLogMutation) AddedCacheCreationCost() (r float64, exists bool) {
- v := m.addcache_creation_cost
- if v == nil {
- return
- }
- return *v, true
- }
- // ResetCacheCreationCost resets all changes to the "cache_creation_cost" field.
- func (m *UsageLogMutation) ResetCacheCreationCost() {
- m.cache_creation_cost = nil
- m.addcache_creation_cost = nil
- }
- // SetCacheReadCost sets the "cache_read_cost" field.
- func (m *UsageLogMutation) SetCacheReadCost(f float64) {
- m.cache_read_cost = &f
- m.addcache_read_cost = nil
- }
- // CacheReadCost returns the value of the "cache_read_cost" field in the mutation.
- func (m *UsageLogMutation) CacheReadCost() (r float64, exists bool) {
- v := m.cache_read_cost
- if v == nil {
- return
- }
- return *v, true
- }
- // OldCacheReadCost returns the old "cache_read_cost" field's value of the UsageLog entity.
- // If the UsageLog object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *UsageLogMutation) OldCacheReadCost(ctx context.Context) (v float64, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldCacheReadCost is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldCacheReadCost requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldCacheReadCost: %w", err)
- }
- return oldValue.CacheReadCost, nil
- }
- // AddCacheReadCost adds f to the "cache_read_cost" field.
- func (m *UsageLogMutation) AddCacheReadCost(f float64) {
- if m.addcache_read_cost != nil {
- *m.addcache_read_cost += f
- } else {
- m.addcache_read_cost = &f
- }
- }
- // AddedCacheReadCost returns the value that was added to the "cache_read_cost" field in this mutation.
- func (m *UsageLogMutation) AddedCacheReadCost() (r float64, exists bool) {
- v := m.addcache_read_cost
- if v == nil {
- return
- }
- return *v, true
- }
- // ResetCacheReadCost resets all changes to the "cache_read_cost" field.
- func (m *UsageLogMutation) ResetCacheReadCost() {
- m.cache_read_cost = nil
- m.addcache_read_cost = nil
- }
- // SetTotalCost sets the "total_cost" field.
- func (m *UsageLogMutation) SetTotalCost(f float64) {
- m.total_cost = &f
- m.addtotal_cost = nil
- }
- // TotalCost returns the value of the "total_cost" field in the mutation.
- func (m *UsageLogMutation) TotalCost() (r float64, exists bool) {
- v := m.total_cost
- if v == nil {
- return
- }
- return *v, true
- }
- // OldTotalCost returns the old "total_cost" field's value of the UsageLog entity.
- // If the UsageLog object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *UsageLogMutation) OldTotalCost(ctx context.Context) (v float64, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldTotalCost is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldTotalCost requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldTotalCost: %w", err)
- }
- return oldValue.TotalCost, nil
- }
- // AddTotalCost adds f to the "total_cost" field.
- func (m *UsageLogMutation) AddTotalCost(f float64) {
- if m.addtotal_cost != nil {
- *m.addtotal_cost += f
- } else {
- m.addtotal_cost = &f
- }
- }
- // AddedTotalCost returns the value that was added to the "total_cost" field in this mutation.
- func (m *UsageLogMutation) AddedTotalCost() (r float64, exists bool) {
- v := m.addtotal_cost
- if v == nil {
- return
- }
- return *v, true
- }
- // ResetTotalCost resets all changes to the "total_cost" field.
- func (m *UsageLogMutation) ResetTotalCost() {
- m.total_cost = nil
- m.addtotal_cost = nil
- }
- // SetActualCost sets the "actual_cost" field.
- func (m *UsageLogMutation) SetActualCost(f float64) {
- m.actual_cost = &f
- m.addactual_cost = nil
- }
- // ActualCost returns the value of the "actual_cost" field in the mutation.
- func (m *UsageLogMutation) ActualCost() (r float64, exists bool) {
- v := m.actual_cost
- if v == nil {
- return
- }
- return *v, true
- }
- // OldActualCost returns the old "actual_cost" field's value of the UsageLog entity.
- // If the UsageLog object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *UsageLogMutation) OldActualCost(ctx context.Context) (v float64, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldActualCost is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldActualCost requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldActualCost: %w", err)
- }
- return oldValue.ActualCost, nil
- }
- // AddActualCost adds f to the "actual_cost" field.
- func (m *UsageLogMutation) AddActualCost(f float64) {
- if m.addactual_cost != nil {
- *m.addactual_cost += f
- } else {
- m.addactual_cost = &f
- }
- }
- // AddedActualCost returns the value that was added to the "actual_cost" field in this mutation.
- func (m *UsageLogMutation) AddedActualCost() (r float64, exists bool) {
- v := m.addactual_cost
- if v == nil {
- return
- }
- return *v, true
- }
- // ResetActualCost resets all changes to the "actual_cost" field.
- func (m *UsageLogMutation) ResetActualCost() {
- m.actual_cost = nil
- m.addactual_cost = nil
- }
- // SetRateMultiplier sets the "rate_multiplier" field.
- func (m *UsageLogMutation) SetRateMultiplier(f float64) {
- m.rate_multiplier = &f
- m.addrate_multiplier = nil
- }
- // RateMultiplier returns the value of the "rate_multiplier" field in the mutation.
- func (m *UsageLogMutation) RateMultiplier() (r float64, exists bool) {
- v := m.rate_multiplier
- if v == nil {
- return
- }
- return *v, true
- }
- // OldRateMultiplier returns the old "rate_multiplier" field's value of the UsageLog entity.
- // If the UsageLog object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *UsageLogMutation) OldRateMultiplier(ctx context.Context) (v float64, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldRateMultiplier is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldRateMultiplier requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldRateMultiplier: %w", err)
- }
- return oldValue.RateMultiplier, nil
- }
- // AddRateMultiplier adds f to the "rate_multiplier" field.
- func (m *UsageLogMutation) AddRateMultiplier(f float64) {
- if m.addrate_multiplier != nil {
- *m.addrate_multiplier += f
- } else {
- m.addrate_multiplier = &f
- }
- }
- // AddedRateMultiplier returns the value that was added to the "rate_multiplier" field in this mutation.
- func (m *UsageLogMutation) AddedRateMultiplier() (r float64, exists bool) {
- v := m.addrate_multiplier
- if v == nil {
- return
- }
- return *v, true
- }
- // ResetRateMultiplier resets all changes to the "rate_multiplier" field.
- func (m *UsageLogMutation) ResetRateMultiplier() {
- m.rate_multiplier = nil
- m.addrate_multiplier = nil
- }
- // SetLongContextBillingApplied sets the "long_context_billing_applied" field.
- func (m *UsageLogMutation) SetLongContextBillingApplied(b bool) {
- m.long_context_billing_applied = &b
- }
- // LongContextBillingApplied returns the value of the "long_context_billing_applied" field in the mutation.
- func (m *UsageLogMutation) LongContextBillingApplied() (r bool, exists bool) {
- v := m.long_context_billing_applied
- if v == nil {
- return
- }
- return *v, true
- }
- // OldLongContextBillingApplied returns the old "long_context_billing_applied" field's value of the UsageLog entity.
- // If the UsageLog object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *UsageLogMutation) OldLongContextBillingApplied(ctx context.Context) (v bool, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldLongContextBillingApplied is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldLongContextBillingApplied requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldLongContextBillingApplied: %w", err)
- }
- return oldValue.LongContextBillingApplied, nil
- }
- // ResetLongContextBillingApplied resets all changes to the "long_context_billing_applied" field.
- func (m *UsageLogMutation) ResetLongContextBillingApplied() {
- m.long_context_billing_applied = nil
- }
- // SetAccountRateMultiplier sets the "account_rate_multiplier" field.
- func (m *UsageLogMutation) SetAccountRateMultiplier(f float64) {
- m.account_rate_multiplier = &f
- m.addaccount_rate_multiplier = nil
- }
- // AccountRateMultiplier returns the value of the "account_rate_multiplier" field in the mutation.
- func (m *UsageLogMutation) AccountRateMultiplier() (r float64, exists bool) {
- v := m.account_rate_multiplier
- if v == nil {
- return
- }
- return *v, true
- }
- // OldAccountRateMultiplier returns the old "account_rate_multiplier" field's value of the UsageLog entity.
- // If the UsageLog object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *UsageLogMutation) OldAccountRateMultiplier(ctx context.Context) (v *float64, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldAccountRateMultiplier is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldAccountRateMultiplier requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldAccountRateMultiplier: %w", err)
- }
- return oldValue.AccountRateMultiplier, nil
- }
- // AddAccountRateMultiplier adds f to the "account_rate_multiplier" field.
- func (m *UsageLogMutation) AddAccountRateMultiplier(f float64) {
- if m.addaccount_rate_multiplier != nil {
- *m.addaccount_rate_multiplier += f
- } else {
- m.addaccount_rate_multiplier = &f
- }
- }
- // AddedAccountRateMultiplier returns the value that was added to the "account_rate_multiplier" field in this mutation.
- func (m *UsageLogMutation) AddedAccountRateMultiplier() (r float64, exists bool) {
- v := m.addaccount_rate_multiplier
- if v == nil {
- return
- }
- return *v, true
- }
- // ClearAccountRateMultiplier clears the value of the "account_rate_multiplier" field.
- func (m *UsageLogMutation) ClearAccountRateMultiplier() {
- m.account_rate_multiplier = nil
- m.addaccount_rate_multiplier = nil
- m.clearedFields[usagelog.FieldAccountRateMultiplier] = struct{}{}
- }
- // AccountRateMultiplierCleared returns if the "account_rate_multiplier" field was cleared in this mutation.
- func (m *UsageLogMutation) AccountRateMultiplierCleared() bool {
- _, ok := m.clearedFields[usagelog.FieldAccountRateMultiplier]
- return ok
- }
- // ResetAccountRateMultiplier resets all changes to the "account_rate_multiplier" field.
- func (m *UsageLogMutation) ResetAccountRateMultiplier() {
- m.account_rate_multiplier = nil
- m.addaccount_rate_multiplier = nil
- delete(m.clearedFields, usagelog.FieldAccountRateMultiplier)
- }
- // SetBillingType sets the "billing_type" field.
- func (m *UsageLogMutation) SetBillingType(i int8) {
- m.billing_type = &i
- m.addbilling_type = nil
- }
- // BillingType returns the value of the "billing_type" field in the mutation.
- func (m *UsageLogMutation) BillingType() (r int8, exists bool) {
- v := m.billing_type
- if v == nil {
- return
- }
- return *v, true
- }
- // OldBillingType returns the old "billing_type" field's value of the UsageLog entity.
- // If the UsageLog object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *UsageLogMutation) OldBillingType(ctx context.Context) (v int8, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldBillingType is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldBillingType requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldBillingType: %w", err)
- }
- return oldValue.BillingType, nil
- }
- // AddBillingType adds i to the "billing_type" field.
- func (m *UsageLogMutation) AddBillingType(i int8) {
- if m.addbilling_type != nil {
- *m.addbilling_type += i
- } else {
- m.addbilling_type = &i
- }
- }
- // AddedBillingType returns the value that was added to the "billing_type" field in this mutation.
- func (m *UsageLogMutation) AddedBillingType() (r int8, exists bool) {
- v := m.addbilling_type
- if v == nil {
- return
- }
- return *v, true
- }
- // ResetBillingType resets all changes to the "billing_type" field.
- func (m *UsageLogMutation) ResetBillingType() {
- m.billing_type = nil
- m.addbilling_type = nil
- }
- // SetStream sets the "stream" field.
- func (m *UsageLogMutation) SetStream(b bool) {
- m.stream = &b
- }
- // Stream returns the value of the "stream" field in the mutation.
- func (m *UsageLogMutation) Stream() (r bool, exists bool) {
- v := m.stream
- if v == nil {
- return
- }
- return *v, true
- }
- // OldStream returns the old "stream" field's value of the UsageLog entity.
- // If the UsageLog object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *UsageLogMutation) OldStream(ctx context.Context) (v bool, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldStream is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldStream requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldStream: %w", err)
- }
- return oldValue.Stream, nil
- }
- // ResetStream resets all changes to the "stream" field.
- func (m *UsageLogMutation) ResetStream() {
- m.stream = nil
- }
- // SetDurationMs sets the "duration_ms" field.
- func (m *UsageLogMutation) SetDurationMs(i int) {
- m.duration_ms = &i
- m.addduration_ms = nil
- }
- // DurationMs returns the value of the "duration_ms" field in the mutation.
- func (m *UsageLogMutation) DurationMs() (r int, exists bool) {
- v := m.duration_ms
- if v == nil {
- return
- }
- return *v, true
- }
- // OldDurationMs returns the old "duration_ms" field's value of the UsageLog entity.
- // If the UsageLog object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *UsageLogMutation) OldDurationMs(ctx context.Context) (v *int, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldDurationMs is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldDurationMs requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldDurationMs: %w", err)
- }
- return oldValue.DurationMs, nil
- }
- // AddDurationMs adds i to the "duration_ms" field.
- func (m *UsageLogMutation) AddDurationMs(i int) {
- if m.addduration_ms != nil {
- *m.addduration_ms += i
- } else {
- m.addduration_ms = &i
- }
- }
- // AddedDurationMs returns the value that was added to the "duration_ms" field in this mutation.
- func (m *UsageLogMutation) AddedDurationMs() (r int, exists bool) {
- v := m.addduration_ms
- if v == nil {
- return
- }
- return *v, true
- }
- // ClearDurationMs clears the value of the "duration_ms" field.
- func (m *UsageLogMutation) ClearDurationMs() {
- m.duration_ms = nil
- m.addduration_ms = nil
- m.clearedFields[usagelog.FieldDurationMs] = struct{}{}
- }
- // DurationMsCleared returns if the "duration_ms" field was cleared in this mutation.
- func (m *UsageLogMutation) DurationMsCleared() bool {
- _, ok := m.clearedFields[usagelog.FieldDurationMs]
- return ok
- }
- // ResetDurationMs resets all changes to the "duration_ms" field.
- func (m *UsageLogMutation) ResetDurationMs() {
- m.duration_ms = nil
- m.addduration_ms = nil
- delete(m.clearedFields, usagelog.FieldDurationMs)
- }
- // SetFirstTokenMs sets the "first_token_ms" field.
- func (m *UsageLogMutation) SetFirstTokenMs(i int) {
- m.first_token_ms = &i
- m.addfirst_token_ms = nil
- }
- // FirstTokenMs returns the value of the "first_token_ms" field in the mutation.
- func (m *UsageLogMutation) FirstTokenMs() (r int, exists bool) {
- v := m.first_token_ms
- if v == nil {
- return
- }
- return *v, true
- }
- // OldFirstTokenMs returns the old "first_token_ms" field's value of the UsageLog entity.
- // If the UsageLog object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *UsageLogMutation) OldFirstTokenMs(ctx context.Context) (v *int, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldFirstTokenMs is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldFirstTokenMs requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldFirstTokenMs: %w", err)
- }
- return oldValue.FirstTokenMs, nil
- }
- // AddFirstTokenMs adds i to the "first_token_ms" field.
- func (m *UsageLogMutation) AddFirstTokenMs(i int) {
- if m.addfirst_token_ms != nil {
- *m.addfirst_token_ms += i
- } else {
- m.addfirst_token_ms = &i
- }
- }
- // AddedFirstTokenMs returns the value that was added to the "first_token_ms" field in this mutation.
- func (m *UsageLogMutation) AddedFirstTokenMs() (r int, exists bool) {
- v := m.addfirst_token_ms
- if v == nil {
- return
- }
- return *v, true
- }
- // ClearFirstTokenMs clears the value of the "first_token_ms" field.
- func (m *UsageLogMutation) ClearFirstTokenMs() {
- m.first_token_ms = nil
- m.addfirst_token_ms = nil
- m.clearedFields[usagelog.FieldFirstTokenMs] = struct{}{}
- }
- // FirstTokenMsCleared returns if the "first_token_ms" field was cleared in this mutation.
- func (m *UsageLogMutation) FirstTokenMsCleared() bool {
- _, ok := m.clearedFields[usagelog.FieldFirstTokenMs]
- return ok
- }
- // ResetFirstTokenMs resets all changes to the "first_token_ms" field.
- func (m *UsageLogMutation) ResetFirstTokenMs() {
- m.first_token_ms = nil
- m.addfirst_token_ms = nil
- delete(m.clearedFields, usagelog.FieldFirstTokenMs)
- }
- // SetUserAgent sets the "user_agent" field.
- func (m *UsageLogMutation) SetUserAgent(s string) {
- m.user_agent = &s
- }
- // UserAgent returns the value of the "user_agent" field in the mutation.
- func (m *UsageLogMutation) UserAgent() (r string, exists bool) {
- v := m.user_agent
- if v == nil {
- return
- }
- return *v, true
- }
- // OldUserAgent returns the old "user_agent" field's value of the UsageLog entity.
- // If the UsageLog object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *UsageLogMutation) OldUserAgent(ctx context.Context) (v *string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldUserAgent is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldUserAgent requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldUserAgent: %w", err)
- }
- return oldValue.UserAgent, nil
- }
- // ClearUserAgent clears the value of the "user_agent" field.
- func (m *UsageLogMutation) ClearUserAgent() {
- m.user_agent = nil
- m.clearedFields[usagelog.FieldUserAgent] = struct{}{}
- }
- // UserAgentCleared returns if the "user_agent" field was cleared in this mutation.
- func (m *UsageLogMutation) UserAgentCleared() bool {
- _, ok := m.clearedFields[usagelog.FieldUserAgent]
- return ok
- }
- // ResetUserAgent resets all changes to the "user_agent" field.
- func (m *UsageLogMutation) ResetUserAgent() {
- m.user_agent = nil
- delete(m.clearedFields, usagelog.FieldUserAgent)
- }
- // SetIPAddress sets the "ip_address" field.
- func (m *UsageLogMutation) SetIPAddress(s string) {
- m.ip_address = &s
- }
- // IPAddress returns the value of the "ip_address" field in the mutation.
- func (m *UsageLogMutation) IPAddress() (r string, exists bool) {
- v := m.ip_address
- if v == nil {
- return
- }
- return *v, true
- }
- // OldIPAddress returns the old "ip_address" field's value of the UsageLog entity.
- // If the UsageLog object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *UsageLogMutation) OldIPAddress(ctx context.Context) (v *string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldIPAddress is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldIPAddress requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldIPAddress: %w", err)
- }
- return oldValue.IPAddress, nil
- }
- // ClearIPAddress clears the value of the "ip_address" field.
- func (m *UsageLogMutation) ClearIPAddress() {
- m.ip_address = nil
- m.clearedFields[usagelog.FieldIPAddress] = struct{}{}
- }
- // IPAddressCleared returns if the "ip_address" field was cleared in this mutation.
- func (m *UsageLogMutation) IPAddressCleared() bool {
- _, ok := m.clearedFields[usagelog.FieldIPAddress]
- return ok
- }
- // ResetIPAddress resets all changes to the "ip_address" field.
- func (m *UsageLogMutation) ResetIPAddress() {
- m.ip_address = nil
- delete(m.clearedFields, usagelog.FieldIPAddress)
- }
- // SetImageCount sets the "image_count" field.
- func (m *UsageLogMutation) SetImageCount(i int) {
- m.image_count = &i
- m.addimage_count = nil
- }
- // ImageCount returns the value of the "image_count" field in the mutation.
- func (m *UsageLogMutation) ImageCount() (r int, exists bool) {
- v := m.image_count
- if v == nil {
- return
- }
- return *v, true
- }
- // OldImageCount returns the old "image_count" field's value of the UsageLog entity.
- // If the UsageLog object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *UsageLogMutation) OldImageCount(ctx context.Context) (v int, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldImageCount is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldImageCount requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldImageCount: %w", err)
- }
- return oldValue.ImageCount, nil
- }
- // AddImageCount adds i to the "image_count" field.
- func (m *UsageLogMutation) AddImageCount(i int) {
- if m.addimage_count != nil {
- *m.addimage_count += i
- } else {
- m.addimage_count = &i
- }
- }
- // AddedImageCount returns the value that was added to the "image_count" field in this mutation.
- func (m *UsageLogMutation) AddedImageCount() (r int, exists bool) {
- v := m.addimage_count
- if v == nil {
- return
- }
- return *v, true
- }
- // ResetImageCount resets all changes to the "image_count" field.
- func (m *UsageLogMutation) ResetImageCount() {
- m.image_count = nil
- m.addimage_count = nil
- }
- // SetImageSize sets the "image_size" field.
- func (m *UsageLogMutation) SetImageSize(s string) {
- m.image_size = &s
- }
- // ImageSize returns the value of the "image_size" field in the mutation.
- func (m *UsageLogMutation) ImageSize() (r string, exists bool) {
- v := m.image_size
- if v == nil {
- return
- }
- return *v, true
- }
- // OldImageSize returns the old "image_size" field's value of the UsageLog entity.
- // If the UsageLog object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *UsageLogMutation) OldImageSize(ctx context.Context) (v *string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldImageSize is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldImageSize requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldImageSize: %w", err)
- }
- return oldValue.ImageSize, nil
- }
- // ClearImageSize clears the value of the "image_size" field.
- func (m *UsageLogMutation) ClearImageSize() {
- m.image_size = nil
- m.clearedFields[usagelog.FieldImageSize] = struct{}{}
- }
- // ImageSizeCleared returns if the "image_size" field was cleared in this mutation.
- func (m *UsageLogMutation) ImageSizeCleared() bool {
- _, ok := m.clearedFields[usagelog.FieldImageSize]
- return ok
- }
- // ResetImageSize resets all changes to the "image_size" field.
- func (m *UsageLogMutation) ResetImageSize() {
- m.image_size = nil
- delete(m.clearedFields, usagelog.FieldImageSize)
- }
- // SetImageInputSize sets the "image_input_size" field.
- func (m *UsageLogMutation) SetImageInputSize(s string) {
- m.image_input_size = &s
- }
- // ImageInputSize returns the value of the "image_input_size" field in the mutation.
- func (m *UsageLogMutation) ImageInputSize() (r string, exists bool) {
- v := m.image_input_size
- if v == nil {
- return
- }
- return *v, true
- }
- // OldImageInputSize returns the old "image_input_size" field's value of the UsageLog entity.
- // If the UsageLog object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *UsageLogMutation) OldImageInputSize(ctx context.Context) (v *string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldImageInputSize is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldImageInputSize requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldImageInputSize: %w", err)
- }
- return oldValue.ImageInputSize, nil
- }
- // ClearImageInputSize clears the value of the "image_input_size" field.
- func (m *UsageLogMutation) ClearImageInputSize() {
- m.image_input_size = nil
- m.clearedFields[usagelog.FieldImageInputSize] = struct{}{}
- }
- // ImageInputSizeCleared returns if the "image_input_size" field was cleared in this mutation.
- func (m *UsageLogMutation) ImageInputSizeCleared() bool {
- _, ok := m.clearedFields[usagelog.FieldImageInputSize]
- return ok
- }
- // ResetImageInputSize resets all changes to the "image_input_size" field.
- func (m *UsageLogMutation) ResetImageInputSize() {
- m.image_input_size = nil
- delete(m.clearedFields, usagelog.FieldImageInputSize)
- }
- // SetImageOutputSize sets the "image_output_size" field.
- func (m *UsageLogMutation) SetImageOutputSize(s string) {
- m.image_output_size = &s
- }
- // ImageOutputSize returns the value of the "image_output_size" field in the mutation.
- func (m *UsageLogMutation) ImageOutputSize() (r string, exists bool) {
- v := m.image_output_size
- if v == nil {
- return
- }
- return *v, true
- }
- // OldImageOutputSize returns the old "image_output_size" field's value of the UsageLog entity.
- // If the UsageLog object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *UsageLogMutation) OldImageOutputSize(ctx context.Context) (v *string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldImageOutputSize is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldImageOutputSize requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldImageOutputSize: %w", err)
- }
- return oldValue.ImageOutputSize, nil
- }
- // ClearImageOutputSize clears the value of the "image_output_size" field.
- func (m *UsageLogMutation) ClearImageOutputSize() {
- m.image_output_size = nil
- m.clearedFields[usagelog.FieldImageOutputSize] = struct{}{}
- }
- // ImageOutputSizeCleared returns if the "image_output_size" field was cleared in this mutation.
- func (m *UsageLogMutation) ImageOutputSizeCleared() bool {
- _, ok := m.clearedFields[usagelog.FieldImageOutputSize]
- return ok
- }
- // ResetImageOutputSize resets all changes to the "image_output_size" field.
- func (m *UsageLogMutation) ResetImageOutputSize() {
- m.image_output_size = nil
- delete(m.clearedFields, usagelog.FieldImageOutputSize)
- }
- // SetImageSizeSource sets the "image_size_source" field.
- func (m *UsageLogMutation) SetImageSizeSource(s string) {
- m.image_size_source = &s
- }
- // ImageSizeSource returns the value of the "image_size_source" field in the mutation.
- func (m *UsageLogMutation) ImageSizeSource() (r string, exists bool) {
- v := m.image_size_source
- if v == nil {
- return
- }
- return *v, true
- }
- // OldImageSizeSource returns the old "image_size_source" field's value of the UsageLog entity.
- // If the UsageLog object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *UsageLogMutation) OldImageSizeSource(ctx context.Context) (v *string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldImageSizeSource is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldImageSizeSource requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldImageSizeSource: %w", err)
- }
- return oldValue.ImageSizeSource, nil
- }
- // ClearImageSizeSource clears the value of the "image_size_source" field.
- func (m *UsageLogMutation) ClearImageSizeSource() {
- m.image_size_source = nil
- m.clearedFields[usagelog.FieldImageSizeSource] = struct{}{}
- }
- // ImageSizeSourceCleared returns if the "image_size_source" field was cleared in this mutation.
- func (m *UsageLogMutation) ImageSizeSourceCleared() bool {
- _, ok := m.clearedFields[usagelog.FieldImageSizeSource]
- return ok
- }
- // ResetImageSizeSource resets all changes to the "image_size_source" field.
- func (m *UsageLogMutation) ResetImageSizeSource() {
- m.image_size_source = nil
- delete(m.clearedFields, usagelog.FieldImageSizeSource)
- }
- // SetImageSizeBreakdown sets the "image_size_breakdown" field.
- func (m *UsageLogMutation) SetImageSizeBreakdown(value map[string]int) {
- m.image_size_breakdown = &value
- }
- // ImageSizeBreakdown returns the value of the "image_size_breakdown" field in the mutation.
- func (m *UsageLogMutation) ImageSizeBreakdown() (r map[string]int, exists bool) {
- v := m.image_size_breakdown
- if v == nil {
- return
- }
- return *v, true
- }
- // OldImageSizeBreakdown returns the old "image_size_breakdown" field's value of the UsageLog entity.
- // If the UsageLog object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *UsageLogMutation) OldImageSizeBreakdown(ctx context.Context) (v map[string]int, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldImageSizeBreakdown is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldImageSizeBreakdown requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldImageSizeBreakdown: %w", err)
- }
- return oldValue.ImageSizeBreakdown, nil
- }
- // ClearImageSizeBreakdown clears the value of the "image_size_breakdown" field.
- func (m *UsageLogMutation) ClearImageSizeBreakdown() {
- m.image_size_breakdown = nil
- m.clearedFields[usagelog.FieldImageSizeBreakdown] = struct{}{}
- }
- // ImageSizeBreakdownCleared returns if the "image_size_breakdown" field was cleared in this mutation.
- func (m *UsageLogMutation) ImageSizeBreakdownCleared() bool {
- _, ok := m.clearedFields[usagelog.FieldImageSizeBreakdown]
- return ok
- }
- // ResetImageSizeBreakdown resets all changes to the "image_size_breakdown" field.
- func (m *UsageLogMutation) ResetImageSizeBreakdown() {
- m.image_size_breakdown = nil
- delete(m.clearedFields, usagelog.FieldImageSizeBreakdown)
- }
- // SetVideoCount sets the "video_count" field.
- func (m *UsageLogMutation) SetVideoCount(i int) {
- m.video_count = &i
- m.addvideo_count = nil
- }
- // VideoCount returns the value of the "video_count" field in the mutation.
- func (m *UsageLogMutation) VideoCount() (r int, exists bool) {
- v := m.video_count
- if v == nil {
- return
- }
- return *v, true
- }
- // OldVideoCount returns the old "video_count" field's value of the UsageLog entity.
- // If the UsageLog object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *UsageLogMutation) OldVideoCount(ctx context.Context) (v int, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldVideoCount is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldVideoCount requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldVideoCount: %w", err)
- }
- return oldValue.VideoCount, nil
- }
- // AddVideoCount adds i to the "video_count" field.
- func (m *UsageLogMutation) AddVideoCount(i int) {
- if m.addvideo_count != nil {
- *m.addvideo_count += i
- } else {
- m.addvideo_count = &i
- }
- }
- // AddedVideoCount returns the value that was added to the "video_count" field in this mutation.
- func (m *UsageLogMutation) AddedVideoCount() (r int, exists bool) {
- v := m.addvideo_count
- if v == nil {
- return
- }
- return *v, true
- }
- // ResetVideoCount resets all changes to the "video_count" field.
- func (m *UsageLogMutation) ResetVideoCount() {
- m.video_count = nil
- m.addvideo_count = nil
- }
- // SetVideoResolution sets the "video_resolution" field.
- func (m *UsageLogMutation) SetVideoResolution(s string) {
- m.video_resolution = &s
- }
- // VideoResolution returns the value of the "video_resolution" field in the mutation.
- func (m *UsageLogMutation) VideoResolution() (r string, exists bool) {
- v := m.video_resolution
- if v == nil {
- return
- }
- return *v, true
- }
- // OldVideoResolution returns the old "video_resolution" field's value of the UsageLog entity.
- // If the UsageLog object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *UsageLogMutation) OldVideoResolution(ctx context.Context) (v *string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldVideoResolution is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldVideoResolution requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldVideoResolution: %w", err)
- }
- return oldValue.VideoResolution, nil
- }
- // ClearVideoResolution clears the value of the "video_resolution" field.
- func (m *UsageLogMutation) ClearVideoResolution() {
- m.video_resolution = nil
- m.clearedFields[usagelog.FieldVideoResolution] = struct{}{}
- }
- // VideoResolutionCleared returns if the "video_resolution" field was cleared in this mutation.
- func (m *UsageLogMutation) VideoResolutionCleared() bool {
- _, ok := m.clearedFields[usagelog.FieldVideoResolution]
- return ok
- }
- // ResetVideoResolution resets all changes to the "video_resolution" field.
- func (m *UsageLogMutation) ResetVideoResolution() {
- m.video_resolution = nil
- delete(m.clearedFields, usagelog.FieldVideoResolution)
- }
- // SetVideoDurationSeconds sets the "video_duration_seconds" field.
- func (m *UsageLogMutation) SetVideoDurationSeconds(i int) {
- m.video_duration_seconds = &i
- m.addvideo_duration_seconds = nil
- }
- // VideoDurationSeconds returns the value of the "video_duration_seconds" field in the mutation.
- func (m *UsageLogMutation) VideoDurationSeconds() (r int, exists bool) {
- v := m.video_duration_seconds
- if v == nil {
- return
- }
- return *v, true
- }
- // OldVideoDurationSeconds returns the old "video_duration_seconds" field's value of the UsageLog entity.
- // If the UsageLog object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *UsageLogMutation) OldVideoDurationSeconds(ctx context.Context) (v *int, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldVideoDurationSeconds is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldVideoDurationSeconds requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldVideoDurationSeconds: %w", err)
- }
- return oldValue.VideoDurationSeconds, nil
- }
- // AddVideoDurationSeconds adds i to the "video_duration_seconds" field.
- func (m *UsageLogMutation) AddVideoDurationSeconds(i int) {
- if m.addvideo_duration_seconds != nil {
- *m.addvideo_duration_seconds += i
- } else {
- m.addvideo_duration_seconds = &i
- }
- }
- // AddedVideoDurationSeconds returns the value that was added to the "video_duration_seconds" field in this mutation.
- func (m *UsageLogMutation) AddedVideoDurationSeconds() (r int, exists bool) {
- v := m.addvideo_duration_seconds
- if v == nil {
- return
- }
- return *v, true
- }
- // ClearVideoDurationSeconds clears the value of the "video_duration_seconds" field.
- func (m *UsageLogMutation) ClearVideoDurationSeconds() {
- m.video_duration_seconds = nil
- m.addvideo_duration_seconds = nil
- m.clearedFields[usagelog.FieldVideoDurationSeconds] = struct{}{}
- }
- // VideoDurationSecondsCleared returns if the "video_duration_seconds" field was cleared in this mutation.
- func (m *UsageLogMutation) VideoDurationSecondsCleared() bool {
- _, ok := m.clearedFields[usagelog.FieldVideoDurationSeconds]
- return ok
- }
- // ResetVideoDurationSeconds resets all changes to the "video_duration_seconds" field.
- func (m *UsageLogMutation) ResetVideoDurationSeconds() {
- m.video_duration_seconds = nil
- m.addvideo_duration_seconds = nil
- delete(m.clearedFields, usagelog.FieldVideoDurationSeconds)
- }
- // SetCacheTTLOverridden sets the "cache_ttl_overridden" field.
- func (m *UsageLogMutation) SetCacheTTLOverridden(b bool) {
- m.cache_ttl_overridden = &b
- }
- // CacheTTLOverridden returns the value of the "cache_ttl_overridden" field in the mutation.
- func (m *UsageLogMutation) CacheTTLOverridden() (r bool, exists bool) {
- v := m.cache_ttl_overridden
- if v == nil {
- return
- }
- return *v, true
- }
- // OldCacheTTLOverridden returns the old "cache_ttl_overridden" field's value of the UsageLog entity.
- // If the UsageLog object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *UsageLogMutation) OldCacheTTLOverridden(ctx context.Context) (v bool, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldCacheTTLOverridden is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldCacheTTLOverridden requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldCacheTTLOverridden: %w", err)
- }
- return oldValue.CacheTTLOverridden, nil
- }
- // ResetCacheTTLOverridden resets all changes to the "cache_ttl_overridden" field.
- func (m *UsageLogMutation) ResetCacheTTLOverridden() {
- m.cache_ttl_overridden = nil
- }
- // SetCreatedAt sets the "created_at" field.
- func (m *UsageLogMutation) SetCreatedAt(t time.Time) {
- m.created_at = &t
- }
- // CreatedAt returns the value of the "created_at" field in the mutation.
- func (m *UsageLogMutation) CreatedAt() (r time.Time, exists bool) {
- v := m.created_at
- if v == nil {
- return
- }
- return *v, true
- }
- // OldCreatedAt returns the old "created_at" field's value of the UsageLog entity.
- // If the UsageLog object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *UsageLogMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldCreatedAt requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
- }
- return oldValue.CreatedAt, nil
- }
- // ResetCreatedAt resets all changes to the "created_at" field.
- func (m *UsageLogMutation) ResetCreatedAt() {
- m.created_at = nil
- }
- // ClearUser clears the "user" edge to the User entity.
- func (m *UsageLogMutation) ClearUser() {
- m.cleareduser = true
- m.clearedFields[usagelog.FieldUserID] = struct{}{}
- }
- // UserCleared reports if the "user" edge to the User entity was cleared.
- func (m *UsageLogMutation) UserCleared() bool {
- return m.cleareduser
- }
- // UserIDs returns the "user" edge IDs in the mutation.
- // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
- // UserID instead. It exists only for internal usage by the builders.
- func (m *UsageLogMutation) UserIDs() (ids []int64) {
- if id := m.user; id != nil {
- ids = append(ids, *id)
- }
- return
- }
- // ResetUser resets all changes to the "user" edge.
- func (m *UsageLogMutation) ResetUser() {
- m.user = nil
- m.cleareduser = false
- }
- // ClearAPIKey clears the "api_key" edge to the APIKey entity.
- func (m *UsageLogMutation) ClearAPIKey() {
- m.clearedapi_key = true
- m.clearedFields[usagelog.FieldAPIKeyID] = struct{}{}
- }
- // APIKeyCleared reports if the "api_key" edge to the APIKey entity was cleared.
- func (m *UsageLogMutation) APIKeyCleared() bool {
- return m.clearedapi_key
- }
- // APIKeyIDs returns the "api_key" edge IDs in the mutation.
- // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
- // APIKeyID instead. It exists only for internal usage by the builders.
- func (m *UsageLogMutation) APIKeyIDs() (ids []int64) {
- if id := m.api_key; id != nil {
- ids = append(ids, *id)
- }
- return
- }
- // ResetAPIKey resets all changes to the "api_key" edge.
- func (m *UsageLogMutation) ResetAPIKey() {
- m.api_key = nil
- m.clearedapi_key = false
- }
- // ClearAccount clears the "account" edge to the Account entity.
- func (m *UsageLogMutation) ClearAccount() {
- m.clearedaccount = true
- m.clearedFields[usagelog.FieldAccountID] = struct{}{}
- }
- // AccountCleared reports if the "account" edge to the Account entity was cleared.
- func (m *UsageLogMutation) AccountCleared() bool {
- return m.clearedaccount
- }
- // AccountIDs returns the "account" edge IDs in the mutation.
- // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
- // AccountID instead. It exists only for internal usage by the builders.
- func (m *UsageLogMutation) AccountIDs() (ids []int64) {
- if id := m.account; id != nil {
- ids = append(ids, *id)
- }
- return
- }
- // ResetAccount resets all changes to the "account" edge.
- func (m *UsageLogMutation) ResetAccount() {
- m.account = nil
- m.clearedaccount = false
- }
- // ClearGroup clears the "group" edge to the Group entity.
- func (m *UsageLogMutation) ClearGroup() {
- m.clearedgroup = true
- m.clearedFields[usagelog.FieldGroupID] = struct{}{}
- }
- // GroupCleared reports if the "group" edge to the Group entity was cleared.
- func (m *UsageLogMutation) GroupCleared() bool {
- return m.GroupIDCleared() || m.clearedgroup
- }
- // GroupIDs returns the "group" edge IDs in the mutation.
- // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
- // GroupID instead. It exists only for internal usage by the builders.
- func (m *UsageLogMutation) GroupIDs() (ids []int64) {
- if id := m.group; id != nil {
- ids = append(ids, *id)
- }
- return
- }
- // ResetGroup resets all changes to the "group" edge.
- func (m *UsageLogMutation) ResetGroup() {
- m.group = nil
- m.clearedgroup = false
- }
- // ClearSubscription clears the "subscription" edge to the UserSubscription entity.
- func (m *UsageLogMutation) ClearSubscription() {
- m.clearedsubscription = true
- m.clearedFields[usagelog.FieldSubscriptionID] = struct{}{}
- }
- // SubscriptionCleared reports if the "subscription" edge to the UserSubscription entity was cleared.
- func (m *UsageLogMutation) SubscriptionCleared() bool {
- return m.SubscriptionIDCleared() || m.clearedsubscription
- }
- // SubscriptionIDs returns the "subscription" edge IDs in the mutation.
- // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
- // SubscriptionID instead. It exists only for internal usage by the builders.
- func (m *UsageLogMutation) SubscriptionIDs() (ids []int64) {
- if id := m.subscription; id != nil {
- ids = append(ids, *id)
- }
- return
- }
- // ResetSubscription resets all changes to the "subscription" edge.
- func (m *UsageLogMutation) ResetSubscription() {
- m.subscription = nil
- m.clearedsubscription = false
- }
- // Where appends a list predicates to the UsageLogMutation builder.
- func (m *UsageLogMutation) Where(ps ...predicate.UsageLog) {
- m.predicates = append(m.predicates, ps...)
- }
- // WhereP appends storage-level predicates to the UsageLogMutation builder. Using this method,
- // users can use type-assertion to append predicates that do not depend on any generated package.
- func (m *UsageLogMutation) WhereP(ps ...func(*sql.Selector)) {
- p := make([]predicate.UsageLog, len(ps))
- for i := range ps {
- p[i] = ps[i]
- }
- m.Where(p...)
- }
- // Op returns the operation name.
- func (m *UsageLogMutation) Op() Op {
- return m.op
- }
- // SetOp allows setting the mutation operation.
- func (m *UsageLogMutation) SetOp(op Op) {
- m.op = op
- }
- // Type returns the node type of this mutation (UsageLog).
- func (m *UsageLogMutation) Type() string {
- return m.typ
- }
- // Fields returns all fields that were changed during this mutation. Note that in
- // order to get all numeric fields that were incremented/decremented, call
- // AddedFields().
- func (m *UsageLogMutation) Fields() []string {
- fields := make([]string, 0, 47)
- if m.user != nil {
- fields = append(fields, usagelog.FieldUserID)
- }
- if m.api_key != nil {
- fields = append(fields, usagelog.FieldAPIKeyID)
- }
- if m.account != nil {
- fields = append(fields, usagelog.FieldAccountID)
- }
- if m.request_id != nil {
- fields = append(fields, usagelog.FieldRequestID)
- }
- if m.model != nil {
- fields = append(fields, usagelog.FieldModel)
- }
- if m.requested_model != nil {
- fields = append(fields, usagelog.FieldRequestedModel)
- }
- if m.upstream_model != nil {
- fields = append(fields, usagelog.FieldUpstreamModel)
- }
- if m.upstream_response_model != nil {
- fields = append(fields, usagelog.FieldUpstreamResponseModel)
- }
- if m.upstream_model_mismatch != nil {
- fields = append(fields, usagelog.FieldUpstreamModelMismatch)
- }
- if m.channel_id != nil {
- fields = append(fields, usagelog.FieldChannelID)
- }
- if m.model_mapping_chain != nil {
- fields = append(fields, usagelog.FieldModelMappingChain)
- }
- if m.billing_tier != nil {
- fields = append(fields, usagelog.FieldBillingTier)
- }
- if m.billing_mode != nil {
- fields = append(fields, usagelog.FieldBillingMode)
- }
- if m.group != nil {
- fields = append(fields, usagelog.FieldGroupID)
- }
- if m.subscription != nil {
- fields = append(fields, usagelog.FieldSubscriptionID)
- }
- if m.input_tokens != nil {
- fields = append(fields, usagelog.FieldInputTokens)
- }
- if m.output_tokens != nil {
- fields = append(fields, usagelog.FieldOutputTokens)
- }
- if m.cache_creation_tokens != nil {
- fields = append(fields, usagelog.FieldCacheCreationTokens)
- }
- if m.cache_read_tokens != nil {
- fields = append(fields, usagelog.FieldCacheReadTokens)
- }
- if m.cache_creation_5m_tokens != nil {
- fields = append(fields, usagelog.FieldCacheCreation5mTokens)
- }
- if m.cache_creation_1h_tokens != nil {
- fields = append(fields, usagelog.FieldCacheCreation1hTokens)
- }
- if m.input_cost != nil {
- fields = append(fields, usagelog.FieldInputCost)
- }
- if m.output_cost != nil {
- fields = append(fields, usagelog.FieldOutputCost)
- }
- if m.cache_creation_cost != nil {
- fields = append(fields, usagelog.FieldCacheCreationCost)
- }
- if m.cache_read_cost != nil {
- fields = append(fields, usagelog.FieldCacheReadCost)
- }
- if m.total_cost != nil {
- fields = append(fields, usagelog.FieldTotalCost)
- }
- if m.actual_cost != nil {
- fields = append(fields, usagelog.FieldActualCost)
- }
- if m.rate_multiplier != nil {
- fields = append(fields, usagelog.FieldRateMultiplier)
- }
- if m.long_context_billing_applied != nil {
- fields = append(fields, usagelog.FieldLongContextBillingApplied)
- }
- if m.account_rate_multiplier != nil {
- fields = append(fields, usagelog.FieldAccountRateMultiplier)
- }
- if m.billing_type != nil {
- fields = append(fields, usagelog.FieldBillingType)
- }
- if m.stream != nil {
- fields = append(fields, usagelog.FieldStream)
- }
- if m.duration_ms != nil {
- fields = append(fields, usagelog.FieldDurationMs)
- }
- if m.first_token_ms != nil {
- fields = append(fields, usagelog.FieldFirstTokenMs)
- }
- if m.user_agent != nil {
- fields = append(fields, usagelog.FieldUserAgent)
- }
- if m.ip_address != nil {
- fields = append(fields, usagelog.FieldIPAddress)
- }
- if m.image_count != nil {
- fields = append(fields, usagelog.FieldImageCount)
- }
- if m.image_size != nil {
- fields = append(fields, usagelog.FieldImageSize)
- }
- if m.image_input_size != nil {
- fields = append(fields, usagelog.FieldImageInputSize)
- }
- if m.image_output_size != nil {
- fields = append(fields, usagelog.FieldImageOutputSize)
- }
- if m.image_size_source != nil {
- fields = append(fields, usagelog.FieldImageSizeSource)
- }
- if m.image_size_breakdown != nil {
- fields = append(fields, usagelog.FieldImageSizeBreakdown)
- }
- if m.video_count != nil {
- fields = append(fields, usagelog.FieldVideoCount)
- }
- if m.video_resolution != nil {
- fields = append(fields, usagelog.FieldVideoResolution)
- }
- if m.video_duration_seconds != nil {
- fields = append(fields, usagelog.FieldVideoDurationSeconds)
- }
- if m.cache_ttl_overridden != nil {
- fields = append(fields, usagelog.FieldCacheTTLOverridden)
- }
- if m.created_at != nil {
- fields = append(fields, usagelog.FieldCreatedAt)
- }
- return fields
- }
- // Field returns the value of a field with the given name. The second boolean
- // return value indicates that this field was not set, or was not defined in the
- // schema.
- func (m *UsageLogMutation) Field(name string) (ent.Value, bool) {
- switch name {
- case usagelog.FieldUserID:
- return m.UserID()
- case usagelog.FieldAPIKeyID:
- return m.APIKeyID()
- case usagelog.FieldAccountID:
- return m.AccountID()
- case usagelog.FieldRequestID:
- return m.RequestID()
- case usagelog.FieldModel:
- return m.Model()
- case usagelog.FieldRequestedModel:
- return m.RequestedModel()
- case usagelog.FieldUpstreamModel:
- return m.UpstreamModel()
- case usagelog.FieldUpstreamResponseModel:
- return m.UpstreamResponseModel()
- case usagelog.FieldUpstreamModelMismatch:
- return m.UpstreamModelMismatch()
- case usagelog.FieldChannelID:
- return m.ChannelID()
- case usagelog.FieldModelMappingChain:
- return m.ModelMappingChain()
- case usagelog.FieldBillingTier:
- return m.BillingTier()
- case usagelog.FieldBillingMode:
- return m.BillingMode()
- case usagelog.FieldGroupID:
- return m.GroupID()
- case usagelog.FieldSubscriptionID:
- return m.SubscriptionID()
- case usagelog.FieldInputTokens:
- return m.InputTokens()
- case usagelog.FieldOutputTokens:
- return m.OutputTokens()
- case usagelog.FieldCacheCreationTokens:
- return m.CacheCreationTokens()
- case usagelog.FieldCacheReadTokens:
- return m.CacheReadTokens()
- case usagelog.FieldCacheCreation5mTokens:
- return m.CacheCreation5mTokens()
- case usagelog.FieldCacheCreation1hTokens:
- return m.CacheCreation1hTokens()
- case usagelog.FieldInputCost:
- return m.InputCost()
- case usagelog.FieldOutputCost:
- return m.OutputCost()
- case usagelog.FieldCacheCreationCost:
- return m.CacheCreationCost()
- case usagelog.FieldCacheReadCost:
- return m.CacheReadCost()
- case usagelog.FieldTotalCost:
- return m.TotalCost()
- case usagelog.FieldActualCost:
- return m.ActualCost()
- case usagelog.FieldRateMultiplier:
- return m.RateMultiplier()
- case usagelog.FieldLongContextBillingApplied:
- return m.LongContextBillingApplied()
- case usagelog.FieldAccountRateMultiplier:
- return m.AccountRateMultiplier()
- case usagelog.FieldBillingType:
- return m.BillingType()
- case usagelog.FieldStream:
- return m.Stream()
- case usagelog.FieldDurationMs:
- return m.DurationMs()
- case usagelog.FieldFirstTokenMs:
- return m.FirstTokenMs()
- case usagelog.FieldUserAgent:
- return m.UserAgent()
- case usagelog.FieldIPAddress:
- return m.IPAddress()
- case usagelog.FieldImageCount:
- return m.ImageCount()
- case usagelog.FieldImageSize:
- return m.ImageSize()
- case usagelog.FieldImageInputSize:
- return m.ImageInputSize()
- case usagelog.FieldImageOutputSize:
- return m.ImageOutputSize()
- case usagelog.FieldImageSizeSource:
- return m.ImageSizeSource()
- case usagelog.FieldImageSizeBreakdown:
- return m.ImageSizeBreakdown()
- case usagelog.FieldVideoCount:
- return m.VideoCount()
- case usagelog.FieldVideoResolution:
- return m.VideoResolution()
- case usagelog.FieldVideoDurationSeconds:
- return m.VideoDurationSeconds()
- case usagelog.FieldCacheTTLOverridden:
- return m.CacheTTLOverridden()
- case usagelog.FieldCreatedAt:
- return m.CreatedAt()
- }
- return nil, false
- }
- // OldField returns the old value of the field from the database. An error is
- // returned if the mutation operation is not UpdateOne, or the query to the
- // database failed.
- func (m *UsageLogMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
- switch name {
- case usagelog.FieldUserID:
- return m.OldUserID(ctx)
- case usagelog.FieldAPIKeyID:
- return m.OldAPIKeyID(ctx)
- case usagelog.FieldAccountID:
- return m.OldAccountID(ctx)
- case usagelog.FieldRequestID:
- return m.OldRequestID(ctx)
- case usagelog.FieldModel:
- return m.OldModel(ctx)
- case usagelog.FieldRequestedModel:
- return m.OldRequestedModel(ctx)
- case usagelog.FieldUpstreamModel:
- return m.OldUpstreamModel(ctx)
- case usagelog.FieldUpstreamResponseModel:
- return m.OldUpstreamResponseModel(ctx)
- case usagelog.FieldUpstreamModelMismatch:
- return m.OldUpstreamModelMismatch(ctx)
- case usagelog.FieldChannelID:
- return m.OldChannelID(ctx)
- case usagelog.FieldModelMappingChain:
- return m.OldModelMappingChain(ctx)
- case usagelog.FieldBillingTier:
- return m.OldBillingTier(ctx)
- case usagelog.FieldBillingMode:
- return m.OldBillingMode(ctx)
- case usagelog.FieldGroupID:
- return m.OldGroupID(ctx)
- case usagelog.FieldSubscriptionID:
- return m.OldSubscriptionID(ctx)
- case usagelog.FieldInputTokens:
- return m.OldInputTokens(ctx)
- case usagelog.FieldOutputTokens:
- return m.OldOutputTokens(ctx)
- case usagelog.FieldCacheCreationTokens:
- return m.OldCacheCreationTokens(ctx)
- case usagelog.FieldCacheReadTokens:
- return m.OldCacheReadTokens(ctx)
- case usagelog.FieldCacheCreation5mTokens:
- return m.OldCacheCreation5mTokens(ctx)
- case usagelog.FieldCacheCreation1hTokens:
- return m.OldCacheCreation1hTokens(ctx)
- case usagelog.FieldInputCost:
- return m.OldInputCost(ctx)
- case usagelog.FieldOutputCost:
- return m.OldOutputCost(ctx)
- case usagelog.FieldCacheCreationCost:
- return m.OldCacheCreationCost(ctx)
- case usagelog.FieldCacheReadCost:
- return m.OldCacheReadCost(ctx)
- case usagelog.FieldTotalCost:
- return m.OldTotalCost(ctx)
- case usagelog.FieldActualCost:
- return m.OldActualCost(ctx)
- case usagelog.FieldRateMultiplier:
- return m.OldRateMultiplier(ctx)
- case usagelog.FieldLongContextBillingApplied:
- return m.OldLongContextBillingApplied(ctx)
- case usagelog.FieldAccountRateMultiplier:
- return m.OldAccountRateMultiplier(ctx)
- case usagelog.FieldBillingType:
- return m.OldBillingType(ctx)
- case usagelog.FieldStream:
- return m.OldStream(ctx)
- case usagelog.FieldDurationMs:
- return m.OldDurationMs(ctx)
- case usagelog.FieldFirstTokenMs:
- return m.OldFirstTokenMs(ctx)
- case usagelog.FieldUserAgent:
- return m.OldUserAgent(ctx)
- case usagelog.FieldIPAddress:
- return m.OldIPAddress(ctx)
- case usagelog.FieldImageCount:
- return m.OldImageCount(ctx)
- case usagelog.FieldImageSize:
- return m.OldImageSize(ctx)
- case usagelog.FieldImageInputSize:
- return m.OldImageInputSize(ctx)
- case usagelog.FieldImageOutputSize:
- return m.OldImageOutputSize(ctx)
- case usagelog.FieldImageSizeSource:
- return m.OldImageSizeSource(ctx)
- case usagelog.FieldImageSizeBreakdown:
- return m.OldImageSizeBreakdown(ctx)
- case usagelog.FieldVideoCount:
- return m.OldVideoCount(ctx)
- case usagelog.FieldVideoResolution:
- return m.OldVideoResolution(ctx)
- case usagelog.FieldVideoDurationSeconds:
- return m.OldVideoDurationSeconds(ctx)
- case usagelog.FieldCacheTTLOverridden:
- return m.OldCacheTTLOverridden(ctx)
- case usagelog.FieldCreatedAt:
- return m.OldCreatedAt(ctx)
- }
- return nil, fmt.Errorf("unknown UsageLog field %s", name)
- }
- // SetField sets the value of a field with the given name. It returns an error if
- // the field is not defined in the schema, or if the type mismatched the field
- // type.
- func (m *UsageLogMutation) SetField(name string, value ent.Value) error {
- switch name {
- case usagelog.FieldUserID:
- v, ok := value.(int64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetUserID(v)
- return nil
- case usagelog.FieldAPIKeyID:
- v, ok := value.(int64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetAPIKeyID(v)
- return nil
- case usagelog.FieldAccountID:
- v, ok := value.(int64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetAccountID(v)
- return nil
- case usagelog.FieldRequestID:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetRequestID(v)
- return nil
- case usagelog.FieldModel:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetModel(v)
- return nil
- case usagelog.FieldRequestedModel:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetRequestedModel(v)
- return nil
- case usagelog.FieldUpstreamModel:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetUpstreamModel(v)
- return nil
- case usagelog.FieldUpstreamResponseModel:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetUpstreamResponseModel(v)
- return nil
- case usagelog.FieldUpstreamModelMismatch:
- v, ok := value.(bool)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetUpstreamModelMismatch(v)
- return nil
- case usagelog.FieldChannelID:
- v, ok := value.(int64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetChannelID(v)
- return nil
- case usagelog.FieldModelMappingChain:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetModelMappingChain(v)
- return nil
- case usagelog.FieldBillingTier:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetBillingTier(v)
- return nil
- case usagelog.FieldBillingMode:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetBillingMode(v)
- return nil
- case usagelog.FieldGroupID:
- v, ok := value.(int64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetGroupID(v)
- return nil
- case usagelog.FieldSubscriptionID:
- v, ok := value.(int64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetSubscriptionID(v)
- return nil
- case usagelog.FieldInputTokens:
- v, ok := value.(int)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetInputTokens(v)
- return nil
- case usagelog.FieldOutputTokens:
- v, ok := value.(int)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetOutputTokens(v)
- return nil
- case usagelog.FieldCacheCreationTokens:
- v, ok := value.(int)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetCacheCreationTokens(v)
- return nil
- case usagelog.FieldCacheReadTokens:
- v, ok := value.(int)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetCacheReadTokens(v)
- return nil
- case usagelog.FieldCacheCreation5mTokens:
- v, ok := value.(int)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetCacheCreation5mTokens(v)
- return nil
- case usagelog.FieldCacheCreation1hTokens:
- v, ok := value.(int)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetCacheCreation1hTokens(v)
- return nil
- case usagelog.FieldInputCost:
- v, ok := value.(float64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetInputCost(v)
- return nil
- case usagelog.FieldOutputCost:
- v, ok := value.(float64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetOutputCost(v)
- return nil
- case usagelog.FieldCacheCreationCost:
- v, ok := value.(float64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetCacheCreationCost(v)
- return nil
- case usagelog.FieldCacheReadCost:
- v, ok := value.(float64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetCacheReadCost(v)
- return nil
- case usagelog.FieldTotalCost:
- v, ok := value.(float64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetTotalCost(v)
- return nil
- case usagelog.FieldActualCost:
- v, ok := value.(float64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetActualCost(v)
- return nil
- case usagelog.FieldRateMultiplier:
- v, ok := value.(float64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetRateMultiplier(v)
- return nil
- case usagelog.FieldLongContextBillingApplied:
- v, ok := value.(bool)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetLongContextBillingApplied(v)
- return nil
- case usagelog.FieldAccountRateMultiplier:
- v, ok := value.(float64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetAccountRateMultiplier(v)
- return nil
- case usagelog.FieldBillingType:
- v, ok := value.(int8)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetBillingType(v)
- return nil
- case usagelog.FieldStream:
- v, ok := value.(bool)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetStream(v)
- return nil
- case usagelog.FieldDurationMs:
- v, ok := value.(int)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetDurationMs(v)
- return nil
- case usagelog.FieldFirstTokenMs:
- v, ok := value.(int)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetFirstTokenMs(v)
- return nil
- case usagelog.FieldUserAgent:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetUserAgent(v)
- return nil
- case usagelog.FieldIPAddress:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetIPAddress(v)
- return nil
- case usagelog.FieldImageCount:
- v, ok := value.(int)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetImageCount(v)
- return nil
- case usagelog.FieldImageSize:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetImageSize(v)
- return nil
- case usagelog.FieldImageInputSize:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetImageInputSize(v)
- return nil
- case usagelog.FieldImageOutputSize:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetImageOutputSize(v)
- return nil
- case usagelog.FieldImageSizeSource:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetImageSizeSource(v)
- return nil
- case usagelog.FieldImageSizeBreakdown:
- v, ok := value.(map[string]int)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetImageSizeBreakdown(v)
- return nil
- case usagelog.FieldVideoCount:
- v, ok := value.(int)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetVideoCount(v)
- return nil
- case usagelog.FieldVideoResolution:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetVideoResolution(v)
- return nil
- case usagelog.FieldVideoDurationSeconds:
- v, ok := value.(int)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetVideoDurationSeconds(v)
- return nil
- case usagelog.FieldCacheTTLOverridden:
- v, ok := value.(bool)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetCacheTTLOverridden(v)
- return nil
- case usagelog.FieldCreatedAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetCreatedAt(v)
- return nil
- }
- return fmt.Errorf("unknown UsageLog field %s", name)
- }
- // AddedFields returns all numeric fields that were incremented/decremented during
- // this mutation.
- func (m *UsageLogMutation) AddedFields() []string {
- var fields []string
- if m.addchannel_id != nil {
- fields = append(fields, usagelog.FieldChannelID)
- }
- if m.addinput_tokens != nil {
- fields = append(fields, usagelog.FieldInputTokens)
- }
- if m.addoutput_tokens != nil {
- fields = append(fields, usagelog.FieldOutputTokens)
- }
- if m.addcache_creation_tokens != nil {
- fields = append(fields, usagelog.FieldCacheCreationTokens)
- }
- if m.addcache_read_tokens != nil {
- fields = append(fields, usagelog.FieldCacheReadTokens)
- }
- if m.addcache_creation_5m_tokens != nil {
- fields = append(fields, usagelog.FieldCacheCreation5mTokens)
- }
- if m.addcache_creation_1h_tokens != nil {
- fields = append(fields, usagelog.FieldCacheCreation1hTokens)
- }
- if m.addinput_cost != nil {
- fields = append(fields, usagelog.FieldInputCost)
- }
- if m.addoutput_cost != nil {
- fields = append(fields, usagelog.FieldOutputCost)
- }
- if m.addcache_creation_cost != nil {
- fields = append(fields, usagelog.FieldCacheCreationCost)
- }
- if m.addcache_read_cost != nil {
- fields = append(fields, usagelog.FieldCacheReadCost)
- }
- if m.addtotal_cost != nil {
- fields = append(fields, usagelog.FieldTotalCost)
- }
- if m.addactual_cost != nil {
- fields = append(fields, usagelog.FieldActualCost)
- }
- if m.addrate_multiplier != nil {
- fields = append(fields, usagelog.FieldRateMultiplier)
- }
- if m.addaccount_rate_multiplier != nil {
- fields = append(fields, usagelog.FieldAccountRateMultiplier)
- }
- if m.addbilling_type != nil {
- fields = append(fields, usagelog.FieldBillingType)
- }
- if m.addduration_ms != nil {
- fields = append(fields, usagelog.FieldDurationMs)
- }
- if m.addfirst_token_ms != nil {
- fields = append(fields, usagelog.FieldFirstTokenMs)
- }
- if m.addimage_count != nil {
- fields = append(fields, usagelog.FieldImageCount)
- }
- if m.addvideo_count != nil {
- fields = append(fields, usagelog.FieldVideoCount)
- }
- if m.addvideo_duration_seconds != nil {
- fields = append(fields, usagelog.FieldVideoDurationSeconds)
- }
- return fields
- }
- // AddedField returns the numeric value that was incremented/decremented on a field
- // with the given name. The second boolean return value indicates that this field
- // was not set, or was not defined in the schema.
- func (m *UsageLogMutation) AddedField(name string) (ent.Value, bool) {
- switch name {
- case usagelog.FieldChannelID:
- return m.AddedChannelID()
- case usagelog.FieldInputTokens:
- return m.AddedInputTokens()
- case usagelog.FieldOutputTokens:
- return m.AddedOutputTokens()
- case usagelog.FieldCacheCreationTokens:
- return m.AddedCacheCreationTokens()
- case usagelog.FieldCacheReadTokens:
- return m.AddedCacheReadTokens()
- case usagelog.FieldCacheCreation5mTokens:
- return m.AddedCacheCreation5mTokens()
- case usagelog.FieldCacheCreation1hTokens:
- return m.AddedCacheCreation1hTokens()
- case usagelog.FieldInputCost:
- return m.AddedInputCost()
- case usagelog.FieldOutputCost:
- return m.AddedOutputCost()
- case usagelog.FieldCacheCreationCost:
- return m.AddedCacheCreationCost()
- case usagelog.FieldCacheReadCost:
- return m.AddedCacheReadCost()
- case usagelog.FieldTotalCost:
- return m.AddedTotalCost()
- case usagelog.FieldActualCost:
- return m.AddedActualCost()
- case usagelog.FieldRateMultiplier:
- return m.AddedRateMultiplier()
- case usagelog.FieldAccountRateMultiplier:
- return m.AddedAccountRateMultiplier()
- case usagelog.FieldBillingType:
- return m.AddedBillingType()
- case usagelog.FieldDurationMs:
- return m.AddedDurationMs()
- case usagelog.FieldFirstTokenMs:
- return m.AddedFirstTokenMs()
- case usagelog.FieldImageCount:
- return m.AddedImageCount()
- case usagelog.FieldVideoCount:
- return m.AddedVideoCount()
- case usagelog.FieldVideoDurationSeconds:
- return m.AddedVideoDurationSeconds()
- }
- return nil, false
- }
- // AddField adds the value to the field with the given name. It returns an error if
- // the field is not defined in the schema, or if the type mismatched the field
- // type.
- func (m *UsageLogMutation) AddField(name string, value ent.Value) error {
- switch name {
- case usagelog.FieldChannelID:
- v, ok := value.(int64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.AddChannelID(v)
- return nil
- case usagelog.FieldInputTokens:
- v, ok := value.(int)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.AddInputTokens(v)
- return nil
- case usagelog.FieldOutputTokens:
- v, ok := value.(int)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.AddOutputTokens(v)
- return nil
- case usagelog.FieldCacheCreationTokens:
- v, ok := value.(int)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.AddCacheCreationTokens(v)
- return nil
- case usagelog.FieldCacheReadTokens:
- v, ok := value.(int)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.AddCacheReadTokens(v)
- return nil
- case usagelog.FieldCacheCreation5mTokens:
- v, ok := value.(int)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.AddCacheCreation5mTokens(v)
- return nil
- case usagelog.FieldCacheCreation1hTokens:
- v, ok := value.(int)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.AddCacheCreation1hTokens(v)
- return nil
- case usagelog.FieldInputCost:
- v, ok := value.(float64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.AddInputCost(v)
- return nil
- case usagelog.FieldOutputCost:
- v, ok := value.(float64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.AddOutputCost(v)
- return nil
- case usagelog.FieldCacheCreationCost:
- v, ok := value.(float64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.AddCacheCreationCost(v)
- return nil
- case usagelog.FieldCacheReadCost:
- v, ok := value.(float64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.AddCacheReadCost(v)
- return nil
- case usagelog.FieldTotalCost:
- v, ok := value.(float64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.AddTotalCost(v)
- return nil
- case usagelog.FieldActualCost:
- v, ok := value.(float64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.AddActualCost(v)
- return nil
- case usagelog.FieldRateMultiplier:
- v, ok := value.(float64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.AddRateMultiplier(v)
- return nil
- case usagelog.FieldAccountRateMultiplier:
- v, ok := value.(float64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.AddAccountRateMultiplier(v)
- return nil
- case usagelog.FieldBillingType:
- v, ok := value.(int8)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.AddBillingType(v)
- return nil
- case usagelog.FieldDurationMs:
- v, ok := value.(int)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.AddDurationMs(v)
- return nil
- case usagelog.FieldFirstTokenMs:
- v, ok := value.(int)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.AddFirstTokenMs(v)
- return nil
- case usagelog.FieldImageCount:
- v, ok := value.(int)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.AddImageCount(v)
- return nil
- case usagelog.FieldVideoCount:
- v, ok := value.(int)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.AddVideoCount(v)
- return nil
- case usagelog.FieldVideoDurationSeconds:
- v, ok := value.(int)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.AddVideoDurationSeconds(v)
- return nil
- }
- return fmt.Errorf("unknown UsageLog numeric field %s", name)
- }
- // ClearedFields returns all nullable fields that were cleared during this
- // mutation.
- func (m *UsageLogMutation) ClearedFields() []string {
- var fields []string
- if m.FieldCleared(usagelog.FieldRequestedModel) {
- fields = append(fields, usagelog.FieldRequestedModel)
- }
- if m.FieldCleared(usagelog.FieldUpstreamModel) {
- fields = append(fields, usagelog.FieldUpstreamModel)
- }
- if m.FieldCleared(usagelog.FieldUpstreamResponseModel) {
- fields = append(fields, usagelog.FieldUpstreamResponseModel)
- }
- if m.FieldCleared(usagelog.FieldUpstreamModelMismatch) {
- fields = append(fields, usagelog.FieldUpstreamModelMismatch)
- }
- if m.FieldCleared(usagelog.FieldChannelID) {
- fields = append(fields, usagelog.FieldChannelID)
- }
- if m.FieldCleared(usagelog.FieldModelMappingChain) {
- fields = append(fields, usagelog.FieldModelMappingChain)
- }
- if m.FieldCleared(usagelog.FieldBillingTier) {
- fields = append(fields, usagelog.FieldBillingTier)
- }
- if m.FieldCleared(usagelog.FieldBillingMode) {
- fields = append(fields, usagelog.FieldBillingMode)
- }
- if m.FieldCleared(usagelog.FieldGroupID) {
- fields = append(fields, usagelog.FieldGroupID)
- }
- if m.FieldCleared(usagelog.FieldSubscriptionID) {
- fields = append(fields, usagelog.FieldSubscriptionID)
- }
- if m.FieldCleared(usagelog.FieldAccountRateMultiplier) {
- fields = append(fields, usagelog.FieldAccountRateMultiplier)
- }
- if m.FieldCleared(usagelog.FieldDurationMs) {
- fields = append(fields, usagelog.FieldDurationMs)
- }
- if m.FieldCleared(usagelog.FieldFirstTokenMs) {
- fields = append(fields, usagelog.FieldFirstTokenMs)
- }
- if m.FieldCleared(usagelog.FieldUserAgent) {
- fields = append(fields, usagelog.FieldUserAgent)
- }
- if m.FieldCleared(usagelog.FieldIPAddress) {
- fields = append(fields, usagelog.FieldIPAddress)
- }
- if m.FieldCleared(usagelog.FieldImageSize) {
- fields = append(fields, usagelog.FieldImageSize)
- }
- if m.FieldCleared(usagelog.FieldImageInputSize) {
- fields = append(fields, usagelog.FieldImageInputSize)
- }
- if m.FieldCleared(usagelog.FieldImageOutputSize) {
- fields = append(fields, usagelog.FieldImageOutputSize)
- }
- if m.FieldCleared(usagelog.FieldImageSizeSource) {
- fields = append(fields, usagelog.FieldImageSizeSource)
- }
- if m.FieldCleared(usagelog.FieldImageSizeBreakdown) {
- fields = append(fields, usagelog.FieldImageSizeBreakdown)
- }
- if m.FieldCleared(usagelog.FieldVideoResolution) {
- fields = append(fields, usagelog.FieldVideoResolution)
- }
- if m.FieldCleared(usagelog.FieldVideoDurationSeconds) {
- fields = append(fields, usagelog.FieldVideoDurationSeconds)
- }
- return fields
- }
- // FieldCleared returns a boolean indicating if a field with the given name was
- // cleared in this mutation.
- func (m *UsageLogMutation) FieldCleared(name string) bool {
- _, ok := m.clearedFields[name]
- return ok
- }
- // ClearField clears the value of the field with the given name. It returns an
- // error if the field is not defined in the schema.
- func (m *UsageLogMutation) ClearField(name string) error {
- switch name {
- case usagelog.FieldRequestedModel:
- m.ClearRequestedModel()
- return nil
- case usagelog.FieldUpstreamModel:
- m.ClearUpstreamModel()
- return nil
- case usagelog.FieldUpstreamResponseModel:
- m.ClearUpstreamResponseModel()
- return nil
- case usagelog.FieldUpstreamModelMismatch:
- m.ClearUpstreamModelMismatch()
- return nil
- case usagelog.FieldChannelID:
- m.ClearChannelID()
- return nil
- case usagelog.FieldModelMappingChain:
- m.ClearModelMappingChain()
- return nil
- case usagelog.FieldBillingTier:
- m.ClearBillingTier()
- return nil
- case usagelog.FieldBillingMode:
- m.ClearBillingMode()
- return nil
- case usagelog.FieldGroupID:
- m.ClearGroupID()
- return nil
- case usagelog.FieldSubscriptionID:
- m.ClearSubscriptionID()
- return nil
- case usagelog.FieldAccountRateMultiplier:
- m.ClearAccountRateMultiplier()
- return nil
- case usagelog.FieldDurationMs:
- m.ClearDurationMs()
- return nil
- case usagelog.FieldFirstTokenMs:
- m.ClearFirstTokenMs()
- return nil
- case usagelog.FieldUserAgent:
- m.ClearUserAgent()
- return nil
- case usagelog.FieldIPAddress:
- m.ClearIPAddress()
- return nil
- case usagelog.FieldImageSize:
- m.ClearImageSize()
- return nil
- case usagelog.FieldImageInputSize:
- m.ClearImageInputSize()
- return nil
- case usagelog.FieldImageOutputSize:
- m.ClearImageOutputSize()
- return nil
- case usagelog.FieldImageSizeSource:
- m.ClearImageSizeSource()
- return nil
- case usagelog.FieldImageSizeBreakdown:
- m.ClearImageSizeBreakdown()
- return nil
- case usagelog.FieldVideoResolution:
- m.ClearVideoResolution()
- return nil
- case usagelog.FieldVideoDurationSeconds:
- m.ClearVideoDurationSeconds()
- return nil
- }
- return fmt.Errorf("unknown UsageLog nullable field %s", name)
- }
- // ResetField resets all changes in the mutation for the field with the given name.
- // It returns an error if the field is not defined in the schema.
- func (m *UsageLogMutation) ResetField(name string) error {
- switch name {
- case usagelog.FieldUserID:
- m.ResetUserID()
- return nil
- case usagelog.FieldAPIKeyID:
- m.ResetAPIKeyID()
- return nil
- case usagelog.FieldAccountID:
- m.ResetAccountID()
- return nil
- case usagelog.FieldRequestID:
- m.ResetRequestID()
- return nil
- case usagelog.FieldModel:
- m.ResetModel()
- return nil
- case usagelog.FieldRequestedModel:
- m.ResetRequestedModel()
- return nil
- case usagelog.FieldUpstreamModel:
- m.ResetUpstreamModel()
- return nil
- case usagelog.FieldUpstreamResponseModel:
- m.ResetUpstreamResponseModel()
- return nil
- case usagelog.FieldUpstreamModelMismatch:
- m.ResetUpstreamModelMismatch()
- return nil
- case usagelog.FieldChannelID:
- m.ResetChannelID()
- return nil
- case usagelog.FieldModelMappingChain:
- m.ResetModelMappingChain()
- return nil
- case usagelog.FieldBillingTier:
- m.ResetBillingTier()
- return nil
- case usagelog.FieldBillingMode:
- m.ResetBillingMode()
- return nil
- case usagelog.FieldGroupID:
- m.ResetGroupID()
- return nil
- case usagelog.FieldSubscriptionID:
- m.ResetSubscriptionID()
- return nil
- case usagelog.FieldInputTokens:
- m.ResetInputTokens()
- return nil
- case usagelog.FieldOutputTokens:
- m.ResetOutputTokens()
- return nil
- case usagelog.FieldCacheCreationTokens:
- m.ResetCacheCreationTokens()
- return nil
- case usagelog.FieldCacheReadTokens:
- m.ResetCacheReadTokens()
- return nil
- case usagelog.FieldCacheCreation5mTokens:
- m.ResetCacheCreation5mTokens()
- return nil
- case usagelog.FieldCacheCreation1hTokens:
- m.ResetCacheCreation1hTokens()
- return nil
- case usagelog.FieldInputCost:
- m.ResetInputCost()
- return nil
- case usagelog.FieldOutputCost:
- m.ResetOutputCost()
- return nil
- case usagelog.FieldCacheCreationCost:
- m.ResetCacheCreationCost()
- return nil
- case usagelog.FieldCacheReadCost:
- m.ResetCacheReadCost()
- return nil
- case usagelog.FieldTotalCost:
- m.ResetTotalCost()
- return nil
- case usagelog.FieldActualCost:
- m.ResetActualCost()
- return nil
- case usagelog.FieldRateMultiplier:
- m.ResetRateMultiplier()
- return nil
- case usagelog.FieldLongContextBillingApplied:
- m.ResetLongContextBillingApplied()
- return nil
- case usagelog.FieldAccountRateMultiplier:
- m.ResetAccountRateMultiplier()
- return nil
- case usagelog.FieldBillingType:
- m.ResetBillingType()
- return nil
- case usagelog.FieldStream:
- m.ResetStream()
- return nil
- case usagelog.FieldDurationMs:
- m.ResetDurationMs()
- return nil
- case usagelog.FieldFirstTokenMs:
- m.ResetFirstTokenMs()
- return nil
- case usagelog.FieldUserAgent:
- m.ResetUserAgent()
- return nil
- case usagelog.FieldIPAddress:
- m.ResetIPAddress()
- return nil
- case usagelog.FieldImageCount:
- m.ResetImageCount()
- return nil
- case usagelog.FieldImageSize:
- m.ResetImageSize()
- return nil
- case usagelog.FieldImageInputSize:
- m.ResetImageInputSize()
- return nil
- case usagelog.FieldImageOutputSize:
- m.ResetImageOutputSize()
- return nil
- case usagelog.FieldImageSizeSource:
- m.ResetImageSizeSource()
- return nil
- case usagelog.FieldImageSizeBreakdown:
- m.ResetImageSizeBreakdown()
- return nil
- case usagelog.FieldVideoCount:
- m.ResetVideoCount()
- return nil
- case usagelog.FieldVideoResolution:
- m.ResetVideoResolution()
- return nil
- case usagelog.FieldVideoDurationSeconds:
- m.ResetVideoDurationSeconds()
- return nil
- case usagelog.FieldCacheTTLOverridden:
- m.ResetCacheTTLOverridden()
- return nil
- case usagelog.FieldCreatedAt:
- m.ResetCreatedAt()
- return nil
- }
- return fmt.Errorf("unknown UsageLog field %s", name)
- }
- // AddedEdges returns all edge names that were set/added in this mutation.
- func (m *UsageLogMutation) AddedEdges() []string {
- edges := make([]string, 0, 5)
- if m.user != nil {
- edges = append(edges, usagelog.EdgeUser)
- }
- if m.api_key != nil {
- edges = append(edges, usagelog.EdgeAPIKey)
- }
- if m.account != nil {
- edges = append(edges, usagelog.EdgeAccount)
- }
- if m.group != nil {
- edges = append(edges, usagelog.EdgeGroup)
- }
- if m.subscription != nil {
- edges = append(edges, usagelog.EdgeSubscription)
- }
- return edges
- }
- // AddedIDs returns all IDs (to other nodes) that were added for the given edge
- // name in this mutation.
- func (m *UsageLogMutation) AddedIDs(name string) []ent.Value {
- switch name {
- case usagelog.EdgeUser:
- if id := m.user; id != nil {
- return []ent.Value{*id}
- }
- case usagelog.EdgeAPIKey:
- if id := m.api_key; id != nil {
- return []ent.Value{*id}
- }
- case usagelog.EdgeAccount:
- if id := m.account; id != nil {
- return []ent.Value{*id}
- }
- case usagelog.EdgeGroup:
- if id := m.group; id != nil {
- return []ent.Value{*id}
- }
- case usagelog.EdgeSubscription:
- if id := m.subscription; id != nil {
- return []ent.Value{*id}
- }
- }
- return nil
- }
- // RemovedEdges returns all edge names that were removed in this mutation.
- func (m *UsageLogMutation) RemovedEdges() []string {
- edges := make([]string, 0, 5)
- return edges
- }
- // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
- // the given name in this mutation.
- func (m *UsageLogMutation) RemovedIDs(name string) []ent.Value {
- return nil
- }
- // ClearedEdges returns all edge names that were cleared in this mutation.
- func (m *UsageLogMutation) ClearedEdges() []string {
- edges := make([]string, 0, 5)
- if m.cleareduser {
- edges = append(edges, usagelog.EdgeUser)
- }
- if m.clearedapi_key {
- edges = append(edges, usagelog.EdgeAPIKey)
- }
- if m.clearedaccount {
- edges = append(edges, usagelog.EdgeAccount)
- }
- if m.clearedgroup {
- edges = append(edges, usagelog.EdgeGroup)
- }
- if m.clearedsubscription {
- edges = append(edges, usagelog.EdgeSubscription)
- }
- return edges
- }
- // EdgeCleared returns a boolean which indicates if the edge with the given name
- // was cleared in this mutation.
- func (m *UsageLogMutation) EdgeCleared(name string) bool {
- switch name {
- case usagelog.EdgeUser:
- return m.cleareduser
- case usagelog.EdgeAPIKey:
- return m.clearedapi_key
- case usagelog.EdgeAccount:
- return m.clearedaccount
- case usagelog.EdgeGroup:
- return m.clearedgroup
- case usagelog.EdgeSubscription:
- return m.clearedsubscription
- }
- return false
- }
- // ClearEdge clears the value of the edge with the given name. It returns an error
- // if that edge is not defined in the schema.
- func (m *UsageLogMutation) ClearEdge(name string) error {
- switch name {
- case usagelog.EdgeUser:
- m.ClearUser()
- return nil
- case usagelog.EdgeAPIKey:
- m.ClearAPIKey()
- return nil
- case usagelog.EdgeAccount:
- m.ClearAccount()
- return nil
- case usagelog.EdgeGroup:
- m.ClearGroup()
- return nil
- case usagelog.EdgeSubscription:
- m.ClearSubscription()
- return nil
- }
- return fmt.Errorf("unknown UsageLog unique edge %s", name)
- }
- // ResetEdge resets all changes to the edge with the given name in this mutation.
- // It returns an error if the edge is not defined in the schema.
- func (m *UsageLogMutation) ResetEdge(name string) error {
- switch name {
- case usagelog.EdgeUser:
- m.ResetUser()
- return nil
- case usagelog.EdgeAPIKey:
- m.ResetAPIKey()
- return nil
- case usagelog.EdgeAccount:
- m.ResetAccount()
- return nil
- case usagelog.EdgeGroup:
- m.ResetGroup()
- return nil
- case usagelog.EdgeSubscription:
- m.ResetSubscription()
- return nil
- }
- return fmt.Errorf("unknown UsageLog edge %s", name)
- }
- // UserMutation represents an operation that mutates the User nodes in the graph.
- type UserMutation struct {
- config
- op Op
- typ string
- id *int64
- created_at *time.Time
- updated_at *time.Time
- deleted_at *time.Time
- email *string
- password_hash *string
- role *string
- balance *float64
- addbalance *float64
- frozen_balance *float64
- addfrozen_balance *float64
- concurrency *int
- addconcurrency *int
- status *string
- username *string
- notes *string
- totp_secret_encrypted *string
- totp_enabled *bool
- totp_enabled_at *time.Time
- signup_source *string
- last_login_at *time.Time
- last_active_at *time.Time
- restrict_public_groups *bool
- balance_notify_enabled *bool
- balance_notify_threshold_type *string
- balance_notify_threshold *float64
- addbalance_notify_threshold *float64
- balance_notify_extra_emails *string
- total_recharged *float64
- addtotal_recharged *float64
- rpm_limit *int
- addrpm_limit *int
- clearedFields map[string]struct{}
- api_keys map[int64]struct{}
- removedapi_keys map[int64]struct{}
- clearedapi_keys bool
- redeem_codes map[int64]struct{}
- removedredeem_codes map[int64]struct{}
- clearedredeem_codes bool
- subscriptions map[int64]struct{}
- removedsubscriptions map[int64]struct{}
- clearedsubscriptions bool
- assigned_subscriptions map[int64]struct{}
- removedassigned_subscriptions map[int64]struct{}
- clearedassigned_subscriptions bool
- announcement_reads map[int64]struct{}
- removedannouncement_reads map[int64]struct{}
- clearedannouncement_reads bool
- allowed_groups map[int64]struct{}
- removedallowed_groups map[int64]struct{}
- clearedallowed_groups bool
- usage_logs map[int64]struct{}
- removedusage_logs map[int64]struct{}
- clearedusage_logs bool
- attribute_values map[int64]struct{}
- removedattribute_values map[int64]struct{}
- clearedattribute_values bool
- promo_code_usages map[int64]struct{}
- removedpromo_code_usages map[int64]struct{}
- clearedpromo_code_usages bool
- payment_orders map[int64]struct{}
- removedpayment_orders map[int64]struct{}
- clearedpayment_orders bool
- auth_identities map[int64]struct{}
- removedauth_identities map[int64]struct{}
- clearedauth_identities bool
- pending_auth_sessions map[int64]struct{}
- removedpending_auth_sessions map[int64]struct{}
- clearedpending_auth_sessions bool
- platform_quotas map[int64]struct{}
- removedplatform_quotas map[int64]struct{}
- clearedplatform_quotas bool
- done bool
- oldValue func(context.Context) (*User, error)
- predicates []predicate.User
- }
- var _ ent.Mutation = (*UserMutation)(nil)
- // userOption allows management of the mutation configuration using functional options.
- type userOption func(*UserMutation)
- // newUserMutation creates new mutation for the User entity.
- func newUserMutation(c config, op Op, opts ...userOption) *UserMutation {
- m := &UserMutation{
- config: c,
- op: op,
- typ: TypeUser,
- clearedFields: make(map[string]struct{}),
- }
- for _, opt := range opts {
- opt(m)
- }
- return m
- }
- // withUserID sets the ID field of the mutation.
- func withUserID(id int64) userOption {
- return func(m *UserMutation) {
- var (
- err error
- once sync.Once
- value *User
- )
- m.oldValue = func(ctx context.Context) (*User, error) {
- once.Do(func() {
- if m.done {
- err = errors.New("querying old values post mutation is not allowed")
- } else {
- value, err = m.Client().User.Get(ctx, id)
- }
- })
- return value, err
- }
- m.id = &id
- }
- }
- // withUser sets the old User of the mutation.
- func withUser(node *User) userOption {
- return func(m *UserMutation) {
- m.oldValue = func(context.Context) (*User, error) {
- return node, nil
- }
- m.id = &node.ID
- }
- }
- // Client returns a new `ent.Client` from the mutation. If the mutation was
- // executed in a transaction (ent.Tx), a transactional client is returned.
- func (m UserMutation) Client() *Client {
- client := &Client{config: m.config}
- client.init()
- return client
- }
- // Tx returns an `ent.Tx` for mutations that were executed in transactions;
- // it returns an error otherwise.
- func (m UserMutation) Tx() (*Tx, error) {
- if _, ok := m.driver.(*txDriver); !ok {
- return nil, errors.New("ent: mutation is not running in a transaction")
- }
- tx := &Tx{config: m.config}
- tx.init()
- return tx, nil
- }
- // ID returns the ID value in the mutation. Note that the ID is only available
- // if it was provided to the builder or after it was returned from the database.
- func (m *UserMutation) ID() (id int64, exists bool) {
- if m.id == nil {
- return
- }
- return *m.id, true
- }
- // IDs queries the database and returns the entity ids that match the mutation's predicate.
- // That means, if the mutation is applied within a transaction with an isolation level such
- // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
- // or updated by the mutation.
- func (m *UserMutation) IDs(ctx context.Context) ([]int64, error) {
- switch {
- case m.op.Is(OpUpdateOne | OpDeleteOne):
- id, exists := m.ID()
- if exists {
- return []int64{id}, nil
- }
- fallthrough
- case m.op.Is(OpUpdate | OpDelete):
- return m.Client().User.Query().Where(m.predicates...).IDs(ctx)
- default:
- return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
- }
- }
- // SetCreatedAt sets the "created_at" field.
- func (m *UserMutation) SetCreatedAt(t time.Time) {
- m.created_at = &t
- }
- // CreatedAt returns the value of the "created_at" field in the mutation.
- func (m *UserMutation) CreatedAt() (r time.Time, exists bool) {
- v := m.created_at
- if v == nil {
- return
- }
- return *v, true
- }
- // OldCreatedAt returns the old "created_at" field's value of the User entity.
- // If the User object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *UserMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldCreatedAt requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
- }
- return oldValue.CreatedAt, nil
- }
- // ResetCreatedAt resets all changes to the "created_at" field.
- func (m *UserMutation) ResetCreatedAt() {
- m.created_at = nil
- }
- // SetUpdatedAt sets the "updated_at" field.
- func (m *UserMutation) SetUpdatedAt(t time.Time) {
- m.updated_at = &t
- }
- // UpdatedAt returns the value of the "updated_at" field in the mutation.
- func (m *UserMutation) UpdatedAt() (r time.Time, exists bool) {
- v := m.updated_at
- if v == nil {
- return
- }
- return *v, true
- }
- // OldUpdatedAt returns the old "updated_at" field's value of the User entity.
- // If the User object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *UserMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
- }
- return oldValue.UpdatedAt, nil
- }
- // ResetUpdatedAt resets all changes to the "updated_at" field.
- func (m *UserMutation) ResetUpdatedAt() {
- m.updated_at = nil
- }
- // SetDeletedAt sets the "deleted_at" field.
- func (m *UserMutation) SetDeletedAt(t time.Time) {
- m.deleted_at = &t
- }
- // DeletedAt returns the value of the "deleted_at" field in the mutation.
- func (m *UserMutation) DeletedAt() (r time.Time, exists bool) {
- v := m.deleted_at
- if v == nil {
- return
- }
- return *v, true
- }
- // OldDeletedAt returns the old "deleted_at" field's value of the User entity.
- // If the User object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *UserMutation) OldDeletedAt(ctx context.Context) (v *time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldDeletedAt requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
- }
- return oldValue.DeletedAt, nil
- }
- // ClearDeletedAt clears the value of the "deleted_at" field.
- func (m *UserMutation) ClearDeletedAt() {
- m.deleted_at = nil
- m.clearedFields[user.FieldDeletedAt] = struct{}{}
- }
- // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
- func (m *UserMutation) DeletedAtCleared() bool {
- _, ok := m.clearedFields[user.FieldDeletedAt]
- return ok
- }
- // ResetDeletedAt resets all changes to the "deleted_at" field.
- func (m *UserMutation) ResetDeletedAt() {
- m.deleted_at = nil
- delete(m.clearedFields, user.FieldDeletedAt)
- }
- // SetEmail sets the "email" field.
- func (m *UserMutation) SetEmail(s string) {
- m.email = &s
- }
- // Email returns the value of the "email" field in the mutation.
- func (m *UserMutation) Email() (r string, exists bool) {
- v := m.email
- if v == nil {
- return
- }
- return *v, true
- }
- // OldEmail returns the old "email" field's value of the User entity.
- // If the User object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *UserMutation) OldEmail(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldEmail is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldEmail requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldEmail: %w", err)
- }
- return oldValue.Email, nil
- }
- // ResetEmail resets all changes to the "email" field.
- func (m *UserMutation) ResetEmail() {
- m.email = nil
- }
- // SetPasswordHash sets the "password_hash" field.
- func (m *UserMutation) SetPasswordHash(s string) {
- m.password_hash = &s
- }
- // PasswordHash returns the value of the "password_hash" field in the mutation.
- func (m *UserMutation) PasswordHash() (r string, exists bool) {
- v := m.password_hash
- if v == nil {
- return
- }
- return *v, true
- }
- // OldPasswordHash returns the old "password_hash" field's value of the User entity.
- // If the User object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *UserMutation) OldPasswordHash(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldPasswordHash is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldPasswordHash requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldPasswordHash: %w", err)
- }
- return oldValue.PasswordHash, nil
- }
- // ResetPasswordHash resets all changes to the "password_hash" field.
- func (m *UserMutation) ResetPasswordHash() {
- m.password_hash = nil
- }
- // SetRole sets the "role" field.
- func (m *UserMutation) SetRole(s string) {
- m.role = &s
- }
- // Role returns the value of the "role" field in the mutation.
- func (m *UserMutation) Role() (r string, exists bool) {
- v := m.role
- if v == nil {
- return
- }
- return *v, true
- }
- // OldRole returns the old "role" field's value of the User entity.
- // If the User object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *UserMutation) OldRole(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldRole is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldRole requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldRole: %w", err)
- }
- return oldValue.Role, nil
- }
- // ResetRole resets all changes to the "role" field.
- func (m *UserMutation) ResetRole() {
- m.role = nil
- }
- // SetBalance sets the "balance" field.
- func (m *UserMutation) SetBalance(f float64) {
- m.balance = &f
- m.addbalance = nil
- }
- // Balance returns the value of the "balance" field in the mutation.
- func (m *UserMutation) Balance() (r float64, exists bool) {
- v := m.balance
- if v == nil {
- return
- }
- return *v, true
- }
- // OldBalance returns the old "balance" field's value of the User entity.
- // If the User object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *UserMutation) OldBalance(ctx context.Context) (v float64, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldBalance is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldBalance requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldBalance: %w", err)
- }
- return oldValue.Balance, nil
- }
- // AddBalance adds f to the "balance" field.
- func (m *UserMutation) AddBalance(f float64) {
- if m.addbalance != nil {
- *m.addbalance += f
- } else {
- m.addbalance = &f
- }
- }
- // AddedBalance returns the value that was added to the "balance" field in this mutation.
- func (m *UserMutation) AddedBalance() (r float64, exists bool) {
- v := m.addbalance
- if v == nil {
- return
- }
- return *v, true
- }
- // ResetBalance resets all changes to the "balance" field.
- func (m *UserMutation) ResetBalance() {
- m.balance = nil
- m.addbalance = nil
- }
- // SetFrozenBalance sets the "frozen_balance" field.
- func (m *UserMutation) SetFrozenBalance(f float64) {
- m.frozen_balance = &f
- m.addfrozen_balance = nil
- }
- // FrozenBalance returns the value of the "frozen_balance" field in the mutation.
- func (m *UserMutation) FrozenBalance() (r float64, exists bool) {
- v := m.frozen_balance
- if v == nil {
- return
- }
- return *v, true
- }
- // OldFrozenBalance returns the old "frozen_balance" field's value of the User entity.
- // If the User object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *UserMutation) OldFrozenBalance(ctx context.Context) (v float64, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldFrozenBalance is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldFrozenBalance requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldFrozenBalance: %w", err)
- }
- return oldValue.FrozenBalance, nil
- }
- // AddFrozenBalance adds f to the "frozen_balance" field.
- func (m *UserMutation) AddFrozenBalance(f float64) {
- if m.addfrozen_balance != nil {
- *m.addfrozen_balance += f
- } else {
- m.addfrozen_balance = &f
- }
- }
- // AddedFrozenBalance returns the value that was added to the "frozen_balance" field in this mutation.
- func (m *UserMutation) AddedFrozenBalance() (r float64, exists bool) {
- v := m.addfrozen_balance
- if v == nil {
- return
- }
- return *v, true
- }
- // ResetFrozenBalance resets all changes to the "frozen_balance" field.
- func (m *UserMutation) ResetFrozenBalance() {
- m.frozen_balance = nil
- m.addfrozen_balance = nil
- }
- // SetConcurrency sets the "concurrency" field.
- func (m *UserMutation) SetConcurrency(i int) {
- m.concurrency = &i
- m.addconcurrency = nil
- }
- // Concurrency returns the value of the "concurrency" field in the mutation.
- func (m *UserMutation) Concurrency() (r int, exists bool) {
- v := m.concurrency
- if v == nil {
- return
- }
- return *v, true
- }
- // OldConcurrency returns the old "concurrency" field's value of the User entity.
- // If the User object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *UserMutation) OldConcurrency(ctx context.Context) (v int, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldConcurrency is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldConcurrency requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldConcurrency: %w", err)
- }
- return oldValue.Concurrency, nil
- }
- // AddConcurrency adds i to the "concurrency" field.
- func (m *UserMutation) AddConcurrency(i int) {
- if m.addconcurrency != nil {
- *m.addconcurrency += i
- } else {
- m.addconcurrency = &i
- }
- }
- // AddedConcurrency returns the value that was added to the "concurrency" field in this mutation.
- func (m *UserMutation) AddedConcurrency() (r int, exists bool) {
- v := m.addconcurrency
- if v == nil {
- return
- }
- return *v, true
- }
- // ResetConcurrency resets all changes to the "concurrency" field.
- func (m *UserMutation) ResetConcurrency() {
- m.concurrency = nil
- m.addconcurrency = nil
- }
- // SetStatus sets the "status" field.
- func (m *UserMutation) SetStatus(s string) {
- m.status = &s
- }
- // Status returns the value of the "status" field in the mutation.
- func (m *UserMutation) Status() (r string, exists bool) {
- v := m.status
- if v == nil {
- return
- }
- return *v, true
- }
- // OldStatus returns the old "status" field's value of the User entity.
- // If the User object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *UserMutation) OldStatus(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldStatus is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldStatus requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldStatus: %w", err)
- }
- return oldValue.Status, nil
- }
- // ResetStatus resets all changes to the "status" field.
- func (m *UserMutation) ResetStatus() {
- m.status = nil
- }
- // SetUsername sets the "username" field.
- func (m *UserMutation) SetUsername(s string) {
- m.username = &s
- }
- // Username returns the value of the "username" field in the mutation.
- func (m *UserMutation) Username() (r string, exists bool) {
- v := m.username
- if v == nil {
- return
- }
- return *v, true
- }
- // OldUsername returns the old "username" field's value of the User entity.
- // If the User object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *UserMutation) OldUsername(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldUsername is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldUsername requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldUsername: %w", err)
- }
- return oldValue.Username, nil
- }
- // ResetUsername resets all changes to the "username" field.
- func (m *UserMutation) ResetUsername() {
- m.username = nil
- }
- // SetNotes sets the "notes" field.
- func (m *UserMutation) SetNotes(s string) {
- m.notes = &s
- }
- // Notes returns the value of the "notes" field in the mutation.
- func (m *UserMutation) Notes() (r string, exists bool) {
- v := m.notes
- if v == nil {
- return
- }
- return *v, true
- }
- // OldNotes returns the old "notes" field's value of the User entity.
- // If the User object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *UserMutation) OldNotes(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldNotes is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldNotes requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldNotes: %w", err)
- }
- return oldValue.Notes, nil
- }
- // ResetNotes resets all changes to the "notes" field.
- func (m *UserMutation) ResetNotes() {
- m.notes = nil
- }
- // SetTotpSecretEncrypted sets the "totp_secret_encrypted" field.
- func (m *UserMutation) SetTotpSecretEncrypted(s string) {
- m.totp_secret_encrypted = &s
- }
- // TotpSecretEncrypted returns the value of the "totp_secret_encrypted" field in the mutation.
- func (m *UserMutation) TotpSecretEncrypted() (r string, exists bool) {
- v := m.totp_secret_encrypted
- if v == nil {
- return
- }
- return *v, true
- }
- // OldTotpSecretEncrypted returns the old "totp_secret_encrypted" field's value of the User entity.
- // If the User object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *UserMutation) OldTotpSecretEncrypted(ctx context.Context) (v *string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldTotpSecretEncrypted is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldTotpSecretEncrypted requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldTotpSecretEncrypted: %w", err)
- }
- return oldValue.TotpSecretEncrypted, nil
- }
- // ClearTotpSecretEncrypted clears the value of the "totp_secret_encrypted" field.
- func (m *UserMutation) ClearTotpSecretEncrypted() {
- m.totp_secret_encrypted = nil
- m.clearedFields[user.FieldTotpSecretEncrypted] = struct{}{}
- }
- // TotpSecretEncryptedCleared returns if the "totp_secret_encrypted" field was cleared in this mutation.
- func (m *UserMutation) TotpSecretEncryptedCleared() bool {
- _, ok := m.clearedFields[user.FieldTotpSecretEncrypted]
- return ok
- }
- // ResetTotpSecretEncrypted resets all changes to the "totp_secret_encrypted" field.
- func (m *UserMutation) ResetTotpSecretEncrypted() {
- m.totp_secret_encrypted = nil
- delete(m.clearedFields, user.FieldTotpSecretEncrypted)
- }
- // SetTotpEnabled sets the "totp_enabled" field.
- func (m *UserMutation) SetTotpEnabled(b bool) {
- m.totp_enabled = &b
- }
- // TotpEnabled returns the value of the "totp_enabled" field in the mutation.
- func (m *UserMutation) TotpEnabled() (r bool, exists bool) {
- v := m.totp_enabled
- if v == nil {
- return
- }
- return *v, true
- }
- // OldTotpEnabled returns the old "totp_enabled" field's value of the User entity.
- // If the User object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *UserMutation) OldTotpEnabled(ctx context.Context) (v bool, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldTotpEnabled is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldTotpEnabled requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldTotpEnabled: %w", err)
- }
- return oldValue.TotpEnabled, nil
- }
- // ResetTotpEnabled resets all changes to the "totp_enabled" field.
- func (m *UserMutation) ResetTotpEnabled() {
- m.totp_enabled = nil
- }
- // SetTotpEnabledAt sets the "totp_enabled_at" field.
- func (m *UserMutation) SetTotpEnabledAt(t time.Time) {
- m.totp_enabled_at = &t
- }
- // TotpEnabledAt returns the value of the "totp_enabled_at" field in the mutation.
- func (m *UserMutation) TotpEnabledAt() (r time.Time, exists bool) {
- v := m.totp_enabled_at
- if v == nil {
- return
- }
- return *v, true
- }
- // OldTotpEnabledAt returns the old "totp_enabled_at" field's value of the User entity.
- // If the User object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *UserMutation) OldTotpEnabledAt(ctx context.Context) (v *time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldTotpEnabledAt is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldTotpEnabledAt requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldTotpEnabledAt: %w", err)
- }
- return oldValue.TotpEnabledAt, nil
- }
- // ClearTotpEnabledAt clears the value of the "totp_enabled_at" field.
- func (m *UserMutation) ClearTotpEnabledAt() {
- m.totp_enabled_at = nil
- m.clearedFields[user.FieldTotpEnabledAt] = struct{}{}
- }
- // TotpEnabledAtCleared returns if the "totp_enabled_at" field was cleared in this mutation.
- func (m *UserMutation) TotpEnabledAtCleared() bool {
- _, ok := m.clearedFields[user.FieldTotpEnabledAt]
- return ok
- }
- // ResetTotpEnabledAt resets all changes to the "totp_enabled_at" field.
- func (m *UserMutation) ResetTotpEnabledAt() {
- m.totp_enabled_at = nil
- delete(m.clearedFields, user.FieldTotpEnabledAt)
- }
- // SetSignupSource sets the "signup_source" field.
- func (m *UserMutation) SetSignupSource(s string) {
- m.signup_source = &s
- }
- // SignupSource returns the value of the "signup_source" field in the mutation.
- func (m *UserMutation) SignupSource() (r string, exists bool) {
- v := m.signup_source
- if v == nil {
- return
- }
- return *v, true
- }
- // OldSignupSource returns the old "signup_source" field's value of the User entity.
- // If the User object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *UserMutation) OldSignupSource(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldSignupSource is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldSignupSource requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldSignupSource: %w", err)
- }
- return oldValue.SignupSource, nil
- }
- // ResetSignupSource resets all changes to the "signup_source" field.
- func (m *UserMutation) ResetSignupSource() {
- m.signup_source = nil
- }
- // SetLastLoginAt sets the "last_login_at" field.
- func (m *UserMutation) SetLastLoginAt(t time.Time) {
- m.last_login_at = &t
- }
- // LastLoginAt returns the value of the "last_login_at" field in the mutation.
- func (m *UserMutation) LastLoginAt() (r time.Time, exists bool) {
- v := m.last_login_at
- if v == nil {
- return
- }
- return *v, true
- }
- // OldLastLoginAt returns the old "last_login_at" field's value of the User entity.
- // If the User object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *UserMutation) OldLastLoginAt(ctx context.Context) (v *time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldLastLoginAt is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldLastLoginAt requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldLastLoginAt: %w", err)
- }
- return oldValue.LastLoginAt, nil
- }
- // ClearLastLoginAt clears the value of the "last_login_at" field.
- func (m *UserMutation) ClearLastLoginAt() {
- m.last_login_at = nil
- m.clearedFields[user.FieldLastLoginAt] = struct{}{}
- }
- // LastLoginAtCleared returns if the "last_login_at" field was cleared in this mutation.
- func (m *UserMutation) LastLoginAtCleared() bool {
- _, ok := m.clearedFields[user.FieldLastLoginAt]
- return ok
- }
- // ResetLastLoginAt resets all changes to the "last_login_at" field.
- func (m *UserMutation) ResetLastLoginAt() {
- m.last_login_at = nil
- delete(m.clearedFields, user.FieldLastLoginAt)
- }
- // SetLastActiveAt sets the "last_active_at" field.
- func (m *UserMutation) SetLastActiveAt(t time.Time) {
- m.last_active_at = &t
- }
- // LastActiveAt returns the value of the "last_active_at" field in the mutation.
- func (m *UserMutation) LastActiveAt() (r time.Time, exists bool) {
- v := m.last_active_at
- if v == nil {
- return
- }
- return *v, true
- }
- // OldLastActiveAt returns the old "last_active_at" field's value of the User entity.
- // If the User object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *UserMutation) OldLastActiveAt(ctx context.Context) (v *time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldLastActiveAt is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldLastActiveAt requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldLastActiveAt: %w", err)
- }
- return oldValue.LastActiveAt, nil
- }
- // ClearLastActiveAt clears the value of the "last_active_at" field.
- func (m *UserMutation) ClearLastActiveAt() {
- m.last_active_at = nil
- m.clearedFields[user.FieldLastActiveAt] = struct{}{}
- }
- // LastActiveAtCleared returns if the "last_active_at" field was cleared in this mutation.
- func (m *UserMutation) LastActiveAtCleared() bool {
- _, ok := m.clearedFields[user.FieldLastActiveAt]
- return ok
- }
- // ResetLastActiveAt resets all changes to the "last_active_at" field.
- func (m *UserMutation) ResetLastActiveAt() {
- m.last_active_at = nil
- delete(m.clearedFields, user.FieldLastActiveAt)
- }
- // SetRestrictPublicGroups sets the "restrict_public_groups" field.
- func (m *UserMutation) SetRestrictPublicGroups(b bool) {
- m.restrict_public_groups = &b
- }
- // RestrictPublicGroups returns the value of the "restrict_public_groups" field in the mutation.
- func (m *UserMutation) RestrictPublicGroups() (r bool, exists bool) {
- v := m.restrict_public_groups
- if v == nil {
- return
- }
- return *v, true
- }
- // OldRestrictPublicGroups returns the old "restrict_public_groups" field's value of the User entity.
- // If the User object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *UserMutation) OldRestrictPublicGroups(ctx context.Context) (v bool, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldRestrictPublicGroups is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldRestrictPublicGroups requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldRestrictPublicGroups: %w", err)
- }
- return oldValue.RestrictPublicGroups, nil
- }
- // ResetRestrictPublicGroups resets all changes to the "restrict_public_groups" field.
- func (m *UserMutation) ResetRestrictPublicGroups() {
- m.restrict_public_groups = nil
- }
- // SetBalanceNotifyEnabled sets the "balance_notify_enabled" field.
- func (m *UserMutation) SetBalanceNotifyEnabled(b bool) {
- m.balance_notify_enabled = &b
- }
- // BalanceNotifyEnabled returns the value of the "balance_notify_enabled" field in the mutation.
- func (m *UserMutation) BalanceNotifyEnabled() (r bool, exists bool) {
- v := m.balance_notify_enabled
- if v == nil {
- return
- }
- return *v, true
- }
- // OldBalanceNotifyEnabled returns the old "balance_notify_enabled" field's value of the User entity.
- // If the User object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *UserMutation) OldBalanceNotifyEnabled(ctx context.Context) (v bool, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldBalanceNotifyEnabled is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldBalanceNotifyEnabled requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldBalanceNotifyEnabled: %w", err)
- }
- return oldValue.BalanceNotifyEnabled, nil
- }
- // ResetBalanceNotifyEnabled resets all changes to the "balance_notify_enabled" field.
- func (m *UserMutation) ResetBalanceNotifyEnabled() {
- m.balance_notify_enabled = nil
- }
- // SetBalanceNotifyThresholdType sets the "balance_notify_threshold_type" field.
- func (m *UserMutation) SetBalanceNotifyThresholdType(s string) {
- m.balance_notify_threshold_type = &s
- }
- // BalanceNotifyThresholdType returns the value of the "balance_notify_threshold_type" field in the mutation.
- func (m *UserMutation) BalanceNotifyThresholdType() (r string, exists bool) {
- v := m.balance_notify_threshold_type
- if v == nil {
- return
- }
- return *v, true
- }
- // OldBalanceNotifyThresholdType returns the old "balance_notify_threshold_type" field's value of the User entity.
- // If the User object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *UserMutation) OldBalanceNotifyThresholdType(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldBalanceNotifyThresholdType is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldBalanceNotifyThresholdType requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldBalanceNotifyThresholdType: %w", err)
- }
- return oldValue.BalanceNotifyThresholdType, nil
- }
- // ResetBalanceNotifyThresholdType resets all changes to the "balance_notify_threshold_type" field.
- func (m *UserMutation) ResetBalanceNotifyThresholdType() {
- m.balance_notify_threshold_type = nil
- }
- // SetBalanceNotifyThreshold sets the "balance_notify_threshold" field.
- func (m *UserMutation) SetBalanceNotifyThreshold(f float64) {
- m.balance_notify_threshold = &f
- m.addbalance_notify_threshold = nil
- }
- // BalanceNotifyThreshold returns the value of the "balance_notify_threshold" field in the mutation.
- func (m *UserMutation) BalanceNotifyThreshold() (r float64, exists bool) {
- v := m.balance_notify_threshold
- if v == nil {
- return
- }
- return *v, true
- }
- // OldBalanceNotifyThreshold returns the old "balance_notify_threshold" field's value of the User entity.
- // If the User object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *UserMutation) OldBalanceNotifyThreshold(ctx context.Context) (v *float64, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldBalanceNotifyThreshold is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldBalanceNotifyThreshold requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldBalanceNotifyThreshold: %w", err)
- }
- return oldValue.BalanceNotifyThreshold, nil
- }
- // AddBalanceNotifyThreshold adds f to the "balance_notify_threshold" field.
- func (m *UserMutation) AddBalanceNotifyThreshold(f float64) {
- if m.addbalance_notify_threshold != nil {
- *m.addbalance_notify_threshold += f
- } else {
- m.addbalance_notify_threshold = &f
- }
- }
- // AddedBalanceNotifyThreshold returns the value that was added to the "balance_notify_threshold" field in this mutation.
- func (m *UserMutation) AddedBalanceNotifyThreshold() (r float64, exists bool) {
- v := m.addbalance_notify_threshold
- if v == nil {
- return
- }
- return *v, true
- }
- // ClearBalanceNotifyThreshold clears the value of the "balance_notify_threshold" field.
- func (m *UserMutation) ClearBalanceNotifyThreshold() {
- m.balance_notify_threshold = nil
- m.addbalance_notify_threshold = nil
- m.clearedFields[user.FieldBalanceNotifyThreshold] = struct{}{}
- }
- // BalanceNotifyThresholdCleared returns if the "balance_notify_threshold" field was cleared in this mutation.
- func (m *UserMutation) BalanceNotifyThresholdCleared() bool {
- _, ok := m.clearedFields[user.FieldBalanceNotifyThreshold]
- return ok
- }
- // ResetBalanceNotifyThreshold resets all changes to the "balance_notify_threshold" field.
- func (m *UserMutation) ResetBalanceNotifyThreshold() {
- m.balance_notify_threshold = nil
- m.addbalance_notify_threshold = nil
- delete(m.clearedFields, user.FieldBalanceNotifyThreshold)
- }
- // SetBalanceNotifyExtraEmails sets the "balance_notify_extra_emails" field.
- func (m *UserMutation) SetBalanceNotifyExtraEmails(s string) {
- m.balance_notify_extra_emails = &s
- }
- // BalanceNotifyExtraEmails returns the value of the "balance_notify_extra_emails" field in the mutation.
- func (m *UserMutation) BalanceNotifyExtraEmails() (r string, exists bool) {
- v := m.balance_notify_extra_emails
- if v == nil {
- return
- }
- return *v, true
- }
- // OldBalanceNotifyExtraEmails returns the old "balance_notify_extra_emails" field's value of the User entity.
- // If the User object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *UserMutation) OldBalanceNotifyExtraEmails(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldBalanceNotifyExtraEmails is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldBalanceNotifyExtraEmails requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldBalanceNotifyExtraEmails: %w", err)
- }
- return oldValue.BalanceNotifyExtraEmails, nil
- }
- // ResetBalanceNotifyExtraEmails resets all changes to the "balance_notify_extra_emails" field.
- func (m *UserMutation) ResetBalanceNotifyExtraEmails() {
- m.balance_notify_extra_emails = nil
- }
- // SetTotalRecharged sets the "total_recharged" field.
- func (m *UserMutation) SetTotalRecharged(f float64) {
- m.total_recharged = &f
- m.addtotal_recharged = nil
- }
- // TotalRecharged returns the value of the "total_recharged" field in the mutation.
- func (m *UserMutation) TotalRecharged() (r float64, exists bool) {
- v := m.total_recharged
- if v == nil {
- return
- }
- return *v, true
- }
- // OldTotalRecharged returns the old "total_recharged" field's value of the User entity.
- // If the User object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *UserMutation) OldTotalRecharged(ctx context.Context) (v float64, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldTotalRecharged is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldTotalRecharged requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldTotalRecharged: %w", err)
- }
- return oldValue.TotalRecharged, nil
- }
- // AddTotalRecharged adds f to the "total_recharged" field.
- func (m *UserMutation) AddTotalRecharged(f float64) {
- if m.addtotal_recharged != nil {
- *m.addtotal_recharged += f
- } else {
- m.addtotal_recharged = &f
- }
- }
- // AddedTotalRecharged returns the value that was added to the "total_recharged" field in this mutation.
- func (m *UserMutation) AddedTotalRecharged() (r float64, exists bool) {
- v := m.addtotal_recharged
- if v == nil {
- return
- }
- return *v, true
- }
- // ResetTotalRecharged resets all changes to the "total_recharged" field.
- func (m *UserMutation) ResetTotalRecharged() {
- m.total_recharged = nil
- m.addtotal_recharged = nil
- }
- // SetRpmLimit sets the "rpm_limit" field.
- func (m *UserMutation) SetRpmLimit(i int) {
- m.rpm_limit = &i
- m.addrpm_limit = nil
- }
- // RpmLimit returns the value of the "rpm_limit" field in the mutation.
- func (m *UserMutation) RpmLimit() (r int, exists bool) {
- v := m.rpm_limit
- if v == nil {
- return
- }
- return *v, true
- }
- // OldRpmLimit returns the old "rpm_limit" field's value of the User entity.
- // If the User object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *UserMutation) OldRpmLimit(ctx context.Context) (v int, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldRpmLimit is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldRpmLimit requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldRpmLimit: %w", err)
- }
- return oldValue.RpmLimit, nil
- }
- // AddRpmLimit adds i to the "rpm_limit" field.
- func (m *UserMutation) AddRpmLimit(i int) {
- if m.addrpm_limit != nil {
- *m.addrpm_limit += i
- } else {
- m.addrpm_limit = &i
- }
- }
- // AddedRpmLimit returns the value that was added to the "rpm_limit" field in this mutation.
- func (m *UserMutation) AddedRpmLimit() (r int, exists bool) {
- v := m.addrpm_limit
- if v == nil {
- return
- }
- return *v, true
- }
- // ResetRpmLimit resets all changes to the "rpm_limit" field.
- func (m *UserMutation) ResetRpmLimit() {
- m.rpm_limit = nil
- m.addrpm_limit = nil
- }
- // AddAPIKeyIDs adds the "api_keys" edge to the APIKey entity by ids.
- func (m *UserMutation) AddAPIKeyIDs(ids ...int64) {
- if m.api_keys == nil {
- m.api_keys = make(map[int64]struct{})
- }
- for i := range ids {
- m.api_keys[ids[i]] = struct{}{}
- }
- }
- // ClearAPIKeys clears the "api_keys" edge to the APIKey entity.
- func (m *UserMutation) ClearAPIKeys() {
- m.clearedapi_keys = true
- }
- // APIKeysCleared reports if the "api_keys" edge to the APIKey entity was cleared.
- func (m *UserMutation) APIKeysCleared() bool {
- return m.clearedapi_keys
- }
- // RemoveAPIKeyIDs removes the "api_keys" edge to the APIKey entity by IDs.
- func (m *UserMutation) RemoveAPIKeyIDs(ids ...int64) {
- if m.removedapi_keys == nil {
- m.removedapi_keys = make(map[int64]struct{})
- }
- for i := range ids {
- delete(m.api_keys, ids[i])
- m.removedapi_keys[ids[i]] = struct{}{}
- }
- }
- // RemovedAPIKeys returns the removed IDs of the "api_keys" edge to the APIKey entity.
- func (m *UserMutation) RemovedAPIKeysIDs() (ids []int64) {
- for id := range m.removedapi_keys {
- ids = append(ids, id)
- }
- return
- }
- // APIKeysIDs returns the "api_keys" edge IDs in the mutation.
- func (m *UserMutation) APIKeysIDs() (ids []int64) {
- for id := range m.api_keys {
- ids = append(ids, id)
- }
- return
- }
- // ResetAPIKeys resets all changes to the "api_keys" edge.
- func (m *UserMutation) ResetAPIKeys() {
- m.api_keys = nil
- m.clearedapi_keys = false
- m.removedapi_keys = nil
- }
- // AddRedeemCodeIDs adds the "redeem_codes" edge to the RedeemCode entity by ids.
- func (m *UserMutation) AddRedeemCodeIDs(ids ...int64) {
- if m.redeem_codes == nil {
- m.redeem_codes = make(map[int64]struct{})
- }
- for i := range ids {
- m.redeem_codes[ids[i]] = struct{}{}
- }
- }
- // ClearRedeemCodes clears the "redeem_codes" edge to the RedeemCode entity.
- func (m *UserMutation) ClearRedeemCodes() {
- m.clearedredeem_codes = true
- }
- // RedeemCodesCleared reports if the "redeem_codes" edge to the RedeemCode entity was cleared.
- func (m *UserMutation) RedeemCodesCleared() bool {
- return m.clearedredeem_codes
- }
- // RemoveRedeemCodeIDs removes the "redeem_codes" edge to the RedeemCode entity by IDs.
- func (m *UserMutation) RemoveRedeemCodeIDs(ids ...int64) {
- if m.removedredeem_codes == nil {
- m.removedredeem_codes = make(map[int64]struct{})
- }
- for i := range ids {
- delete(m.redeem_codes, ids[i])
- m.removedredeem_codes[ids[i]] = struct{}{}
- }
- }
- // RemovedRedeemCodes returns the removed IDs of the "redeem_codes" edge to the RedeemCode entity.
- func (m *UserMutation) RemovedRedeemCodesIDs() (ids []int64) {
- for id := range m.removedredeem_codes {
- ids = append(ids, id)
- }
- return
- }
- // RedeemCodesIDs returns the "redeem_codes" edge IDs in the mutation.
- func (m *UserMutation) RedeemCodesIDs() (ids []int64) {
- for id := range m.redeem_codes {
- ids = append(ids, id)
- }
- return
- }
- // ResetRedeemCodes resets all changes to the "redeem_codes" edge.
- func (m *UserMutation) ResetRedeemCodes() {
- m.redeem_codes = nil
- m.clearedredeem_codes = false
- m.removedredeem_codes = nil
- }
- // AddSubscriptionIDs adds the "subscriptions" edge to the UserSubscription entity by ids.
- func (m *UserMutation) AddSubscriptionIDs(ids ...int64) {
- if m.subscriptions == nil {
- m.subscriptions = make(map[int64]struct{})
- }
- for i := range ids {
- m.subscriptions[ids[i]] = struct{}{}
- }
- }
- // ClearSubscriptions clears the "subscriptions" edge to the UserSubscription entity.
- func (m *UserMutation) ClearSubscriptions() {
- m.clearedsubscriptions = true
- }
- // SubscriptionsCleared reports if the "subscriptions" edge to the UserSubscription entity was cleared.
- func (m *UserMutation) SubscriptionsCleared() bool {
- return m.clearedsubscriptions
- }
- // RemoveSubscriptionIDs removes the "subscriptions" edge to the UserSubscription entity by IDs.
- func (m *UserMutation) RemoveSubscriptionIDs(ids ...int64) {
- if m.removedsubscriptions == nil {
- m.removedsubscriptions = make(map[int64]struct{})
- }
- for i := range ids {
- delete(m.subscriptions, ids[i])
- m.removedsubscriptions[ids[i]] = struct{}{}
- }
- }
- // RemovedSubscriptions returns the removed IDs of the "subscriptions" edge to the UserSubscription entity.
- func (m *UserMutation) RemovedSubscriptionsIDs() (ids []int64) {
- for id := range m.removedsubscriptions {
- ids = append(ids, id)
- }
- return
- }
- // SubscriptionsIDs returns the "subscriptions" edge IDs in the mutation.
- func (m *UserMutation) SubscriptionsIDs() (ids []int64) {
- for id := range m.subscriptions {
- ids = append(ids, id)
- }
- return
- }
- // ResetSubscriptions resets all changes to the "subscriptions" edge.
- func (m *UserMutation) ResetSubscriptions() {
- m.subscriptions = nil
- m.clearedsubscriptions = false
- m.removedsubscriptions = nil
- }
- // AddAssignedSubscriptionIDs adds the "assigned_subscriptions" edge to the UserSubscription entity by ids.
- func (m *UserMutation) AddAssignedSubscriptionIDs(ids ...int64) {
- if m.assigned_subscriptions == nil {
- m.assigned_subscriptions = make(map[int64]struct{})
- }
- for i := range ids {
- m.assigned_subscriptions[ids[i]] = struct{}{}
- }
- }
- // ClearAssignedSubscriptions clears the "assigned_subscriptions" edge to the UserSubscription entity.
- func (m *UserMutation) ClearAssignedSubscriptions() {
- m.clearedassigned_subscriptions = true
- }
- // AssignedSubscriptionsCleared reports if the "assigned_subscriptions" edge to the UserSubscription entity was cleared.
- func (m *UserMutation) AssignedSubscriptionsCleared() bool {
- return m.clearedassigned_subscriptions
- }
- // RemoveAssignedSubscriptionIDs removes the "assigned_subscriptions" edge to the UserSubscription entity by IDs.
- func (m *UserMutation) RemoveAssignedSubscriptionIDs(ids ...int64) {
- if m.removedassigned_subscriptions == nil {
- m.removedassigned_subscriptions = make(map[int64]struct{})
- }
- for i := range ids {
- delete(m.assigned_subscriptions, ids[i])
- m.removedassigned_subscriptions[ids[i]] = struct{}{}
- }
- }
- // RemovedAssignedSubscriptions returns the removed IDs of the "assigned_subscriptions" edge to the UserSubscription entity.
- func (m *UserMutation) RemovedAssignedSubscriptionsIDs() (ids []int64) {
- for id := range m.removedassigned_subscriptions {
- ids = append(ids, id)
- }
- return
- }
- // AssignedSubscriptionsIDs returns the "assigned_subscriptions" edge IDs in the mutation.
- func (m *UserMutation) AssignedSubscriptionsIDs() (ids []int64) {
- for id := range m.assigned_subscriptions {
- ids = append(ids, id)
- }
- return
- }
- // ResetAssignedSubscriptions resets all changes to the "assigned_subscriptions" edge.
- func (m *UserMutation) ResetAssignedSubscriptions() {
- m.assigned_subscriptions = nil
- m.clearedassigned_subscriptions = false
- m.removedassigned_subscriptions = nil
- }
- // AddAnnouncementReadIDs adds the "announcement_reads" edge to the AnnouncementRead entity by ids.
- func (m *UserMutation) AddAnnouncementReadIDs(ids ...int64) {
- if m.announcement_reads == nil {
- m.announcement_reads = make(map[int64]struct{})
- }
- for i := range ids {
- m.announcement_reads[ids[i]] = struct{}{}
- }
- }
- // ClearAnnouncementReads clears the "announcement_reads" edge to the AnnouncementRead entity.
- func (m *UserMutation) ClearAnnouncementReads() {
- m.clearedannouncement_reads = true
- }
- // AnnouncementReadsCleared reports if the "announcement_reads" edge to the AnnouncementRead entity was cleared.
- func (m *UserMutation) AnnouncementReadsCleared() bool {
- return m.clearedannouncement_reads
- }
- // RemoveAnnouncementReadIDs removes the "announcement_reads" edge to the AnnouncementRead entity by IDs.
- func (m *UserMutation) RemoveAnnouncementReadIDs(ids ...int64) {
- if m.removedannouncement_reads == nil {
- m.removedannouncement_reads = make(map[int64]struct{})
- }
- for i := range ids {
- delete(m.announcement_reads, ids[i])
- m.removedannouncement_reads[ids[i]] = struct{}{}
- }
- }
- // RemovedAnnouncementReads returns the removed IDs of the "announcement_reads" edge to the AnnouncementRead entity.
- func (m *UserMutation) RemovedAnnouncementReadsIDs() (ids []int64) {
- for id := range m.removedannouncement_reads {
- ids = append(ids, id)
- }
- return
- }
- // AnnouncementReadsIDs returns the "announcement_reads" edge IDs in the mutation.
- func (m *UserMutation) AnnouncementReadsIDs() (ids []int64) {
- for id := range m.announcement_reads {
- ids = append(ids, id)
- }
- return
- }
- // ResetAnnouncementReads resets all changes to the "announcement_reads" edge.
- func (m *UserMutation) ResetAnnouncementReads() {
- m.announcement_reads = nil
- m.clearedannouncement_reads = false
- m.removedannouncement_reads = nil
- }
- // AddAllowedGroupIDs adds the "allowed_groups" edge to the Group entity by ids.
- func (m *UserMutation) AddAllowedGroupIDs(ids ...int64) {
- if m.allowed_groups == nil {
- m.allowed_groups = make(map[int64]struct{})
- }
- for i := range ids {
- m.allowed_groups[ids[i]] = struct{}{}
- }
- }
- // ClearAllowedGroups clears the "allowed_groups" edge to the Group entity.
- func (m *UserMutation) ClearAllowedGroups() {
- m.clearedallowed_groups = true
- }
- // AllowedGroupsCleared reports if the "allowed_groups" edge to the Group entity was cleared.
- func (m *UserMutation) AllowedGroupsCleared() bool {
- return m.clearedallowed_groups
- }
- // RemoveAllowedGroupIDs removes the "allowed_groups" edge to the Group entity by IDs.
- func (m *UserMutation) RemoveAllowedGroupIDs(ids ...int64) {
- if m.removedallowed_groups == nil {
- m.removedallowed_groups = make(map[int64]struct{})
- }
- for i := range ids {
- delete(m.allowed_groups, ids[i])
- m.removedallowed_groups[ids[i]] = struct{}{}
- }
- }
- // RemovedAllowedGroups returns the removed IDs of the "allowed_groups" edge to the Group entity.
- func (m *UserMutation) RemovedAllowedGroupsIDs() (ids []int64) {
- for id := range m.removedallowed_groups {
- ids = append(ids, id)
- }
- return
- }
- // AllowedGroupsIDs returns the "allowed_groups" edge IDs in the mutation.
- func (m *UserMutation) AllowedGroupsIDs() (ids []int64) {
- for id := range m.allowed_groups {
- ids = append(ids, id)
- }
- return
- }
- // ResetAllowedGroups resets all changes to the "allowed_groups" edge.
- func (m *UserMutation) ResetAllowedGroups() {
- m.allowed_groups = nil
- m.clearedallowed_groups = false
- m.removedallowed_groups = nil
- }
- // AddUsageLogIDs adds the "usage_logs" edge to the UsageLog entity by ids.
- func (m *UserMutation) AddUsageLogIDs(ids ...int64) {
- if m.usage_logs == nil {
- m.usage_logs = make(map[int64]struct{})
- }
- for i := range ids {
- m.usage_logs[ids[i]] = struct{}{}
- }
- }
- // ClearUsageLogs clears the "usage_logs" edge to the UsageLog entity.
- func (m *UserMutation) ClearUsageLogs() {
- m.clearedusage_logs = true
- }
- // UsageLogsCleared reports if the "usage_logs" edge to the UsageLog entity was cleared.
- func (m *UserMutation) UsageLogsCleared() bool {
- return m.clearedusage_logs
- }
- // RemoveUsageLogIDs removes the "usage_logs" edge to the UsageLog entity by IDs.
- func (m *UserMutation) RemoveUsageLogIDs(ids ...int64) {
- if m.removedusage_logs == nil {
- m.removedusage_logs = make(map[int64]struct{})
- }
- for i := range ids {
- delete(m.usage_logs, ids[i])
- m.removedusage_logs[ids[i]] = struct{}{}
- }
- }
- // RemovedUsageLogs returns the removed IDs of the "usage_logs" edge to the UsageLog entity.
- func (m *UserMutation) RemovedUsageLogsIDs() (ids []int64) {
- for id := range m.removedusage_logs {
- ids = append(ids, id)
- }
- return
- }
- // UsageLogsIDs returns the "usage_logs" edge IDs in the mutation.
- func (m *UserMutation) UsageLogsIDs() (ids []int64) {
- for id := range m.usage_logs {
- ids = append(ids, id)
- }
- return
- }
- // ResetUsageLogs resets all changes to the "usage_logs" edge.
- func (m *UserMutation) ResetUsageLogs() {
- m.usage_logs = nil
- m.clearedusage_logs = false
- m.removedusage_logs = nil
- }
- // AddAttributeValueIDs adds the "attribute_values" edge to the UserAttributeValue entity by ids.
- func (m *UserMutation) AddAttributeValueIDs(ids ...int64) {
- if m.attribute_values == nil {
- m.attribute_values = make(map[int64]struct{})
- }
- for i := range ids {
- m.attribute_values[ids[i]] = struct{}{}
- }
- }
- // ClearAttributeValues clears the "attribute_values" edge to the UserAttributeValue entity.
- func (m *UserMutation) ClearAttributeValues() {
- m.clearedattribute_values = true
- }
- // AttributeValuesCleared reports if the "attribute_values" edge to the UserAttributeValue entity was cleared.
- func (m *UserMutation) AttributeValuesCleared() bool {
- return m.clearedattribute_values
- }
- // RemoveAttributeValueIDs removes the "attribute_values" edge to the UserAttributeValue entity by IDs.
- func (m *UserMutation) RemoveAttributeValueIDs(ids ...int64) {
- if m.removedattribute_values == nil {
- m.removedattribute_values = make(map[int64]struct{})
- }
- for i := range ids {
- delete(m.attribute_values, ids[i])
- m.removedattribute_values[ids[i]] = struct{}{}
- }
- }
- // RemovedAttributeValues returns the removed IDs of the "attribute_values" edge to the UserAttributeValue entity.
- func (m *UserMutation) RemovedAttributeValuesIDs() (ids []int64) {
- for id := range m.removedattribute_values {
- ids = append(ids, id)
- }
- return
- }
- // AttributeValuesIDs returns the "attribute_values" edge IDs in the mutation.
- func (m *UserMutation) AttributeValuesIDs() (ids []int64) {
- for id := range m.attribute_values {
- ids = append(ids, id)
- }
- return
- }
- // ResetAttributeValues resets all changes to the "attribute_values" edge.
- func (m *UserMutation) ResetAttributeValues() {
- m.attribute_values = nil
- m.clearedattribute_values = false
- m.removedattribute_values = nil
- }
- // AddPromoCodeUsageIDs adds the "promo_code_usages" edge to the PromoCodeUsage entity by ids.
- func (m *UserMutation) AddPromoCodeUsageIDs(ids ...int64) {
- if m.promo_code_usages == nil {
- m.promo_code_usages = make(map[int64]struct{})
- }
- for i := range ids {
- m.promo_code_usages[ids[i]] = struct{}{}
- }
- }
- // ClearPromoCodeUsages clears the "promo_code_usages" edge to the PromoCodeUsage entity.
- func (m *UserMutation) ClearPromoCodeUsages() {
- m.clearedpromo_code_usages = true
- }
- // PromoCodeUsagesCleared reports if the "promo_code_usages" edge to the PromoCodeUsage entity was cleared.
- func (m *UserMutation) PromoCodeUsagesCleared() bool {
- return m.clearedpromo_code_usages
- }
- // RemovePromoCodeUsageIDs removes the "promo_code_usages" edge to the PromoCodeUsage entity by IDs.
- func (m *UserMutation) RemovePromoCodeUsageIDs(ids ...int64) {
- if m.removedpromo_code_usages == nil {
- m.removedpromo_code_usages = make(map[int64]struct{})
- }
- for i := range ids {
- delete(m.promo_code_usages, ids[i])
- m.removedpromo_code_usages[ids[i]] = struct{}{}
- }
- }
- // RemovedPromoCodeUsages returns the removed IDs of the "promo_code_usages" edge to the PromoCodeUsage entity.
- func (m *UserMutation) RemovedPromoCodeUsagesIDs() (ids []int64) {
- for id := range m.removedpromo_code_usages {
- ids = append(ids, id)
- }
- return
- }
- // PromoCodeUsagesIDs returns the "promo_code_usages" edge IDs in the mutation.
- func (m *UserMutation) PromoCodeUsagesIDs() (ids []int64) {
- for id := range m.promo_code_usages {
- ids = append(ids, id)
- }
- return
- }
- // ResetPromoCodeUsages resets all changes to the "promo_code_usages" edge.
- func (m *UserMutation) ResetPromoCodeUsages() {
- m.promo_code_usages = nil
- m.clearedpromo_code_usages = false
- m.removedpromo_code_usages = nil
- }
- // AddPaymentOrderIDs adds the "payment_orders" edge to the PaymentOrder entity by ids.
- func (m *UserMutation) AddPaymentOrderIDs(ids ...int64) {
- if m.payment_orders == nil {
- m.payment_orders = make(map[int64]struct{})
- }
- for i := range ids {
- m.payment_orders[ids[i]] = struct{}{}
- }
- }
- // ClearPaymentOrders clears the "payment_orders" edge to the PaymentOrder entity.
- func (m *UserMutation) ClearPaymentOrders() {
- m.clearedpayment_orders = true
- }
- // PaymentOrdersCleared reports if the "payment_orders" edge to the PaymentOrder entity was cleared.
- func (m *UserMutation) PaymentOrdersCleared() bool {
- return m.clearedpayment_orders
- }
- // RemovePaymentOrderIDs removes the "payment_orders" edge to the PaymentOrder entity by IDs.
- func (m *UserMutation) RemovePaymentOrderIDs(ids ...int64) {
- if m.removedpayment_orders == nil {
- m.removedpayment_orders = make(map[int64]struct{})
- }
- for i := range ids {
- delete(m.payment_orders, ids[i])
- m.removedpayment_orders[ids[i]] = struct{}{}
- }
- }
- // RemovedPaymentOrders returns the removed IDs of the "payment_orders" edge to the PaymentOrder entity.
- func (m *UserMutation) RemovedPaymentOrdersIDs() (ids []int64) {
- for id := range m.removedpayment_orders {
- ids = append(ids, id)
- }
- return
- }
- // PaymentOrdersIDs returns the "payment_orders" edge IDs in the mutation.
- func (m *UserMutation) PaymentOrdersIDs() (ids []int64) {
- for id := range m.payment_orders {
- ids = append(ids, id)
- }
- return
- }
- // ResetPaymentOrders resets all changes to the "payment_orders" edge.
- func (m *UserMutation) ResetPaymentOrders() {
- m.payment_orders = nil
- m.clearedpayment_orders = false
- m.removedpayment_orders = nil
- }
- // AddAuthIdentityIDs adds the "auth_identities" edge to the AuthIdentity entity by ids.
- func (m *UserMutation) AddAuthIdentityIDs(ids ...int64) {
- if m.auth_identities == nil {
- m.auth_identities = make(map[int64]struct{})
- }
- for i := range ids {
- m.auth_identities[ids[i]] = struct{}{}
- }
- }
- // ClearAuthIdentities clears the "auth_identities" edge to the AuthIdentity entity.
- func (m *UserMutation) ClearAuthIdentities() {
- m.clearedauth_identities = true
- }
- // AuthIdentitiesCleared reports if the "auth_identities" edge to the AuthIdentity entity was cleared.
- func (m *UserMutation) AuthIdentitiesCleared() bool {
- return m.clearedauth_identities
- }
- // RemoveAuthIdentityIDs removes the "auth_identities" edge to the AuthIdentity entity by IDs.
- func (m *UserMutation) RemoveAuthIdentityIDs(ids ...int64) {
- if m.removedauth_identities == nil {
- m.removedauth_identities = make(map[int64]struct{})
- }
- for i := range ids {
- delete(m.auth_identities, ids[i])
- m.removedauth_identities[ids[i]] = struct{}{}
- }
- }
- // RemovedAuthIdentities returns the removed IDs of the "auth_identities" edge to the AuthIdentity entity.
- func (m *UserMutation) RemovedAuthIdentitiesIDs() (ids []int64) {
- for id := range m.removedauth_identities {
- ids = append(ids, id)
- }
- return
- }
- // AuthIdentitiesIDs returns the "auth_identities" edge IDs in the mutation.
- func (m *UserMutation) AuthIdentitiesIDs() (ids []int64) {
- for id := range m.auth_identities {
- ids = append(ids, id)
- }
- return
- }
- // ResetAuthIdentities resets all changes to the "auth_identities" edge.
- func (m *UserMutation) ResetAuthIdentities() {
- m.auth_identities = nil
- m.clearedauth_identities = false
- m.removedauth_identities = nil
- }
- // AddPendingAuthSessionIDs adds the "pending_auth_sessions" edge to the PendingAuthSession entity by ids.
- func (m *UserMutation) AddPendingAuthSessionIDs(ids ...int64) {
- if m.pending_auth_sessions == nil {
- m.pending_auth_sessions = make(map[int64]struct{})
- }
- for i := range ids {
- m.pending_auth_sessions[ids[i]] = struct{}{}
- }
- }
- // ClearPendingAuthSessions clears the "pending_auth_sessions" edge to the PendingAuthSession entity.
- func (m *UserMutation) ClearPendingAuthSessions() {
- m.clearedpending_auth_sessions = true
- }
- // PendingAuthSessionsCleared reports if the "pending_auth_sessions" edge to the PendingAuthSession entity was cleared.
- func (m *UserMutation) PendingAuthSessionsCleared() bool {
- return m.clearedpending_auth_sessions
- }
- // RemovePendingAuthSessionIDs removes the "pending_auth_sessions" edge to the PendingAuthSession entity by IDs.
- func (m *UserMutation) RemovePendingAuthSessionIDs(ids ...int64) {
- if m.removedpending_auth_sessions == nil {
- m.removedpending_auth_sessions = make(map[int64]struct{})
- }
- for i := range ids {
- delete(m.pending_auth_sessions, ids[i])
- m.removedpending_auth_sessions[ids[i]] = struct{}{}
- }
- }
- // RemovedPendingAuthSessions returns the removed IDs of the "pending_auth_sessions" edge to the PendingAuthSession entity.
- func (m *UserMutation) RemovedPendingAuthSessionsIDs() (ids []int64) {
- for id := range m.removedpending_auth_sessions {
- ids = append(ids, id)
- }
- return
- }
- // PendingAuthSessionsIDs returns the "pending_auth_sessions" edge IDs in the mutation.
- func (m *UserMutation) PendingAuthSessionsIDs() (ids []int64) {
- for id := range m.pending_auth_sessions {
- ids = append(ids, id)
- }
- return
- }
- // ResetPendingAuthSessions resets all changes to the "pending_auth_sessions" edge.
- func (m *UserMutation) ResetPendingAuthSessions() {
- m.pending_auth_sessions = nil
- m.clearedpending_auth_sessions = false
- m.removedpending_auth_sessions = nil
- }
- // AddPlatformQuotaIDs adds the "platform_quotas" edge to the UserPlatformQuota entity by ids.
- func (m *UserMutation) AddPlatformQuotaIDs(ids ...int64) {
- if m.platform_quotas == nil {
- m.platform_quotas = make(map[int64]struct{})
- }
- for i := range ids {
- m.platform_quotas[ids[i]] = struct{}{}
- }
- }
- // ClearPlatformQuotas clears the "platform_quotas" edge to the UserPlatformQuota entity.
- func (m *UserMutation) ClearPlatformQuotas() {
- m.clearedplatform_quotas = true
- }
- // PlatformQuotasCleared reports if the "platform_quotas" edge to the UserPlatformQuota entity was cleared.
- func (m *UserMutation) PlatformQuotasCleared() bool {
- return m.clearedplatform_quotas
- }
- // RemovePlatformQuotaIDs removes the "platform_quotas" edge to the UserPlatformQuota entity by IDs.
- func (m *UserMutation) RemovePlatformQuotaIDs(ids ...int64) {
- if m.removedplatform_quotas == nil {
- m.removedplatform_quotas = make(map[int64]struct{})
- }
- for i := range ids {
- delete(m.platform_quotas, ids[i])
- m.removedplatform_quotas[ids[i]] = struct{}{}
- }
- }
- // RemovedPlatformQuotas returns the removed IDs of the "platform_quotas" edge to the UserPlatformQuota entity.
- func (m *UserMutation) RemovedPlatformQuotasIDs() (ids []int64) {
- for id := range m.removedplatform_quotas {
- ids = append(ids, id)
- }
- return
- }
- // PlatformQuotasIDs returns the "platform_quotas" edge IDs in the mutation.
- func (m *UserMutation) PlatformQuotasIDs() (ids []int64) {
- for id := range m.platform_quotas {
- ids = append(ids, id)
- }
- return
- }
- // ResetPlatformQuotas resets all changes to the "platform_quotas" edge.
- func (m *UserMutation) ResetPlatformQuotas() {
- m.platform_quotas = nil
- m.clearedplatform_quotas = false
- m.removedplatform_quotas = nil
- }
- // Where appends a list predicates to the UserMutation builder.
- func (m *UserMutation) Where(ps ...predicate.User) {
- m.predicates = append(m.predicates, ps...)
- }
- // WhereP appends storage-level predicates to the UserMutation builder. Using this method,
- // users can use type-assertion to append predicates that do not depend on any generated package.
- func (m *UserMutation) WhereP(ps ...func(*sql.Selector)) {
- p := make([]predicate.User, len(ps))
- for i := range ps {
- p[i] = ps[i]
- }
- m.Where(p...)
- }
- // Op returns the operation name.
- func (m *UserMutation) Op() Op {
- return m.op
- }
- // SetOp allows setting the mutation operation.
- func (m *UserMutation) SetOp(op Op) {
- m.op = op
- }
- // Type returns the node type of this mutation (User).
- func (m *UserMutation) Type() string {
- return m.typ
- }
- // Fields returns all fields that were changed during this mutation. Note that in
- // order to get all numeric fields that were incremented/decremented, call
- // AddedFields().
- func (m *UserMutation) Fields() []string {
- fields := make([]string, 0, 25)
- if m.created_at != nil {
- fields = append(fields, user.FieldCreatedAt)
- }
- if m.updated_at != nil {
- fields = append(fields, user.FieldUpdatedAt)
- }
- if m.deleted_at != nil {
- fields = append(fields, user.FieldDeletedAt)
- }
- if m.email != nil {
- fields = append(fields, user.FieldEmail)
- }
- if m.password_hash != nil {
- fields = append(fields, user.FieldPasswordHash)
- }
- if m.role != nil {
- fields = append(fields, user.FieldRole)
- }
- if m.balance != nil {
- fields = append(fields, user.FieldBalance)
- }
- if m.frozen_balance != nil {
- fields = append(fields, user.FieldFrozenBalance)
- }
- if m.concurrency != nil {
- fields = append(fields, user.FieldConcurrency)
- }
- if m.status != nil {
- fields = append(fields, user.FieldStatus)
- }
- if m.username != nil {
- fields = append(fields, user.FieldUsername)
- }
- if m.notes != nil {
- fields = append(fields, user.FieldNotes)
- }
- if m.totp_secret_encrypted != nil {
- fields = append(fields, user.FieldTotpSecretEncrypted)
- }
- if m.totp_enabled != nil {
- fields = append(fields, user.FieldTotpEnabled)
- }
- if m.totp_enabled_at != nil {
- fields = append(fields, user.FieldTotpEnabledAt)
- }
- if m.signup_source != nil {
- fields = append(fields, user.FieldSignupSource)
- }
- if m.last_login_at != nil {
- fields = append(fields, user.FieldLastLoginAt)
- }
- if m.last_active_at != nil {
- fields = append(fields, user.FieldLastActiveAt)
- }
- if m.restrict_public_groups != nil {
- fields = append(fields, user.FieldRestrictPublicGroups)
- }
- if m.balance_notify_enabled != nil {
- fields = append(fields, user.FieldBalanceNotifyEnabled)
- }
- if m.balance_notify_threshold_type != nil {
- fields = append(fields, user.FieldBalanceNotifyThresholdType)
- }
- if m.balance_notify_threshold != nil {
- fields = append(fields, user.FieldBalanceNotifyThreshold)
- }
- if m.balance_notify_extra_emails != nil {
- fields = append(fields, user.FieldBalanceNotifyExtraEmails)
- }
- if m.total_recharged != nil {
- fields = append(fields, user.FieldTotalRecharged)
- }
- if m.rpm_limit != nil {
- fields = append(fields, user.FieldRpmLimit)
- }
- return fields
- }
- // Field returns the value of a field with the given name. The second boolean
- // return value indicates that this field was not set, or was not defined in the
- // schema.
- func (m *UserMutation) Field(name string) (ent.Value, bool) {
- switch name {
- case user.FieldCreatedAt:
- return m.CreatedAt()
- case user.FieldUpdatedAt:
- return m.UpdatedAt()
- case user.FieldDeletedAt:
- return m.DeletedAt()
- case user.FieldEmail:
- return m.Email()
- case user.FieldPasswordHash:
- return m.PasswordHash()
- case user.FieldRole:
- return m.Role()
- case user.FieldBalance:
- return m.Balance()
- case user.FieldFrozenBalance:
- return m.FrozenBalance()
- case user.FieldConcurrency:
- return m.Concurrency()
- case user.FieldStatus:
- return m.Status()
- case user.FieldUsername:
- return m.Username()
- case user.FieldNotes:
- return m.Notes()
- case user.FieldTotpSecretEncrypted:
- return m.TotpSecretEncrypted()
- case user.FieldTotpEnabled:
- return m.TotpEnabled()
- case user.FieldTotpEnabledAt:
- return m.TotpEnabledAt()
- case user.FieldSignupSource:
- return m.SignupSource()
- case user.FieldLastLoginAt:
- return m.LastLoginAt()
- case user.FieldLastActiveAt:
- return m.LastActiveAt()
- case user.FieldRestrictPublicGroups:
- return m.RestrictPublicGroups()
- case user.FieldBalanceNotifyEnabled:
- return m.BalanceNotifyEnabled()
- case user.FieldBalanceNotifyThresholdType:
- return m.BalanceNotifyThresholdType()
- case user.FieldBalanceNotifyThreshold:
- return m.BalanceNotifyThreshold()
- case user.FieldBalanceNotifyExtraEmails:
- return m.BalanceNotifyExtraEmails()
- case user.FieldTotalRecharged:
- return m.TotalRecharged()
- case user.FieldRpmLimit:
- return m.RpmLimit()
- }
- return nil, false
- }
- // OldField returns the old value of the field from the database. An error is
- // returned if the mutation operation is not UpdateOne, or the query to the
- // database failed.
- func (m *UserMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
- switch name {
- case user.FieldCreatedAt:
- return m.OldCreatedAt(ctx)
- case user.FieldUpdatedAt:
- return m.OldUpdatedAt(ctx)
- case user.FieldDeletedAt:
- return m.OldDeletedAt(ctx)
- case user.FieldEmail:
- return m.OldEmail(ctx)
- case user.FieldPasswordHash:
- return m.OldPasswordHash(ctx)
- case user.FieldRole:
- return m.OldRole(ctx)
- case user.FieldBalance:
- return m.OldBalance(ctx)
- case user.FieldFrozenBalance:
- return m.OldFrozenBalance(ctx)
- case user.FieldConcurrency:
- return m.OldConcurrency(ctx)
- case user.FieldStatus:
- return m.OldStatus(ctx)
- case user.FieldUsername:
- return m.OldUsername(ctx)
- case user.FieldNotes:
- return m.OldNotes(ctx)
- case user.FieldTotpSecretEncrypted:
- return m.OldTotpSecretEncrypted(ctx)
- case user.FieldTotpEnabled:
- return m.OldTotpEnabled(ctx)
- case user.FieldTotpEnabledAt:
- return m.OldTotpEnabledAt(ctx)
- case user.FieldSignupSource:
- return m.OldSignupSource(ctx)
- case user.FieldLastLoginAt:
- return m.OldLastLoginAt(ctx)
- case user.FieldLastActiveAt:
- return m.OldLastActiveAt(ctx)
- case user.FieldRestrictPublicGroups:
- return m.OldRestrictPublicGroups(ctx)
- case user.FieldBalanceNotifyEnabled:
- return m.OldBalanceNotifyEnabled(ctx)
- case user.FieldBalanceNotifyThresholdType:
- return m.OldBalanceNotifyThresholdType(ctx)
- case user.FieldBalanceNotifyThreshold:
- return m.OldBalanceNotifyThreshold(ctx)
- case user.FieldBalanceNotifyExtraEmails:
- return m.OldBalanceNotifyExtraEmails(ctx)
- case user.FieldTotalRecharged:
- return m.OldTotalRecharged(ctx)
- case user.FieldRpmLimit:
- return m.OldRpmLimit(ctx)
- }
- return nil, fmt.Errorf("unknown User field %s", name)
- }
- // SetField sets the value of a field with the given name. It returns an error if
- // the field is not defined in the schema, or if the type mismatched the field
- // type.
- func (m *UserMutation) SetField(name string, value ent.Value) error {
- switch name {
- case user.FieldCreatedAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetCreatedAt(v)
- return nil
- case user.FieldUpdatedAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetUpdatedAt(v)
- return nil
- case user.FieldDeletedAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetDeletedAt(v)
- return nil
- case user.FieldEmail:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetEmail(v)
- return nil
- case user.FieldPasswordHash:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetPasswordHash(v)
- return nil
- case user.FieldRole:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetRole(v)
- return nil
- case user.FieldBalance:
- v, ok := value.(float64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetBalance(v)
- return nil
- case user.FieldFrozenBalance:
- v, ok := value.(float64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetFrozenBalance(v)
- return nil
- case user.FieldConcurrency:
- v, ok := value.(int)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetConcurrency(v)
- return nil
- case user.FieldStatus:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetStatus(v)
- return nil
- case user.FieldUsername:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetUsername(v)
- return nil
- case user.FieldNotes:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetNotes(v)
- return nil
- case user.FieldTotpSecretEncrypted:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetTotpSecretEncrypted(v)
- return nil
- case user.FieldTotpEnabled:
- v, ok := value.(bool)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetTotpEnabled(v)
- return nil
- case user.FieldTotpEnabledAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetTotpEnabledAt(v)
- return nil
- case user.FieldSignupSource:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetSignupSource(v)
- return nil
- case user.FieldLastLoginAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetLastLoginAt(v)
- return nil
- case user.FieldLastActiveAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetLastActiveAt(v)
- return nil
- case user.FieldRestrictPublicGroups:
- v, ok := value.(bool)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetRestrictPublicGroups(v)
- return nil
- case user.FieldBalanceNotifyEnabled:
- v, ok := value.(bool)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetBalanceNotifyEnabled(v)
- return nil
- case user.FieldBalanceNotifyThresholdType:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetBalanceNotifyThresholdType(v)
- return nil
- case user.FieldBalanceNotifyThreshold:
- v, ok := value.(float64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetBalanceNotifyThreshold(v)
- return nil
- case user.FieldBalanceNotifyExtraEmails:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetBalanceNotifyExtraEmails(v)
- return nil
- case user.FieldTotalRecharged:
- v, ok := value.(float64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetTotalRecharged(v)
- return nil
- case user.FieldRpmLimit:
- v, ok := value.(int)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetRpmLimit(v)
- return nil
- }
- return fmt.Errorf("unknown User field %s", name)
- }
- // AddedFields returns all numeric fields that were incremented/decremented during
- // this mutation.
- func (m *UserMutation) AddedFields() []string {
- var fields []string
- if m.addbalance != nil {
- fields = append(fields, user.FieldBalance)
- }
- if m.addfrozen_balance != nil {
- fields = append(fields, user.FieldFrozenBalance)
- }
- if m.addconcurrency != nil {
- fields = append(fields, user.FieldConcurrency)
- }
- if m.addbalance_notify_threshold != nil {
- fields = append(fields, user.FieldBalanceNotifyThreshold)
- }
- if m.addtotal_recharged != nil {
- fields = append(fields, user.FieldTotalRecharged)
- }
- if m.addrpm_limit != nil {
- fields = append(fields, user.FieldRpmLimit)
- }
- return fields
- }
- // AddedField returns the numeric value that was incremented/decremented on a field
- // with the given name. The second boolean return value indicates that this field
- // was not set, or was not defined in the schema.
- func (m *UserMutation) AddedField(name string) (ent.Value, bool) {
- switch name {
- case user.FieldBalance:
- return m.AddedBalance()
- case user.FieldFrozenBalance:
- return m.AddedFrozenBalance()
- case user.FieldConcurrency:
- return m.AddedConcurrency()
- case user.FieldBalanceNotifyThreshold:
- return m.AddedBalanceNotifyThreshold()
- case user.FieldTotalRecharged:
- return m.AddedTotalRecharged()
- case user.FieldRpmLimit:
- return m.AddedRpmLimit()
- }
- return nil, false
- }
- // AddField adds the value to the field with the given name. It returns an error if
- // the field is not defined in the schema, or if the type mismatched the field
- // type.
- func (m *UserMutation) AddField(name string, value ent.Value) error {
- switch name {
- case user.FieldBalance:
- v, ok := value.(float64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.AddBalance(v)
- return nil
- case user.FieldFrozenBalance:
- v, ok := value.(float64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.AddFrozenBalance(v)
- return nil
- case user.FieldConcurrency:
- v, ok := value.(int)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.AddConcurrency(v)
- return nil
- case user.FieldBalanceNotifyThreshold:
- v, ok := value.(float64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.AddBalanceNotifyThreshold(v)
- return nil
- case user.FieldTotalRecharged:
- v, ok := value.(float64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.AddTotalRecharged(v)
- return nil
- case user.FieldRpmLimit:
- v, ok := value.(int)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.AddRpmLimit(v)
- return nil
- }
- return fmt.Errorf("unknown User numeric field %s", name)
- }
- // ClearedFields returns all nullable fields that were cleared during this
- // mutation.
- func (m *UserMutation) ClearedFields() []string {
- var fields []string
- if m.FieldCleared(user.FieldDeletedAt) {
- fields = append(fields, user.FieldDeletedAt)
- }
- if m.FieldCleared(user.FieldTotpSecretEncrypted) {
- fields = append(fields, user.FieldTotpSecretEncrypted)
- }
- if m.FieldCleared(user.FieldTotpEnabledAt) {
- fields = append(fields, user.FieldTotpEnabledAt)
- }
- if m.FieldCleared(user.FieldLastLoginAt) {
- fields = append(fields, user.FieldLastLoginAt)
- }
- if m.FieldCleared(user.FieldLastActiveAt) {
- fields = append(fields, user.FieldLastActiveAt)
- }
- if m.FieldCleared(user.FieldBalanceNotifyThreshold) {
- fields = append(fields, user.FieldBalanceNotifyThreshold)
- }
- return fields
- }
- // FieldCleared returns a boolean indicating if a field with the given name was
- // cleared in this mutation.
- func (m *UserMutation) FieldCleared(name string) bool {
- _, ok := m.clearedFields[name]
- return ok
- }
- // ClearField clears the value of the field with the given name. It returns an
- // error if the field is not defined in the schema.
- func (m *UserMutation) ClearField(name string) error {
- switch name {
- case user.FieldDeletedAt:
- m.ClearDeletedAt()
- return nil
- case user.FieldTotpSecretEncrypted:
- m.ClearTotpSecretEncrypted()
- return nil
- case user.FieldTotpEnabledAt:
- m.ClearTotpEnabledAt()
- return nil
- case user.FieldLastLoginAt:
- m.ClearLastLoginAt()
- return nil
- case user.FieldLastActiveAt:
- m.ClearLastActiveAt()
- return nil
- case user.FieldBalanceNotifyThreshold:
- m.ClearBalanceNotifyThreshold()
- return nil
- }
- return fmt.Errorf("unknown User nullable field %s", name)
- }
- // ResetField resets all changes in the mutation for the field with the given name.
- // It returns an error if the field is not defined in the schema.
- func (m *UserMutation) ResetField(name string) error {
- switch name {
- case user.FieldCreatedAt:
- m.ResetCreatedAt()
- return nil
- case user.FieldUpdatedAt:
- m.ResetUpdatedAt()
- return nil
- case user.FieldDeletedAt:
- m.ResetDeletedAt()
- return nil
- case user.FieldEmail:
- m.ResetEmail()
- return nil
- case user.FieldPasswordHash:
- m.ResetPasswordHash()
- return nil
- case user.FieldRole:
- m.ResetRole()
- return nil
- case user.FieldBalance:
- m.ResetBalance()
- return nil
- case user.FieldFrozenBalance:
- m.ResetFrozenBalance()
- return nil
- case user.FieldConcurrency:
- m.ResetConcurrency()
- return nil
- case user.FieldStatus:
- m.ResetStatus()
- return nil
- case user.FieldUsername:
- m.ResetUsername()
- return nil
- case user.FieldNotes:
- m.ResetNotes()
- return nil
- case user.FieldTotpSecretEncrypted:
- m.ResetTotpSecretEncrypted()
- return nil
- case user.FieldTotpEnabled:
- m.ResetTotpEnabled()
- return nil
- case user.FieldTotpEnabledAt:
- m.ResetTotpEnabledAt()
- return nil
- case user.FieldSignupSource:
- m.ResetSignupSource()
- return nil
- case user.FieldLastLoginAt:
- m.ResetLastLoginAt()
- return nil
- case user.FieldLastActiveAt:
- m.ResetLastActiveAt()
- return nil
- case user.FieldRestrictPublicGroups:
- m.ResetRestrictPublicGroups()
- return nil
- case user.FieldBalanceNotifyEnabled:
- m.ResetBalanceNotifyEnabled()
- return nil
- case user.FieldBalanceNotifyThresholdType:
- m.ResetBalanceNotifyThresholdType()
- return nil
- case user.FieldBalanceNotifyThreshold:
- m.ResetBalanceNotifyThreshold()
- return nil
- case user.FieldBalanceNotifyExtraEmails:
- m.ResetBalanceNotifyExtraEmails()
- return nil
- case user.FieldTotalRecharged:
- m.ResetTotalRecharged()
- return nil
- case user.FieldRpmLimit:
- m.ResetRpmLimit()
- return nil
- }
- return fmt.Errorf("unknown User field %s", name)
- }
- // AddedEdges returns all edge names that were set/added in this mutation.
- func (m *UserMutation) AddedEdges() []string {
- edges := make([]string, 0, 13)
- if m.api_keys != nil {
- edges = append(edges, user.EdgeAPIKeys)
- }
- if m.redeem_codes != nil {
- edges = append(edges, user.EdgeRedeemCodes)
- }
- if m.subscriptions != nil {
- edges = append(edges, user.EdgeSubscriptions)
- }
- if m.assigned_subscriptions != nil {
- edges = append(edges, user.EdgeAssignedSubscriptions)
- }
- if m.announcement_reads != nil {
- edges = append(edges, user.EdgeAnnouncementReads)
- }
- if m.allowed_groups != nil {
- edges = append(edges, user.EdgeAllowedGroups)
- }
- if m.usage_logs != nil {
- edges = append(edges, user.EdgeUsageLogs)
- }
- if m.attribute_values != nil {
- edges = append(edges, user.EdgeAttributeValues)
- }
- if m.promo_code_usages != nil {
- edges = append(edges, user.EdgePromoCodeUsages)
- }
- if m.payment_orders != nil {
- edges = append(edges, user.EdgePaymentOrders)
- }
- if m.auth_identities != nil {
- edges = append(edges, user.EdgeAuthIdentities)
- }
- if m.pending_auth_sessions != nil {
- edges = append(edges, user.EdgePendingAuthSessions)
- }
- if m.platform_quotas != nil {
- edges = append(edges, user.EdgePlatformQuotas)
- }
- return edges
- }
- // AddedIDs returns all IDs (to other nodes) that were added for the given edge
- // name in this mutation.
- func (m *UserMutation) AddedIDs(name string) []ent.Value {
- switch name {
- case user.EdgeAPIKeys:
- ids := make([]ent.Value, 0, len(m.api_keys))
- for id := range m.api_keys {
- ids = append(ids, id)
- }
- return ids
- case user.EdgeRedeemCodes:
- ids := make([]ent.Value, 0, len(m.redeem_codes))
- for id := range m.redeem_codes {
- ids = append(ids, id)
- }
- return ids
- case user.EdgeSubscriptions:
- ids := make([]ent.Value, 0, len(m.subscriptions))
- for id := range m.subscriptions {
- ids = append(ids, id)
- }
- return ids
- case user.EdgeAssignedSubscriptions:
- ids := make([]ent.Value, 0, len(m.assigned_subscriptions))
- for id := range m.assigned_subscriptions {
- ids = append(ids, id)
- }
- return ids
- case user.EdgeAnnouncementReads:
- ids := make([]ent.Value, 0, len(m.announcement_reads))
- for id := range m.announcement_reads {
- ids = append(ids, id)
- }
- return ids
- case user.EdgeAllowedGroups:
- ids := make([]ent.Value, 0, len(m.allowed_groups))
- for id := range m.allowed_groups {
- ids = append(ids, id)
- }
- return ids
- case user.EdgeUsageLogs:
- ids := make([]ent.Value, 0, len(m.usage_logs))
- for id := range m.usage_logs {
- ids = append(ids, id)
- }
- return ids
- case user.EdgeAttributeValues:
- ids := make([]ent.Value, 0, len(m.attribute_values))
- for id := range m.attribute_values {
- ids = append(ids, id)
- }
- return ids
- case user.EdgePromoCodeUsages:
- ids := make([]ent.Value, 0, len(m.promo_code_usages))
- for id := range m.promo_code_usages {
- ids = append(ids, id)
- }
- return ids
- case user.EdgePaymentOrders:
- ids := make([]ent.Value, 0, len(m.payment_orders))
- for id := range m.payment_orders {
- ids = append(ids, id)
- }
- return ids
- case user.EdgeAuthIdentities:
- ids := make([]ent.Value, 0, len(m.auth_identities))
- for id := range m.auth_identities {
- ids = append(ids, id)
- }
- return ids
- case user.EdgePendingAuthSessions:
- ids := make([]ent.Value, 0, len(m.pending_auth_sessions))
- for id := range m.pending_auth_sessions {
- ids = append(ids, id)
- }
- return ids
- case user.EdgePlatformQuotas:
- ids := make([]ent.Value, 0, len(m.platform_quotas))
- for id := range m.platform_quotas {
- ids = append(ids, id)
- }
- return ids
- }
- return nil
- }
- // RemovedEdges returns all edge names that were removed in this mutation.
- func (m *UserMutation) RemovedEdges() []string {
- edges := make([]string, 0, 13)
- if m.removedapi_keys != nil {
- edges = append(edges, user.EdgeAPIKeys)
- }
- if m.removedredeem_codes != nil {
- edges = append(edges, user.EdgeRedeemCodes)
- }
- if m.removedsubscriptions != nil {
- edges = append(edges, user.EdgeSubscriptions)
- }
- if m.removedassigned_subscriptions != nil {
- edges = append(edges, user.EdgeAssignedSubscriptions)
- }
- if m.removedannouncement_reads != nil {
- edges = append(edges, user.EdgeAnnouncementReads)
- }
- if m.removedallowed_groups != nil {
- edges = append(edges, user.EdgeAllowedGroups)
- }
- if m.removedusage_logs != nil {
- edges = append(edges, user.EdgeUsageLogs)
- }
- if m.removedattribute_values != nil {
- edges = append(edges, user.EdgeAttributeValues)
- }
- if m.removedpromo_code_usages != nil {
- edges = append(edges, user.EdgePromoCodeUsages)
- }
- if m.removedpayment_orders != nil {
- edges = append(edges, user.EdgePaymentOrders)
- }
- if m.removedauth_identities != nil {
- edges = append(edges, user.EdgeAuthIdentities)
- }
- if m.removedpending_auth_sessions != nil {
- edges = append(edges, user.EdgePendingAuthSessions)
- }
- if m.removedplatform_quotas != nil {
- edges = append(edges, user.EdgePlatformQuotas)
- }
- return edges
- }
- // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
- // the given name in this mutation.
- func (m *UserMutation) RemovedIDs(name string) []ent.Value {
- switch name {
- case user.EdgeAPIKeys:
- ids := make([]ent.Value, 0, len(m.removedapi_keys))
- for id := range m.removedapi_keys {
- ids = append(ids, id)
- }
- return ids
- case user.EdgeRedeemCodes:
- ids := make([]ent.Value, 0, len(m.removedredeem_codes))
- for id := range m.removedredeem_codes {
- ids = append(ids, id)
- }
- return ids
- case user.EdgeSubscriptions:
- ids := make([]ent.Value, 0, len(m.removedsubscriptions))
- for id := range m.removedsubscriptions {
- ids = append(ids, id)
- }
- return ids
- case user.EdgeAssignedSubscriptions:
- ids := make([]ent.Value, 0, len(m.removedassigned_subscriptions))
- for id := range m.removedassigned_subscriptions {
- ids = append(ids, id)
- }
- return ids
- case user.EdgeAnnouncementReads:
- ids := make([]ent.Value, 0, len(m.removedannouncement_reads))
- for id := range m.removedannouncement_reads {
- ids = append(ids, id)
- }
- return ids
- case user.EdgeAllowedGroups:
- ids := make([]ent.Value, 0, len(m.removedallowed_groups))
- for id := range m.removedallowed_groups {
- ids = append(ids, id)
- }
- return ids
- case user.EdgeUsageLogs:
- ids := make([]ent.Value, 0, len(m.removedusage_logs))
- for id := range m.removedusage_logs {
- ids = append(ids, id)
- }
- return ids
- case user.EdgeAttributeValues:
- ids := make([]ent.Value, 0, len(m.removedattribute_values))
- for id := range m.removedattribute_values {
- ids = append(ids, id)
- }
- return ids
- case user.EdgePromoCodeUsages:
- ids := make([]ent.Value, 0, len(m.removedpromo_code_usages))
- for id := range m.removedpromo_code_usages {
- ids = append(ids, id)
- }
- return ids
- case user.EdgePaymentOrders:
- ids := make([]ent.Value, 0, len(m.removedpayment_orders))
- for id := range m.removedpayment_orders {
- ids = append(ids, id)
- }
- return ids
- case user.EdgeAuthIdentities:
- ids := make([]ent.Value, 0, len(m.removedauth_identities))
- for id := range m.removedauth_identities {
- ids = append(ids, id)
- }
- return ids
- case user.EdgePendingAuthSessions:
- ids := make([]ent.Value, 0, len(m.removedpending_auth_sessions))
- for id := range m.removedpending_auth_sessions {
- ids = append(ids, id)
- }
- return ids
- case user.EdgePlatformQuotas:
- ids := make([]ent.Value, 0, len(m.removedplatform_quotas))
- for id := range m.removedplatform_quotas {
- ids = append(ids, id)
- }
- return ids
- }
- return nil
- }
- // ClearedEdges returns all edge names that were cleared in this mutation.
- func (m *UserMutation) ClearedEdges() []string {
- edges := make([]string, 0, 13)
- if m.clearedapi_keys {
- edges = append(edges, user.EdgeAPIKeys)
- }
- if m.clearedredeem_codes {
- edges = append(edges, user.EdgeRedeemCodes)
- }
- if m.clearedsubscriptions {
- edges = append(edges, user.EdgeSubscriptions)
- }
- if m.clearedassigned_subscriptions {
- edges = append(edges, user.EdgeAssignedSubscriptions)
- }
- if m.clearedannouncement_reads {
- edges = append(edges, user.EdgeAnnouncementReads)
- }
- if m.clearedallowed_groups {
- edges = append(edges, user.EdgeAllowedGroups)
- }
- if m.clearedusage_logs {
- edges = append(edges, user.EdgeUsageLogs)
- }
- if m.clearedattribute_values {
- edges = append(edges, user.EdgeAttributeValues)
- }
- if m.clearedpromo_code_usages {
- edges = append(edges, user.EdgePromoCodeUsages)
- }
- if m.clearedpayment_orders {
- edges = append(edges, user.EdgePaymentOrders)
- }
- if m.clearedauth_identities {
- edges = append(edges, user.EdgeAuthIdentities)
- }
- if m.clearedpending_auth_sessions {
- edges = append(edges, user.EdgePendingAuthSessions)
- }
- if m.clearedplatform_quotas {
- edges = append(edges, user.EdgePlatformQuotas)
- }
- return edges
- }
- // EdgeCleared returns a boolean which indicates if the edge with the given name
- // was cleared in this mutation.
- func (m *UserMutation) EdgeCleared(name string) bool {
- switch name {
- case user.EdgeAPIKeys:
- return m.clearedapi_keys
- case user.EdgeRedeemCodes:
- return m.clearedredeem_codes
- case user.EdgeSubscriptions:
- return m.clearedsubscriptions
- case user.EdgeAssignedSubscriptions:
- return m.clearedassigned_subscriptions
- case user.EdgeAnnouncementReads:
- return m.clearedannouncement_reads
- case user.EdgeAllowedGroups:
- return m.clearedallowed_groups
- case user.EdgeUsageLogs:
- return m.clearedusage_logs
- case user.EdgeAttributeValues:
- return m.clearedattribute_values
- case user.EdgePromoCodeUsages:
- return m.clearedpromo_code_usages
- case user.EdgePaymentOrders:
- return m.clearedpayment_orders
- case user.EdgeAuthIdentities:
- return m.clearedauth_identities
- case user.EdgePendingAuthSessions:
- return m.clearedpending_auth_sessions
- case user.EdgePlatformQuotas:
- return m.clearedplatform_quotas
- }
- return false
- }
- // ClearEdge clears the value of the edge with the given name. It returns an error
- // if that edge is not defined in the schema.
- func (m *UserMutation) ClearEdge(name string) error {
- switch name {
- }
- return fmt.Errorf("unknown User unique edge %s", name)
- }
- // ResetEdge resets all changes to the edge with the given name in this mutation.
- // It returns an error if the edge is not defined in the schema.
- func (m *UserMutation) ResetEdge(name string) error {
- switch name {
- case user.EdgeAPIKeys:
- m.ResetAPIKeys()
- return nil
- case user.EdgeRedeemCodes:
- m.ResetRedeemCodes()
- return nil
- case user.EdgeSubscriptions:
- m.ResetSubscriptions()
- return nil
- case user.EdgeAssignedSubscriptions:
- m.ResetAssignedSubscriptions()
- return nil
- case user.EdgeAnnouncementReads:
- m.ResetAnnouncementReads()
- return nil
- case user.EdgeAllowedGroups:
- m.ResetAllowedGroups()
- return nil
- case user.EdgeUsageLogs:
- m.ResetUsageLogs()
- return nil
- case user.EdgeAttributeValues:
- m.ResetAttributeValues()
- return nil
- case user.EdgePromoCodeUsages:
- m.ResetPromoCodeUsages()
- return nil
- case user.EdgePaymentOrders:
- m.ResetPaymentOrders()
- return nil
- case user.EdgeAuthIdentities:
- m.ResetAuthIdentities()
- return nil
- case user.EdgePendingAuthSessions:
- m.ResetPendingAuthSessions()
- return nil
- case user.EdgePlatformQuotas:
- m.ResetPlatformQuotas()
- return nil
- }
- return fmt.Errorf("unknown User edge %s", name)
- }
- // UserAllowedGroupMutation represents an operation that mutates the UserAllowedGroup nodes in the graph.
- type UserAllowedGroupMutation struct {
- config
- op Op
- typ string
- created_at *time.Time
- clearedFields map[string]struct{}
- user *int64
- cleareduser bool
- group *int64
- clearedgroup bool
- done bool
- oldValue func(context.Context) (*UserAllowedGroup, error)
- predicates []predicate.UserAllowedGroup
- }
- var _ ent.Mutation = (*UserAllowedGroupMutation)(nil)
- // userallowedgroupOption allows management of the mutation configuration using functional options.
- type userallowedgroupOption func(*UserAllowedGroupMutation)
- // newUserAllowedGroupMutation creates new mutation for the UserAllowedGroup entity.
- func newUserAllowedGroupMutation(c config, op Op, opts ...userallowedgroupOption) *UserAllowedGroupMutation {
- m := &UserAllowedGroupMutation{
- config: c,
- op: op,
- typ: TypeUserAllowedGroup,
- clearedFields: make(map[string]struct{}),
- }
- for _, opt := range opts {
- opt(m)
- }
- return m
- }
- // Client returns a new `ent.Client` from the mutation. If the mutation was
- // executed in a transaction (ent.Tx), a transactional client is returned.
- func (m UserAllowedGroupMutation) Client() *Client {
- client := &Client{config: m.config}
- client.init()
- return client
- }
- // Tx returns an `ent.Tx` for mutations that were executed in transactions;
- // it returns an error otherwise.
- func (m UserAllowedGroupMutation) Tx() (*Tx, error) {
- if _, ok := m.driver.(*txDriver); !ok {
- return nil, errors.New("ent: mutation is not running in a transaction")
- }
- tx := &Tx{config: m.config}
- tx.init()
- return tx, nil
- }
- // SetUserID sets the "user_id" field.
- func (m *UserAllowedGroupMutation) SetUserID(i int64) {
- m.user = &i
- }
- // UserID returns the value of the "user_id" field in the mutation.
- func (m *UserAllowedGroupMutation) UserID() (r int64, exists bool) {
- v := m.user
- if v == nil {
- return
- }
- return *v, true
- }
- // ResetUserID resets all changes to the "user_id" field.
- func (m *UserAllowedGroupMutation) ResetUserID() {
- m.user = nil
- }
- // SetGroupID sets the "group_id" field.
- func (m *UserAllowedGroupMutation) SetGroupID(i int64) {
- m.group = &i
- }
- // GroupID returns the value of the "group_id" field in the mutation.
- func (m *UserAllowedGroupMutation) GroupID() (r int64, exists bool) {
- v := m.group
- if v == nil {
- return
- }
- return *v, true
- }
- // ResetGroupID resets all changes to the "group_id" field.
- func (m *UserAllowedGroupMutation) ResetGroupID() {
- m.group = nil
- }
- // SetCreatedAt sets the "created_at" field.
- func (m *UserAllowedGroupMutation) SetCreatedAt(t time.Time) {
- m.created_at = &t
- }
- // CreatedAt returns the value of the "created_at" field in the mutation.
- func (m *UserAllowedGroupMutation) CreatedAt() (r time.Time, exists bool) {
- v := m.created_at
- if v == nil {
- return
- }
- return *v, true
- }
- // ResetCreatedAt resets all changes to the "created_at" field.
- func (m *UserAllowedGroupMutation) ResetCreatedAt() {
- m.created_at = nil
- }
- // ClearUser clears the "user" edge to the User entity.
- func (m *UserAllowedGroupMutation) ClearUser() {
- m.cleareduser = true
- m.clearedFields[userallowedgroup.FieldUserID] = struct{}{}
- }
- // UserCleared reports if the "user" edge to the User entity was cleared.
- func (m *UserAllowedGroupMutation) UserCleared() bool {
- return m.cleareduser
- }
- // UserIDs returns the "user" edge IDs in the mutation.
- // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
- // UserID instead. It exists only for internal usage by the builders.
- func (m *UserAllowedGroupMutation) UserIDs() (ids []int64) {
- if id := m.user; id != nil {
- ids = append(ids, *id)
- }
- return
- }
- // ResetUser resets all changes to the "user" edge.
- func (m *UserAllowedGroupMutation) ResetUser() {
- m.user = nil
- m.cleareduser = false
- }
- // ClearGroup clears the "group" edge to the Group entity.
- func (m *UserAllowedGroupMutation) ClearGroup() {
- m.clearedgroup = true
- m.clearedFields[userallowedgroup.FieldGroupID] = struct{}{}
- }
- // GroupCleared reports if the "group" edge to the Group entity was cleared.
- func (m *UserAllowedGroupMutation) GroupCleared() bool {
- return m.clearedgroup
- }
- // GroupIDs returns the "group" edge IDs in the mutation.
- // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
- // GroupID instead. It exists only for internal usage by the builders.
- func (m *UserAllowedGroupMutation) GroupIDs() (ids []int64) {
- if id := m.group; id != nil {
- ids = append(ids, *id)
- }
- return
- }
- // ResetGroup resets all changes to the "group" edge.
- func (m *UserAllowedGroupMutation) ResetGroup() {
- m.group = nil
- m.clearedgroup = false
- }
- // Where appends a list predicates to the UserAllowedGroupMutation builder.
- func (m *UserAllowedGroupMutation) Where(ps ...predicate.UserAllowedGroup) {
- m.predicates = append(m.predicates, ps...)
- }
- // WhereP appends storage-level predicates to the UserAllowedGroupMutation builder. Using this method,
- // users can use type-assertion to append predicates that do not depend on any generated package.
- func (m *UserAllowedGroupMutation) WhereP(ps ...func(*sql.Selector)) {
- p := make([]predicate.UserAllowedGroup, len(ps))
- for i := range ps {
- p[i] = ps[i]
- }
- m.Where(p...)
- }
- // Op returns the operation name.
- func (m *UserAllowedGroupMutation) Op() Op {
- return m.op
- }
- // SetOp allows setting the mutation operation.
- func (m *UserAllowedGroupMutation) SetOp(op Op) {
- m.op = op
- }
- // Type returns the node type of this mutation (UserAllowedGroup).
- func (m *UserAllowedGroupMutation) Type() string {
- return m.typ
- }
- // Fields returns all fields that were changed during this mutation. Note that in
- // order to get all numeric fields that were incremented/decremented, call
- // AddedFields().
- func (m *UserAllowedGroupMutation) Fields() []string {
- fields := make([]string, 0, 3)
- if m.user != nil {
- fields = append(fields, userallowedgroup.FieldUserID)
- }
- if m.group != nil {
- fields = append(fields, userallowedgroup.FieldGroupID)
- }
- if m.created_at != nil {
- fields = append(fields, userallowedgroup.FieldCreatedAt)
- }
- return fields
- }
- // Field returns the value of a field with the given name. The second boolean
- // return value indicates that this field was not set, or was not defined in the
- // schema.
- func (m *UserAllowedGroupMutation) Field(name string) (ent.Value, bool) {
- switch name {
- case userallowedgroup.FieldUserID:
- return m.UserID()
- case userallowedgroup.FieldGroupID:
- return m.GroupID()
- case userallowedgroup.FieldCreatedAt:
- return m.CreatedAt()
- }
- return nil, false
- }
- // OldField returns the old value of the field from the database. An error is
- // returned if the mutation operation is not UpdateOne, or the query to the
- // database failed.
- func (m *UserAllowedGroupMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
- return nil, errors.New("edge schema UserAllowedGroup does not support getting old values")
- }
- // SetField sets the value of a field with the given name. It returns an error if
- // the field is not defined in the schema, or if the type mismatched the field
- // type.
- func (m *UserAllowedGroupMutation) SetField(name string, value ent.Value) error {
- switch name {
- case userallowedgroup.FieldUserID:
- v, ok := value.(int64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetUserID(v)
- return nil
- case userallowedgroup.FieldGroupID:
- v, ok := value.(int64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetGroupID(v)
- return nil
- case userallowedgroup.FieldCreatedAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetCreatedAt(v)
- return nil
- }
- return fmt.Errorf("unknown UserAllowedGroup field %s", name)
- }
- // AddedFields returns all numeric fields that were incremented/decremented during
- // this mutation.
- func (m *UserAllowedGroupMutation) AddedFields() []string {
- var fields []string
- return fields
- }
- // AddedField returns the numeric value that was incremented/decremented on a field
- // with the given name. The second boolean return value indicates that this field
- // was not set, or was not defined in the schema.
- func (m *UserAllowedGroupMutation) AddedField(name string) (ent.Value, bool) {
- switch name {
- }
- return nil, false
- }
- // AddField adds the value to the field with the given name. It returns an error if
- // the field is not defined in the schema, or if the type mismatched the field
- // type.
- func (m *UserAllowedGroupMutation) AddField(name string, value ent.Value) error {
- switch name {
- }
- return fmt.Errorf("unknown UserAllowedGroup numeric field %s", name)
- }
- // ClearedFields returns all nullable fields that were cleared during this
- // mutation.
- func (m *UserAllowedGroupMutation) ClearedFields() []string {
- return nil
- }
- // FieldCleared returns a boolean indicating if a field with the given name was
- // cleared in this mutation.
- func (m *UserAllowedGroupMutation) FieldCleared(name string) bool {
- _, ok := m.clearedFields[name]
- return ok
- }
- // ClearField clears the value of the field with the given name. It returns an
- // error if the field is not defined in the schema.
- func (m *UserAllowedGroupMutation) ClearField(name string) error {
- return fmt.Errorf("unknown UserAllowedGroup nullable field %s", name)
- }
- // ResetField resets all changes in the mutation for the field with the given name.
- // It returns an error if the field is not defined in the schema.
- func (m *UserAllowedGroupMutation) ResetField(name string) error {
- switch name {
- case userallowedgroup.FieldUserID:
- m.ResetUserID()
- return nil
- case userallowedgroup.FieldGroupID:
- m.ResetGroupID()
- return nil
- case userallowedgroup.FieldCreatedAt:
- m.ResetCreatedAt()
- return nil
- }
- return fmt.Errorf("unknown UserAllowedGroup field %s", name)
- }
- // AddedEdges returns all edge names that were set/added in this mutation.
- func (m *UserAllowedGroupMutation) AddedEdges() []string {
- edges := make([]string, 0, 2)
- if m.user != nil {
- edges = append(edges, userallowedgroup.EdgeUser)
- }
- if m.group != nil {
- edges = append(edges, userallowedgroup.EdgeGroup)
- }
- return edges
- }
- // AddedIDs returns all IDs (to other nodes) that were added for the given edge
- // name in this mutation.
- func (m *UserAllowedGroupMutation) AddedIDs(name string) []ent.Value {
- switch name {
- case userallowedgroup.EdgeUser:
- if id := m.user; id != nil {
- return []ent.Value{*id}
- }
- case userallowedgroup.EdgeGroup:
- if id := m.group; id != nil {
- return []ent.Value{*id}
- }
- }
- return nil
- }
- // RemovedEdges returns all edge names that were removed in this mutation.
- func (m *UserAllowedGroupMutation) RemovedEdges() []string {
- edges := make([]string, 0, 2)
- return edges
- }
- // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
- // the given name in this mutation.
- func (m *UserAllowedGroupMutation) RemovedIDs(name string) []ent.Value {
- return nil
- }
- // ClearedEdges returns all edge names that were cleared in this mutation.
- func (m *UserAllowedGroupMutation) ClearedEdges() []string {
- edges := make([]string, 0, 2)
- if m.cleareduser {
- edges = append(edges, userallowedgroup.EdgeUser)
- }
- if m.clearedgroup {
- edges = append(edges, userallowedgroup.EdgeGroup)
- }
- return edges
- }
- // EdgeCleared returns a boolean which indicates if the edge with the given name
- // was cleared in this mutation.
- func (m *UserAllowedGroupMutation) EdgeCleared(name string) bool {
- switch name {
- case userallowedgroup.EdgeUser:
- return m.cleareduser
- case userallowedgroup.EdgeGroup:
- return m.clearedgroup
- }
- return false
- }
- // ClearEdge clears the value of the edge with the given name. It returns an error
- // if that edge is not defined in the schema.
- func (m *UserAllowedGroupMutation) ClearEdge(name string) error {
- switch name {
- case userallowedgroup.EdgeUser:
- m.ClearUser()
- return nil
- case userallowedgroup.EdgeGroup:
- m.ClearGroup()
- return nil
- }
- return fmt.Errorf("unknown UserAllowedGroup unique edge %s", name)
- }
- // ResetEdge resets all changes to the edge with the given name in this mutation.
- // It returns an error if the edge is not defined in the schema.
- func (m *UserAllowedGroupMutation) ResetEdge(name string) error {
- switch name {
- case userallowedgroup.EdgeUser:
- m.ResetUser()
- return nil
- case userallowedgroup.EdgeGroup:
- m.ResetGroup()
- return nil
- }
- return fmt.Errorf("unknown UserAllowedGroup edge %s", name)
- }
- // UserAttributeDefinitionMutation represents an operation that mutates the UserAttributeDefinition nodes in the graph.
- type UserAttributeDefinitionMutation struct {
- config
- op Op
- typ string
- id *int64
- created_at *time.Time
- updated_at *time.Time
- deleted_at *time.Time
- key *string
- name *string
- description *string
- _type *string
- options *[]map[string]interface{}
- appendoptions []map[string]interface{}
- required *bool
- validation *map[string]interface{}
- placeholder *string
- display_order *int
- adddisplay_order *int
- enabled *bool
- clearedFields map[string]struct{}
- values map[int64]struct{}
- removedvalues map[int64]struct{}
- clearedvalues bool
- done bool
- oldValue func(context.Context) (*UserAttributeDefinition, error)
- predicates []predicate.UserAttributeDefinition
- }
- var _ ent.Mutation = (*UserAttributeDefinitionMutation)(nil)
- // userattributedefinitionOption allows management of the mutation configuration using functional options.
- type userattributedefinitionOption func(*UserAttributeDefinitionMutation)
- // newUserAttributeDefinitionMutation creates new mutation for the UserAttributeDefinition entity.
- func newUserAttributeDefinitionMutation(c config, op Op, opts ...userattributedefinitionOption) *UserAttributeDefinitionMutation {
- m := &UserAttributeDefinitionMutation{
- config: c,
- op: op,
- typ: TypeUserAttributeDefinition,
- clearedFields: make(map[string]struct{}),
- }
- for _, opt := range opts {
- opt(m)
- }
- return m
- }
- // withUserAttributeDefinitionID sets the ID field of the mutation.
- func withUserAttributeDefinitionID(id int64) userattributedefinitionOption {
- return func(m *UserAttributeDefinitionMutation) {
- var (
- err error
- once sync.Once
- value *UserAttributeDefinition
- )
- m.oldValue = func(ctx context.Context) (*UserAttributeDefinition, error) {
- once.Do(func() {
- if m.done {
- err = errors.New("querying old values post mutation is not allowed")
- } else {
- value, err = m.Client().UserAttributeDefinition.Get(ctx, id)
- }
- })
- return value, err
- }
- m.id = &id
- }
- }
- // withUserAttributeDefinition sets the old UserAttributeDefinition of the mutation.
- func withUserAttributeDefinition(node *UserAttributeDefinition) userattributedefinitionOption {
- return func(m *UserAttributeDefinitionMutation) {
- m.oldValue = func(context.Context) (*UserAttributeDefinition, error) {
- return node, nil
- }
- m.id = &node.ID
- }
- }
- // Client returns a new `ent.Client` from the mutation. If the mutation was
- // executed in a transaction (ent.Tx), a transactional client is returned.
- func (m UserAttributeDefinitionMutation) Client() *Client {
- client := &Client{config: m.config}
- client.init()
- return client
- }
- // Tx returns an `ent.Tx` for mutations that were executed in transactions;
- // it returns an error otherwise.
- func (m UserAttributeDefinitionMutation) Tx() (*Tx, error) {
- if _, ok := m.driver.(*txDriver); !ok {
- return nil, errors.New("ent: mutation is not running in a transaction")
- }
- tx := &Tx{config: m.config}
- tx.init()
- return tx, nil
- }
- // ID returns the ID value in the mutation. Note that the ID is only available
- // if it was provided to the builder or after it was returned from the database.
- func (m *UserAttributeDefinitionMutation) ID() (id int64, exists bool) {
- if m.id == nil {
- return
- }
- return *m.id, true
- }
- // IDs queries the database and returns the entity ids that match the mutation's predicate.
- // That means, if the mutation is applied within a transaction with an isolation level such
- // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
- // or updated by the mutation.
- func (m *UserAttributeDefinitionMutation) IDs(ctx context.Context) ([]int64, error) {
- switch {
- case m.op.Is(OpUpdateOne | OpDeleteOne):
- id, exists := m.ID()
- if exists {
- return []int64{id}, nil
- }
- fallthrough
- case m.op.Is(OpUpdate | OpDelete):
- return m.Client().UserAttributeDefinition.Query().Where(m.predicates...).IDs(ctx)
- default:
- return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
- }
- }
- // SetCreatedAt sets the "created_at" field.
- func (m *UserAttributeDefinitionMutation) SetCreatedAt(t time.Time) {
- m.created_at = &t
- }
- // CreatedAt returns the value of the "created_at" field in the mutation.
- func (m *UserAttributeDefinitionMutation) CreatedAt() (r time.Time, exists bool) {
- v := m.created_at
- if v == nil {
- return
- }
- return *v, true
- }
- // OldCreatedAt returns the old "created_at" field's value of the UserAttributeDefinition entity.
- // If the UserAttributeDefinition object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *UserAttributeDefinitionMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldCreatedAt requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
- }
- return oldValue.CreatedAt, nil
- }
- // ResetCreatedAt resets all changes to the "created_at" field.
- func (m *UserAttributeDefinitionMutation) ResetCreatedAt() {
- m.created_at = nil
- }
- // SetUpdatedAt sets the "updated_at" field.
- func (m *UserAttributeDefinitionMutation) SetUpdatedAt(t time.Time) {
- m.updated_at = &t
- }
- // UpdatedAt returns the value of the "updated_at" field in the mutation.
- func (m *UserAttributeDefinitionMutation) UpdatedAt() (r time.Time, exists bool) {
- v := m.updated_at
- if v == nil {
- return
- }
- return *v, true
- }
- // OldUpdatedAt returns the old "updated_at" field's value of the UserAttributeDefinition entity.
- // If the UserAttributeDefinition object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *UserAttributeDefinitionMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
- }
- return oldValue.UpdatedAt, nil
- }
- // ResetUpdatedAt resets all changes to the "updated_at" field.
- func (m *UserAttributeDefinitionMutation) ResetUpdatedAt() {
- m.updated_at = nil
- }
- // SetDeletedAt sets the "deleted_at" field.
- func (m *UserAttributeDefinitionMutation) SetDeletedAt(t time.Time) {
- m.deleted_at = &t
- }
- // DeletedAt returns the value of the "deleted_at" field in the mutation.
- func (m *UserAttributeDefinitionMutation) DeletedAt() (r time.Time, exists bool) {
- v := m.deleted_at
- if v == nil {
- return
- }
- return *v, true
- }
- // OldDeletedAt returns the old "deleted_at" field's value of the UserAttributeDefinition entity.
- // If the UserAttributeDefinition object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *UserAttributeDefinitionMutation) OldDeletedAt(ctx context.Context) (v *time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldDeletedAt requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
- }
- return oldValue.DeletedAt, nil
- }
- // ClearDeletedAt clears the value of the "deleted_at" field.
- func (m *UserAttributeDefinitionMutation) ClearDeletedAt() {
- m.deleted_at = nil
- m.clearedFields[userattributedefinition.FieldDeletedAt] = struct{}{}
- }
- // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
- func (m *UserAttributeDefinitionMutation) DeletedAtCleared() bool {
- _, ok := m.clearedFields[userattributedefinition.FieldDeletedAt]
- return ok
- }
- // ResetDeletedAt resets all changes to the "deleted_at" field.
- func (m *UserAttributeDefinitionMutation) ResetDeletedAt() {
- m.deleted_at = nil
- delete(m.clearedFields, userattributedefinition.FieldDeletedAt)
- }
- // SetKey sets the "key" field.
- func (m *UserAttributeDefinitionMutation) SetKey(s string) {
- m.key = &s
- }
- // Key returns the value of the "key" field in the mutation.
- func (m *UserAttributeDefinitionMutation) Key() (r string, exists bool) {
- v := m.key
- if v == nil {
- return
- }
- return *v, true
- }
- // OldKey returns the old "key" field's value of the UserAttributeDefinition entity.
- // If the UserAttributeDefinition object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *UserAttributeDefinitionMutation) OldKey(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldKey is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldKey requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldKey: %w", err)
- }
- return oldValue.Key, nil
- }
- // ResetKey resets all changes to the "key" field.
- func (m *UserAttributeDefinitionMutation) ResetKey() {
- m.key = nil
- }
- // SetName sets the "name" field.
- func (m *UserAttributeDefinitionMutation) SetName(s string) {
- m.name = &s
- }
- // Name returns the value of the "name" field in the mutation.
- func (m *UserAttributeDefinitionMutation) Name() (r string, exists bool) {
- v := m.name
- if v == nil {
- return
- }
- return *v, true
- }
- // OldName returns the old "name" field's value of the UserAttributeDefinition entity.
- // If the UserAttributeDefinition object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *UserAttributeDefinitionMutation) OldName(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldName is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldName requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldName: %w", err)
- }
- return oldValue.Name, nil
- }
- // ResetName resets all changes to the "name" field.
- func (m *UserAttributeDefinitionMutation) ResetName() {
- m.name = nil
- }
- // SetDescription sets the "description" field.
- func (m *UserAttributeDefinitionMutation) SetDescription(s string) {
- m.description = &s
- }
- // Description returns the value of the "description" field in the mutation.
- func (m *UserAttributeDefinitionMutation) Description() (r string, exists bool) {
- v := m.description
- if v == nil {
- return
- }
- return *v, true
- }
- // OldDescription returns the old "description" field's value of the UserAttributeDefinition entity.
- // If the UserAttributeDefinition object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *UserAttributeDefinitionMutation) OldDescription(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldDescription is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldDescription requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldDescription: %w", err)
- }
- return oldValue.Description, nil
- }
- // ResetDescription resets all changes to the "description" field.
- func (m *UserAttributeDefinitionMutation) ResetDescription() {
- m.description = nil
- }
- // SetType sets the "type" field.
- func (m *UserAttributeDefinitionMutation) SetType(s string) {
- m._type = &s
- }
- // GetType returns the value of the "type" field in the mutation.
- func (m *UserAttributeDefinitionMutation) GetType() (r string, exists bool) {
- v := m._type
- if v == nil {
- return
- }
- return *v, true
- }
- // OldType returns the old "type" field's value of the UserAttributeDefinition entity.
- // If the UserAttributeDefinition object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *UserAttributeDefinitionMutation) OldType(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldType is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldType requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldType: %w", err)
- }
- return oldValue.Type, nil
- }
- // ResetType resets all changes to the "type" field.
- func (m *UserAttributeDefinitionMutation) ResetType() {
- m._type = nil
- }
- // SetOptions sets the "options" field.
- func (m *UserAttributeDefinitionMutation) SetOptions(value []map[string]interface{}) {
- m.options = &value
- m.appendoptions = nil
- }
- // Options returns the value of the "options" field in the mutation.
- func (m *UserAttributeDefinitionMutation) Options() (r []map[string]interface{}, exists bool) {
- v := m.options
- if v == nil {
- return
- }
- return *v, true
- }
- // OldOptions returns the old "options" field's value of the UserAttributeDefinition entity.
- // If the UserAttributeDefinition object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *UserAttributeDefinitionMutation) OldOptions(ctx context.Context) (v []map[string]interface{}, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldOptions is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldOptions requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldOptions: %w", err)
- }
- return oldValue.Options, nil
- }
- // AppendOptions adds value to the "options" field.
- func (m *UserAttributeDefinitionMutation) AppendOptions(value []map[string]interface{}) {
- m.appendoptions = append(m.appendoptions, value...)
- }
- // AppendedOptions returns the list of values that were appended to the "options" field in this mutation.
- func (m *UserAttributeDefinitionMutation) AppendedOptions() ([]map[string]interface{}, bool) {
- if len(m.appendoptions) == 0 {
- return nil, false
- }
- return m.appendoptions, true
- }
- // ResetOptions resets all changes to the "options" field.
- func (m *UserAttributeDefinitionMutation) ResetOptions() {
- m.options = nil
- m.appendoptions = nil
- }
- // SetRequired sets the "required" field.
- func (m *UserAttributeDefinitionMutation) SetRequired(b bool) {
- m.required = &b
- }
- // Required returns the value of the "required" field in the mutation.
- func (m *UserAttributeDefinitionMutation) Required() (r bool, exists bool) {
- v := m.required
- if v == nil {
- return
- }
- return *v, true
- }
- // OldRequired returns the old "required" field's value of the UserAttributeDefinition entity.
- // If the UserAttributeDefinition object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *UserAttributeDefinitionMutation) OldRequired(ctx context.Context) (v bool, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldRequired is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldRequired requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldRequired: %w", err)
- }
- return oldValue.Required, nil
- }
- // ResetRequired resets all changes to the "required" field.
- func (m *UserAttributeDefinitionMutation) ResetRequired() {
- m.required = nil
- }
- // SetValidation sets the "validation" field.
- func (m *UserAttributeDefinitionMutation) SetValidation(value map[string]interface{}) {
- m.validation = &value
- }
- // Validation returns the value of the "validation" field in the mutation.
- func (m *UserAttributeDefinitionMutation) Validation() (r map[string]interface{}, exists bool) {
- v := m.validation
- if v == nil {
- return
- }
- return *v, true
- }
- // OldValidation returns the old "validation" field's value of the UserAttributeDefinition entity.
- // If the UserAttributeDefinition object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *UserAttributeDefinitionMutation) OldValidation(ctx context.Context) (v map[string]interface{}, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldValidation is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldValidation requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldValidation: %w", err)
- }
- return oldValue.Validation, nil
- }
- // ResetValidation resets all changes to the "validation" field.
- func (m *UserAttributeDefinitionMutation) ResetValidation() {
- m.validation = nil
- }
- // SetPlaceholder sets the "placeholder" field.
- func (m *UserAttributeDefinitionMutation) SetPlaceholder(s string) {
- m.placeholder = &s
- }
- // Placeholder returns the value of the "placeholder" field in the mutation.
- func (m *UserAttributeDefinitionMutation) Placeholder() (r string, exists bool) {
- v := m.placeholder
- if v == nil {
- return
- }
- return *v, true
- }
- // OldPlaceholder returns the old "placeholder" field's value of the UserAttributeDefinition entity.
- // If the UserAttributeDefinition object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *UserAttributeDefinitionMutation) OldPlaceholder(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldPlaceholder is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldPlaceholder requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldPlaceholder: %w", err)
- }
- return oldValue.Placeholder, nil
- }
- // ResetPlaceholder resets all changes to the "placeholder" field.
- func (m *UserAttributeDefinitionMutation) ResetPlaceholder() {
- m.placeholder = nil
- }
- // SetDisplayOrder sets the "display_order" field.
- func (m *UserAttributeDefinitionMutation) SetDisplayOrder(i int) {
- m.display_order = &i
- m.adddisplay_order = nil
- }
- // DisplayOrder returns the value of the "display_order" field in the mutation.
- func (m *UserAttributeDefinitionMutation) DisplayOrder() (r int, exists bool) {
- v := m.display_order
- if v == nil {
- return
- }
- return *v, true
- }
- // OldDisplayOrder returns the old "display_order" field's value of the UserAttributeDefinition entity.
- // If the UserAttributeDefinition object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *UserAttributeDefinitionMutation) OldDisplayOrder(ctx context.Context) (v int, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldDisplayOrder is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldDisplayOrder requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldDisplayOrder: %w", err)
- }
- return oldValue.DisplayOrder, nil
- }
- // AddDisplayOrder adds i to the "display_order" field.
- func (m *UserAttributeDefinitionMutation) AddDisplayOrder(i int) {
- if m.adddisplay_order != nil {
- *m.adddisplay_order += i
- } else {
- m.adddisplay_order = &i
- }
- }
- // AddedDisplayOrder returns the value that was added to the "display_order" field in this mutation.
- func (m *UserAttributeDefinitionMutation) AddedDisplayOrder() (r int, exists bool) {
- v := m.adddisplay_order
- if v == nil {
- return
- }
- return *v, true
- }
- // ResetDisplayOrder resets all changes to the "display_order" field.
- func (m *UserAttributeDefinitionMutation) ResetDisplayOrder() {
- m.display_order = nil
- m.adddisplay_order = nil
- }
- // SetEnabled sets the "enabled" field.
- func (m *UserAttributeDefinitionMutation) SetEnabled(b bool) {
- m.enabled = &b
- }
- // Enabled returns the value of the "enabled" field in the mutation.
- func (m *UserAttributeDefinitionMutation) Enabled() (r bool, exists bool) {
- v := m.enabled
- if v == nil {
- return
- }
- return *v, true
- }
- // OldEnabled returns the old "enabled" field's value of the UserAttributeDefinition entity.
- // If the UserAttributeDefinition object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *UserAttributeDefinitionMutation) OldEnabled(ctx context.Context) (v bool, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldEnabled is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldEnabled requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldEnabled: %w", err)
- }
- return oldValue.Enabled, nil
- }
- // ResetEnabled resets all changes to the "enabled" field.
- func (m *UserAttributeDefinitionMutation) ResetEnabled() {
- m.enabled = nil
- }
- // AddValueIDs adds the "values" edge to the UserAttributeValue entity by ids.
- func (m *UserAttributeDefinitionMutation) AddValueIDs(ids ...int64) {
- if m.values == nil {
- m.values = make(map[int64]struct{})
- }
- for i := range ids {
- m.values[ids[i]] = struct{}{}
- }
- }
- // ClearValues clears the "values" edge to the UserAttributeValue entity.
- func (m *UserAttributeDefinitionMutation) ClearValues() {
- m.clearedvalues = true
- }
- // ValuesCleared reports if the "values" edge to the UserAttributeValue entity was cleared.
- func (m *UserAttributeDefinitionMutation) ValuesCleared() bool {
- return m.clearedvalues
- }
- // RemoveValueIDs removes the "values" edge to the UserAttributeValue entity by IDs.
- func (m *UserAttributeDefinitionMutation) RemoveValueIDs(ids ...int64) {
- if m.removedvalues == nil {
- m.removedvalues = make(map[int64]struct{})
- }
- for i := range ids {
- delete(m.values, ids[i])
- m.removedvalues[ids[i]] = struct{}{}
- }
- }
- // RemovedValues returns the removed IDs of the "values" edge to the UserAttributeValue entity.
- func (m *UserAttributeDefinitionMutation) RemovedValuesIDs() (ids []int64) {
- for id := range m.removedvalues {
- ids = append(ids, id)
- }
- return
- }
- // ValuesIDs returns the "values" edge IDs in the mutation.
- func (m *UserAttributeDefinitionMutation) ValuesIDs() (ids []int64) {
- for id := range m.values {
- ids = append(ids, id)
- }
- return
- }
- // ResetValues resets all changes to the "values" edge.
- func (m *UserAttributeDefinitionMutation) ResetValues() {
- m.values = nil
- m.clearedvalues = false
- m.removedvalues = nil
- }
- // Where appends a list predicates to the UserAttributeDefinitionMutation builder.
- func (m *UserAttributeDefinitionMutation) Where(ps ...predicate.UserAttributeDefinition) {
- m.predicates = append(m.predicates, ps...)
- }
- // WhereP appends storage-level predicates to the UserAttributeDefinitionMutation builder. Using this method,
- // users can use type-assertion to append predicates that do not depend on any generated package.
- func (m *UserAttributeDefinitionMutation) WhereP(ps ...func(*sql.Selector)) {
- p := make([]predicate.UserAttributeDefinition, len(ps))
- for i := range ps {
- p[i] = ps[i]
- }
- m.Where(p...)
- }
- // Op returns the operation name.
- func (m *UserAttributeDefinitionMutation) Op() Op {
- return m.op
- }
- // SetOp allows setting the mutation operation.
- func (m *UserAttributeDefinitionMutation) SetOp(op Op) {
- m.op = op
- }
- // Type returns the node type of this mutation (UserAttributeDefinition).
- func (m *UserAttributeDefinitionMutation) Type() string {
- return m.typ
- }
- // Fields returns all fields that were changed during this mutation. Note that in
- // order to get all numeric fields that were incremented/decremented, call
- // AddedFields().
- func (m *UserAttributeDefinitionMutation) Fields() []string {
- fields := make([]string, 0, 13)
- if m.created_at != nil {
- fields = append(fields, userattributedefinition.FieldCreatedAt)
- }
- if m.updated_at != nil {
- fields = append(fields, userattributedefinition.FieldUpdatedAt)
- }
- if m.deleted_at != nil {
- fields = append(fields, userattributedefinition.FieldDeletedAt)
- }
- if m.key != nil {
- fields = append(fields, userattributedefinition.FieldKey)
- }
- if m.name != nil {
- fields = append(fields, userattributedefinition.FieldName)
- }
- if m.description != nil {
- fields = append(fields, userattributedefinition.FieldDescription)
- }
- if m._type != nil {
- fields = append(fields, userattributedefinition.FieldType)
- }
- if m.options != nil {
- fields = append(fields, userattributedefinition.FieldOptions)
- }
- if m.required != nil {
- fields = append(fields, userattributedefinition.FieldRequired)
- }
- if m.validation != nil {
- fields = append(fields, userattributedefinition.FieldValidation)
- }
- if m.placeholder != nil {
- fields = append(fields, userattributedefinition.FieldPlaceholder)
- }
- if m.display_order != nil {
- fields = append(fields, userattributedefinition.FieldDisplayOrder)
- }
- if m.enabled != nil {
- fields = append(fields, userattributedefinition.FieldEnabled)
- }
- return fields
- }
- // Field returns the value of a field with the given name. The second boolean
- // return value indicates that this field was not set, or was not defined in the
- // schema.
- func (m *UserAttributeDefinitionMutation) Field(name string) (ent.Value, bool) {
- switch name {
- case userattributedefinition.FieldCreatedAt:
- return m.CreatedAt()
- case userattributedefinition.FieldUpdatedAt:
- return m.UpdatedAt()
- case userattributedefinition.FieldDeletedAt:
- return m.DeletedAt()
- case userattributedefinition.FieldKey:
- return m.Key()
- case userattributedefinition.FieldName:
- return m.Name()
- case userattributedefinition.FieldDescription:
- return m.Description()
- case userattributedefinition.FieldType:
- return m.GetType()
- case userattributedefinition.FieldOptions:
- return m.Options()
- case userattributedefinition.FieldRequired:
- return m.Required()
- case userattributedefinition.FieldValidation:
- return m.Validation()
- case userattributedefinition.FieldPlaceholder:
- return m.Placeholder()
- case userattributedefinition.FieldDisplayOrder:
- return m.DisplayOrder()
- case userattributedefinition.FieldEnabled:
- return m.Enabled()
- }
- return nil, false
- }
- // OldField returns the old value of the field from the database. An error is
- // returned if the mutation operation is not UpdateOne, or the query to the
- // database failed.
- func (m *UserAttributeDefinitionMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
- switch name {
- case userattributedefinition.FieldCreatedAt:
- return m.OldCreatedAt(ctx)
- case userattributedefinition.FieldUpdatedAt:
- return m.OldUpdatedAt(ctx)
- case userattributedefinition.FieldDeletedAt:
- return m.OldDeletedAt(ctx)
- case userattributedefinition.FieldKey:
- return m.OldKey(ctx)
- case userattributedefinition.FieldName:
- return m.OldName(ctx)
- case userattributedefinition.FieldDescription:
- return m.OldDescription(ctx)
- case userattributedefinition.FieldType:
- return m.OldType(ctx)
- case userattributedefinition.FieldOptions:
- return m.OldOptions(ctx)
- case userattributedefinition.FieldRequired:
- return m.OldRequired(ctx)
- case userattributedefinition.FieldValidation:
- return m.OldValidation(ctx)
- case userattributedefinition.FieldPlaceholder:
- return m.OldPlaceholder(ctx)
- case userattributedefinition.FieldDisplayOrder:
- return m.OldDisplayOrder(ctx)
- case userattributedefinition.FieldEnabled:
- return m.OldEnabled(ctx)
- }
- return nil, fmt.Errorf("unknown UserAttributeDefinition field %s", name)
- }
- // SetField sets the value of a field with the given name. It returns an error if
- // the field is not defined in the schema, or if the type mismatched the field
- // type.
- func (m *UserAttributeDefinitionMutation) SetField(name string, value ent.Value) error {
- switch name {
- case userattributedefinition.FieldCreatedAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetCreatedAt(v)
- return nil
- case userattributedefinition.FieldUpdatedAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetUpdatedAt(v)
- return nil
- case userattributedefinition.FieldDeletedAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetDeletedAt(v)
- return nil
- case userattributedefinition.FieldKey:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetKey(v)
- return nil
- case userattributedefinition.FieldName:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetName(v)
- return nil
- case userattributedefinition.FieldDescription:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetDescription(v)
- return nil
- case userattributedefinition.FieldType:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetType(v)
- return nil
- case userattributedefinition.FieldOptions:
- v, ok := value.([]map[string]interface{})
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetOptions(v)
- return nil
- case userattributedefinition.FieldRequired:
- v, ok := value.(bool)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetRequired(v)
- return nil
- case userattributedefinition.FieldValidation:
- v, ok := value.(map[string]interface{})
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetValidation(v)
- return nil
- case userattributedefinition.FieldPlaceholder:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetPlaceholder(v)
- return nil
- case userattributedefinition.FieldDisplayOrder:
- v, ok := value.(int)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetDisplayOrder(v)
- return nil
- case userattributedefinition.FieldEnabled:
- v, ok := value.(bool)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetEnabled(v)
- return nil
- }
- return fmt.Errorf("unknown UserAttributeDefinition field %s", name)
- }
- // AddedFields returns all numeric fields that were incremented/decremented during
- // this mutation.
- func (m *UserAttributeDefinitionMutation) AddedFields() []string {
- var fields []string
- if m.adddisplay_order != nil {
- fields = append(fields, userattributedefinition.FieldDisplayOrder)
- }
- return fields
- }
- // AddedField returns the numeric value that was incremented/decremented on a field
- // with the given name. The second boolean return value indicates that this field
- // was not set, or was not defined in the schema.
- func (m *UserAttributeDefinitionMutation) AddedField(name string) (ent.Value, bool) {
- switch name {
- case userattributedefinition.FieldDisplayOrder:
- return m.AddedDisplayOrder()
- }
- return nil, false
- }
- // AddField adds the value to the field with the given name. It returns an error if
- // the field is not defined in the schema, or if the type mismatched the field
- // type.
- func (m *UserAttributeDefinitionMutation) AddField(name string, value ent.Value) error {
- switch name {
- case userattributedefinition.FieldDisplayOrder:
- v, ok := value.(int)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.AddDisplayOrder(v)
- return nil
- }
- return fmt.Errorf("unknown UserAttributeDefinition numeric field %s", name)
- }
- // ClearedFields returns all nullable fields that were cleared during this
- // mutation.
- func (m *UserAttributeDefinitionMutation) ClearedFields() []string {
- var fields []string
- if m.FieldCleared(userattributedefinition.FieldDeletedAt) {
- fields = append(fields, userattributedefinition.FieldDeletedAt)
- }
- return fields
- }
- // FieldCleared returns a boolean indicating if a field with the given name was
- // cleared in this mutation.
- func (m *UserAttributeDefinitionMutation) FieldCleared(name string) bool {
- _, ok := m.clearedFields[name]
- return ok
- }
- // ClearField clears the value of the field with the given name. It returns an
- // error if the field is not defined in the schema.
- func (m *UserAttributeDefinitionMutation) ClearField(name string) error {
- switch name {
- case userattributedefinition.FieldDeletedAt:
- m.ClearDeletedAt()
- return nil
- }
- return fmt.Errorf("unknown UserAttributeDefinition nullable field %s", name)
- }
- // ResetField resets all changes in the mutation for the field with the given name.
- // It returns an error if the field is not defined in the schema.
- func (m *UserAttributeDefinitionMutation) ResetField(name string) error {
- switch name {
- case userattributedefinition.FieldCreatedAt:
- m.ResetCreatedAt()
- return nil
- case userattributedefinition.FieldUpdatedAt:
- m.ResetUpdatedAt()
- return nil
- case userattributedefinition.FieldDeletedAt:
- m.ResetDeletedAt()
- return nil
- case userattributedefinition.FieldKey:
- m.ResetKey()
- return nil
- case userattributedefinition.FieldName:
- m.ResetName()
- return nil
- case userattributedefinition.FieldDescription:
- m.ResetDescription()
- return nil
- case userattributedefinition.FieldType:
- m.ResetType()
- return nil
- case userattributedefinition.FieldOptions:
- m.ResetOptions()
- return nil
- case userattributedefinition.FieldRequired:
- m.ResetRequired()
- return nil
- case userattributedefinition.FieldValidation:
- m.ResetValidation()
- return nil
- case userattributedefinition.FieldPlaceholder:
- m.ResetPlaceholder()
- return nil
- case userattributedefinition.FieldDisplayOrder:
- m.ResetDisplayOrder()
- return nil
- case userattributedefinition.FieldEnabled:
- m.ResetEnabled()
- return nil
- }
- return fmt.Errorf("unknown UserAttributeDefinition field %s", name)
- }
- // AddedEdges returns all edge names that were set/added in this mutation.
- func (m *UserAttributeDefinitionMutation) AddedEdges() []string {
- edges := make([]string, 0, 1)
- if m.values != nil {
- edges = append(edges, userattributedefinition.EdgeValues)
- }
- return edges
- }
- // AddedIDs returns all IDs (to other nodes) that were added for the given edge
- // name in this mutation.
- func (m *UserAttributeDefinitionMutation) AddedIDs(name string) []ent.Value {
- switch name {
- case userattributedefinition.EdgeValues:
- ids := make([]ent.Value, 0, len(m.values))
- for id := range m.values {
- ids = append(ids, id)
- }
- return ids
- }
- return nil
- }
- // RemovedEdges returns all edge names that were removed in this mutation.
- func (m *UserAttributeDefinitionMutation) RemovedEdges() []string {
- edges := make([]string, 0, 1)
- if m.removedvalues != nil {
- edges = append(edges, userattributedefinition.EdgeValues)
- }
- return edges
- }
- // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
- // the given name in this mutation.
- func (m *UserAttributeDefinitionMutation) RemovedIDs(name string) []ent.Value {
- switch name {
- case userattributedefinition.EdgeValues:
- ids := make([]ent.Value, 0, len(m.removedvalues))
- for id := range m.removedvalues {
- ids = append(ids, id)
- }
- return ids
- }
- return nil
- }
- // ClearedEdges returns all edge names that were cleared in this mutation.
- func (m *UserAttributeDefinitionMutation) ClearedEdges() []string {
- edges := make([]string, 0, 1)
- if m.clearedvalues {
- edges = append(edges, userattributedefinition.EdgeValues)
- }
- return edges
- }
- // EdgeCleared returns a boolean which indicates if the edge with the given name
- // was cleared in this mutation.
- func (m *UserAttributeDefinitionMutation) EdgeCleared(name string) bool {
- switch name {
- case userattributedefinition.EdgeValues:
- return m.clearedvalues
- }
- return false
- }
- // ClearEdge clears the value of the edge with the given name. It returns an error
- // if that edge is not defined in the schema.
- func (m *UserAttributeDefinitionMutation) ClearEdge(name string) error {
- switch name {
- }
- return fmt.Errorf("unknown UserAttributeDefinition unique edge %s", name)
- }
- // ResetEdge resets all changes to the edge with the given name in this mutation.
- // It returns an error if the edge is not defined in the schema.
- func (m *UserAttributeDefinitionMutation) ResetEdge(name string) error {
- switch name {
- case userattributedefinition.EdgeValues:
- m.ResetValues()
- return nil
- }
- return fmt.Errorf("unknown UserAttributeDefinition edge %s", name)
- }
- // UserAttributeValueMutation represents an operation that mutates the UserAttributeValue nodes in the graph.
- type UserAttributeValueMutation struct {
- config
- op Op
- typ string
- id *int64
- created_at *time.Time
- updated_at *time.Time
- value *string
- clearedFields map[string]struct{}
- user *int64
- cleareduser bool
- definition *int64
- cleareddefinition bool
- done bool
- oldValue func(context.Context) (*UserAttributeValue, error)
- predicates []predicate.UserAttributeValue
- }
- var _ ent.Mutation = (*UserAttributeValueMutation)(nil)
- // userattributevalueOption allows management of the mutation configuration using functional options.
- type userattributevalueOption func(*UserAttributeValueMutation)
- // newUserAttributeValueMutation creates new mutation for the UserAttributeValue entity.
- func newUserAttributeValueMutation(c config, op Op, opts ...userattributevalueOption) *UserAttributeValueMutation {
- m := &UserAttributeValueMutation{
- config: c,
- op: op,
- typ: TypeUserAttributeValue,
- clearedFields: make(map[string]struct{}),
- }
- for _, opt := range opts {
- opt(m)
- }
- return m
- }
- // withUserAttributeValueID sets the ID field of the mutation.
- func withUserAttributeValueID(id int64) userattributevalueOption {
- return func(m *UserAttributeValueMutation) {
- var (
- err error
- once sync.Once
- value *UserAttributeValue
- )
- m.oldValue = func(ctx context.Context) (*UserAttributeValue, error) {
- once.Do(func() {
- if m.done {
- err = errors.New("querying old values post mutation is not allowed")
- } else {
- value, err = m.Client().UserAttributeValue.Get(ctx, id)
- }
- })
- return value, err
- }
- m.id = &id
- }
- }
- // withUserAttributeValue sets the old UserAttributeValue of the mutation.
- func withUserAttributeValue(node *UserAttributeValue) userattributevalueOption {
- return func(m *UserAttributeValueMutation) {
- m.oldValue = func(context.Context) (*UserAttributeValue, error) {
- return node, nil
- }
- m.id = &node.ID
- }
- }
- // Client returns a new `ent.Client` from the mutation. If the mutation was
- // executed in a transaction (ent.Tx), a transactional client is returned.
- func (m UserAttributeValueMutation) Client() *Client {
- client := &Client{config: m.config}
- client.init()
- return client
- }
- // Tx returns an `ent.Tx` for mutations that were executed in transactions;
- // it returns an error otherwise.
- func (m UserAttributeValueMutation) Tx() (*Tx, error) {
- if _, ok := m.driver.(*txDriver); !ok {
- return nil, errors.New("ent: mutation is not running in a transaction")
- }
- tx := &Tx{config: m.config}
- tx.init()
- return tx, nil
- }
- // ID returns the ID value in the mutation. Note that the ID is only available
- // if it was provided to the builder or after it was returned from the database.
- func (m *UserAttributeValueMutation) ID() (id int64, exists bool) {
- if m.id == nil {
- return
- }
- return *m.id, true
- }
- // IDs queries the database and returns the entity ids that match the mutation's predicate.
- // That means, if the mutation is applied within a transaction with an isolation level such
- // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
- // or updated by the mutation.
- func (m *UserAttributeValueMutation) IDs(ctx context.Context) ([]int64, error) {
- switch {
- case m.op.Is(OpUpdateOne | OpDeleteOne):
- id, exists := m.ID()
- if exists {
- return []int64{id}, nil
- }
- fallthrough
- case m.op.Is(OpUpdate | OpDelete):
- return m.Client().UserAttributeValue.Query().Where(m.predicates...).IDs(ctx)
- default:
- return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
- }
- }
- // SetCreatedAt sets the "created_at" field.
- func (m *UserAttributeValueMutation) SetCreatedAt(t time.Time) {
- m.created_at = &t
- }
- // CreatedAt returns the value of the "created_at" field in the mutation.
- func (m *UserAttributeValueMutation) CreatedAt() (r time.Time, exists bool) {
- v := m.created_at
- if v == nil {
- return
- }
- return *v, true
- }
- // OldCreatedAt returns the old "created_at" field's value of the UserAttributeValue entity.
- // If the UserAttributeValue object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *UserAttributeValueMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldCreatedAt requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
- }
- return oldValue.CreatedAt, nil
- }
- // ResetCreatedAt resets all changes to the "created_at" field.
- func (m *UserAttributeValueMutation) ResetCreatedAt() {
- m.created_at = nil
- }
- // SetUpdatedAt sets the "updated_at" field.
- func (m *UserAttributeValueMutation) SetUpdatedAt(t time.Time) {
- m.updated_at = &t
- }
- // UpdatedAt returns the value of the "updated_at" field in the mutation.
- func (m *UserAttributeValueMutation) UpdatedAt() (r time.Time, exists bool) {
- v := m.updated_at
- if v == nil {
- return
- }
- return *v, true
- }
- // OldUpdatedAt returns the old "updated_at" field's value of the UserAttributeValue entity.
- // If the UserAttributeValue object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *UserAttributeValueMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
- }
- return oldValue.UpdatedAt, nil
- }
- // ResetUpdatedAt resets all changes to the "updated_at" field.
- func (m *UserAttributeValueMutation) ResetUpdatedAt() {
- m.updated_at = nil
- }
- // SetUserID sets the "user_id" field.
- func (m *UserAttributeValueMutation) SetUserID(i int64) {
- m.user = &i
- }
- // UserID returns the value of the "user_id" field in the mutation.
- func (m *UserAttributeValueMutation) UserID() (r int64, exists bool) {
- v := m.user
- if v == nil {
- return
- }
- return *v, true
- }
- // OldUserID returns the old "user_id" field's value of the UserAttributeValue entity.
- // If the UserAttributeValue object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *UserAttributeValueMutation) OldUserID(ctx context.Context) (v int64, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldUserID is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldUserID requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldUserID: %w", err)
- }
- return oldValue.UserID, nil
- }
- // ResetUserID resets all changes to the "user_id" field.
- func (m *UserAttributeValueMutation) ResetUserID() {
- m.user = nil
- }
- // SetAttributeID sets the "attribute_id" field.
- func (m *UserAttributeValueMutation) SetAttributeID(i int64) {
- m.definition = &i
- }
- // AttributeID returns the value of the "attribute_id" field in the mutation.
- func (m *UserAttributeValueMutation) AttributeID() (r int64, exists bool) {
- v := m.definition
- if v == nil {
- return
- }
- return *v, true
- }
- // OldAttributeID returns the old "attribute_id" field's value of the UserAttributeValue entity.
- // If the UserAttributeValue object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *UserAttributeValueMutation) OldAttributeID(ctx context.Context) (v int64, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldAttributeID is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldAttributeID requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldAttributeID: %w", err)
- }
- return oldValue.AttributeID, nil
- }
- // ResetAttributeID resets all changes to the "attribute_id" field.
- func (m *UserAttributeValueMutation) ResetAttributeID() {
- m.definition = nil
- }
- // SetValue sets the "value" field.
- func (m *UserAttributeValueMutation) SetValue(s string) {
- m.value = &s
- }
- // Value returns the value of the "value" field in the mutation.
- func (m *UserAttributeValueMutation) Value() (r string, exists bool) {
- v := m.value
- if v == nil {
- return
- }
- return *v, true
- }
- // OldValue returns the old "value" field's value of the UserAttributeValue entity.
- // If the UserAttributeValue object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *UserAttributeValueMutation) OldValue(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldValue is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldValue requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldValue: %w", err)
- }
- return oldValue.Value, nil
- }
- // ResetValue resets all changes to the "value" field.
- func (m *UserAttributeValueMutation) ResetValue() {
- m.value = nil
- }
- // ClearUser clears the "user" edge to the User entity.
- func (m *UserAttributeValueMutation) ClearUser() {
- m.cleareduser = true
- m.clearedFields[userattributevalue.FieldUserID] = struct{}{}
- }
- // UserCleared reports if the "user" edge to the User entity was cleared.
- func (m *UserAttributeValueMutation) UserCleared() bool {
- return m.cleareduser
- }
- // UserIDs returns the "user" edge IDs in the mutation.
- // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
- // UserID instead. It exists only for internal usage by the builders.
- func (m *UserAttributeValueMutation) UserIDs() (ids []int64) {
- if id := m.user; id != nil {
- ids = append(ids, *id)
- }
- return
- }
- // ResetUser resets all changes to the "user" edge.
- func (m *UserAttributeValueMutation) ResetUser() {
- m.user = nil
- m.cleareduser = false
- }
- // SetDefinitionID sets the "definition" edge to the UserAttributeDefinition entity by id.
- func (m *UserAttributeValueMutation) SetDefinitionID(id int64) {
- m.definition = &id
- }
- // ClearDefinition clears the "definition" edge to the UserAttributeDefinition entity.
- func (m *UserAttributeValueMutation) ClearDefinition() {
- m.cleareddefinition = true
- m.clearedFields[userattributevalue.FieldAttributeID] = struct{}{}
- }
- // DefinitionCleared reports if the "definition" edge to the UserAttributeDefinition entity was cleared.
- func (m *UserAttributeValueMutation) DefinitionCleared() bool {
- return m.cleareddefinition
- }
- // DefinitionID returns the "definition" edge ID in the mutation.
- func (m *UserAttributeValueMutation) DefinitionID() (id int64, exists bool) {
- if m.definition != nil {
- return *m.definition, true
- }
- return
- }
- // DefinitionIDs returns the "definition" edge IDs in the mutation.
- // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
- // DefinitionID instead. It exists only for internal usage by the builders.
- func (m *UserAttributeValueMutation) DefinitionIDs() (ids []int64) {
- if id := m.definition; id != nil {
- ids = append(ids, *id)
- }
- return
- }
- // ResetDefinition resets all changes to the "definition" edge.
- func (m *UserAttributeValueMutation) ResetDefinition() {
- m.definition = nil
- m.cleareddefinition = false
- }
- // Where appends a list predicates to the UserAttributeValueMutation builder.
- func (m *UserAttributeValueMutation) Where(ps ...predicate.UserAttributeValue) {
- m.predicates = append(m.predicates, ps...)
- }
- // WhereP appends storage-level predicates to the UserAttributeValueMutation builder. Using this method,
- // users can use type-assertion to append predicates that do not depend on any generated package.
- func (m *UserAttributeValueMutation) WhereP(ps ...func(*sql.Selector)) {
- p := make([]predicate.UserAttributeValue, len(ps))
- for i := range ps {
- p[i] = ps[i]
- }
- m.Where(p...)
- }
- // Op returns the operation name.
- func (m *UserAttributeValueMutation) Op() Op {
- return m.op
- }
- // SetOp allows setting the mutation operation.
- func (m *UserAttributeValueMutation) SetOp(op Op) {
- m.op = op
- }
- // Type returns the node type of this mutation (UserAttributeValue).
- func (m *UserAttributeValueMutation) Type() string {
- return m.typ
- }
- // Fields returns all fields that were changed during this mutation. Note that in
- // order to get all numeric fields that were incremented/decremented, call
- // AddedFields().
- func (m *UserAttributeValueMutation) Fields() []string {
- fields := make([]string, 0, 5)
- if m.created_at != nil {
- fields = append(fields, userattributevalue.FieldCreatedAt)
- }
- if m.updated_at != nil {
- fields = append(fields, userattributevalue.FieldUpdatedAt)
- }
- if m.user != nil {
- fields = append(fields, userattributevalue.FieldUserID)
- }
- if m.definition != nil {
- fields = append(fields, userattributevalue.FieldAttributeID)
- }
- if m.value != nil {
- fields = append(fields, userattributevalue.FieldValue)
- }
- return fields
- }
- // Field returns the value of a field with the given name. The second boolean
- // return value indicates that this field was not set, or was not defined in the
- // schema.
- func (m *UserAttributeValueMutation) Field(name string) (ent.Value, bool) {
- switch name {
- case userattributevalue.FieldCreatedAt:
- return m.CreatedAt()
- case userattributevalue.FieldUpdatedAt:
- return m.UpdatedAt()
- case userattributevalue.FieldUserID:
- return m.UserID()
- case userattributevalue.FieldAttributeID:
- return m.AttributeID()
- case userattributevalue.FieldValue:
- return m.Value()
- }
- return nil, false
- }
- // OldField returns the old value of the field from the database. An error is
- // returned if the mutation operation is not UpdateOne, or the query to the
- // database failed.
- func (m *UserAttributeValueMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
- switch name {
- case userattributevalue.FieldCreatedAt:
- return m.OldCreatedAt(ctx)
- case userattributevalue.FieldUpdatedAt:
- return m.OldUpdatedAt(ctx)
- case userattributevalue.FieldUserID:
- return m.OldUserID(ctx)
- case userattributevalue.FieldAttributeID:
- return m.OldAttributeID(ctx)
- case userattributevalue.FieldValue:
- return m.OldValue(ctx)
- }
- return nil, fmt.Errorf("unknown UserAttributeValue field %s", name)
- }
- // SetField sets the value of a field with the given name. It returns an error if
- // the field is not defined in the schema, or if the type mismatched the field
- // type.
- func (m *UserAttributeValueMutation) SetField(name string, value ent.Value) error {
- switch name {
- case userattributevalue.FieldCreatedAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetCreatedAt(v)
- return nil
- case userattributevalue.FieldUpdatedAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetUpdatedAt(v)
- return nil
- case userattributevalue.FieldUserID:
- v, ok := value.(int64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetUserID(v)
- return nil
- case userattributevalue.FieldAttributeID:
- v, ok := value.(int64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetAttributeID(v)
- return nil
- case userattributevalue.FieldValue:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetValue(v)
- return nil
- }
- return fmt.Errorf("unknown UserAttributeValue field %s", name)
- }
- // AddedFields returns all numeric fields that were incremented/decremented during
- // this mutation.
- func (m *UserAttributeValueMutation) AddedFields() []string {
- var fields []string
- return fields
- }
- // AddedField returns the numeric value that was incremented/decremented on a field
- // with the given name. The second boolean return value indicates that this field
- // was not set, or was not defined in the schema.
- func (m *UserAttributeValueMutation) AddedField(name string) (ent.Value, bool) {
- switch name {
- }
- return nil, false
- }
- // AddField adds the value to the field with the given name. It returns an error if
- // the field is not defined in the schema, or if the type mismatched the field
- // type.
- func (m *UserAttributeValueMutation) AddField(name string, value ent.Value) error {
- switch name {
- }
- return fmt.Errorf("unknown UserAttributeValue numeric field %s", name)
- }
- // ClearedFields returns all nullable fields that were cleared during this
- // mutation.
- func (m *UserAttributeValueMutation) ClearedFields() []string {
- return nil
- }
- // FieldCleared returns a boolean indicating if a field with the given name was
- // cleared in this mutation.
- func (m *UserAttributeValueMutation) FieldCleared(name string) bool {
- _, ok := m.clearedFields[name]
- return ok
- }
- // ClearField clears the value of the field with the given name. It returns an
- // error if the field is not defined in the schema.
- func (m *UserAttributeValueMutation) ClearField(name string) error {
- return fmt.Errorf("unknown UserAttributeValue nullable field %s", name)
- }
- // ResetField resets all changes in the mutation for the field with the given name.
- // It returns an error if the field is not defined in the schema.
- func (m *UserAttributeValueMutation) ResetField(name string) error {
- switch name {
- case userattributevalue.FieldCreatedAt:
- m.ResetCreatedAt()
- return nil
- case userattributevalue.FieldUpdatedAt:
- m.ResetUpdatedAt()
- return nil
- case userattributevalue.FieldUserID:
- m.ResetUserID()
- return nil
- case userattributevalue.FieldAttributeID:
- m.ResetAttributeID()
- return nil
- case userattributevalue.FieldValue:
- m.ResetValue()
- return nil
- }
- return fmt.Errorf("unknown UserAttributeValue field %s", name)
- }
- // AddedEdges returns all edge names that were set/added in this mutation.
- func (m *UserAttributeValueMutation) AddedEdges() []string {
- edges := make([]string, 0, 2)
- if m.user != nil {
- edges = append(edges, userattributevalue.EdgeUser)
- }
- if m.definition != nil {
- edges = append(edges, userattributevalue.EdgeDefinition)
- }
- return edges
- }
- // AddedIDs returns all IDs (to other nodes) that were added for the given edge
- // name in this mutation.
- func (m *UserAttributeValueMutation) AddedIDs(name string) []ent.Value {
- switch name {
- case userattributevalue.EdgeUser:
- if id := m.user; id != nil {
- return []ent.Value{*id}
- }
- case userattributevalue.EdgeDefinition:
- if id := m.definition; id != nil {
- return []ent.Value{*id}
- }
- }
- return nil
- }
- // RemovedEdges returns all edge names that were removed in this mutation.
- func (m *UserAttributeValueMutation) RemovedEdges() []string {
- edges := make([]string, 0, 2)
- return edges
- }
- // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
- // the given name in this mutation.
- func (m *UserAttributeValueMutation) RemovedIDs(name string) []ent.Value {
- return nil
- }
- // ClearedEdges returns all edge names that were cleared in this mutation.
- func (m *UserAttributeValueMutation) ClearedEdges() []string {
- edges := make([]string, 0, 2)
- if m.cleareduser {
- edges = append(edges, userattributevalue.EdgeUser)
- }
- if m.cleareddefinition {
- edges = append(edges, userattributevalue.EdgeDefinition)
- }
- return edges
- }
- // EdgeCleared returns a boolean which indicates if the edge with the given name
- // was cleared in this mutation.
- func (m *UserAttributeValueMutation) EdgeCleared(name string) bool {
- switch name {
- case userattributevalue.EdgeUser:
- return m.cleareduser
- case userattributevalue.EdgeDefinition:
- return m.cleareddefinition
- }
- return false
- }
- // ClearEdge clears the value of the edge with the given name. It returns an error
- // if that edge is not defined in the schema.
- func (m *UserAttributeValueMutation) ClearEdge(name string) error {
- switch name {
- case userattributevalue.EdgeUser:
- m.ClearUser()
- return nil
- case userattributevalue.EdgeDefinition:
- m.ClearDefinition()
- return nil
- }
- return fmt.Errorf("unknown UserAttributeValue unique edge %s", name)
- }
- // ResetEdge resets all changes to the edge with the given name in this mutation.
- // It returns an error if the edge is not defined in the schema.
- func (m *UserAttributeValueMutation) ResetEdge(name string) error {
- switch name {
- case userattributevalue.EdgeUser:
- m.ResetUser()
- return nil
- case userattributevalue.EdgeDefinition:
- m.ResetDefinition()
- return nil
- }
- return fmt.Errorf("unknown UserAttributeValue edge %s", name)
- }
- // UserPlatformQuotaMutation represents an operation that mutates the UserPlatformQuota nodes in the graph.
- type UserPlatformQuotaMutation struct {
- config
- op Op
- typ string
- id *int64
- created_at *time.Time
- updated_at *time.Time
- deleted_at *time.Time
- platform *string
- daily_limit_usd *float64
- adddaily_limit_usd *float64
- weekly_limit_usd *float64
- addweekly_limit_usd *float64
- monthly_limit_usd *float64
- addmonthly_limit_usd *float64
- daily_usage_usd *float64
- adddaily_usage_usd *float64
- weekly_usage_usd *float64
- addweekly_usage_usd *float64
- monthly_usage_usd *float64
- addmonthly_usage_usd *float64
- daily_window_start *time.Time
- weekly_window_start *time.Time
- monthly_window_start *time.Time
- clearedFields map[string]struct{}
- user *int64
- cleareduser bool
- done bool
- oldValue func(context.Context) (*UserPlatformQuota, error)
- predicates []predicate.UserPlatformQuota
- }
- var _ ent.Mutation = (*UserPlatformQuotaMutation)(nil)
- // userplatformquotaOption allows management of the mutation configuration using functional options.
- type userplatformquotaOption func(*UserPlatformQuotaMutation)
- // newUserPlatformQuotaMutation creates new mutation for the UserPlatformQuota entity.
- func newUserPlatformQuotaMutation(c config, op Op, opts ...userplatformquotaOption) *UserPlatformQuotaMutation {
- m := &UserPlatformQuotaMutation{
- config: c,
- op: op,
- typ: TypeUserPlatformQuota,
- clearedFields: make(map[string]struct{}),
- }
- for _, opt := range opts {
- opt(m)
- }
- return m
- }
- // withUserPlatformQuotaID sets the ID field of the mutation.
- func withUserPlatformQuotaID(id int64) userplatformquotaOption {
- return func(m *UserPlatformQuotaMutation) {
- var (
- err error
- once sync.Once
- value *UserPlatformQuota
- )
- m.oldValue = func(ctx context.Context) (*UserPlatformQuota, error) {
- once.Do(func() {
- if m.done {
- err = errors.New("querying old values post mutation is not allowed")
- } else {
- value, err = m.Client().UserPlatformQuota.Get(ctx, id)
- }
- })
- return value, err
- }
- m.id = &id
- }
- }
- // withUserPlatformQuota sets the old UserPlatformQuota of the mutation.
- func withUserPlatformQuota(node *UserPlatformQuota) userplatformquotaOption {
- return func(m *UserPlatformQuotaMutation) {
- m.oldValue = func(context.Context) (*UserPlatformQuota, error) {
- return node, nil
- }
- m.id = &node.ID
- }
- }
- // Client returns a new `ent.Client` from the mutation. If the mutation was
- // executed in a transaction (ent.Tx), a transactional client is returned.
- func (m UserPlatformQuotaMutation) Client() *Client {
- client := &Client{config: m.config}
- client.init()
- return client
- }
- // Tx returns an `ent.Tx` for mutations that were executed in transactions;
- // it returns an error otherwise.
- func (m UserPlatformQuotaMutation) Tx() (*Tx, error) {
- if _, ok := m.driver.(*txDriver); !ok {
- return nil, errors.New("ent: mutation is not running in a transaction")
- }
- tx := &Tx{config: m.config}
- tx.init()
- return tx, nil
- }
- // ID returns the ID value in the mutation. Note that the ID is only available
- // if it was provided to the builder or after it was returned from the database.
- func (m *UserPlatformQuotaMutation) ID() (id int64, exists bool) {
- if m.id == nil {
- return
- }
- return *m.id, true
- }
- // IDs queries the database and returns the entity ids that match the mutation's predicate.
- // That means, if the mutation is applied within a transaction with an isolation level such
- // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
- // or updated by the mutation.
- func (m *UserPlatformQuotaMutation) IDs(ctx context.Context) ([]int64, error) {
- switch {
- case m.op.Is(OpUpdateOne | OpDeleteOne):
- id, exists := m.ID()
- if exists {
- return []int64{id}, nil
- }
- fallthrough
- case m.op.Is(OpUpdate | OpDelete):
- return m.Client().UserPlatformQuota.Query().Where(m.predicates...).IDs(ctx)
- default:
- return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
- }
- }
- // SetCreatedAt sets the "created_at" field.
- func (m *UserPlatformQuotaMutation) SetCreatedAt(t time.Time) {
- m.created_at = &t
- }
- // CreatedAt returns the value of the "created_at" field in the mutation.
- func (m *UserPlatformQuotaMutation) CreatedAt() (r time.Time, exists bool) {
- v := m.created_at
- if v == nil {
- return
- }
- return *v, true
- }
- // OldCreatedAt returns the old "created_at" field's value of the UserPlatformQuota entity.
- // If the UserPlatformQuota object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *UserPlatformQuotaMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldCreatedAt requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
- }
- return oldValue.CreatedAt, nil
- }
- // ResetCreatedAt resets all changes to the "created_at" field.
- func (m *UserPlatformQuotaMutation) ResetCreatedAt() {
- m.created_at = nil
- }
- // SetUpdatedAt sets the "updated_at" field.
- func (m *UserPlatformQuotaMutation) SetUpdatedAt(t time.Time) {
- m.updated_at = &t
- }
- // UpdatedAt returns the value of the "updated_at" field in the mutation.
- func (m *UserPlatformQuotaMutation) UpdatedAt() (r time.Time, exists bool) {
- v := m.updated_at
- if v == nil {
- return
- }
- return *v, true
- }
- // OldUpdatedAt returns the old "updated_at" field's value of the UserPlatformQuota entity.
- // If the UserPlatformQuota object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *UserPlatformQuotaMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
- }
- return oldValue.UpdatedAt, nil
- }
- // ResetUpdatedAt resets all changes to the "updated_at" field.
- func (m *UserPlatformQuotaMutation) ResetUpdatedAt() {
- m.updated_at = nil
- }
- // SetDeletedAt sets the "deleted_at" field.
- func (m *UserPlatformQuotaMutation) SetDeletedAt(t time.Time) {
- m.deleted_at = &t
- }
- // DeletedAt returns the value of the "deleted_at" field in the mutation.
- func (m *UserPlatformQuotaMutation) DeletedAt() (r time.Time, exists bool) {
- v := m.deleted_at
- if v == nil {
- return
- }
- return *v, true
- }
- // OldDeletedAt returns the old "deleted_at" field's value of the UserPlatformQuota entity.
- // If the UserPlatformQuota object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *UserPlatformQuotaMutation) OldDeletedAt(ctx context.Context) (v *time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldDeletedAt requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
- }
- return oldValue.DeletedAt, nil
- }
- // ClearDeletedAt clears the value of the "deleted_at" field.
- func (m *UserPlatformQuotaMutation) ClearDeletedAt() {
- m.deleted_at = nil
- m.clearedFields[userplatformquota.FieldDeletedAt] = struct{}{}
- }
- // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
- func (m *UserPlatformQuotaMutation) DeletedAtCleared() bool {
- _, ok := m.clearedFields[userplatformquota.FieldDeletedAt]
- return ok
- }
- // ResetDeletedAt resets all changes to the "deleted_at" field.
- func (m *UserPlatformQuotaMutation) ResetDeletedAt() {
- m.deleted_at = nil
- delete(m.clearedFields, userplatformquota.FieldDeletedAt)
- }
- // SetUserID sets the "user_id" field.
- func (m *UserPlatformQuotaMutation) SetUserID(i int64) {
- m.user = &i
- }
- // UserID returns the value of the "user_id" field in the mutation.
- func (m *UserPlatformQuotaMutation) UserID() (r int64, exists bool) {
- v := m.user
- if v == nil {
- return
- }
- return *v, true
- }
- // OldUserID returns the old "user_id" field's value of the UserPlatformQuota entity.
- // If the UserPlatformQuota object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *UserPlatformQuotaMutation) OldUserID(ctx context.Context) (v int64, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldUserID is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldUserID requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldUserID: %w", err)
- }
- return oldValue.UserID, nil
- }
- // ResetUserID resets all changes to the "user_id" field.
- func (m *UserPlatformQuotaMutation) ResetUserID() {
- m.user = nil
- }
- // SetPlatform sets the "platform" field.
- func (m *UserPlatformQuotaMutation) SetPlatform(s string) {
- m.platform = &s
- }
- // Platform returns the value of the "platform" field in the mutation.
- func (m *UserPlatformQuotaMutation) Platform() (r string, exists bool) {
- v := m.platform
- if v == nil {
- return
- }
- return *v, true
- }
- // OldPlatform returns the old "platform" field's value of the UserPlatformQuota entity.
- // If the UserPlatformQuota object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *UserPlatformQuotaMutation) OldPlatform(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldPlatform is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldPlatform requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldPlatform: %w", err)
- }
- return oldValue.Platform, nil
- }
- // ResetPlatform resets all changes to the "platform" field.
- func (m *UserPlatformQuotaMutation) ResetPlatform() {
- m.platform = nil
- }
- // SetDailyLimitUsd sets the "daily_limit_usd" field.
- func (m *UserPlatformQuotaMutation) SetDailyLimitUsd(f float64) {
- m.daily_limit_usd = &f
- m.adddaily_limit_usd = nil
- }
- // DailyLimitUsd returns the value of the "daily_limit_usd" field in the mutation.
- func (m *UserPlatformQuotaMutation) DailyLimitUsd() (r float64, exists bool) {
- v := m.daily_limit_usd
- if v == nil {
- return
- }
- return *v, true
- }
- // OldDailyLimitUsd returns the old "daily_limit_usd" field's value of the UserPlatformQuota entity.
- // If the UserPlatformQuota object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *UserPlatformQuotaMutation) OldDailyLimitUsd(ctx context.Context) (v *float64, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldDailyLimitUsd is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldDailyLimitUsd requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldDailyLimitUsd: %w", err)
- }
- return oldValue.DailyLimitUsd, nil
- }
- // AddDailyLimitUsd adds f to the "daily_limit_usd" field.
- func (m *UserPlatformQuotaMutation) AddDailyLimitUsd(f float64) {
- if m.adddaily_limit_usd != nil {
- *m.adddaily_limit_usd += f
- } else {
- m.adddaily_limit_usd = &f
- }
- }
- // AddedDailyLimitUsd returns the value that was added to the "daily_limit_usd" field in this mutation.
- func (m *UserPlatformQuotaMutation) AddedDailyLimitUsd() (r float64, exists bool) {
- v := m.adddaily_limit_usd
- if v == nil {
- return
- }
- return *v, true
- }
- // ClearDailyLimitUsd clears the value of the "daily_limit_usd" field.
- func (m *UserPlatformQuotaMutation) ClearDailyLimitUsd() {
- m.daily_limit_usd = nil
- m.adddaily_limit_usd = nil
- m.clearedFields[userplatformquota.FieldDailyLimitUsd] = struct{}{}
- }
- // DailyLimitUsdCleared returns if the "daily_limit_usd" field was cleared in this mutation.
- func (m *UserPlatformQuotaMutation) DailyLimitUsdCleared() bool {
- _, ok := m.clearedFields[userplatformquota.FieldDailyLimitUsd]
- return ok
- }
- // ResetDailyLimitUsd resets all changes to the "daily_limit_usd" field.
- func (m *UserPlatformQuotaMutation) ResetDailyLimitUsd() {
- m.daily_limit_usd = nil
- m.adddaily_limit_usd = nil
- delete(m.clearedFields, userplatformquota.FieldDailyLimitUsd)
- }
- // SetWeeklyLimitUsd sets the "weekly_limit_usd" field.
- func (m *UserPlatformQuotaMutation) SetWeeklyLimitUsd(f float64) {
- m.weekly_limit_usd = &f
- m.addweekly_limit_usd = nil
- }
- // WeeklyLimitUsd returns the value of the "weekly_limit_usd" field in the mutation.
- func (m *UserPlatformQuotaMutation) WeeklyLimitUsd() (r float64, exists bool) {
- v := m.weekly_limit_usd
- if v == nil {
- return
- }
- return *v, true
- }
- // OldWeeklyLimitUsd returns the old "weekly_limit_usd" field's value of the UserPlatformQuota entity.
- // If the UserPlatformQuota object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *UserPlatformQuotaMutation) OldWeeklyLimitUsd(ctx context.Context) (v *float64, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldWeeklyLimitUsd is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldWeeklyLimitUsd requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldWeeklyLimitUsd: %w", err)
- }
- return oldValue.WeeklyLimitUsd, nil
- }
- // AddWeeklyLimitUsd adds f to the "weekly_limit_usd" field.
- func (m *UserPlatformQuotaMutation) AddWeeklyLimitUsd(f float64) {
- if m.addweekly_limit_usd != nil {
- *m.addweekly_limit_usd += f
- } else {
- m.addweekly_limit_usd = &f
- }
- }
- // AddedWeeklyLimitUsd returns the value that was added to the "weekly_limit_usd" field in this mutation.
- func (m *UserPlatformQuotaMutation) AddedWeeklyLimitUsd() (r float64, exists bool) {
- v := m.addweekly_limit_usd
- if v == nil {
- return
- }
- return *v, true
- }
- // ClearWeeklyLimitUsd clears the value of the "weekly_limit_usd" field.
- func (m *UserPlatformQuotaMutation) ClearWeeklyLimitUsd() {
- m.weekly_limit_usd = nil
- m.addweekly_limit_usd = nil
- m.clearedFields[userplatformquota.FieldWeeklyLimitUsd] = struct{}{}
- }
- // WeeklyLimitUsdCleared returns if the "weekly_limit_usd" field was cleared in this mutation.
- func (m *UserPlatformQuotaMutation) WeeklyLimitUsdCleared() bool {
- _, ok := m.clearedFields[userplatformquota.FieldWeeklyLimitUsd]
- return ok
- }
- // ResetWeeklyLimitUsd resets all changes to the "weekly_limit_usd" field.
- func (m *UserPlatformQuotaMutation) ResetWeeklyLimitUsd() {
- m.weekly_limit_usd = nil
- m.addweekly_limit_usd = nil
- delete(m.clearedFields, userplatformquota.FieldWeeklyLimitUsd)
- }
- // SetMonthlyLimitUsd sets the "monthly_limit_usd" field.
- func (m *UserPlatformQuotaMutation) SetMonthlyLimitUsd(f float64) {
- m.monthly_limit_usd = &f
- m.addmonthly_limit_usd = nil
- }
- // MonthlyLimitUsd returns the value of the "monthly_limit_usd" field in the mutation.
- func (m *UserPlatformQuotaMutation) MonthlyLimitUsd() (r float64, exists bool) {
- v := m.monthly_limit_usd
- if v == nil {
- return
- }
- return *v, true
- }
- // OldMonthlyLimitUsd returns the old "monthly_limit_usd" field's value of the UserPlatformQuota entity.
- // If the UserPlatformQuota object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *UserPlatformQuotaMutation) OldMonthlyLimitUsd(ctx context.Context) (v *float64, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldMonthlyLimitUsd is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldMonthlyLimitUsd requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldMonthlyLimitUsd: %w", err)
- }
- return oldValue.MonthlyLimitUsd, nil
- }
- // AddMonthlyLimitUsd adds f to the "monthly_limit_usd" field.
- func (m *UserPlatformQuotaMutation) AddMonthlyLimitUsd(f float64) {
- if m.addmonthly_limit_usd != nil {
- *m.addmonthly_limit_usd += f
- } else {
- m.addmonthly_limit_usd = &f
- }
- }
- // AddedMonthlyLimitUsd returns the value that was added to the "monthly_limit_usd" field in this mutation.
- func (m *UserPlatformQuotaMutation) AddedMonthlyLimitUsd() (r float64, exists bool) {
- v := m.addmonthly_limit_usd
- if v == nil {
- return
- }
- return *v, true
- }
- // ClearMonthlyLimitUsd clears the value of the "monthly_limit_usd" field.
- func (m *UserPlatformQuotaMutation) ClearMonthlyLimitUsd() {
- m.monthly_limit_usd = nil
- m.addmonthly_limit_usd = nil
- m.clearedFields[userplatformquota.FieldMonthlyLimitUsd] = struct{}{}
- }
- // MonthlyLimitUsdCleared returns if the "monthly_limit_usd" field was cleared in this mutation.
- func (m *UserPlatformQuotaMutation) MonthlyLimitUsdCleared() bool {
- _, ok := m.clearedFields[userplatformquota.FieldMonthlyLimitUsd]
- return ok
- }
- // ResetMonthlyLimitUsd resets all changes to the "monthly_limit_usd" field.
- func (m *UserPlatformQuotaMutation) ResetMonthlyLimitUsd() {
- m.monthly_limit_usd = nil
- m.addmonthly_limit_usd = nil
- delete(m.clearedFields, userplatformquota.FieldMonthlyLimitUsd)
- }
- // SetDailyUsageUsd sets the "daily_usage_usd" field.
- func (m *UserPlatformQuotaMutation) SetDailyUsageUsd(f float64) {
- m.daily_usage_usd = &f
- m.adddaily_usage_usd = nil
- }
- // DailyUsageUsd returns the value of the "daily_usage_usd" field in the mutation.
- func (m *UserPlatformQuotaMutation) DailyUsageUsd() (r float64, exists bool) {
- v := m.daily_usage_usd
- if v == nil {
- return
- }
- return *v, true
- }
- // OldDailyUsageUsd returns the old "daily_usage_usd" field's value of the UserPlatformQuota entity.
- // If the UserPlatformQuota object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *UserPlatformQuotaMutation) OldDailyUsageUsd(ctx context.Context) (v float64, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldDailyUsageUsd is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldDailyUsageUsd requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldDailyUsageUsd: %w", err)
- }
- return oldValue.DailyUsageUsd, nil
- }
- // AddDailyUsageUsd adds f to the "daily_usage_usd" field.
- func (m *UserPlatformQuotaMutation) AddDailyUsageUsd(f float64) {
- if m.adddaily_usage_usd != nil {
- *m.adddaily_usage_usd += f
- } else {
- m.adddaily_usage_usd = &f
- }
- }
- // AddedDailyUsageUsd returns the value that was added to the "daily_usage_usd" field in this mutation.
- func (m *UserPlatformQuotaMutation) AddedDailyUsageUsd() (r float64, exists bool) {
- v := m.adddaily_usage_usd
- if v == nil {
- return
- }
- return *v, true
- }
- // ResetDailyUsageUsd resets all changes to the "daily_usage_usd" field.
- func (m *UserPlatformQuotaMutation) ResetDailyUsageUsd() {
- m.daily_usage_usd = nil
- m.adddaily_usage_usd = nil
- }
- // SetWeeklyUsageUsd sets the "weekly_usage_usd" field.
- func (m *UserPlatformQuotaMutation) SetWeeklyUsageUsd(f float64) {
- m.weekly_usage_usd = &f
- m.addweekly_usage_usd = nil
- }
- // WeeklyUsageUsd returns the value of the "weekly_usage_usd" field in the mutation.
- func (m *UserPlatformQuotaMutation) WeeklyUsageUsd() (r float64, exists bool) {
- v := m.weekly_usage_usd
- if v == nil {
- return
- }
- return *v, true
- }
- // OldWeeklyUsageUsd returns the old "weekly_usage_usd" field's value of the UserPlatformQuota entity.
- // If the UserPlatformQuota object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *UserPlatformQuotaMutation) OldWeeklyUsageUsd(ctx context.Context) (v float64, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldWeeklyUsageUsd is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldWeeklyUsageUsd requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldWeeklyUsageUsd: %w", err)
- }
- return oldValue.WeeklyUsageUsd, nil
- }
- // AddWeeklyUsageUsd adds f to the "weekly_usage_usd" field.
- func (m *UserPlatformQuotaMutation) AddWeeklyUsageUsd(f float64) {
- if m.addweekly_usage_usd != nil {
- *m.addweekly_usage_usd += f
- } else {
- m.addweekly_usage_usd = &f
- }
- }
- // AddedWeeklyUsageUsd returns the value that was added to the "weekly_usage_usd" field in this mutation.
- func (m *UserPlatformQuotaMutation) AddedWeeklyUsageUsd() (r float64, exists bool) {
- v := m.addweekly_usage_usd
- if v == nil {
- return
- }
- return *v, true
- }
- // ResetWeeklyUsageUsd resets all changes to the "weekly_usage_usd" field.
- func (m *UserPlatformQuotaMutation) ResetWeeklyUsageUsd() {
- m.weekly_usage_usd = nil
- m.addweekly_usage_usd = nil
- }
- // SetMonthlyUsageUsd sets the "monthly_usage_usd" field.
- func (m *UserPlatformQuotaMutation) SetMonthlyUsageUsd(f float64) {
- m.monthly_usage_usd = &f
- m.addmonthly_usage_usd = nil
- }
- // MonthlyUsageUsd returns the value of the "monthly_usage_usd" field in the mutation.
- func (m *UserPlatformQuotaMutation) MonthlyUsageUsd() (r float64, exists bool) {
- v := m.monthly_usage_usd
- if v == nil {
- return
- }
- return *v, true
- }
- // OldMonthlyUsageUsd returns the old "monthly_usage_usd" field's value of the UserPlatformQuota entity.
- // If the UserPlatformQuota object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *UserPlatformQuotaMutation) OldMonthlyUsageUsd(ctx context.Context) (v float64, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldMonthlyUsageUsd is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldMonthlyUsageUsd requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldMonthlyUsageUsd: %w", err)
- }
- return oldValue.MonthlyUsageUsd, nil
- }
- // AddMonthlyUsageUsd adds f to the "monthly_usage_usd" field.
- func (m *UserPlatformQuotaMutation) AddMonthlyUsageUsd(f float64) {
- if m.addmonthly_usage_usd != nil {
- *m.addmonthly_usage_usd += f
- } else {
- m.addmonthly_usage_usd = &f
- }
- }
- // AddedMonthlyUsageUsd returns the value that was added to the "monthly_usage_usd" field in this mutation.
- func (m *UserPlatformQuotaMutation) AddedMonthlyUsageUsd() (r float64, exists bool) {
- v := m.addmonthly_usage_usd
- if v == nil {
- return
- }
- return *v, true
- }
- // ResetMonthlyUsageUsd resets all changes to the "monthly_usage_usd" field.
- func (m *UserPlatformQuotaMutation) ResetMonthlyUsageUsd() {
- m.monthly_usage_usd = nil
- m.addmonthly_usage_usd = nil
- }
- // SetDailyWindowStart sets the "daily_window_start" field.
- func (m *UserPlatformQuotaMutation) SetDailyWindowStart(t time.Time) {
- m.daily_window_start = &t
- }
- // DailyWindowStart returns the value of the "daily_window_start" field in the mutation.
- func (m *UserPlatformQuotaMutation) DailyWindowStart() (r time.Time, exists bool) {
- v := m.daily_window_start
- if v == nil {
- return
- }
- return *v, true
- }
- // OldDailyWindowStart returns the old "daily_window_start" field's value of the UserPlatformQuota entity.
- // If the UserPlatformQuota object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *UserPlatformQuotaMutation) OldDailyWindowStart(ctx context.Context) (v *time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldDailyWindowStart is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldDailyWindowStart requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldDailyWindowStart: %w", err)
- }
- return oldValue.DailyWindowStart, nil
- }
- // ClearDailyWindowStart clears the value of the "daily_window_start" field.
- func (m *UserPlatformQuotaMutation) ClearDailyWindowStart() {
- m.daily_window_start = nil
- m.clearedFields[userplatformquota.FieldDailyWindowStart] = struct{}{}
- }
- // DailyWindowStartCleared returns if the "daily_window_start" field was cleared in this mutation.
- func (m *UserPlatformQuotaMutation) DailyWindowStartCleared() bool {
- _, ok := m.clearedFields[userplatformquota.FieldDailyWindowStart]
- return ok
- }
- // ResetDailyWindowStart resets all changes to the "daily_window_start" field.
- func (m *UserPlatformQuotaMutation) ResetDailyWindowStart() {
- m.daily_window_start = nil
- delete(m.clearedFields, userplatformquota.FieldDailyWindowStart)
- }
- // SetWeeklyWindowStart sets the "weekly_window_start" field.
- func (m *UserPlatformQuotaMutation) SetWeeklyWindowStart(t time.Time) {
- m.weekly_window_start = &t
- }
- // WeeklyWindowStart returns the value of the "weekly_window_start" field in the mutation.
- func (m *UserPlatformQuotaMutation) WeeklyWindowStart() (r time.Time, exists bool) {
- v := m.weekly_window_start
- if v == nil {
- return
- }
- return *v, true
- }
- // OldWeeklyWindowStart returns the old "weekly_window_start" field's value of the UserPlatformQuota entity.
- // If the UserPlatformQuota object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *UserPlatformQuotaMutation) OldWeeklyWindowStart(ctx context.Context) (v *time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldWeeklyWindowStart is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldWeeklyWindowStart requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldWeeklyWindowStart: %w", err)
- }
- return oldValue.WeeklyWindowStart, nil
- }
- // ClearWeeklyWindowStart clears the value of the "weekly_window_start" field.
- func (m *UserPlatformQuotaMutation) ClearWeeklyWindowStart() {
- m.weekly_window_start = nil
- m.clearedFields[userplatformquota.FieldWeeklyWindowStart] = struct{}{}
- }
- // WeeklyWindowStartCleared returns if the "weekly_window_start" field was cleared in this mutation.
- func (m *UserPlatformQuotaMutation) WeeklyWindowStartCleared() bool {
- _, ok := m.clearedFields[userplatformquota.FieldWeeklyWindowStart]
- return ok
- }
- // ResetWeeklyWindowStart resets all changes to the "weekly_window_start" field.
- func (m *UserPlatformQuotaMutation) ResetWeeklyWindowStart() {
- m.weekly_window_start = nil
- delete(m.clearedFields, userplatformquota.FieldWeeklyWindowStart)
- }
- // SetMonthlyWindowStart sets the "monthly_window_start" field.
- func (m *UserPlatformQuotaMutation) SetMonthlyWindowStart(t time.Time) {
- m.monthly_window_start = &t
- }
- // MonthlyWindowStart returns the value of the "monthly_window_start" field in the mutation.
- func (m *UserPlatformQuotaMutation) MonthlyWindowStart() (r time.Time, exists bool) {
- v := m.monthly_window_start
- if v == nil {
- return
- }
- return *v, true
- }
- // OldMonthlyWindowStart returns the old "monthly_window_start" field's value of the UserPlatformQuota entity.
- // If the UserPlatformQuota object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *UserPlatformQuotaMutation) OldMonthlyWindowStart(ctx context.Context) (v *time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldMonthlyWindowStart is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldMonthlyWindowStart requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldMonthlyWindowStart: %w", err)
- }
- return oldValue.MonthlyWindowStart, nil
- }
- // ClearMonthlyWindowStart clears the value of the "monthly_window_start" field.
- func (m *UserPlatformQuotaMutation) ClearMonthlyWindowStart() {
- m.monthly_window_start = nil
- m.clearedFields[userplatformquota.FieldMonthlyWindowStart] = struct{}{}
- }
- // MonthlyWindowStartCleared returns if the "monthly_window_start" field was cleared in this mutation.
- func (m *UserPlatformQuotaMutation) MonthlyWindowStartCleared() bool {
- _, ok := m.clearedFields[userplatformquota.FieldMonthlyWindowStart]
- return ok
- }
- // ResetMonthlyWindowStart resets all changes to the "monthly_window_start" field.
- func (m *UserPlatformQuotaMutation) ResetMonthlyWindowStart() {
- m.monthly_window_start = nil
- delete(m.clearedFields, userplatformquota.FieldMonthlyWindowStart)
- }
- // ClearUser clears the "user" edge to the User entity.
- func (m *UserPlatformQuotaMutation) ClearUser() {
- m.cleareduser = true
- m.clearedFields[userplatformquota.FieldUserID] = struct{}{}
- }
- // UserCleared reports if the "user" edge to the User entity was cleared.
- func (m *UserPlatformQuotaMutation) UserCleared() bool {
- return m.cleareduser
- }
- // UserIDs returns the "user" edge IDs in the mutation.
- // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
- // UserID instead. It exists only for internal usage by the builders.
- func (m *UserPlatformQuotaMutation) UserIDs() (ids []int64) {
- if id := m.user; id != nil {
- ids = append(ids, *id)
- }
- return
- }
- // ResetUser resets all changes to the "user" edge.
- func (m *UserPlatformQuotaMutation) ResetUser() {
- m.user = nil
- m.cleareduser = false
- }
- // Where appends a list predicates to the UserPlatformQuotaMutation builder.
- func (m *UserPlatformQuotaMutation) Where(ps ...predicate.UserPlatformQuota) {
- m.predicates = append(m.predicates, ps...)
- }
- // WhereP appends storage-level predicates to the UserPlatformQuotaMutation builder. Using this method,
- // users can use type-assertion to append predicates that do not depend on any generated package.
- func (m *UserPlatformQuotaMutation) WhereP(ps ...func(*sql.Selector)) {
- p := make([]predicate.UserPlatformQuota, len(ps))
- for i := range ps {
- p[i] = ps[i]
- }
- m.Where(p...)
- }
- // Op returns the operation name.
- func (m *UserPlatformQuotaMutation) Op() Op {
- return m.op
- }
- // SetOp allows setting the mutation operation.
- func (m *UserPlatformQuotaMutation) SetOp(op Op) {
- m.op = op
- }
- // Type returns the node type of this mutation (UserPlatformQuota).
- func (m *UserPlatformQuotaMutation) Type() string {
- return m.typ
- }
- // Fields returns all fields that were changed during this mutation. Note that in
- // order to get all numeric fields that were incremented/decremented, call
- // AddedFields().
- func (m *UserPlatformQuotaMutation) Fields() []string {
- fields := make([]string, 0, 14)
- if m.created_at != nil {
- fields = append(fields, userplatformquota.FieldCreatedAt)
- }
- if m.updated_at != nil {
- fields = append(fields, userplatformquota.FieldUpdatedAt)
- }
- if m.deleted_at != nil {
- fields = append(fields, userplatformquota.FieldDeletedAt)
- }
- if m.user != nil {
- fields = append(fields, userplatformquota.FieldUserID)
- }
- if m.platform != nil {
- fields = append(fields, userplatformquota.FieldPlatform)
- }
- if m.daily_limit_usd != nil {
- fields = append(fields, userplatformquota.FieldDailyLimitUsd)
- }
- if m.weekly_limit_usd != nil {
- fields = append(fields, userplatformquota.FieldWeeklyLimitUsd)
- }
- if m.monthly_limit_usd != nil {
- fields = append(fields, userplatformquota.FieldMonthlyLimitUsd)
- }
- if m.daily_usage_usd != nil {
- fields = append(fields, userplatformquota.FieldDailyUsageUsd)
- }
- if m.weekly_usage_usd != nil {
- fields = append(fields, userplatformquota.FieldWeeklyUsageUsd)
- }
- if m.monthly_usage_usd != nil {
- fields = append(fields, userplatformquota.FieldMonthlyUsageUsd)
- }
- if m.daily_window_start != nil {
- fields = append(fields, userplatformquota.FieldDailyWindowStart)
- }
- if m.weekly_window_start != nil {
- fields = append(fields, userplatformquota.FieldWeeklyWindowStart)
- }
- if m.monthly_window_start != nil {
- fields = append(fields, userplatformquota.FieldMonthlyWindowStart)
- }
- return fields
- }
- // Field returns the value of a field with the given name. The second boolean
- // return value indicates that this field was not set, or was not defined in the
- // schema.
- func (m *UserPlatformQuotaMutation) Field(name string) (ent.Value, bool) {
- switch name {
- case userplatformquota.FieldCreatedAt:
- return m.CreatedAt()
- case userplatformquota.FieldUpdatedAt:
- return m.UpdatedAt()
- case userplatformquota.FieldDeletedAt:
- return m.DeletedAt()
- case userplatformquota.FieldUserID:
- return m.UserID()
- case userplatformquota.FieldPlatform:
- return m.Platform()
- case userplatformquota.FieldDailyLimitUsd:
- return m.DailyLimitUsd()
- case userplatformquota.FieldWeeklyLimitUsd:
- return m.WeeklyLimitUsd()
- case userplatformquota.FieldMonthlyLimitUsd:
- return m.MonthlyLimitUsd()
- case userplatformquota.FieldDailyUsageUsd:
- return m.DailyUsageUsd()
- case userplatformquota.FieldWeeklyUsageUsd:
- return m.WeeklyUsageUsd()
- case userplatformquota.FieldMonthlyUsageUsd:
- return m.MonthlyUsageUsd()
- case userplatformquota.FieldDailyWindowStart:
- return m.DailyWindowStart()
- case userplatformquota.FieldWeeklyWindowStart:
- return m.WeeklyWindowStart()
- case userplatformquota.FieldMonthlyWindowStart:
- return m.MonthlyWindowStart()
- }
- return nil, false
- }
- // OldField returns the old value of the field from the database. An error is
- // returned if the mutation operation is not UpdateOne, or the query to the
- // database failed.
- func (m *UserPlatformQuotaMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
- switch name {
- case userplatformquota.FieldCreatedAt:
- return m.OldCreatedAt(ctx)
- case userplatformquota.FieldUpdatedAt:
- return m.OldUpdatedAt(ctx)
- case userplatformquota.FieldDeletedAt:
- return m.OldDeletedAt(ctx)
- case userplatformquota.FieldUserID:
- return m.OldUserID(ctx)
- case userplatformquota.FieldPlatform:
- return m.OldPlatform(ctx)
- case userplatformquota.FieldDailyLimitUsd:
- return m.OldDailyLimitUsd(ctx)
- case userplatformquota.FieldWeeklyLimitUsd:
- return m.OldWeeklyLimitUsd(ctx)
- case userplatformquota.FieldMonthlyLimitUsd:
- return m.OldMonthlyLimitUsd(ctx)
- case userplatformquota.FieldDailyUsageUsd:
- return m.OldDailyUsageUsd(ctx)
- case userplatformquota.FieldWeeklyUsageUsd:
- return m.OldWeeklyUsageUsd(ctx)
- case userplatformquota.FieldMonthlyUsageUsd:
- return m.OldMonthlyUsageUsd(ctx)
- case userplatformquota.FieldDailyWindowStart:
- return m.OldDailyWindowStart(ctx)
- case userplatformquota.FieldWeeklyWindowStart:
- return m.OldWeeklyWindowStart(ctx)
- case userplatformquota.FieldMonthlyWindowStart:
- return m.OldMonthlyWindowStart(ctx)
- }
- return nil, fmt.Errorf("unknown UserPlatformQuota field %s", name)
- }
- // SetField sets the value of a field with the given name. It returns an error if
- // the field is not defined in the schema, or if the type mismatched the field
- // type.
- func (m *UserPlatformQuotaMutation) SetField(name string, value ent.Value) error {
- switch name {
- case userplatformquota.FieldCreatedAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetCreatedAt(v)
- return nil
- case userplatformquota.FieldUpdatedAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetUpdatedAt(v)
- return nil
- case userplatformquota.FieldDeletedAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetDeletedAt(v)
- return nil
- case userplatformquota.FieldUserID:
- v, ok := value.(int64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetUserID(v)
- return nil
- case userplatformquota.FieldPlatform:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetPlatform(v)
- return nil
- case userplatformquota.FieldDailyLimitUsd:
- v, ok := value.(float64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetDailyLimitUsd(v)
- return nil
- case userplatformquota.FieldWeeklyLimitUsd:
- v, ok := value.(float64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetWeeklyLimitUsd(v)
- return nil
- case userplatformquota.FieldMonthlyLimitUsd:
- v, ok := value.(float64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetMonthlyLimitUsd(v)
- return nil
- case userplatformquota.FieldDailyUsageUsd:
- v, ok := value.(float64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetDailyUsageUsd(v)
- return nil
- case userplatformquota.FieldWeeklyUsageUsd:
- v, ok := value.(float64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetWeeklyUsageUsd(v)
- return nil
- case userplatformquota.FieldMonthlyUsageUsd:
- v, ok := value.(float64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetMonthlyUsageUsd(v)
- return nil
- case userplatformquota.FieldDailyWindowStart:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetDailyWindowStart(v)
- return nil
- case userplatformquota.FieldWeeklyWindowStart:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetWeeklyWindowStart(v)
- return nil
- case userplatformquota.FieldMonthlyWindowStart:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetMonthlyWindowStart(v)
- return nil
- }
- return fmt.Errorf("unknown UserPlatformQuota field %s", name)
- }
- // AddedFields returns all numeric fields that were incremented/decremented during
- // this mutation.
- func (m *UserPlatformQuotaMutation) AddedFields() []string {
- var fields []string
- if m.adddaily_limit_usd != nil {
- fields = append(fields, userplatformquota.FieldDailyLimitUsd)
- }
- if m.addweekly_limit_usd != nil {
- fields = append(fields, userplatformquota.FieldWeeklyLimitUsd)
- }
- if m.addmonthly_limit_usd != nil {
- fields = append(fields, userplatformquota.FieldMonthlyLimitUsd)
- }
- if m.adddaily_usage_usd != nil {
- fields = append(fields, userplatformquota.FieldDailyUsageUsd)
- }
- if m.addweekly_usage_usd != nil {
- fields = append(fields, userplatformquota.FieldWeeklyUsageUsd)
- }
- if m.addmonthly_usage_usd != nil {
- fields = append(fields, userplatformquota.FieldMonthlyUsageUsd)
- }
- return fields
- }
- // AddedField returns the numeric value that was incremented/decremented on a field
- // with the given name. The second boolean return value indicates that this field
- // was not set, or was not defined in the schema.
- func (m *UserPlatformQuotaMutation) AddedField(name string) (ent.Value, bool) {
- switch name {
- case userplatformquota.FieldDailyLimitUsd:
- return m.AddedDailyLimitUsd()
- case userplatformquota.FieldWeeklyLimitUsd:
- return m.AddedWeeklyLimitUsd()
- case userplatformquota.FieldMonthlyLimitUsd:
- return m.AddedMonthlyLimitUsd()
- case userplatformquota.FieldDailyUsageUsd:
- return m.AddedDailyUsageUsd()
- case userplatformquota.FieldWeeklyUsageUsd:
- return m.AddedWeeklyUsageUsd()
- case userplatformquota.FieldMonthlyUsageUsd:
- return m.AddedMonthlyUsageUsd()
- }
- return nil, false
- }
- // AddField adds the value to the field with the given name. It returns an error if
- // the field is not defined in the schema, or if the type mismatched the field
- // type.
- func (m *UserPlatformQuotaMutation) AddField(name string, value ent.Value) error {
- switch name {
- case userplatformquota.FieldDailyLimitUsd:
- v, ok := value.(float64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.AddDailyLimitUsd(v)
- return nil
- case userplatformquota.FieldWeeklyLimitUsd:
- v, ok := value.(float64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.AddWeeklyLimitUsd(v)
- return nil
- case userplatformquota.FieldMonthlyLimitUsd:
- v, ok := value.(float64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.AddMonthlyLimitUsd(v)
- return nil
- case userplatformquota.FieldDailyUsageUsd:
- v, ok := value.(float64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.AddDailyUsageUsd(v)
- return nil
- case userplatformquota.FieldWeeklyUsageUsd:
- v, ok := value.(float64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.AddWeeklyUsageUsd(v)
- return nil
- case userplatformquota.FieldMonthlyUsageUsd:
- v, ok := value.(float64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.AddMonthlyUsageUsd(v)
- return nil
- }
- return fmt.Errorf("unknown UserPlatformQuota numeric field %s", name)
- }
- // ClearedFields returns all nullable fields that were cleared during this
- // mutation.
- func (m *UserPlatformQuotaMutation) ClearedFields() []string {
- var fields []string
- if m.FieldCleared(userplatformquota.FieldDeletedAt) {
- fields = append(fields, userplatformquota.FieldDeletedAt)
- }
- if m.FieldCleared(userplatformquota.FieldDailyLimitUsd) {
- fields = append(fields, userplatformquota.FieldDailyLimitUsd)
- }
- if m.FieldCleared(userplatformquota.FieldWeeklyLimitUsd) {
- fields = append(fields, userplatformquota.FieldWeeklyLimitUsd)
- }
- if m.FieldCleared(userplatformquota.FieldMonthlyLimitUsd) {
- fields = append(fields, userplatformquota.FieldMonthlyLimitUsd)
- }
- if m.FieldCleared(userplatformquota.FieldDailyWindowStart) {
- fields = append(fields, userplatformquota.FieldDailyWindowStart)
- }
- if m.FieldCleared(userplatformquota.FieldWeeklyWindowStart) {
- fields = append(fields, userplatformquota.FieldWeeklyWindowStart)
- }
- if m.FieldCleared(userplatformquota.FieldMonthlyWindowStart) {
- fields = append(fields, userplatformquota.FieldMonthlyWindowStart)
- }
- return fields
- }
- // FieldCleared returns a boolean indicating if a field with the given name was
- // cleared in this mutation.
- func (m *UserPlatformQuotaMutation) FieldCleared(name string) bool {
- _, ok := m.clearedFields[name]
- return ok
- }
- // ClearField clears the value of the field with the given name. It returns an
- // error if the field is not defined in the schema.
- func (m *UserPlatformQuotaMutation) ClearField(name string) error {
- switch name {
- case userplatformquota.FieldDeletedAt:
- m.ClearDeletedAt()
- return nil
- case userplatformquota.FieldDailyLimitUsd:
- m.ClearDailyLimitUsd()
- return nil
- case userplatformquota.FieldWeeklyLimitUsd:
- m.ClearWeeklyLimitUsd()
- return nil
- case userplatformquota.FieldMonthlyLimitUsd:
- m.ClearMonthlyLimitUsd()
- return nil
- case userplatformquota.FieldDailyWindowStart:
- m.ClearDailyWindowStart()
- return nil
- case userplatformquota.FieldWeeklyWindowStart:
- m.ClearWeeklyWindowStart()
- return nil
- case userplatformquota.FieldMonthlyWindowStart:
- m.ClearMonthlyWindowStart()
- return nil
- }
- return fmt.Errorf("unknown UserPlatformQuota nullable field %s", name)
- }
- // ResetField resets all changes in the mutation for the field with the given name.
- // It returns an error if the field is not defined in the schema.
- func (m *UserPlatformQuotaMutation) ResetField(name string) error {
- switch name {
- case userplatformquota.FieldCreatedAt:
- m.ResetCreatedAt()
- return nil
- case userplatformquota.FieldUpdatedAt:
- m.ResetUpdatedAt()
- return nil
- case userplatformquota.FieldDeletedAt:
- m.ResetDeletedAt()
- return nil
- case userplatformquota.FieldUserID:
- m.ResetUserID()
- return nil
- case userplatformquota.FieldPlatform:
- m.ResetPlatform()
- return nil
- case userplatformquota.FieldDailyLimitUsd:
- m.ResetDailyLimitUsd()
- return nil
- case userplatformquota.FieldWeeklyLimitUsd:
- m.ResetWeeklyLimitUsd()
- return nil
- case userplatformquota.FieldMonthlyLimitUsd:
- m.ResetMonthlyLimitUsd()
- return nil
- case userplatformquota.FieldDailyUsageUsd:
- m.ResetDailyUsageUsd()
- return nil
- case userplatformquota.FieldWeeklyUsageUsd:
- m.ResetWeeklyUsageUsd()
- return nil
- case userplatformquota.FieldMonthlyUsageUsd:
- m.ResetMonthlyUsageUsd()
- return nil
- case userplatformquota.FieldDailyWindowStart:
- m.ResetDailyWindowStart()
- return nil
- case userplatformquota.FieldWeeklyWindowStart:
- m.ResetWeeklyWindowStart()
- return nil
- case userplatformquota.FieldMonthlyWindowStart:
- m.ResetMonthlyWindowStart()
- return nil
- }
- return fmt.Errorf("unknown UserPlatformQuota field %s", name)
- }
- // AddedEdges returns all edge names that were set/added in this mutation.
- func (m *UserPlatformQuotaMutation) AddedEdges() []string {
- edges := make([]string, 0, 1)
- if m.user != nil {
- edges = append(edges, userplatformquota.EdgeUser)
- }
- return edges
- }
- // AddedIDs returns all IDs (to other nodes) that were added for the given edge
- // name in this mutation.
- func (m *UserPlatformQuotaMutation) AddedIDs(name string) []ent.Value {
- switch name {
- case userplatformquota.EdgeUser:
- if id := m.user; id != nil {
- return []ent.Value{*id}
- }
- }
- return nil
- }
- // RemovedEdges returns all edge names that were removed in this mutation.
- func (m *UserPlatformQuotaMutation) RemovedEdges() []string {
- edges := make([]string, 0, 1)
- return edges
- }
- // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
- // the given name in this mutation.
- func (m *UserPlatformQuotaMutation) RemovedIDs(name string) []ent.Value {
- return nil
- }
- // ClearedEdges returns all edge names that were cleared in this mutation.
- func (m *UserPlatformQuotaMutation) ClearedEdges() []string {
- edges := make([]string, 0, 1)
- if m.cleareduser {
- edges = append(edges, userplatformquota.EdgeUser)
- }
- return edges
- }
- // EdgeCleared returns a boolean which indicates if the edge with the given name
- // was cleared in this mutation.
- func (m *UserPlatformQuotaMutation) EdgeCleared(name string) bool {
- switch name {
- case userplatformquota.EdgeUser:
- return m.cleareduser
- }
- return false
- }
- // ClearEdge clears the value of the edge with the given name. It returns an error
- // if that edge is not defined in the schema.
- func (m *UserPlatformQuotaMutation) ClearEdge(name string) error {
- switch name {
- case userplatformquota.EdgeUser:
- m.ClearUser()
- return nil
- }
- return fmt.Errorf("unknown UserPlatformQuota unique edge %s", name)
- }
- // ResetEdge resets all changes to the edge with the given name in this mutation.
- // It returns an error if the edge is not defined in the schema.
- func (m *UserPlatformQuotaMutation) ResetEdge(name string) error {
- switch name {
- case userplatformquota.EdgeUser:
- m.ResetUser()
- return nil
- }
- return fmt.Errorf("unknown UserPlatformQuota edge %s", name)
- }
- // UserSubscriptionMutation represents an operation that mutates the UserSubscription nodes in the graph.
- type UserSubscriptionMutation struct {
- config
- op Op
- typ string
- id *int64
- created_at *time.Time
- updated_at *time.Time
- deleted_at *time.Time
- starts_at *time.Time
- expires_at *time.Time
- status *string
- daily_window_start *time.Time
- weekly_window_start *time.Time
- monthly_window_start *time.Time
- daily_usage_usd *float64
- adddaily_usage_usd *float64
- weekly_usage_usd *float64
- addweekly_usage_usd *float64
- monthly_usage_usd *float64
- addmonthly_usage_usd *float64
- assigned_at *time.Time
- notes *string
- clearedFields map[string]struct{}
- user *int64
- cleareduser bool
- group *int64
- clearedgroup bool
- assigned_by_user *int64
- clearedassigned_by_user bool
- usage_logs map[int64]struct{}
- removedusage_logs map[int64]struct{}
- clearedusage_logs bool
- done bool
- oldValue func(context.Context) (*UserSubscription, error)
- predicates []predicate.UserSubscription
- }
- var _ ent.Mutation = (*UserSubscriptionMutation)(nil)
- // usersubscriptionOption allows management of the mutation configuration using functional options.
- type usersubscriptionOption func(*UserSubscriptionMutation)
- // newUserSubscriptionMutation creates new mutation for the UserSubscription entity.
- func newUserSubscriptionMutation(c config, op Op, opts ...usersubscriptionOption) *UserSubscriptionMutation {
- m := &UserSubscriptionMutation{
- config: c,
- op: op,
- typ: TypeUserSubscription,
- clearedFields: make(map[string]struct{}),
- }
- for _, opt := range opts {
- opt(m)
- }
- return m
- }
- // withUserSubscriptionID sets the ID field of the mutation.
- func withUserSubscriptionID(id int64) usersubscriptionOption {
- return func(m *UserSubscriptionMutation) {
- var (
- err error
- once sync.Once
- value *UserSubscription
- )
- m.oldValue = func(ctx context.Context) (*UserSubscription, error) {
- once.Do(func() {
- if m.done {
- err = errors.New("querying old values post mutation is not allowed")
- } else {
- value, err = m.Client().UserSubscription.Get(ctx, id)
- }
- })
- return value, err
- }
- m.id = &id
- }
- }
- // withUserSubscription sets the old UserSubscription of the mutation.
- func withUserSubscription(node *UserSubscription) usersubscriptionOption {
- return func(m *UserSubscriptionMutation) {
- m.oldValue = func(context.Context) (*UserSubscription, error) {
- return node, nil
- }
- m.id = &node.ID
- }
- }
- // Client returns a new `ent.Client` from the mutation. If the mutation was
- // executed in a transaction (ent.Tx), a transactional client is returned.
- func (m UserSubscriptionMutation) Client() *Client {
- client := &Client{config: m.config}
- client.init()
- return client
- }
- // Tx returns an `ent.Tx` for mutations that were executed in transactions;
- // it returns an error otherwise.
- func (m UserSubscriptionMutation) Tx() (*Tx, error) {
- if _, ok := m.driver.(*txDriver); !ok {
- return nil, errors.New("ent: mutation is not running in a transaction")
- }
- tx := &Tx{config: m.config}
- tx.init()
- return tx, nil
- }
- // ID returns the ID value in the mutation. Note that the ID is only available
- // if it was provided to the builder or after it was returned from the database.
- func (m *UserSubscriptionMutation) ID() (id int64, exists bool) {
- if m.id == nil {
- return
- }
- return *m.id, true
- }
- // IDs queries the database and returns the entity ids that match the mutation's predicate.
- // That means, if the mutation is applied within a transaction with an isolation level such
- // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
- // or updated by the mutation.
- func (m *UserSubscriptionMutation) IDs(ctx context.Context) ([]int64, error) {
- switch {
- case m.op.Is(OpUpdateOne | OpDeleteOne):
- id, exists := m.ID()
- if exists {
- return []int64{id}, nil
- }
- fallthrough
- case m.op.Is(OpUpdate | OpDelete):
- return m.Client().UserSubscription.Query().Where(m.predicates...).IDs(ctx)
- default:
- return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
- }
- }
- // SetCreatedAt sets the "created_at" field.
- func (m *UserSubscriptionMutation) SetCreatedAt(t time.Time) {
- m.created_at = &t
- }
- // CreatedAt returns the value of the "created_at" field in the mutation.
- func (m *UserSubscriptionMutation) CreatedAt() (r time.Time, exists bool) {
- v := m.created_at
- if v == nil {
- return
- }
- return *v, true
- }
- // OldCreatedAt returns the old "created_at" field's value of the UserSubscription entity.
- // If the UserSubscription object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *UserSubscriptionMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldCreatedAt requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
- }
- return oldValue.CreatedAt, nil
- }
- // ResetCreatedAt resets all changes to the "created_at" field.
- func (m *UserSubscriptionMutation) ResetCreatedAt() {
- m.created_at = nil
- }
- // SetUpdatedAt sets the "updated_at" field.
- func (m *UserSubscriptionMutation) SetUpdatedAt(t time.Time) {
- m.updated_at = &t
- }
- // UpdatedAt returns the value of the "updated_at" field in the mutation.
- func (m *UserSubscriptionMutation) UpdatedAt() (r time.Time, exists bool) {
- v := m.updated_at
- if v == nil {
- return
- }
- return *v, true
- }
- // OldUpdatedAt returns the old "updated_at" field's value of the UserSubscription entity.
- // If the UserSubscription object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *UserSubscriptionMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
- }
- return oldValue.UpdatedAt, nil
- }
- // ResetUpdatedAt resets all changes to the "updated_at" field.
- func (m *UserSubscriptionMutation) ResetUpdatedAt() {
- m.updated_at = nil
- }
- // SetDeletedAt sets the "deleted_at" field.
- func (m *UserSubscriptionMutation) SetDeletedAt(t time.Time) {
- m.deleted_at = &t
- }
- // DeletedAt returns the value of the "deleted_at" field in the mutation.
- func (m *UserSubscriptionMutation) DeletedAt() (r time.Time, exists bool) {
- v := m.deleted_at
- if v == nil {
- return
- }
- return *v, true
- }
- // OldDeletedAt returns the old "deleted_at" field's value of the UserSubscription entity.
- // If the UserSubscription object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *UserSubscriptionMutation) OldDeletedAt(ctx context.Context) (v *time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldDeletedAt requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
- }
- return oldValue.DeletedAt, nil
- }
- // ClearDeletedAt clears the value of the "deleted_at" field.
- func (m *UserSubscriptionMutation) ClearDeletedAt() {
- m.deleted_at = nil
- m.clearedFields[usersubscription.FieldDeletedAt] = struct{}{}
- }
- // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
- func (m *UserSubscriptionMutation) DeletedAtCleared() bool {
- _, ok := m.clearedFields[usersubscription.FieldDeletedAt]
- return ok
- }
- // ResetDeletedAt resets all changes to the "deleted_at" field.
- func (m *UserSubscriptionMutation) ResetDeletedAt() {
- m.deleted_at = nil
- delete(m.clearedFields, usersubscription.FieldDeletedAt)
- }
- // SetUserID sets the "user_id" field.
- func (m *UserSubscriptionMutation) SetUserID(i int64) {
- m.user = &i
- }
- // UserID returns the value of the "user_id" field in the mutation.
- func (m *UserSubscriptionMutation) UserID() (r int64, exists bool) {
- v := m.user
- if v == nil {
- return
- }
- return *v, true
- }
- // OldUserID returns the old "user_id" field's value of the UserSubscription entity.
- // If the UserSubscription object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *UserSubscriptionMutation) OldUserID(ctx context.Context) (v int64, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldUserID is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldUserID requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldUserID: %w", err)
- }
- return oldValue.UserID, nil
- }
- // ResetUserID resets all changes to the "user_id" field.
- func (m *UserSubscriptionMutation) ResetUserID() {
- m.user = nil
- }
- // SetGroupID sets the "group_id" field.
- func (m *UserSubscriptionMutation) SetGroupID(i int64) {
- m.group = &i
- }
- // GroupID returns the value of the "group_id" field in the mutation.
- func (m *UserSubscriptionMutation) GroupID() (r int64, exists bool) {
- v := m.group
- if v == nil {
- return
- }
- return *v, true
- }
- // OldGroupID returns the old "group_id" field's value of the UserSubscription entity.
- // If the UserSubscription object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *UserSubscriptionMutation) OldGroupID(ctx context.Context) (v int64, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldGroupID is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldGroupID requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldGroupID: %w", err)
- }
- return oldValue.GroupID, nil
- }
- // ResetGroupID resets all changes to the "group_id" field.
- func (m *UserSubscriptionMutation) ResetGroupID() {
- m.group = nil
- }
- // SetStartsAt sets the "starts_at" field.
- func (m *UserSubscriptionMutation) SetStartsAt(t time.Time) {
- m.starts_at = &t
- }
- // StartsAt returns the value of the "starts_at" field in the mutation.
- func (m *UserSubscriptionMutation) StartsAt() (r time.Time, exists bool) {
- v := m.starts_at
- if v == nil {
- return
- }
- return *v, true
- }
- // OldStartsAt returns the old "starts_at" field's value of the UserSubscription entity.
- // If the UserSubscription object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *UserSubscriptionMutation) OldStartsAt(ctx context.Context) (v time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldStartsAt is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldStartsAt requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldStartsAt: %w", err)
- }
- return oldValue.StartsAt, nil
- }
- // ResetStartsAt resets all changes to the "starts_at" field.
- func (m *UserSubscriptionMutation) ResetStartsAt() {
- m.starts_at = nil
- }
- // SetExpiresAt sets the "expires_at" field.
- func (m *UserSubscriptionMutation) SetExpiresAt(t time.Time) {
- m.expires_at = &t
- }
- // ExpiresAt returns the value of the "expires_at" field in the mutation.
- func (m *UserSubscriptionMutation) ExpiresAt() (r time.Time, exists bool) {
- v := m.expires_at
- if v == nil {
- return
- }
- return *v, true
- }
- // OldExpiresAt returns the old "expires_at" field's value of the UserSubscription entity.
- // If the UserSubscription object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *UserSubscriptionMutation) OldExpiresAt(ctx context.Context) (v time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldExpiresAt is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldExpiresAt requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldExpiresAt: %w", err)
- }
- return oldValue.ExpiresAt, nil
- }
- // ResetExpiresAt resets all changes to the "expires_at" field.
- func (m *UserSubscriptionMutation) ResetExpiresAt() {
- m.expires_at = nil
- }
- // SetStatus sets the "status" field.
- func (m *UserSubscriptionMutation) SetStatus(s string) {
- m.status = &s
- }
- // Status returns the value of the "status" field in the mutation.
- func (m *UserSubscriptionMutation) Status() (r string, exists bool) {
- v := m.status
- if v == nil {
- return
- }
- return *v, true
- }
- // OldStatus returns the old "status" field's value of the UserSubscription entity.
- // If the UserSubscription object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *UserSubscriptionMutation) OldStatus(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldStatus is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldStatus requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldStatus: %w", err)
- }
- return oldValue.Status, nil
- }
- // ResetStatus resets all changes to the "status" field.
- func (m *UserSubscriptionMutation) ResetStatus() {
- m.status = nil
- }
- // SetDailyWindowStart sets the "daily_window_start" field.
- func (m *UserSubscriptionMutation) SetDailyWindowStart(t time.Time) {
- m.daily_window_start = &t
- }
- // DailyWindowStart returns the value of the "daily_window_start" field in the mutation.
- func (m *UserSubscriptionMutation) DailyWindowStart() (r time.Time, exists bool) {
- v := m.daily_window_start
- if v == nil {
- return
- }
- return *v, true
- }
- // OldDailyWindowStart returns the old "daily_window_start" field's value of the UserSubscription entity.
- // If the UserSubscription object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *UserSubscriptionMutation) OldDailyWindowStart(ctx context.Context) (v *time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldDailyWindowStart is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldDailyWindowStart requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldDailyWindowStart: %w", err)
- }
- return oldValue.DailyWindowStart, nil
- }
- // ClearDailyWindowStart clears the value of the "daily_window_start" field.
- func (m *UserSubscriptionMutation) ClearDailyWindowStart() {
- m.daily_window_start = nil
- m.clearedFields[usersubscription.FieldDailyWindowStart] = struct{}{}
- }
- // DailyWindowStartCleared returns if the "daily_window_start" field was cleared in this mutation.
- func (m *UserSubscriptionMutation) DailyWindowStartCleared() bool {
- _, ok := m.clearedFields[usersubscription.FieldDailyWindowStart]
- return ok
- }
- // ResetDailyWindowStart resets all changes to the "daily_window_start" field.
- func (m *UserSubscriptionMutation) ResetDailyWindowStart() {
- m.daily_window_start = nil
- delete(m.clearedFields, usersubscription.FieldDailyWindowStart)
- }
- // SetWeeklyWindowStart sets the "weekly_window_start" field.
- func (m *UserSubscriptionMutation) SetWeeklyWindowStart(t time.Time) {
- m.weekly_window_start = &t
- }
- // WeeklyWindowStart returns the value of the "weekly_window_start" field in the mutation.
- func (m *UserSubscriptionMutation) WeeklyWindowStart() (r time.Time, exists bool) {
- v := m.weekly_window_start
- if v == nil {
- return
- }
- return *v, true
- }
- // OldWeeklyWindowStart returns the old "weekly_window_start" field's value of the UserSubscription entity.
- // If the UserSubscription object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *UserSubscriptionMutation) OldWeeklyWindowStart(ctx context.Context) (v *time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldWeeklyWindowStart is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldWeeklyWindowStart requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldWeeklyWindowStart: %w", err)
- }
- return oldValue.WeeklyWindowStart, nil
- }
- // ClearWeeklyWindowStart clears the value of the "weekly_window_start" field.
- func (m *UserSubscriptionMutation) ClearWeeklyWindowStart() {
- m.weekly_window_start = nil
- m.clearedFields[usersubscription.FieldWeeklyWindowStart] = struct{}{}
- }
- // WeeklyWindowStartCleared returns if the "weekly_window_start" field was cleared in this mutation.
- func (m *UserSubscriptionMutation) WeeklyWindowStartCleared() bool {
- _, ok := m.clearedFields[usersubscription.FieldWeeklyWindowStart]
- return ok
- }
- // ResetWeeklyWindowStart resets all changes to the "weekly_window_start" field.
- func (m *UserSubscriptionMutation) ResetWeeklyWindowStart() {
- m.weekly_window_start = nil
- delete(m.clearedFields, usersubscription.FieldWeeklyWindowStart)
- }
- // SetMonthlyWindowStart sets the "monthly_window_start" field.
- func (m *UserSubscriptionMutation) SetMonthlyWindowStart(t time.Time) {
- m.monthly_window_start = &t
- }
- // MonthlyWindowStart returns the value of the "monthly_window_start" field in the mutation.
- func (m *UserSubscriptionMutation) MonthlyWindowStart() (r time.Time, exists bool) {
- v := m.monthly_window_start
- if v == nil {
- return
- }
- return *v, true
- }
- // OldMonthlyWindowStart returns the old "monthly_window_start" field's value of the UserSubscription entity.
- // If the UserSubscription object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *UserSubscriptionMutation) OldMonthlyWindowStart(ctx context.Context) (v *time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldMonthlyWindowStart is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldMonthlyWindowStart requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldMonthlyWindowStart: %w", err)
- }
- return oldValue.MonthlyWindowStart, nil
- }
- // ClearMonthlyWindowStart clears the value of the "monthly_window_start" field.
- func (m *UserSubscriptionMutation) ClearMonthlyWindowStart() {
- m.monthly_window_start = nil
- m.clearedFields[usersubscription.FieldMonthlyWindowStart] = struct{}{}
- }
- // MonthlyWindowStartCleared returns if the "monthly_window_start" field was cleared in this mutation.
- func (m *UserSubscriptionMutation) MonthlyWindowStartCleared() bool {
- _, ok := m.clearedFields[usersubscription.FieldMonthlyWindowStart]
- return ok
- }
- // ResetMonthlyWindowStart resets all changes to the "monthly_window_start" field.
- func (m *UserSubscriptionMutation) ResetMonthlyWindowStart() {
- m.monthly_window_start = nil
- delete(m.clearedFields, usersubscription.FieldMonthlyWindowStart)
- }
- // SetDailyUsageUsd sets the "daily_usage_usd" field.
- func (m *UserSubscriptionMutation) SetDailyUsageUsd(f float64) {
- m.daily_usage_usd = &f
- m.adddaily_usage_usd = nil
- }
- // DailyUsageUsd returns the value of the "daily_usage_usd" field in the mutation.
- func (m *UserSubscriptionMutation) DailyUsageUsd() (r float64, exists bool) {
- v := m.daily_usage_usd
- if v == nil {
- return
- }
- return *v, true
- }
- // OldDailyUsageUsd returns the old "daily_usage_usd" field's value of the UserSubscription entity.
- // If the UserSubscription object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *UserSubscriptionMutation) OldDailyUsageUsd(ctx context.Context) (v float64, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldDailyUsageUsd is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldDailyUsageUsd requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldDailyUsageUsd: %w", err)
- }
- return oldValue.DailyUsageUsd, nil
- }
- // AddDailyUsageUsd adds f to the "daily_usage_usd" field.
- func (m *UserSubscriptionMutation) AddDailyUsageUsd(f float64) {
- if m.adddaily_usage_usd != nil {
- *m.adddaily_usage_usd += f
- } else {
- m.adddaily_usage_usd = &f
- }
- }
- // AddedDailyUsageUsd returns the value that was added to the "daily_usage_usd" field in this mutation.
- func (m *UserSubscriptionMutation) AddedDailyUsageUsd() (r float64, exists bool) {
- v := m.adddaily_usage_usd
- if v == nil {
- return
- }
- return *v, true
- }
- // ResetDailyUsageUsd resets all changes to the "daily_usage_usd" field.
- func (m *UserSubscriptionMutation) ResetDailyUsageUsd() {
- m.daily_usage_usd = nil
- m.adddaily_usage_usd = nil
- }
- // SetWeeklyUsageUsd sets the "weekly_usage_usd" field.
- func (m *UserSubscriptionMutation) SetWeeklyUsageUsd(f float64) {
- m.weekly_usage_usd = &f
- m.addweekly_usage_usd = nil
- }
- // WeeklyUsageUsd returns the value of the "weekly_usage_usd" field in the mutation.
- func (m *UserSubscriptionMutation) WeeklyUsageUsd() (r float64, exists bool) {
- v := m.weekly_usage_usd
- if v == nil {
- return
- }
- return *v, true
- }
- // OldWeeklyUsageUsd returns the old "weekly_usage_usd" field's value of the UserSubscription entity.
- // If the UserSubscription object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *UserSubscriptionMutation) OldWeeklyUsageUsd(ctx context.Context) (v float64, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldWeeklyUsageUsd is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldWeeklyUsageUsd requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldWeeklyUsageUsd: %w", err)
- }
- return oldValue.WeeklyUsageUsd, nil
- }
- // AddWeeklyUsageUsd adds f to the "weekly_usage_usd" field.
- func (m *UserSubscriptionMutation) AddWeeklyUsageUsd(f float64) {
- if m.addweekly_usage_usd != nil {
- *m.addweekly_usage_usd += f
- } else {
- m.addweekly_usage_usd = &f
- }
- }
- // AddedWeeklyUsageUsd returns the value that was added to the "weekly_usage_usd" field in this mutation.
- func (m *UserSubscriptionMutation) AddedWeeklyUsageUsd() (r float64, exists bool) {
- v := m.addweekly_usage_usd
- if v == nil {
- return
- }
- return *v, true
- }
- // ResetWeeklyUsageUsd resets all changes to the "weekly_usage_usd" field.
- func (m *UserSubscriptionMutation) ResetWeeklyUsageUsd() {
- m.weekly_usage_usd = nil
- m.addweekly_usage_usd = nil
- }
- // SetMonthlyUsageUsd sets the "monthly_usage_usd" field.
- func (m *UserSubscriptionMutation) SetMonthlyUsageUsd(f float64) {
- m.monthly_usage_usd = &f
- m.addmonthly_usage_usd = nil
- }
- // MonthlyUsageUsd returns the value of the "monthly_usage_usd" field in the mutation.
- func (m *UserSubscriptionMutation) MonthlyUsageUsd() (r float64, exists bool) {
- v := m.monthly_usage_usd
- if v == nil {
- return
- }
- return *v, true
- }
- // OldMonthlyUsageUsd returns the old "monthly_usage_usd" field's value of the UserSubscription entity.
- // If the UserSubscription object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *UserSubscriptionMutation) OldMonthlyUsageUsd(ctx context.Context) (v float64, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldMonthlyUsageUsd is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldMonthlyUsageUsd requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldMonthlyUsageUsd: %w", err)
- }
- return oldValue.MonthlyUsageUsd, nil
- }
- // AddMonthlyUsageUsd adds f to the "monthly_usage_usd" field.
- func (m *UserSubscriptionMutation) AddMonthlyUsageUsd(f float64) {
- if m.addmonthly_usage_usd != nil {
- *m.addmonthly_usage_usd += f
- } else {
- m.addmonthly_usage_usd = &f
- }
- }
- // AddedMonthlyUsageUsd returns the value that was added to the "monthly_usage_usd" field in this mutation.
- func (m *UserSubscriptionMutation) AddedMonthlyUsageUsd() (r float64, exists bool) {
- v := m.addmonthly_usage_usd
- if v == nil {
- return
- }
- return *v, true
- }
- // ResetMonthlyUsageUsd resets all changes to the "monthly_usage_usd" field.
- func (m *UserSubscriptionMutation) ResetMonthlyUsageUsd() {
- m.monthly_usage_usd = nil
- m.addmonthly_usage_usd = nil
- }
- // SetAssignedBy sets the "assigned_by" field.
- func (m *UserSubscriptionMutation) SetAssignedBy(i int64) {
- m.assigned_by_user = &i
- }
- // AssignedBy returns the value of the "assigned_by" field in the mutation.
- func (m *UserSubscriptionMutation) AssignedBy() (r int64, exists bool) {
- v := m.assigned_by_user
- if v == nil {
- return
- }
- return *v, true
- }
- // OldAssignedBy returns the old "assigned_by" field's value of the UserSubscription entity.
- // If the UserSubscription object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *UserSubscriptionMutation) OldAssignedBy(ctx context.Context) (v *int64, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldAssignedBy is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldAssignedBy requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldAssignedBy: %w", err)
- }
- return oldValue.AssignedBy, nil
- }
- // ClearAssignedBy clears the value of the "assigned_by" field.
- func (m *UserSubscriptionMutation) ClearAssignedBy() {
- m.assigned_by_user = nil
- m.clearedFields[usersubscription.FieldAssignedBy] = struct{}{}
- }
- // AssignedByCleared returns if the "assigned_by" field was cleared in this mutation.
- func (m *UserSubscriptionMutation) AssignedByCleared() bool {
- _, ok := m.clearedFields[usersubscription.FieldAssignedBy]
- return ok
- }
- // ResetAssignedBy resets all changes to the "assigned_by" field.
- func (m *UserSubscriptionMutation) ResetAssignedBy() {
- m.assigned_by_user = nil
- delete(m.clearedFields, usersubscription.FieldAssignedBy)
- }
- // SetAssignedAt sets the "assigned_at" field.
- func (m *UserSubscriptionMutation) SetAssignedAt(t time.Time) {
- m.assigned_at = &t
- }
- // AssignedAt returns the value of the "assigned_at" field in the mutation.
- func (m *UserSubscriptionMutation) AssignedAt() (r time.Time, exists bool) {
- v := m.assigned_at
- if v == nil {
- return
- }
- return *v, true
- }
- // OldAssignedAt returns the old "assigned_at" field's value of the UserSubscription entity.
- // If the UserSubscription object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *UserSubscriptionMutation) OldAssignedAt(ctx context.Context) (v time.Time, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldAssignedAt is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldAssignedAt requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldAssignedAt: %w", err)
- }
- return oldValue.AssignedAt, nil
- }
- // ResetAssignedAt resets all changes to the "assigned_at" field.
- func (m *UserSubscriptionMutation) ResetAssignedAt() {
- m.assigned_at = nil
- }
- // SetNotes sets the "notes" field.
- func (m *UserSubscriptionMutation) SetNotes(s string) {
- m.notes = &s
- }
- // Notes returns the value of the "notes" field in the mutation.
- func (m *UserSubscriptionMutation) Notes() (r string, exists bool) {
- v := m.notes
- if v == nil {
- return
- }
- return *v, true
- }
- // OldNotes returns the old "notes" field's value of the UserSubscription entity.
- // If the UserSubscription object wasn't provided to the builder, the object is fetched from the database.
- // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
- func (m *UserSubscriptionMutation) OldNotes(ctx context.Context) (v *string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldNotes is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldNotes requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldNotes: %w", err)
- }
- return oldValue.Notes, nil
- }
- // ClearNotes clears the value of the "notes" field.
- func (m *UserSubscriptionMutation) ClearNotes() {
- m.notes = nil
- m.clearedFields[usersubscription.FieldNotes] = struct{}{}
- }
- // NotesCleared returns if the "notes" field was cleared in this mutation.
- func (m *UserSubscriptionMutation) NotesCleared() bool {
- _, ok := m.clearedFields[usersubscription.FieldNotes]
- return ok
- }
- // ResetNotes resets all changes to the "notes" field.
- func (m *UserSubscriptionMutation) ResetNotes() {
- m.notes = nil
- delete(m.clearedFields, usersubscription.FieldNotes)
- }
- // ClearUser clears the "user" edge to the User entity.
- func (m *UserSubscriptionMutation) ClearUser() {
- m.cleareduser = true
- m.clearedFields[usersubscription.FieldUserID] = struct{}{}
- }
- // UserCleared reports if the "user" edge to the User entity was cleared.
- func (m *UserSubscriptionMutation) UserCleared() bool {
- return m.cleareduser
- }
- // UserIDs returns the "user" edge IDs in the mutation.
- // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
- // UserID instead. It exists only for internal usage by the builders.
- func (m *UserSubscriptionMutation) UserIDs() (ids []int64) {
- if id := m.user; id != nil {
- ids = append(ids, *id)
- }
- return
- }
- // ResetUser resets all changes to the "user" edge.
- func (m *UserSubscriptionMutation) ResetUser() {
- m.user = nil
- m.cleareduser = false
- }
- // ClearGroup clears the "group" edge to the Group entity.
- func (m *UserSubscriptionMutation) ClearGroup() {
- m.clearedgroup = true
- m.clearedFields[usersubscription.FieldGroupID] = struct{}{}
- }
- // GroupCleared reports if the "group" edge to the Group entity was cleared.
- func (m *UserSubscriptionMutation) GroupCleared() bool {
- return m.clearedgroup
- }
- // GroupIDs returns the "group" edge IDs in the mutation.
- // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
- // GroupID instead. It exists only for internal usage by the builders.
- func (m *UserSubscriptionMutation) GroupIDs() (ids []int64) {
- if id := m.group; id != nil {
- ids = append(ids, *id)
- }
- return
- }
- // ResetGroup resets all changes to the "group" edge.
- func (m *UserSubscriptionMutation) ResetGroup() {
- m.group = nil
- m.clearedgroup = false
- }
- // SetAssignedByUserID sets the "assigned_by_user" edge to the User entity by id.
- func (m *UserSubscriptionMutation) SetAssignedByUserID(id int64) {
- m.assigned_by_user = &id
- }
- // ClearAssignedByUser clears the "assigned_by_user" edge to the User entity.
- func (m *UserSubscriptionMutation) ClearAssignedByUser() {
- m.clearedassigned_by_user = true
- m.clearedFields[usersubscription.FieldAssignedBy] = struct{}{}
- }
- // AssignedByUserCleared reports if the "assigned_by_user" edge to the User entity was cleared.
- func (m *UserSubscriptionMutation) AssignedByUserCleared() bool {
- return m.AssignedByCleared() || m.clearedassigned_by_user
- }
- // AssignedByUserID returns the "assigned_by_user" edge ID in the mutation.
- func (m *UserSubscriptionMutation) AssignedByUserID() (id int64, exists bool) {
- if m.assigned_by_user != nil {
- return *m.assigned_by_user, true
- }
- return
- }
- // AssignedByUserIDs returns the "assigned_by_user" edge IDs in the mutation.
- // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
- // AssignedByUserID instead. It exists only for internal usage by the builders.
- func (m *UserSubscriptionMutation) AssignedByUserIDs() (ids []int64) {
- if id := m.assigned_by_user; id != nil {
- ids = append(ids, *id)
- }
- return
- }
- // ResetAssignedByUser resets all changes to the "assigned_by_user" edge.
- func (m *UserSubscriptionMutation) ResetAssignedByUser() {
- m.assigned_by_user = nil
- m.clearedassigned_by_user = false
- }
- // AddUsageLogIDs adds the "usage_logs" edge to the UsageLog entity by ids.
- func (m *UserSubscriptionMutation) AddUsageLogIDs(ids ...int64) {
- if m.usage_logs == nil {
- m.usage_logs = make(map[int64]struct{})
- }
- for i := range ids {
- m.usage_logs[ids[i]] = struct{}{}
- }
- }
- // ClearUsageLogs clears the "usage_logs" edge to the UsageLog entity.
- func (m *UserSubscriptionMutation) ClearUsageLogs() {
- m.clearedusage_logs = true
- }
- // UsageLogsCleared reports if the "usage_logs" edge to the UsageLog entity was cleared.
- func (m *UserSubscriptionMutation) UsageLogsCleared() bool {
- return m.clearedusage_logs
- }
- // RemoveUsageLogIDs removes the "usage_logs" edge to the UsageLog entity by IDs.
- func (m *UserSubscriptionMutation) RemoveUsageLogIDs(ids ...int64) {
- if m.removedusage_logs == nil {
- m.removedusage_logs = make(map[int64]struct{})
- }
- for i := range ids {
- delete(m.usage_logs, ids[i])
- m.removedusage_logs[ids[i]] = struct{}{}
- }
- }
- // RemovedUsageLogs returns the removed IDs of the "usage_logs" edge to the UsageLog entity.
- func (m *UserSubscriptionMutation) RemovedUsageLogsIDs() (ids []int64) {
- for id := range m.removedusage_logs {
- ids = append(ids, id)
- }
- return
- }
- // UsageLogsIDs returns the "usage_logs" edge IDs in the mutation.
- func (m *UserSubscriptionMutation) UsageLogsIDs() (ids []int64) {
- for id := range m.usage_logs {
- ids = append(ids, id)
- }
- return
- }
- // ResetUsageLogs resets all changes to the "usage_logs" edge.
- func (m *UserSubscriptionMutation) ResetUsageLogs() {
- m.usage_logs = nil
- m.clearedusage_logs = false
- m.removedusage_logs = nil
- }
- // Where appends a list predicates to the UserSubscriptionMutation builder.
- func (m *UserSubscriptionMutation) Where(ps ...predicate.UserSubscription) {
- m.predicates = append(m.predicates, ps...)
- }
- // WhereP appends storage-level predicates to the UserSubscriptionMutation builder. Using this method,
- // users can use type-assertion to append predicates that do not depend on any generated package.
- func (m *UserSubscriptionMutation) WhereP(ps ...func(*sql.Selector)) {
- p := make([]predicate.UserSubscription, len(ps))
- for i := range ps {
- p[i] = ps[i]
- }
- m.Where(p...)
- }
- // Op returns the operation name.
- func (m *UserSubscriptionMutation) Op() Op {
- return m.op
- }
- // SetOp allows setting the mutation operation.
- func (m *UserSubscriptionMutation) SetOp(op Op) {
- m.op = op
- }
- // Type returns the node type of this mutation (UserSubscription).
- func (m *UserSubscriptionMutation) Type() string {
- return m.typ
- }
- // Fields returns all fields that were changed during this mutation. Note that in
- // order to get all numeric fields that were incremented/decremented, call
- // AddedFields().
- func (m *UserSubscriptionMutation) Fields() []string {
- fields := make([]string, 0, 17)
- if m.created_at != nil {
- fields = append(fields, usersubscription.FieldCreatedAt)
- }
- if m.updated_at != nil {
- fields = append(fields, usersubscription.FieldUpdatedAt)
- }
- if m.deleted_at != nil {
- fields = append(fields, usersubscription.FieldDeletedAt)
- }
- if m.user != nil {
- fields = append(fields, usersubscription.FieldUserID)
- }
- if m.group != nil {
- fields = append(fields, usersubscription.FieldGroupID)
- }
- if m.starts_at != nil {
- fields = append(fields, usersubscription.FieldStartsAt)
- }
- if m.expires_at != nil {
- fields = append(fields, usersubscription.FieldExpiresAt)
- }
- if m.status != nil {
- fields = append(fields, usersubscription.FieldStatus)
- }
- if m.daily_window_start != nil {
- fields = append(fields, usersubscription.FieldDailyWindowStart)
- }
- if m.weekly_window_start != nil {
- fields = append(fields, usersubscription.FieldWeeklyWindowStart)
- }
- if m.monthly_window_start != nil {
- fields = append(fields, usersubscription.FieldMonthlyWindowStart)
- }
- if m.daily_usage_usd != nil {
- fields = append(fields, usersubscription.FieldDailyUsageUsd)
- }
- if m.weekly_usage_usd != nil {
- fields = append(fields, usersubscription.FieldWeeklyUsageUsd)
- }
- if m.monthly_usage_usd != nil {
- fields = append(fields, usersubscription.FieldMonthlyUsageUsd)
- }
- if m.assigned_by_user != nil {
- fields = append(fields, usersubscription.FieldAssignedBy)
- }
- if m.assigned_at != nil {
- fields = append(fields, usersubscription.FieldAssignedAt)
- }
- if m.notes != nil {
- fields = append(fields, usersubscription.FieldNotes)
- }
- return fields
- }
- // Field returns the value of a field with the given name. The second boolean
- // return value indicates that this field was not set, or was not defined in the
- // schema.
- func (m *UserSubscriptionMutation) Field(name string) (ent.Value, bool) {
- switch name {
- case usersubscription.FieldCreatedAt:
- return m.CreatedAt()
- case usersubscription.FieldUpdatedAt:
- return m.UpdatedAt()
- case usersubscription.FieldDeletedAt:
- return m.DeletedAt()
- case usersubscription.FieldUserID:
- return m.UserID()
- case usersubscription.FieldGroupID:
- return m.GroupID()
- case usersubscription.FieldStartsAt:
- return m.StartsAt()
- case usersubscription.FieldExpiresAt:
- return m.ExpiresAt()
- case usersubscription.FieldStatus:
- return m.Status()
- case usersubscription.FieldDailyWindowStart:
- return m.DailyWindowStart()
- case usersubscription.FieldWeeklyWindowStart:
- return m.WeeklyWindowStart()
- case usersubscription.FieldMonthlyWindowStart:
- return m.MonthlyWindowStart()
- case usersubscription.FieldDailyUsageUsd:
- return m.DailyUsageUsd()
- case usersubscription.FieldWeeklyUsageUsd:
- return m.WeeklyUsageUsd()
- case usersubscription.FieldMonthlyUsageUsd:
- return m.MonthlyUsageUsd()
- case usersubscription.FieldAssignedBy:
- return m.AssignedBy()
- case usersubscription.FieldAssignedAt:
- return m.AssignedAt()
- case usersubscription.FieldNotes:
- return m.Notes()
- }
- return nil, false
- }
- // OldField returns the old value of the field from the database. An error is
- // returned if the mutation operation is not UpdateOne, or the query to the
- // database failed.
- func (m *UserSubscriptionMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
- switch name {
- case usersubscription.FieldCreatedAt:
- return m.OldCreatedAt(ctx)
- case usersubscription.FieldUpdatedAt:
- return m.OldUpdatedAt(ctx)
- case usersubscription.FieldDeletedAt:
- return m.OldDeletedAt(ctx)
- case usersubscription.FieldUserID:
- return m.OldUserID(ctx)
- case usersubscription.FieldGroupID:
- return m.OldGroupID(ctx)
- case usersubscription.FieldStartsAt:
- return m.OldStartsAt(ctx)
- case usersubscription.FieldExpiresAt:
- return m.OldExpiresAt(ctx)
- case usersubscription.FieldStatus:
- return m.OldStatus(ctx)
- case usersubscription.FieldDailyWindowStart:
- return m.OldDailyWindowStart(ctx)
- case usersubscription.FieldWeeklyWindowStart:
- return m.OldWeeklyWindowStart(ctx)
- case usersubscription.FieldMonthlyWindowStart:
- return m.OldMonthlyWindowStart(ctx)
- case usersubscription.FieldDailyUsageUsd:
- return m.OldDailyUsageUsd(ctx)
- case usersubscription.FieldWeeklyUsageUsd:
- return m.OldWeeklyUsageUsd(ctx)
- case usersubscription.FieldMonthlyUsageUsd:
- return m.OldMonthlyUsageUsd(ctx)
- case usersubscription.FieldAssignedBy:
- return m.OldAssignedBy(ctx)
- case usersubscription.FieldAssignedAt:
- return m.OldAssignedAt(ctx)
- case usersubscription.FieldNotes:
- return m.OldNotes(ctx)
- }
- return nil, fmt.Errorf("unknown UserSubscription field %s", name)
- }
- // SetField sets the value of a field with the given name. It returns an error if
- // the field is not defined in the schema, or if the type mismatched the field
- // type.
- func (m *UserSubscriptionMutation) SetField(name string, value ent.Value) error {
- switch name {
- case usersubscription.FieldCreatedAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetCreatedAt(v)
- return nil
- case usersubscription.FieldUpdatedAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetUpdatedAt(v)
- return nil
- case usersubscription.FieldDeletedAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetDeletedAt(v)
- return nil
- case usersubscription.FieldUserID:
- v, ok := value.(int64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetUserID(v)
- return nil
- case usersubscription.FieldGroupID:
- v, ok := value.(int64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetGroupID(v)
- return nil
- case usersubscription.FieldStartsAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetStartsAt(v)
- return nil
- case usersubscription.FieldExpiresAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetExpiresAt(v)
- return nil
- case usersubscription.FieldStatus:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetStatus(v)
- return nil
- case usersubscription.FieldDailyWindowStart:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetDailyWindowStart(v)
- return nil
- case usersubscription.FieldWeeklyWindowStart:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetWeeklyWindowStart(v)
- return nil
- case usersubscription.FieldMonthlyWindowStart:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetMonthlyWindowStart(v)
- return nil
- case usersubscription.FieldDailyUsageUsd:
- v, ok := value.(float64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetDailyUsageUsd(v)
- return nil
- case usersubscription.FieldWeeklyUsageUsd:
- v, ok := value.(float64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetWeeklyUsageUsd(v)
- return nil
- case usersubscription.FieldMonthlyUsageUsd:
- v, ok := value.(float64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetMonthlyUsageUsd(v)
- return nil
- case usersubscription.FieldAssignedBy:
- v, ok := value.(int64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetAssignedBy(v)
- return nil
- case usersubscription.FieldAssignedAt:
- v, ok := value.(time.Time)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetAssignedAt(v)
- return nil
- case usersubscription.FieldNotes:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetNotes(v)
- return nil
- }
- return fmt.Errorf("unknown UserSubscription field %s", name)
- }
- // AddedFields returns all numeric fields that were incremented/decremented during
- // this mutation.
- func (m *UserSubscriptionMutation) AddedFields() []string {
- var fields []string
- if m.adddaily_usage_usd != nil {
- fields = append(fields, usersubscription.FieldDailyUsageUsd)
- }
- if m.addweekly_usage_usd != nil {
- fields = append(fields, usersubscription.FieldWeeklyUsageUsd)
- }
- if m.addmonthly_usage_usd != nil {
- fields = append(fields, usersubscription.FieldMonthlyUsageUsd)
- }
- return fields
- }
- // AddedField returns the numeric value that was incremented/decremented on a field
- // with the given name. The second boolean return value indicates that this field
- // was not set, or was not defined in the schema.
- func (m *UserSubscriptionMutation) AddedField(name string) (ent.Value, bool) {
- switch name {
- case usersubscription.FieldDailyUsageUsd:
- return m.AddedDailyUsageUsd()
- case usersubscription.FieldWeeklyUsageUsd:
- return m.AddedWeeklyUsageUsd()
- case usersubscription.FieldMonthlyUsageUsd:
- return m.AddedMonthlyUsageUsd()
- }
- return nil, false
- }
- // AddField adds the value to the field with the given name. It returns an error if
- // the field is not defined in the schema, or if the type mismatched the field
- // type.
- func (m *UserSubscriptionMutation) AddField(name string, value ent.Value) error {
- switch name {
- case usersubscription.FieldDailyUsageUsd:
- v, ok := value.(float64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.AddDailyUsageUsd(v)
- return nil
- case usersubscription.FieldWeeklyUsageUsd:
- v, ok := value.(float64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.AddWeeklyUsageUsd(v)
- return nil
- case usersubscription.FieldMonthlyUsageUsd:
- v, ok := value.(float64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.AddMonthlyUsageUsd(v)
- return nil
- }
- return fmt.Errorf("unknown UserSubscription numeric field %s", name)
- }
- // ClearedFields returns all nullable fields that were cleared during this
- // mutation.
- func (m *UserSubscriptionMutation) ClearedFields() []string {
- var fields []string
- if m.FieldCleared(usersubscription.FieldDeletedAt) {
- fields = append(fields, usersubscription.FieldDeletedAt)
- }
- if m.FieldCleared(usersubscription.FieldDailyWindowStart) {
- fields = append(fields, usersubscription.FieldDailyWindowStart)
- }
- if m.FieldCleared(usersubscription.FieldWeeklyWindowStart) {
- fields = append(fields, usersubscription.FieldWeeklyWindowStart)
- }
- if m.FieldCleared(usersubscription.FieldMonthlyWindowStart) {
- fields = append(fields, usersubscription.FieldMonthlyWindowStart)
- }
- if m.FieldCleared(usersubscription.FieldAssignedBy) {
- fields = append(fields, usersubscription.FieldAssignedBy)
- }
- if m.FieldCleared(usersubscription.FieldNotes) {
- fields = append(fields, usersubscription.FieldNotes)
- }
- return fields
- }
- // FieldCleared returns a boolean indicating if a field with the given name was
- // cleared in this mutation.
- func (m *UserSubscriptionMutation) FieldCleared(name string) bool {
- _, ok := m.clearedFields[name]
- return ok
- }
- // ClearField clears the value of the field with the given name. It returns an
- // error if the field is not defined in the schema.
- func (m *UserSubscriptionMutation) ClearField(name string) error {
- switch name {
- case usersubscription.FieldDeletedAt:
- m.ClearDeletedAt()
- return nil
- case usersubscription.FieldDailyWindowStart:
- m.ClearDailyWindowStart()
- return nil
- case usersubscription.FieldWeeklyWindowStart:
- m.ClearWeeklyWindowStart()
- return nil
- case usersubscription.FieldMonthlyWindowStart:
- m.ClearMonthlyWindowStart()
- return nil
- case usersubscription.FieldAssignedBy:
- m.ClearAssignedBy()
- return nil
- case usersubscription.FieldNotes:
- m.ClearNotes()
- return nil
- }
- return fmt.Errorf("unknown UserSubscription nullable field %s", name)
- }
- // ResetField resets all changes in the mutation for the field with the given name.
- // It returns an error if the field is not defined in the schema.
- func (m *UserSubscriptionMutation) ResetField(name string) error {
- switch name {
- case usersubscription.FieldCreatedAt:
- m.ResetCreatedAt()
- return nil
- case usersubscription.FieldUpdatedAt:
- m.ResetUpdatedAt()
- return nil
- case usersubscription.FieldDeletedAt:
- m.ResetDeletedAt()
- return nil
- case usersubscription.FieldUserID:
- m.ResetUserID()
- return nil
- case usersubscription.FieldGroupID:
- m.ResetGroupID()
- return nil
- case usersubscription.FieldStartsAt:
- m.ResetStartsAt()
- return nil
- case usersubscription.FieldExpiresAt:
- m.ResetExpiresAt()
- return nil
- case usersubscription.FieldStatus:
- m.ResetStatus()
- return nil
- case usersubscription.FieldDailyWindowStart:
- m.ResetDailyWindowStart()
- return nil
- case usersubscription.FieldWeeklyWindowStart:
- m.ResetWeeklyWindowStart()
- return nil
- case usersubscription.FieldMonthlyWindowStart:
- m.ResetMonthlyWindowStart()
- return nil
- case usersubscription.FieldDailyUsageUsd:
- m.ResetDailyUsageUsd()
- return nil
- case usersubscription.FieldWeeklyUsageUsd:
- m.ResetWeeklyUsageUsd()
- return nil
- case usersubscription.FieldMonthlyUsageUsd:
- m.ResetMonthlyUsageUsd()
- return nil
- case usersubscription.FieldAssignedBy:
- m.ResetAssignedBy()
- return nil
- case usersubscription.FieldAssignedAt:
- m.ResetAssignedAt()
- return nil
- case usersubscription.FieldNotes:
- m.ResetNotes()
- return nil
- }
- return fmt.Errorf("unknown UserSubscription field %s", name)
- }
- // AddedEdges returns all edge names that were set/added in this mutation.
- func (m *UserSubscriptionMutation) AddedEdges() []string {
- edges := make([]string, 0, 4)
- if m.user != nil {
- edges = append(edges, usersubscription.EdgeUser)
- }
- if m.group != nil {
- edges = append(edges, usersubscription.EdgeGroup)
- }
- if m.assigned_by_user != nil {
- edges = append(edges, usersubscription.EdgeAssignedByUser)
- }
- if m.usage_logs != nil {
- edges = append(edges, usersubscription.EdgeUsageLogs)
- }
- return edges
- }
- // AddedIDs returns all IDs (to other nodes) that were added for the given edge
- // name in this mutation.
- func (m *UserSubscriptionMutation) AddedIDs(name string) []ent.Value {
- switch name {
- case usersubscription.EdgeUser:
- if id := m.user; id != nil {
- return []ent.Value{*id}
- }
- case usersubscription.EdgeGroup:
- if id := m.group; id != nil {
- return []ent.Value{*id}
- }
- case usersubscription.EdgeAssignedByUser:
- if id := m.assigned_by_user; id != nil {
- return []ent.Value{*id}
- }
- case usersubscription.EdgeUsageLogs:
- ids := make([]ent.Value, 0, len(m.usage_logs))
- for id := range m.usage_logs {
- ids = append(ids, id)
- }
- return ids
- }
- return nil
- }
- // RemovedEdges returns all edge names that were removed in this mutation.
- func (m *UserSubscriptionMutation) RemovedEdges() []string {
- edges := make([]string, 0, 4)
- if m.removedusage_logs != nil {
- edges = append(edges, usersubscription.EdgeUsageLogs)
- }
- return edges
- }
- // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
- // the given name in this mutation.
- func (m *UserSubscriptionMutation) RemovedIDs(name string) []ent.Value {
- switch name {
- case usersubscription.EdgeUsageLogs:
- ids := make([]ent.Value, 0, len(m.removedusage_logs))
- for id := range m.removedusage_logs {
- ids = append(ids, id)
- }
- return ids
- }
- return nil
- }
- // ClearedEdges returns all edge names that were cleared in this mutation.
- func (m *UserSubscriptionMutation) ClearedEdges() []string {
- edges := make([]string, 0, 4)
- if m.cleareduser {
- edges = append(edges, usersubscription.EdgeUser)
- }
- if m.clearedgroup {
- edges = append(edges, usersubscription.EdgeGroup)
- }
- if m.clearedassigned_by_user {
- edges = append(edges, usersubscription.EdgeAssignedByUser)
- }
- if m.clearedusage_logs {
- edges = append(edges, usersubscription.EdgeUsageLogs)
- }
- return edges
- }
- // EdgeCleared returns a boolean which indicates if the edge with the given name
- // was cleared in this mutation.
- func (m *UserSubscriptionMutation) EdgeCleared(name string) bool {
- switch name {
- case usersubscription.EdgeUser:
- return m.cleareduser
- case usersubscription.EdgeGroup:
- return m.clearedgroup
- case usersubscription.EdgeAssignedByUser:
- return m.clearedassigned_by_user
- case usersubscription.EdgeUsageLogs:
- return m.clearedusage_logs
- }
- return false
- }
- // ClearEdge clears the value of the edge with the given name. It returns an error
- // if that edge is not defined in the schema.
- func (m *UserSubscriptionMutation) ClearEdge(name string) error {
- switch name {
- case usersubscription.EdgeUser:
- m.ClearUser()
- return nil
- case usersubscription.EdgeGroup:
- m.ClearGroup()
- return nil
- case usersubscription.EdgeAssignedByUser:
- m.ClearAssignedByUser()
- return nil
- }
- return fmt.Errorf("unknown UserSubscription unique edge %s", name)
- }
- // ResetEdge resets all changes to the edge with the given name in this mutation.
- // It returns an error if the edge is not defined in the schema.
- func (m *UserSubscriptionMutation) ResetEdge(name string) error {
- switch name {
- case usersubscription.EdgeUser:
- m.ResetUser()
- return nil
- case usersubscription.EdgeGroup:
- m.ResetGroup()
- return nil
- case usersubscription.EdgeAssignedByUser:
- m.ResetAssignedByUser()
- return nil
- case usersubscription.EdgeUsageLogs:
- m.ResetUsageLogs()
- return nil
- }
- return fmt.Errorf("unknown UserSubscription edge %s", name)
- }
|