| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337 |
- // Code generated by ent, DO NOT EDIT.
- package ent
- import (
- "context"
- "errors"
- "fmt"
- "time"
- "entgo.io/ent/dialect/sql"
- "entgo.io/ent/dialect/sql/sqlgraph"
- "entgo.io/ent/schema/field"
- "github.com/Wei-Shaw/sub2api/ent/account"
- "github.com/Wei-Shaw/sub2api/ent/group"
- "github.com/Wei-Shaw/sub2api/ent/predicate"
- "github.com/Wei-Shaw/sub2api/ent/proxy"
- "github.com/Wei-Shaw/sub2api/ent/usagelog"
- )
- // AccountUpdate is the builder for updating Account entities.
- type AccountUpdate struct {
- config
- hooks []Hook
- mutation *AccountMutation
- }
- // Where appends a list predicates to the AccountUpdate builder.
- func (_u *AccountUpdate) Where(ps ...predicate.Account) *AccountUpdate {
- _u.mutation.Where(ps...)
- return _u
- }
- // SetUpdatedAt sets the "updated_at" field.
- func (_u *AccountUpdate) SetUpdatedAt(v time.Time) *AccountUpdate {
- _u.mutation.SetUpdatedAt(v)
- return _u
- }
- // SetDeletedAt sets the "deleted_at" field.
- func (_u *AccountUpdate) SetDeletedAt(v time.Time) *AccountUpdate {
- _u.mutation.SetDeletedAt(v)
- return _u
- }
- // SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.
- func (_u *AccountUpdate) SetNillableDeletedAt(v *time.Time) *AccountUpdate {
- if v != nil {
- _u.SetDeletedAt(*v)
- }
- return _u
- }
- // ClearDeletedAt clears the value of the "deleted_at" field.
- func (_u *AccountUpdate) ClearDeletedAt() *AccountUpdate {
- _u.mutation.ClearDeletedAt()
- return _u
- }
- // SetName sets the "name" field.
- func (_u *AccountUpdate) SetName(v string) *AccountUpdate {
- _u.mutation.SetName(v)
- return _u
- }
- // SetNillableName sets the "name" field if the given value is not nil.
- func (_u *AccountUpdate) SetNillableName(v *string) *AccountUpdate {
- if v != nil {
- _u.SetName(*v)
- }
- return _u
- }
- // SetNotes sets the "notes" field.
- func (_u *AccountUpdate) SetNotes(v string) *AccountUpdate {
- _u.mutation.SetNotes(v)
- return _u
- }
- // SetNillableNotes sets the "notes" field if the given value is not nil.
- func (_u *AccountUpdate) SetNillableNotes(v *string) *AccountUpdate {
- if v != nil {
- _u.SetNotes(*v)
- }
- return _u
- }
- // ClearNotes clears the value of the "notes" field.
- func (_u *AccountUpdate) ClearNotes() *AccountUpdate {
- _u.mutation.ClearNotes()
- return _u
- }
- // SetPlatform sets the "platform" field.
- func (_u *AccountUpdate) SetPlatform(v string) *AccountUpdate {
- _u.mutation.SetPlatform(v)
- return _u
- }
- // SetNillablePlatform sets the "platform" field if the given value is not nil.
- func (_u *AccountUpdate) SetNillablePlatform(v *string) *AccountUpdate {
- if v != nil {
- _u.SetPlatform(*v)
- }
- return _u
- }
- // SetType sets the "type" field.
- func (_u *AccountUpdate) SetType(v string) *AccountUpdate {
- _u.mutation.SetType(v)
- return _u
- }
- // SetNillableType sets the "type" field if the given value is not nil.
- func (_u *AccountUpdate) SetNillableType(v *string) *AccountUpdate {
- if v != nil {
- _u.SetType(*v)
- }
- return _u
- }
- // SetCredentials sets the "credentials" field.
- func (_u *AccountUpdate) SetCredentials(v map[string]interface{}) *AccountUpdate {
- _u.mutation.SetCredentials(v)
- return _u
- }
- // SetExtra sets the "extra" field.
- func (_u *AccountUpdate) SetExtra(v map[string]interface{}) *AccountUpdate {
- _u.mutation.SetExtra(v)
- return _u
- }
- // SetProxyID sets the "proxy_id" field.
- func (_u *AccountUpdate) SetProxyID(v int64) *AccountUpdate {
- _u.mutation.SetProxyID(v)
- return _u
- }
- // SetNillableProxyID sets the "proxy_id" field if the given value is not nil.
- func (_u *AccountUpdate) SetNillableProxyID(v *int64) *AccountUpdate {
- if v != nil {
- _u.SetProxyID(*v)
- }
- return _u
- }
- // ClearProxyID clears the value of the "proxy_id" field.
- func (_u *AccountUpdate) ClearProxyID() *AccountUpdate {
- _u.mutation.ClearProxyID()
- return _u
- }
- // SetProxyFallbackOriginID sets the "proxy_fallback_origin_id" field.
- func (_u *AccountUpdate) SetProxyFallbackOriginID(v int64) *AccountUpdate {
- _u.mutation.ResetProxyFallbackOriginID()
- _u.mutation.SetProxyFallbackOriginID(v)
- return _u
- }
- // SetNillableProxyFallbackOriginID sets the "proxy_fallback_origin_id" field if the given value is not nil.
- func (_u *AccountUpdate) SetNillableProxyFallbackOriginID(v *int64) *AccountUpdate {
- if v != nil {
- _u.SetProxyFallbackOriginID(*v)
- }
- return _u
- }
- // AddProxyFallbackOriginID adds value to the "proxy_fallback_origin_id" field.
- func (_u *AccountUpdate) AddProxyFallbackOriginID(v int64) *AccountUpdate {
- _u.mutation.AddProxyFallbackOriginID(v)
- return _u
- }
- // ClearProxyFallbackOriginID clears the value of the "proxy_fallback_origin_id" field.
- func (_u *AccountUpdate) ClearProxyFallbackOriginID() *AccountUpdate {
- _u.mutation.ClearProxyFallbackOriginID()
- return _u
- }
- // SetConcurrency sets the "concurrency" field.
- func (_u *AccountUpdate) SetConcurrency(v int) *AccountUpdate {
- _u.mutation.ResetConcurrency()
- _u.mutation.SetConcurrency(v)
- return _u
- }
- // SetNillableConcurrency sets the "concurrency" field if the given value is not nil.
- func (_u *AccountUpdate) SetNillableConcurrency(v *int) *AccountUpdate {
- if v != nil {
- _u.SetConcurrency(*v)
- }
- return _u
- }
- // AddConcurrency adds value to the "concurrency" field.
- func (_u *AccountUpdate) AddConcurrency(v int) *AccountUpdate {
- _u.mutation.AddConcurrency(v)
- return _u
- }
- // SetLoadFactor sets the "load_factor" field.
- func (_u *AccountUpdate) SetLoadFactor(v int) *AccountUpdate {
- _u.mutation.ResetLoadFactor()
- _u.mutation.SetLoadFactor(v)
- return _u
- }
- // SetNillableLoadFactor sets the "load_factor" field if the given value is not nil.
- func (_u *AccountUpdate) SetNillableLoadFactor(v *int) *AccountUpdate {
- if v != nil {
- _u.SetLoadFactor(*v)
- }
- return _u
- }
- // AddLoadFactor adds value to the "load_factor" field.
- func (_u *AccountUpdate) AddLoadFactor(v int) *AccountUpdate {
- _u.mutation.AddLoadFactor(v)
- return _u
- }
- // ClearLoadFactor clears the value of the "load_factor" field.
- func (_u *AccountUpdate) ClearLoadFactor() *AccountUpdate {
- _u.mutation.ClearLoadFactor()
- return _u
- }
- // SetPriority sets the "priority" field.
- func (_u *AccountUpdate) SetPriority(v int) *AccountUpdate {
- _u.mutation.ResetPriority()
- _u.mutation.SetPriority(v)
- return _u
- }
- // SetNillablePriority sets the "priority" field if the given value is not nil.
- func (_u *AccountUpdate) SetNillablePriority(v *int) *AccountUpdate {
- if v != nil {
- _u.SetPriority(*v)
- }
- return _u
- }
- // AddPriority adds value to the "priority" field.
- func (_u *AccountUpdate) AddPriority(v int) *AccountUpdate {
- _u.mutation.AddPriority(v)
- return _u
- }
- // SetRateMultiplier sets the "rate_multiplier" field.
- func (_u *AccountUpdate) SetRateMultiplier(v float64) *AccountUpdate {
- _u.mutation.ResetRateMultiplier()
- _u.mutation.SetRateMultiplier(v)
- return _u
- }
- // SetNillableRateMultiplier sets the "rate_multiplier" field if the given value is not nil.
- func (_u *AccountUpdate) SetNillableRateMultiplier(v *float64) *AccountUpdate {
- if v != nil {
- _u.SetRateMultiplier(*v)
- }
- return _u
- }
- // AddRateMultiplier adds value to the "rate_multiplier" field.
- func (_u *AccountUpdate) AddRateMultiplier(v float64) *AccountUpdate {
- _u.mutation.AddRateMultiplier(v)
- return _u
- }
- // SetStatus sets the "status" field.
- func (_u *AccountUpdate) SetStatus(v string) *AccountUpdate {
- _u.mutation.SetStatus(v)
- return _u
- }
- // SetNillableStatus sets the "status" field if the given value is not nil.
- func (_u *AccountUpdate) SetNillableStatus(v *string) *AccountUpdate {
- if v != nil {
- _u.SetStatus(*v)
- }
- return _u
- }
- // SetErrorMessage sets the "error_message" field.
- func (_u *AccountUpdate) SetErrorMessage(v string) *AccountUpdate {
- _u.mutation.SetErrorMessage(v)
- return _u
- }
- // SetNillableErrorMessage sets the "error_message" field if the given value is not nil.
- func (_u *AccountUpdate) SetNillableErrorMessage(v *string) *AccountUpdate {
- if v != nil {
- _u.SetErrorMessage(*v)
- }
- return _u
- }
- // ClearErrorMessage clears the value of the "error_message" field.
- func (_u *AccountUpdate) ClearErrorMessage() *AccountUpdate {
- _u.mutation.ClearErrorMessage()
- return _u
- }
- // SetLastUsedAt sets the "last_used_at" field.
- func (_u *AccountUpdate) SetLastUsedAt(v time.Time) *AccountUpdate {
- _u.mutation.SetLastUsedAt(v)
- return _u
- }
- // SetNillableLastUsedAt sets the "last_used_at" field if the given value is not nil.
- func (_u *AccountUpdate) SetNillableLastUsedAt(v *time.Time) *AccountUpdate {
- if v != nil {
- _u.SetLastUsedAt(*v)
- }
- return _u
- }
- // ClearLastUsedAt clears the value of the "last_used_at" field.
- func (_u *AccountUpdate) ClearLastUsedAt() *AccountUpdate {
- _u.mutation.ClearLastUsedAt()
- return _u
- }
- // SetExpiresAt sets the "expires_at" field.
- func (_u *AccountUpdate) SetExpiresAt(v time.Time) *AccountUpdate {
- _u.mutation.SetExpiresAt(v)
- return _u
- }
- // SetNillableExpiresAt sets the "expires_at" field if the given value is not nil.
- func (_u *AccountUpdate) SetNillableExpiresAt(v *time.Time) *AccountUpdate {
- if v != nil {
- _u.SetExpiresAt(*v)
- }
- return _u
- }
- // ClearExpiresAt clears the value of the "expires_at" field.
- func (_u *AccountUpdate) ClearExpiresAt() *AccountUpdate {
- _u.mutation.ClearExpiresAt()
- return _u
- }
- // SetAutoPauseOnExpired sets the "auto_pause_on_expired" field.
- func (_u *AccountUpdate) SetAutoPauseOnExpired(v bool) *AccountUpdate {
- _u.mutation.SetAutoPauseOnExpired(v)
- return _u
- }
- // SetNillableAutoPauseOnExpired sets the "auto_pause_on_expired" field if the given value is not nil.
- func (_u *AccountUpdate) SetNillableAutoPauseOnExpired(v *bool) *AccountUpdate {
- if v != nil {
- _u.SetAutoPauseOnExpired(*v)
- }
- return _u
- }
- // SetSchedulable sets the "schedulable" field.
- func (_u *AccountUpdate) SetSchedulable(v bool) *AccountUpdate {
- _u.mutation.SetSchedulable(v)
- return _u
- }
- // SetNillableSchedulable sets the "schedulable" field if the given value is not nil.
- func (_u *AccountUpdate) SetNillableSchedulable(v *bool) *AccountUpdate {
- if v != nil {
- _u.SetSchedulable(*v)
- }
- return _u
- }
- // SetRateLimitedAt sets the "rate_limited_at" field.
- func (_u *AccountUpdate) SetRateLimitedAt(v time.Time) *AccountUpdate {
- _u.mutation.SetRateLimitedAt(v)
- return _u
- }
- // SetNillableRateLimitedAt sets the "rate_limited_at" field if the given value is not nil.
- func (_u *AccountUpdate) SetNillableRateLimitedAt(v *time.Time) *AccountUpdate {
- if v != nil {
- _u.SetRateLimitedAt(*v)
- }
- return _u
- }
- // ClearRateLimitedAt clears the value of the "rate_limited_at" field.
- func (_u *AccountUpdate) ClearRateLimitedAt() *AccountUpdate {
- _u.mutation.ClearRateLimitedAt()
- return _u
- }
- // SetRateLimitResetAt sets the "rate_limit_reset_at" field.
- func (_u *AccountUpdate) SetRateLimitResetAt(v time.Time) *AccountUpdate {
- _u.mutation.SetRateLimitResetAt(v)
- return _u
- }
- // SetNillableRateLimitResetAt sets the "rate_limit_reset_at" field if the given value is not nil.
- func (_u *AccountUpdate) SetNillableRateLimitResetAt(v *time.Time) *AccountUpdate {
- if v != nil {
- _u.SetRateLimitResetAt(*v)
- }
- return _u
- }
- // ClearRateLimitResetAt clears the value of the "rate_limit_reset_at" field.
- func (_u *AccountUpdate) ClearRateLimitResetAt() *AccountUpdate {
- _u.mutation.ClearRateLimitResetAt()
- return _u
- }
- // SetOverloadUntil sets the "overload_until" field.
- func (_u *AccountUpdate) SetOverloadUntil(v time.Time) *AccountUpdate {
- _u.mutation.SetOverloadUntil(v)
- return _u
- }
- // SetNillableOverloadUntil sets the "overload_until" field if the given value is not nil.
- func (_u *AccountUpdate) SetNillableOverloadUntil(v *time.Time) *AccountUpdate {
- if v != nil {
- _u.SetOverloadUntil(*v)
- }
- return _u
- }
- // ClearOverloadUntil clears the value of the "overload_until" field.
- func (_u *AccountUpdate) ClearOverloadUntil() *AccountUpdate {
- _u.mutation.ClearOverloadUntil()
- return _u
- }
- // SetTempUnschedulableUntil sets the "temp_unschedulable_until" field.
- func (_u *AccountUpdate) SetTempUnschedulableUntil(v time.Time) *AccountUpdate {
- _u.mutation.SetTempUnschedulableUntil(v)
- return _u
- }
- // SetNillableTempUnschedulableUntil sets the "temp_unschedulable_until" field if the given value is not nil.
- func (_u *AccountUpdate) SetNillableTempUnschedulableUntil(v *time.Time) *AccountUpdate {
- if v != nil {
- _u.SetTempUnschedulableUntil(*v)
- }
- return _u
- }
- // ClearTempUnschedulableUntil clears the value of the "temp_unschedulable_until" field.
- func (_u *AccountUpdate) ClearTempUnschedulableUntil() *AccountUpdate {
- _u.mutation.ClearTempUnschedulableUntil()
- return _u
- }
- // SetTempUnschedulableReason sets the "temp_unschedulable_reason" field.
- func (_u *AccountUpdate) SetTempUnschedulableReason(v string) *AccountUpdate {
- _u.mutation.SetTempUnschedulableReason(v)
- return _u
- }
- // SetNillableTempUnschedulableReason sets the "temp_unschedulable_reason" field if the given value is not nil.
- func (_u *AccountUpdate) SetNillableTempUnschedulableReason(v *string) *AccountUpdate {
- if v != nil {
- _u.SetTempUnschedulableReason(*v)
- }
- return _u
- }
- // ClearTempUnschedulableReason clears the value of the "temp_unschedulable_reason" field.
- func (_u *AccountUpdate) ClearTempUnschedulableReason() *AccountUpdate {
- _u.mutation.ClearTempUnschedulableReason()
- return _u
- }
- // SetSessionWindowStart sets the "session_window_start" field.
- func (_u *AccountUpdate) SetSessionWindowStart(v time.Time) *AccountUpdate {
- _u.mutation.SetSessionWindowStart(v)
- return _u
- }
- // SetNillableSessionWindowStart sets the "session_window_start" field if the given value is not nil.
- func (_u *AccountUpdate) SetNillableSessionWindowStart(v *time.Time) *AccountUpdate {
- if v != nil {
- _u.SetSessionWindowStart(*v)
- }
- return _u
- }
- // ClearSessionWindowStart clears the value of the "session_window_start" field.
- func (_u *AccountUpdate) ClearSessionWindowStart() *AccountUpdate {
- _u.mutation.ClearSessionWindowStart()
- return _u
- }
- // SetSessionWindowEnd sets the "session_window_end" field.
- func (_u *AccountUpdate) SetSessionWindowEnd(v time.Time) *AccountUpdate {
- _u.mutation.SetSessionWindowEnd(v)
- return _u
- }
- // SetNillableSessionWindowEnd sets the "session_window_end" field if the given value is not nil.
- func (_u *AccountUpdate) SetNillableSessionWindowEnd(v *time.Time) *AccountUpdate {
- if v != nil {
- _u.SetSessionWindowEnd(*v)
- }
- return _u
- }
- // ClearSessionWindowEnd clears the value of the "session_window_end" field.
- func (_u *AccountUpdate) ClearSessionWindowEnd() *AccountUpdate {
- _u.mutation.ClearSessionWindowEnd()
- return _u
- }
- // SetSessionWindowStatus sets the "session_window_status" field.
- func (_u *AccountUpdate) SetSessionWindowStatus(v string) *AccountUpdate {
- _u.mutation.SetSessionWindowStatus(v)
- return _u
- }
- // SetNillableSessionWindowStatus sets the "session_window_status" field if the given value is not nil.
- func (_u *AccountUpdate) SetNillableSessionWindowStatus(v *string) *AccountUpdate {
- if v != nil {
- _u.SetSessionWindowStatus(*v)
- }
- return _u
- }
- // ClearSessionWindowStatus clears the value of the "session_window_status" field.
- func (_u *AccountUpdate) ClearSessionWindowStatus() *AccountUpdate {
- _u.mutation.ClearSessionWindowStatus()
- return _u
- }
- // SetParentAccountID sets the "parent_account_id" field.
- func (_u *AccountUpdate) SetParentAccountID(v int64) *AccountUpdate {
- _u.mutation.SetParentAccountID(v)
- return _u
- }
- // SetNillableParentAccountID sets the "parent_account_id" field if the given value is not nil.
- func (_u *AccountUpdate) SetNillableParentAccountID(v *int64) *AccountUpdate {
- if v != nil {
- _u.SetParentAccountID(*v)
- }
- return _u
- }
- // ClearParentAccountID clears the value of the "parent_account_id" field.
- func (_u *AccountUpdate) ClearParentAccountID() *AccountUpdate {
- _u.mutation.ClearParentAccountID()
- return _u
- }
- // SetQuotaDimension sets the "quota_dimension" field.
- func (_u *AccountUpdate) SetQuotaDimension(v account.QuotaDimension) *AccountUpdate {
- _u.mutation.SetQuotaDimension(v)
- return _u
- }
- // SetNillableQuotaDimension sets the "quota_dimension" field if the given value is not nil.
- func (_u *AccountUpdate) SetNillableQuotaDimension(v *account.QuotaDimension) *AccountUpdate {
- if v != nil {
- _u.SetQuotaDimension(*v)
- }
- return _u
- }
- // AddGroupIDs adds the "groups" edge to the Group entity by IDs.
- func (_u *AccountUpdate) AddGroupIDs(ids ...int64) *AccountUpdate {
- _u.mutation.AddGroupIDs(ids...)
- return _u
- }
- // AddGroups adds the "groups" edges to the Group entity.
- func (_u *AccountUpdate) AddGroups(v ...*Group) *AccountUpdate {
- ids := make([]int64, len(v))
- for i := range v {
- ids[i] = v[i].ID
- }
- return _u.AddGroupIDs(ids...)
- }
- // SetProxy sets the "proxy" edge to the Proxy entity.
- func (_u *AccountUpdate) SetProxy(v *Proxy) *AccountUpdate {
- return _u.SetProxyID(v.ID)
- }
- // SetParentID sets the "parent" edge to the Account entity by ID.
- func (_u *AccountUpdate) SetParentID(id int64) *AccountUpdate {
- _u.mutation.SetParentID(id)
- return _u
- }
- // SetNillableParentID sets the "parent" edge to the Account entity by ID if the given value is not nil.
- func (_u *AccountUpdate) SetNillableParentID(id *int64) *AccountUpdate {
- if id != nil {
- _u = _u.SetParentID(*id)
- }
- return _u
- }
- // SetParent sets the "parent" edge to the Account entity.
- func (_u *AccountUpdate) SetParent(v *Account) *AccountUpdate {
- return _u.SetParentID(v.ID)
- }
- // AddChildIDs adds the "children" edge to the Account entity by IDs.
- func (_u *AccountUpdate) AddChildIDs(ids ...int64) *AccountUpdate {
- _u.mutation.AddChildIDs(ids...)
- return _u
- }
- // AddChildren adds the "children" edges to the Account entity.
- func (_u *AccountUpdate) AddChildren(v ...*Account) *AccountUpdate {
- ids := make([]int64, len(v))
- for i := range v {
- ids[i] = v[i].ID
- }
- return _u.AddChildIDs(ids...)
- }
- // AddUsageLogIDs adds the "usage_logs" edge to the UsageLog entity by IDs.
- func (_u *AccountUpdate) AddUsageLogIDs(ids ...int64) *AccountUpdate {
- _u.mutation.AddUsageLogIDs(ids...)
- return _u
- }
- // AddUsageLogs adds the "usage_logs" edges to the UsageLog entity.
- func (_u *AccountUpdate) AddUsageLogs(v ...*UsageLog) *AccountUpdate {
- ids := make([]int64, len(v))
- for i := range v {
- ids[i] = v[i].ID
- }
- return _u.AddUsageLogIDs(ids...)
- }
- // Mutation returns the AccountMutation object of the builder.
- func (_u *AccountUpdate) Mutation() *AccountMutation {
- return _u.mutation
- }
- // ClearGroups clears all "groups" edges to the Group entity.
- func (_u *AccountUpdate) ClearGroups() *AccountUpdate {
- _u.mutation.ClearGroups()
- return _u
- }
- // RemoveGroupIDs removes the "groups" edge to Group entities by IDs.
- func (_u *AccountUpdate) RemoveGroupIDs(ids ...int64) *AccountUpdate {
- _u.mutation.RemoveGroupIDs(ids...)
- return _u
- }
- // RemoveGroups removes "groups" edges to Group entities.
- func (_u *AccountUpdate) RemoveGroups(v ...*Group) *AccountUpdate {
- ids := make([]int64, len(v))
- for i := range v {
- ids[i] = v[i].ID
- }
- return _u.RemoveGroupIDs(ids...)
- }
- // ClearProxy clears the "proxy" edge to the Proxy entity.
- func (_u *AccountUpdate) ClearProxy() *AccountUpdate {
- _u.mutation.ClearProxy()
- return _u
- }
- // ClearParent clears the "parent" edge to the Account entity.
- func (_u *AccountUpdate) ClearParent() *AccountUpdate {
- _u.mutation.ClearParent()
- return _u
- }
- // ClearChildren clears all "children" edges to the Account entity.
- func (_u *AccountUpdate) ClearChildren() *AccountUpdate {
- _u.mutation.ClearChildren()
- return _u
- }
- // RemoveChildIDs removes the "children" edge to Account entities by IDs.
- func (_u *AccountUpdate) RemoveChildIDs(ids ...int64) *AccountUpdate {
- _u.mutation.RemoveChildIDs(ids...)
- return _u
- }
- // RemoveChildren removes "children" edges to Account entities.
- func (_u *AccountUpdate) RemoveChildren(v ...*Account) *AccountUpdate {
- ids := make([]int64, len(v))
- for i := range v {
- ids[i] = v[i].ID
- }
- return _u.RemoveChildIDs(ids...)
- }
- // ClearUsageLogs clears all "usage_logs" edges to the UsageLog entity.
- func (_u *AccountUpdate) ClearUsageLogs() *AccountUpdate {
- _u.mutation.ClearUsageLogs()
- return _u
- }
- // RemoveUsageLogIDs removes the "usage_logs" edge to UsageLog entities by IDs.
- func (_u *AccountUpdate) RemoveUsageLogIDs(ids ...int64) *AccountUpdate {
- _u.mutation.RemoveUsageLogIDs(ids...)
- return _u
- }
- // RemoveUsageLogs removes "usage_logs" edges to UsageLog entities.
- func (_u *AccountUpdate) RemoveUsageLogs(v ...*UsageLog) *AccountUpdate {
- ids := make([]int64, len(v))
- for i := range v {
- ids[i] = v[i].ID
- }
- return _u.RemoveUsageLogIDs(ids...)
- }
- // Save executes the query and returns the number of nodes affected by the update operation.
- func (_u *AccountUpdate) Save(ctx context.Context) (int, error) {
- if err := _u.defaults(); err != nil {
- return 0, err
- }
- return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
- }
- // SaveX is like Save, but panics if an error occurs.
- func (_u *AccountUpdate) SaveX(ctx context.Context) int {
- affected, err := _u.Save(ctx)
- if err != nil {
- panic(err)
- }
- return affected
- }
- // Exec executes the query.
- func (_u *AccountUpdate) Exec(ctx context.Context) error {
- _, err := _u.Save(ctx)
- return err
- }
- // ExecX is like Exec, but panics if an error occurs.
- func (_u *AccountUpdate) ExecX(ctx context.Context) {
- if err := _u.Exec(ctx); err != nil {
- panic(err)
- }
- }
- // defaults sets the default values of the builder before save.
- func (_u *AccountUpdate) defaults() error {
- if _, ok := _u.mutation.UpdatedAt(); !ok {
- if account.UpdateDefaultUpdatedAt == nil {
- return fmt.Errorf("ent: uninitialized account.UpdateDefaultUpdatedAt (forgotten import ent/runtime?)")
- }
- v := account.UpdateDefaultUpdatedAt()
- _u.mutation.SetUpdatedAt(v)
- }
- return nil
- }
- // check runs all checks and user-defined validators on the builder.
- func (_u *AccountUpdate) check() error {
- if v, ok := _u.mutation.Name(); ok {
- if err := account.NameValidator(v); err != nil {
- return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "Account.name": %w`, err)}
- }
- }
- if v, ok := _u.mutation.Platform(); ok {
- if err := account.PlatformValidator(v); err != nil {
- return &ValidationError{Name: "platform", err: fmt.Errorf(`ent: validator failed for field "Account.platform": %w`, err)}
- }
- }
- if v, ok := _u.mutation.GetType(); ok {
- if err := account.TypeValidator(v); err != nil {
- return &ValidationError{Name: "type", err: fmt.Errorf(`ent: validator failed for field "Account.type": %w`, err)}
- }
- }
- if v, ok := _u.mutation.Status(); ok {
- if err := account.StatusValidator(v); err != nil {
- return &ValidationError{Name: "status", err: fmt.Errorf(`ent: validator failed for field "Account.status": %w`, err)}
- }
- }
- if v, ok := _u.mutation.SessionWindowStatus(); ok {
- if err := account.SessionWindowStatusValidator(v); err != nil {
- return &ValidationError{Name: "session_window_status", err: fmt.Errorf(`ent: validator failed for field "Account.session_window_status": %w`, err)}
- }
- }
- if v, ok := _u.mutation.QuotaDimension(); ok {
- if err := account.QuotaDimensionValidator(v); err != nil {
- return &ValidationError{Name: "quota_dimension", err: fmt.Errorf(`ent: validator failed for field "Account.quota_dimension": %w`, err)}
- }
- }
- return nil
- }
- func (_u *AccountUpdate) sqlSave(ctx context.Context) (_node int, err error) {
- if err := _u.check(); err != nil {
- return _node, err
- }
- _spec := sqlgraph.NewUpdateSpec(account.Table, account.Columns, sqlgraph.NewFieldSpec(account.FieldID, field.TypeInt64))
- if ps := _u.mutation.predicates; len(ps) > 0 {
- _spec.Predicate = func(selector *sql.Selector) {
- for i := range ps {
- ps[i](selector)
- }
- }
- }
- if value, ok := _u.mutation.UpdatedAt(); ok {
- _spec.SetField(account.FieldUpdatedAt, field.TypeTime, value)
- }
- if value, ok := _u.mutation.DeletedAt(); ok {
- _spec.SetField(account.FieldDeletedAt, field.TypeTime, value)
- }
- if _u.mutation.DeletedAtCleared() {
- _spec.ClearField(account.FieldDeletedAt, field.TypeTime)
- }
- if value, ok := _u.mutation.Name(); ok {
- _spec.SetField(account.FieldName, field.TypeString, value)
- }
- if value, ok := _u.mutation.Notes(); ok {
- _spec.SetField(account.FieldNotes, field.TypeString, value)
- }
- if _u.mutation.NotesCleared() {
- _spec.ClearField(account.FieldNotes, field.TypeString)
- }
- if value, ok := _u.mutation.Platform(); ok {
- _spec.SetField(account.FieldPlatform, field.TypeString, value)
- }
- if value, ok := _u.mutation.GetType(); ok {
- _spec.SetField(account.FieldType, field.TypeString, value)
- }
- if value, ok := _u.mutation.Credentials(); ok {
- _spec.SetField(account.FieldCredentials, field.TypeJSON, value)
- }
- if value, ok := _u.mutation.Extra(); ok {
- _spec.SetField(account.FieldExtra, field.TypeJSON, value)
- }
- if value, ok := _u.mutation.ProxyFallbackOriginID(); ok {
- _spec.SetField(account.FieldProxyFallbackOriginID, field.TypeInt64, value)
- }
- if value, ok := _u.mutation.AddedProxyFallbackOriginID(); ok {
- _spec.AddField(account.FieldProxyFallbackOriginID, field.TypeInt64, value)
- }
- if _u.mutation.ProxyFallbackOriginIDCleared() {
- _spec.ClearField(account.FieldProxyFallbackOriginID, field.TypeInt64)
- }
- if value, ok := _u.mutation.Concurrency(); ok {
- _spec.SetField(account.FieldConcurrency, field.TypeInt, value)
- }
- if value, ok := _u.mutation.AddedConcurrency(); ok {
- _spec.AddField(account.FieldConcurrency, field.TypeInt, value)
- }
- if value, ok := _u.mutation.LoadFactor(); ok {
- _spec.SetField(account.FieldLoadFactor, field.TypeInt, value)
- }
- if value, ok := _u.mutation.AddedLoadFactor(); ok {
- _spec.AddField(account.FieldLoadFactor, field.TypeInt, value)
- }
- if _u.mutation.LoadFactorCleared() {
- _spec.ClearField(account.FieldLoadFactor, field.TypeInt)
- }
- if value, ok := _u.mutation.Priority(); ok {
- _spec.SetField(account.FieldPriority, field.TypeInt, value)
- }
- if value, ok := _u.mutation.AddedPriority(); ok {
- _spec.AddField(account.FieldPriority, field.TypeInt, value)
- }
- if value, ok := _u.mutation.RateMultiplier(); ok {
- _spec.SetField(account.FieldRateMultiplier, field.TypeFloat64, value)
- }
- if value, ok := _u.mutation.AddedRateMultiplier(); ok {
- _spec.AddField(account.FieldRateMultiplier, field.TypeFloat64, value)
- }
- if value, ok := _u.mutation.Status(); ok {
- _spec.SetField(account.FieldStatus, field.TypeString, value)
- }
- if value, ok := _u.mutation.ErrorMessage(); ok {
- _spec.SetField(account.FieldErrorMessage, field.TypeString, value)
- }
- if _u.mutation.ErrorMessageCleared() {
- _spec.ClearField(account.FieldErrorMessage, field.TypeString)
- }
- if value, ok := _u.mutation.LastUsedAt(); ok {
- _spec.SetField(account.FieldLastUsedAt, field.TypeTime, value)
- }
- if _u.mutation.LastUsedAtCleared() {
- _spec.ClearField(account.FieldLastUsedAt, field.TypeTime)
- }
- if value, ok := _u.mutation.ExpiresAt(); ok {
- _spec.SetField(account.FieldExpiresAt, field.TypeTime, value)
- }
- if _u.mutation.ExpiresAtCleared() {
- _spec.ClearField(account.FieldExpiresAt, field.TypeTime)
- }
- if value, ok := _u.mutation.AutoPauseOnExpired(); ok {
- _spec.SetField(account.FieldAutoPauseOnExpired, field.TypeBool, value)
- }
- if value, ok := _u.mutation.Schedulable(); ok {
- _spec.SetField(account.FieldSchedulable, field.TypeBool, value)
- }
- if value, ok := _u.mutation.RateLimitedAt(); ok {
- _spec.SetField(account.FieldRateLimitedAt, field.TypeTime, value)
- }
- if _u.mutation.RateLimitedAtCleared() {
- _spec.ClearField(account.FieldRateLimitedAt, field.TypeTime)
- }
- if value, ok := _u.mutation.RateLimitResetAt(); ok {
- _spec.SetField(account.FieldRateLimitResetAt, field.TypeTime, value)
- }
- if _u.mutation.RateLimitResetAtCleared() {
- _spec.ClearField(account.FieldRateLimitResetAt, field.TypeTime)
- }
- if value, ok := _u.mutation.OverloadUntil(); ok {
- _spec.SetField(account.FieldOverloadUntil, field.TypeTime, value)
- }
- if _u.mutation.OverloadUntilCleared() {
- _spec.ClearField(account.FieldOverloadUntil, field.TypeTime)
- }
- if value, ok := _u.mutation.TempUnschedulableUntil(); ok {
- _spec.SetField(account.FieldTempUnschedulableUntil, field.TypeTime, value)
- }
- if _u.mutation.TempUnschedulableUntilCleared() {
- _spec.ClearField(account.FieldTempUnschedulableUntil, field.TypeTime)
- }
- if value, ok := _u.mutation.TempUnschedulableReason(); ok {
- _spec.SetField(account.FieldTempUnschedulableReason, field.TypeString, value)
- }
- if _u.mutation.TempUnschedulableReasonCleared() {
- _spec.ClearField(account.FieldTempUnschedulableReason, field.TypeString)
- }
- if value, ok := _u.mutation.SessionWindowStart(); ok {
- _spec.SetField(account.FieldSessionWindowStart, field.TypeTime, value)
- }
- if _u.mutation.SessionWindowStartCleared() {
- _spec.ClearField(account.FieldSessionWindowStart, field.TypeTime)
- }
- if value, ok := _u.mutation.SessionWindowEnd(); ok {
- _spec.SetField(account.FieldSessionWindowEnd, field.TypeTime, value)
- }
- if _u.mutation.SessionWindowEndCleared() {
- _spec.ClearField(account.FieldSessionWindowEnd, field.TypeTime)
- }
- if value, ok := _u.mutation.SessionWindowStatus(); ok {
- _spec.SetField(account.FieldSessionWindowStatus, field.TypeString, value)
- }
- if _u.mutation.SessionWindowStatusCleared() {
- _spec.ClearField(account.FieldSessionWindowStatus, field.TypeString)
- }
- if value, ok := _u.mutation.QuotaDimension(); ok {
- _spec.SetField(account.FieldQuotaDimension, field.TypeEnum, value)
- }
- if _u.mutation.GroupsCleared() {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.M2M,
- Inverse: false,
- Table: account.GroupsTable,
- Columns: account.GroupsPrimaryKey,
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(group.FieldID, field.TypeInt64),
- },
- }
- createE := &AccountGroupCreate{config: _u.config, mutation: newAccountGroupMutation(_u.config, OpCreate)}
- createE.defaults()
- _, specE := createE.createSpec()
- edge.Target.Fields = specE.Fields
- _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
- }
- if nodes := _u.mutation.RemovedGroupsIDs(); len(nodes) > 0 && !_u.mutation.GroupsCleared() {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.M2M,
- Inverse: false,
- Table: account.GroupsTable,
- Columns: account.GroupsPrimaryKey,
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(group.FieldID, field.TypeInt64),
- },
- }
- for _, k := range nodes {
- edge.Target.Nodes = append(edge.Target.Nodes, k)
- }
- createE := &AccountGroupCreate{config: _u.config, mutation: newAccountGroupMutation(_u.config, OpCreate)}
- createE.defaults()
- _, specE := createE.createSpec()
- edge.Target.Fields = specE.Fields
- _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
- }
- if nodes := _u.mutation.GroupsIDs(); len(nodes) > 0 {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.M2M,
- Inverse: false,
- Table: account.GroupsTable,
- Columns: account.GroupsPrimaryKey,
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(group.FieldID, field.TypeInt64),
- },
- }
- for _, k := range nodes {
- edge.Target.Nodes = append(edge.Target.Nodes, k)
- }
- createE := &AccountGroupCreate{config: _u.config, mutation: newAccountGroupMutation(_u.config, OpCreate)}
- createE.defaults()
- _, specE := createE.createSpec()
- edge.Target.Fields = specE.Fields
- _spec.Edges.Add = append(_spec.Edges.Add, edge)
- }
- if _u.mutation.ProxyCleared() {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.M2O,
- Inverse: false,
- Table: account.ProxyTable,
- Columns: []string{account.ProxyColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(proxy.FieldID, field.TypeInt64),
- },
- }
- _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
- }
- if nodes := _u.mutation.ProxyIDs(); len(nodes) > 0 {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.M2O,
- Inverse: false,
- Table: account.ProxyTable,
- Columns: []string{account.ProxyColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(proxy.FieldID, field.TypeInt64),
- },
- }
- for _, k := range nodes {
- edge.Target.Nodes = append(edge.Target.Nodes, k)
- }
- _spec.Edges.Add = append(_spec.Edges.Add, edge)
- }
- if _u.mutation.ParentCleared() {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.M2O,
- Inverse: true,
- Table: account.ParentTable,
- Columns: []string{account.ParentColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(account.FieldID, field.TypeInt64),
- },
- }
- _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
- }
- if nodes := _u.mutation.ParentIDs(); len(nodes) > 0 {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.M2O,
- Inverse: true,
- Table: account.ParentTable,
- Columns: []string{account.ParentColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(account.FieldID, field.TypeInt64),
- },
- }
- for _, k := range nodes {
- edge.Target.Nodes = append(edge.Target.Nodes, k)
- }
- _spec.Edges.Add = append(_spec.Edges.Add, edge)
- }
- if _u.mutation.ChildrenCleared() {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.O2M,
- Inverse: false,
- Table: account.ChildrenTable,
- Columns: []string{account.ChildrenColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(account.FieldID, field.TypeInt64),
- },
- }
- _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
- }
- if nodes := _u.mutation.RemovedChildrenIDs(); len(nodes) > 0 && !_u.mutation.ChildrenCleared() {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.O2M,
- Inverse: false,
- Table: account.ChildrenTable,
- Columns: []string{account.ChildrenColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(account.FieldID, field.TypeInt64),
- },
- }
- for _, k := range nodes {
- edge.Target.Nodes = append(edge.Target.Nodes, k)
- }
- _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
- }
- if nodes := _u.mutation.ChildrenIDs(); len(nodes) > 0 {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.O2M,
- Inverse: false,
- Table: account.ChildrenTable,
- Columns: []string{account.ChildrenColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(account.FieldID, field.TypeInt64),
- },
- }
- for _, k := range nodes {
- edge.Target.Nodes = append(edge.Target.Nodes, k)
- }
- _spec.Edges.Add = append(_spec.Edges.Add, edge)
- }
- if _u.mutation.UsageLogsCleared() {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.O2M,
- Inverse: false,
- Table: account.UsageLogsTable,
- Columns: []string{account.UsageLogsColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(usagelog.FieldID, field.TypeInt64),
- },
- }
- _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
- }
- if nodes := _u.mutation.RemovedUsageLogsIDs(); len(nodes) > 0 && !_u.mutation.UsageLogsCleared() {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.O2M,
- Inverse: false,
- Table: account.UsageLogsTable,
- Columns: []string{account.UsageLogsColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(usagelog.FieldID, field.TypeInt64),
- },
- }
- for _, k := range nodes {
- edge.Target.Nodes = append(edge.Target.Nodes, k)
- }
- _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
- }
- if nodes := _u.mutation.UsageLogsIDs(); len(nodes) > 0 {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.O2M,
- Inverse: false,
- Table: account.UsageLogsTable,
- Columns: []string{account.UsageLogsColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(usagelog.FieldID, field.TypeInt64),
- },
- }
- for _, k := range nodes {
- edge.Target.Nodes = append(edge.Target.Nodes, k)
- }
- _spec.Edges.Add = append(_spec.Edges.Add, edge)
- }
- if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil {
- if _, ok := err.(*sqlgraph.NotFoundError); ok {
- err = &NotFoundError{account.Label}
- } else if sqlgraph.IsConstraintError(err) {
- err = &ConstraintError{msg: err.Error(), wrap: err}
- }
- return 0, err
- }
- _u.mutation.done = true
- return _node, nil
- }
- // AccountUpdateOne is the builder for updating a single Account entity.
- type AccountUpdateOne struct {
- config
- fields []string
- hooks []Hook
- mutation *AccountMutation
- }
- // SetUpdatedAt sets the "updated_at" field.
- func (_u *AccountUpdateOne) SetUpdatedAt(v time.Time) *AccountUpdateOne {
- _u.mutation.SetUpdatedAt(v)
- return _u
- }
- // SetDeletedAt sets the "deleted_at" field.
- func (_u *AccountUpdateOne) SetDeletedAt(v time.Time) *AccountUpdateOne {
- _u.mutation.SetDeletedAt(v)
- return _u
- }
- // SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.
- func (_u *AccountUpdateOne) SetNillableDeletedAt(v *time.Time) *AccountUpdateOne {
- if v != nil {
- _u.SetDeletedAt(*v)
- }
- return _u
- }
- // ClearDeletedAt clears the value of the "deleted_at" field.
- func (_u *AccountUpdateOne) ClearDeletedAt() *AccountUpdateOne {
- _u.mutation.ClearDeletedAt()
- return _u
- }
- // SetName sets the "name" field.
- func (_u *AccountUpdateOne) SetName(v string) *AccountUpdateOne {
- _u.mutation.SetName(v)
- return _u
- }
- // SetNillableName sets the "name" field if the given value is not nil.
- func (_u *AccountUpdateOne) SetNillableName(v *string) *AccountUpdateOne {
- if v != nil {
- _u.SetName(*v)
- }
- return _u
- }
- // SetNotes sets the "notes" field.
- func (_u *AccountUpdateOne) SetNotes(v string) *AccountUpdateOne {
- _u.mutation.SetNotes(v)
- return _u
- }
- // SetNillableNotes sets the "notes" field if the given value is not nil.
- func (_u *AccountUpdateOne) SetNillableNotes(v *string) *AccountUpdateOne {
- if v != nil {
- _u.SetNotes(*v)
- }
- return _u
- }
- // ClearNotes clears the value of the "notes" field.
- func (_u *AccountUpdateOne) ClearNotes() *AccountUpdateOne {
- _u.mutation.ClearNotes()
- return _u
- }
- // SetPlatform sets the "platform" field.
- func (_u *AccountUpdateOne) SetPlatform(v string) *AccountUpdateOne {
- _u.mutation.SetPlatform(v)
- return _u
- }
- // SetNillablePlatform sets the "platform" field if the given value is not nil.
- func (_u *AccountUpdateOne) SetNillablePlatform(v *string) *AccountUpdateOne {
- if v != nil {
- _u.SetPlatform(*v)
- }
- return _u
- }
- // SetType sets the "type" field.
- func (_u *AccountUpdateOne) SetType(v string) *AccountUpdateOne {
- _u.mutation.SetType(v)
- return _u
- }
- // SetNillableType sets the "type" field if the given value is not nil.
- func (_u *AccountUpdateOne) SetNillableType(v *string) *AccountUpdateOne {
- if v != nil {
- _u.SetType(*v)
- }
- return _u
- }
- // SetCredentials sets the "credentials" field.
- func (_u *AccountUpdateOne) SetCredentials(v map[string]interface{}) *AccountUpdateOne {
- _u.mutation.SetCredentials(v)
- return _u
- }
- // SetExtra sets the "extra" field.
- func (_u *AccountUpdateOne) SetExtra(v map[string]interface{}) *AccountUpdateOne {
- _u.mutation.SetExtra(v)
- return _u
- }
- // SetProxyID sets the "proxy_id" field.
- func (_u *AccountUpdateOne) SetProxyID(v int64) *AccountUpdateOne {
- _u.mutation.SetProxyID(v)
- return _u
- }
- // SetNillableProxyID sets the "proxy_id" field if the given value is not nil.
- func (_u *AccountUpdateOne) SetNillableProxyID(v *int64) *AccountUpdateOne {
- if v != nil {
- _u.SetProxyID(*v)
- }
- return _u
- }
- // ClearProxyID clears the value of the "proxy_id" field.
- func (_u *AccountUpdateOne) ClearProxyID() *AccountUpdateOne {
- _u.mutation.ClearProxyID()
- return _u
- }
- // SetProxyFallbackOriginID sets the "proxy_fallback_origin_id" field.
- func (_u *AccountUpdateOne) SetProxyFallbackOriginID(v int64) *AccountUpdateOne {
- _u.mutation.ResetProxyFallbackOriginID()
- _u.mutation.SetProxyFallbackOriginID(v)
- return _u
- }
- // SetNillableProxyFallbackOriginID sets the "proxy_fallback_origin_id" field if the given value is not nil.
- func (_u *AccountUpdateOne) SetNillableProxyFallbackOriginID(v *int64) *AccountUpdateOne {
- if v != nil {
- _u.SetProxyFallbackOriginID(*v)
- }
- return _u
- }
- // AddProxyFallbackOriginID adds value to the "proxy_fallback_origin_id" field.
- func (_u *AccountUpdateOne) AddProxyFallbackOriginID(v int64) *AccountUpdateOne {
- _u.mutation.AddProxyFallbackOriginID(v)
- return _u
- }
- // ClearProxyFallbackOriginID clears the value of the "proxy_fallback_origin_id" field.
- func (_u *AccountUpdateOne) ClearProxyFallbackOriginID() *AccountUpdateOne {
- _u.mutation.ClearProxyFallbackOriginID()
- return _u
- }
- // SetConcurrency sets the "concurrency" field.
- func (_u *AccountUpdateOne) SetConcurrency(v int) *AccountUpdateOne {
- _u.mutation.ResetConcurrency()
- _u.mutation.SetConcurrency(v)
- return _u
- }
- // SetNillableConcurrency sets the "concurrency" field if the given value is not nil.
- func (_u *AccountUpdateOne) SetNillableConcurrency(v *int) *AccountUpdateOne {
- if v != nil {
- _u.SetConcurrency(*v)
- }
- return _u
- }
- // AddConcurrency adds value to the "concurrency" field.
- func (_u *AccountUpdateOne) AddConcurrency(v int) *AccountUpdateOne {
- _u.mutation.AddConcurrency(v)
- return _u
- }
- // SetLoadFactor sets the "load_factor" field.
- func (_u *AccountUpdateOne) SetLoadFactor(v int) *AccountUpdateOne {
- _u.mutation.ResetLoadFactor()
- _u.mutation.SetLoadFactor(v)
- return _u
- }
- // SetNillableLoadFactor sets the "load_factor" field if the given value is not nil.
- func (_u *AccountUpdateOne) SetNillableLoadFactor(v *int) *AccountUpdateOne {
- if v != nil {
- _u.SetLoadFactor(*v)
- }
- return _u
- }
- // AddLoadFactor adds value to the "load_factor" field.
- func (_u *AccountUpdateOne) AddLoadFactor(v int) *AccountUpdateOne {
- _u.mutation.AddLoadFactor(v)
- return _u
- }
- // ClearLoadFactor clears the value of the "load_factor" field.
- func (_u *AccountUpdateOne) ClearLoadFactor() *AccountUpdateOne {
- _u.mutation.ClearLoadFactor()
- return _u
- }
- // SetPriority sets the "priority" field.
- func (_u *AccountUpdateOne) SetPriority(v int) *AccountUpdateOne {
- _u.mutation.ResetPriority()
- _u.mutation.SetPriority(v)
- return _u
- }
- // SetNillablePriority sets the "priority" field if the given value is not nil.
- func (_u *AccountUpdateOne) SetNillablePriority(v *int) *AccountUpdateOne {
- if v != nil {
- _u.SetPriority(*v)
- }
- return _u
- }
- // AddPriority adds value to the "priority" field.
- func (_u *AccountUpdateOne) AddPriority(v int) *AccountUpdateOne {
- _u.mutation.AddPriority(v)
- return _u
- }
- // SetRateMultiplier sets the "rate_multiplier" field.
- func (_u *AccountUpdateOne) SetRateMultiplier(v float64) *AccountUpdateOne {
- _u.mutation.ResetRateMultiplier()
- _u.mutation.SetRateMultiplier(v)
- return _u
- }
- // SetNillableRateMultiplier sets the "rate_multiplier" field if the given value is not nil.
- func (_u *AccountUpdateOne) SetNillableRateMultiplier(v *float64) *AccountUpdateOne {
- if v != nil {
- _u.SetRateMultiplier(*v)
- }
- return _u
- }
- // AddRateMultiplier adds value to the "rate_multiplier" field.
- func (_u *AccountUpdateOne) AddRateMultiplier(v float64) *AccountUpdateOne {
- _u.mutation.AddRateMultiplier(v)
- return _u
- }
- // SetStatus sets the "status" field.
- func (_u *AccountUpdateOne) SetStatus(v string) *AccountUpdateOne {
- _u.mutation.SetStatus(v)
- return _u
- }
- // SetNillableStatus sets the "status" field if the given value is not nil.
- func (_u *AccountUpdateOne) SetNillableStatus(v *string) *AccountUpdateOne {
- if v != nil {
- _u.SetStatus(*v)
- }
- return _u
- }
- // SetErrorMessage sets the "error_message" field.
- func (_u *AccountUpdateOne) SetErrorMessage(v string) *AccountUpdateOne {
- _u.mutation.SetErrorMessage(v)
- return _u
- }
- // SetNillableErrorMessage sets the "error_message" field if the given value is not nil.
- func (_u *AccountUpdateOne) SetNillableErrorMessage(v *string) *AccountUpdateOne {
- if v != nil {
- _u.SetErrorMessage(*v)
- }
- return _u
- }
- // ClearErrorMessage clears the value of the "error_message" field.
- func (_u *AccountUpdateOne) ClearErrorMessage() *AccountUpdateOne {
- _u.mutation.ClearErrorMessage()
- return _u
- }
- // SetLastUsedAt sets the "last_used_at" field.
- func (_u *AccountUpdateOne) SetLastUsedAt(v time.Time) *AccountUpdateOne {
- _u.mutation.SetLastUsedAt(v)
- return _u
- }
- // SetNillableLastUsedAt sets the "last_used_at" field if the given value is not nil.
- func (_u *AccountUpdateOne) SetNillableLastUsedAt(v *time.Time) *AccountUpdateOne {
- if v != nil {
- _u.SetLastUsedAt(*v)
- }
- return _u
- }
- // ClearLastUsedAt clears the value of the "last_used_at" field.
- func (_u *AccountUpdateOne) ClearLastUsedAt() *AccountUpdateOne {
- _u.mutation.ClearLastUsedAt()
- return _u
- }
- // SetExpiresAt sets the "expires_at" field.
- func (_u *AccountUpdateOne) SetExpiresAt(v time.Time) *AccountUpdateOne {
- _u.mutation.SetExpiresAt(v)
- return _u
- }
- // SetNillableExpiresAt sets the "expires_at" field if the given value is not nil.
- func (_u *AccountUpdateOne) SetNillableExpiresAt(v *time.Time) *AccountUpdateOne {
- if v != nil {
- _u.SetExpiresAt(*v)
- }
- return _u
- }
- // ClearExpiresAt clears the value of the "expires_at" field.
- func (_u *AccountUpdateOne) ClearExpiresAt() *AccountUpdateOne {
- _u.mutation.ClearExpiresAt()
- return _u
- }
- // SetAutoPauseOnExpired sets the "auto_pause_on_expired" field.
- func (_u *AccountUpdateOne) SetAutoPauseOnExpired(v bool) *AccountUpdateOne {
- _u.mutation.SetAutoPauseOnExpired(v)
- return _u
- }
- // SetNillableAutoPauseOnExpired sets the "auto_pause_on_expired" field if the given value is not nil.
- func (_u *AccountUpdateOne) SetNillableAutoPauseOnExpired(v *bool) *AccountUpdateOne {
- if v != nil {
- _u.SetAutoPauseOnExpired(*v)
- }
- return _u
- }
- // SetSchedulable sets the "schedulable" field.
- func (_u *AccountUpdateOne) SetSchedulable(v bool) *AccountUpdateOne {
- _u.mutation.SetSchedulable(v)
- return _u
- }
- // SetNillableSchedulable sets the "schedulable" field if the given value is not nil.
- func (_u *AccountUpdateOne) SetNillableSchedulable(v *bool) *AccountUpdateOne {
- if v != nil {
- _u.SetSchedulable(*v)
- }
- return _u
- }
- // SetRateLimitedAt sets the "rate_limited_at" field.
- func (_u *AccountUpdateOne) SetRateLimitedAt(v time.Time) *AccountUpdateOne {
- _u.mutation.SetRateLimitedAt(v)
- return _u
- }
- // SetNillableRateLimitedAt sets the "rate_limited_at" field if the given value is not nil.
- func (_u *AccountUpdateOne) SetNillableRateLimitedAt(v *time.Time) *AccountUpdateOne {
- if v != nil {
- _u.SetRateLimitedAt(*v)
- }
- return _u
- }
- // ClearRateLimitedAt clears the value of the "rate_limited_at" field.
- func (_u *AccountUpdateOne) ClearRateLimitedAt() *AccountUpdateOne {
- _u.mutation.ClearRateLimitedAt()
- return _u
- }
- // SetRateLimitResetAt sets the "rate_limit_reset_at" field.
- func (_u *AccountUpdateOne) SetRateLimitResetAt(v time.Time) *AccountUpdateOne {
- _u.mutation.SetRateLimitResetAt(v)
- return _u
- }
- // SetNillableRateLimitResetAt sets the "rate_limit_reset_at" field if the given value is not nil.
- func (_u *AccountUpdateOne) SetNillableRateLimitResetAt(v *time.Time) *AccountUpdateOne {
- if v != nil {
- _u.SetRateLimitResetAt(*v)
- }
- return _u
- }
- // ClearRateLimitResetAt clears the value of the "rate_limit_reset_at" field.
- func (_u *AccountUpdateOne) ClearRateLimitResetAt() *AccountUpdateOne {
- _u.mutation.ClearRateLimitResetAt()
- return _u
- }
- // SetOverloadUntil sets the "overload_until" field.
- func (_u *AccountUpdateOne) SetOverloadUntil(v time.Time) *AccountUpdateOne {
- _u.mutation.SetOverloadUntil(v)
- return _u
- }
- // SetNillableOverloadUntil sets the "overload_until" field if the given value is not nil.
- func (_u *AccountUpdateOne) SetNillableOverloadUntil(v *time.Time) *AccountUpdateOne {
- if v != nil {
- _u.SetOverloadUntil(*v)
- }
- return _u
- }
- // ClearOverloadUntil clears the value of the "overload_until" field.
- func (_u *AccountUpdateOne) ClearOverloadUntil() *AccountUpdateOne {
- _u.mutation.ClearOverloadUntil()
- return _u
- }
- // SetTempUnschedulableUntil sets the "temp_unschedulable_until" field.
- func (_u *AccountUpdateOne) SetTempUnschedulableUntil(v time.Time) *AccountUpdateOne {
- _u.mutation.SetTempUnschedulableUntil(v)
- return _u
- }
- // SetNillableTempUnschedulableUntil sets the "temp_unschedulable_until" field if the given value is not nil.
- func (_u *AccountUpdateOne) SetNillableTempUnschedulableUntil(v *time.Time) *AccountUpdateOne {
- if v != nil {
- _u.SetTempUnschedulableUntil(*v)
- }
- return _u
- }
- // ClearTempUnschedulableUntil clears the value of the "temp_unschedulable_until" field.
- func (_u *AccountUpdateOne) ClearTempUnschedulableUntil() *AccountUpdateOne {
- _u.mutation.ClearTempUnschedulableUntil()
- return _u
- }
- // SetTempUnschedulableReason sets the "temp_unschedulable_reason" field.
- func (_u *AccountUpdateOne) SetTempUnschedulableReason(v string) *AccountUpdateOne {
- _u.mutation.SetTempUnschedulableReason(v)
- return _u
- }
- // SetNillableTempUnschedulableReason sets the "temp_unschedulable_reason" field if the given value is not nil.
- func (_u *AccountUpdateOne) SetNillableTempUnschedulableReason(v *string) *AccountUpdateOne {
- if v != nil {
- _u.SetTempUnschedulableReason(*v)
- }
- return _u
- }
- // ClearTempUnschedulableReason clears the value of the "temp_unschedulable_reason" field.
- func (_u *AccountUpdateOne) ClearTempUnschedulableReason() *AccountUpdateOne {
- _u.mutation.ClearTempUnschedulableReason()
- return _u
- }
- // SetSessionWindowStart sets the "session_window_start" field.
- func (_u *AccountUpdateOne) SetSessionWindowStart(v time.Time) *AccountUpdateOne {
- _u.mutation.SetSessionWindowStart(v)
- return _u
- }
- // SetNillableSessionWindowStart sets the "session_window_start" field if the given value is not nil.
- func (_u *AccountUpdateOne) SetNillableSessionWindowStart(v *time.Time) *AccountUpdateOne {
- if v != nil {
- _u.SetSessionWindowStart(*v)
- }
- return _u
- }
- // ClearSessionWindowStart clears the value of the "session_window_start" field.
- func (_u *AccountUpdateOne) ClearSessionWindowStart() *AccountUpdateOne {
- _u.mutation.ClearSessionWindowStart()
- return _u
- }
- // SetSessionWindowEnd sets the "session_window_end" field.
- func (_u *AccountUpdateOne) SetSessionWindowEnd(v time.Time) *AccountUpdateOne {
- _u.mutation.SetSessionWindowEnd(v)
- return _u
- }
- // SetNillableSessionWindowEnd sets the "session_window_end" field if the given value is not nil.
- func (_u *AccountUpdateOne) SetNillableSessionWindowEnd(v *time.Time) *AccountUpdateOne {
- if v != nil {
- _u.SetSessionWindowEnd(*v)
- }
- return _u
- }
- // ClearSessionWindowEnd clears the value of the "session_window_end" field.
- func (_u *AccountUpdateOne) ClearSessionWindowEnd() *AccountUpdateOne {
- _u.mutation.ClearSessionWindowEnd()
- return _u
- }
- // SetSessionWindowStatus sets the "session_window_status" field.
- func (_u *AccountUpdateOne) SetSessionWindowStatus(v string) *AccountUpdateOne {
- _u.mutation.SetSessionWindowStatus(v)
- return _u
- }
- // SetNillableSessionWindowStatus sets the "session_window_status" field if the given value is not nil.
- func (_u *AccountUpdateOne) SetNillableSessionWindowStatus(v *string) *AccountUpdateOne {
- if v != nil {
- _u.SetSessionWindowStatus(*v)
- }
- return _u
- }
- // ClearSessionWindowStatus clears the value of the "session_window_status" field.
- func (_u *AccountUpdateOne) ClearSessionWindowStatus() *AccountUpdateOne {
- _u.mutation.ClearSessionWindowStatus()
- return _u
- }
- // SetParentAccountID sets the "parent_account_id" field.
- func (_u *AccountUpdateOne) SetParentAccountID(v int64) *AccountUpdateOne {
- _u.mutation.SetParentAccountID(v)
- return _u
- }
- // SetNillableParentAccountID sets the "parent_account_id" field if the given value is not nil.
- func (_u *AccountUpdateOne) SetNillableParentAccountID(v *int64) *AccountUpdateOne {
- if v != nil {
- _u.SetParentAccountID(*v)
- }
- return _u
- }
- // ClearParentAccountID clears the value of the "parent_account_id" field.
- func (_u *AccountUpdateOne) ClearParentAccountID() *AccountUpdateOne {
- _u.mutation.ClearParentAccountID()
- return _u
- }
- // SetQuotaDimension sets the "quota_dimension" field.
- func (_u *AccountUpdateOne) SetQuotaDimension(v account.QuotaDimension) *AccountUpdateOne {
- _u.mutation.SetQuotaDimension(v)
- return _u
- }
- // SetNillableQuotaDimension sets the "quota_dimension" field if the given value is not nil.
- func (_u *AccountUpdateOne) SetNillableQuotaDimension(v *account.QuotaDimension) *AccountUpdateOne {
- if v != nil {
- _u.SetQuotaDimension(*v)
- }
- return _u
- }
- // AddGroupIDs adds the "groups" edge to the Group entity by IDs.
- func (_u *AccountUpdateOne) AddGroupIDs(ids ...int64) *AccountUpdateOne {
- _u.mutation.AddGroupIDs(ids...)
- return _u
- }
- // AddGroups adds the "groups" edges to the Group entity.
- func (_u *AccountUpdateOne) AddGroups(v ...*Group) *AccountUpdateOne {
- ids := make([]int64, len(v))
- for i := range v {
- ids[i] = v[i].ID
- }
- return _u.AddGroupIDs(ids...)
- }
- // SetProxy sets the "proxy" edge to the Proxy entity.
- func (_u *AccountUpdateOne) SetProxy(v *Proxy) *AccountUpdateOne {
- return _u.SetProxyID(v.ID)
- }
- // SetParentID sets the "parent" edge to the Account entity by ID.
- func (_u *AccountUpdateOne) SetParentID(id int64) *AccountUpdateOne {
- _u.mutation.SetParentID(id)
- return _u
- }
- // SetNillableParentID sets the "parent" edge to the Account entity by ID if the given value is not nil.
- func (_u *AccountUpdateOne) SetNillableParentID(id *int64) *AccountUpdateOne {
- if id != nil {
- _u = _u.SetParentID(*id)
- }
- return _u
- }
- // SetParent sets the "parent" edge to the Account entity.
- func (_u *AccountUpdateOne) SetParent(v *Account) *AccountUpdateOne {
- return _u.SetParentID(v.ID)
- }
- // AddChildIDs adds the "children" edge to the Account entity by IDs.
- func (_u *AccountUpdateOne) AddChildIDs(ids ...int64) *AccountUpdateOne {
- _u.mutation.AddChildIDs(ids...)
- return _u
- }
- // AddChildren adds the "children" edges to the Account entity.
- func (_u *AccountUpdateOne) AddChildren(v ...*Account) *AccountUpdateOne {
- ids := make([]int64, len(v))
- for i := range v {
- ids[i] = v[i].ID
- }
- return _u.AddChildIDs(ids...)
- }
- // AddUsageLogIDs adds the "usage_logs" edge to the UsageLog entity by IDs.
- func (_u *AccountUpdateOne) AddUsageLogIDs(ids ...int64) *AccountUpdateOne {
- _u.mutation.AddUsageLogIDs(ids...)
- return _u
- }
- // AddUsageLogs adds the "usage_logs" edges to the UsageLog entity.
- func (_u *AccountUpdateOne) AddUsageLogs(v ...*UsageLog) *AccountUpdateOne {
- ids := make([]int64, len(v))
- for i := range v {
- ids[i] = v[i].ID
- }
- return _u.AddUsageLogIDs(ids...)
- }
- // Mutation returns the AccountMutation object of the builder.
- func (_u *AccountUpdateOne) Mutation() *AccountMutation {
- return _u.mutation
- }
- // ClearGroups clears all "groups" edges to the Group entity.
- func (_u *AccountUpdateOne) ClearGroups() *AccountUpdateOne {
- _u.mutation.ClearGroups()
- return _u
- }
- // RemoveGroupIDs removes the "groups" edge to Group entities by IDs.
- func (_u *AccountUpdateOne) RemoveGroupIDs(ids ...int64) *AccountUpdateOne {
- _u.mutation.RemoveGroupIDs(ids...)
- return _u
- }
- // RemoveGroups removes "groups" edges to Group entities.
- func (_u *AccountUpdateOne) RemoveGroups(v ...*Group) *AccountUpdateOne {
- ids := make([]int64, len(v))
- for i := range v {
- ids[i] = v[i].ID
- }
- return _u.RemoveGroupIDs(ids...)
- }
- // ClearProxy clears the "proxy" edge to the Proxy entity.
- func (_u *AccountUpdateOne) ClearProxy() *AccountUpdateOne {
- _u.mutation.ClearProxy()
- return _u
- }
- // ClearParent clears the "parent" edge to the Account entity.
- func (_u *AccountUpdateOne) ClearParent() *AccountUpdateOne {
- _u.mutation.ClearParent()
- return _u
- }
- // ClearChildren clears all "children" edges to the Account entity.
- func (_u *AccountUpdateOne) ClearChildren() *AccountUpdateOne {
- _u.mutation.ClearChildren()
- return _u
- }
- // RemoveChildIDs removes the "children" edge to Account entities by IDs.
- func (_u *AccountUpdateOne) RemoveChildIDs(ids ...int64) *AccountUpdateOne {
- _u.mutation.RemoveChildIDs(ids...)
- return _u
- }
- // RemoveChildren removes "children" edges to Account entities.
- func (_u *AccountUpdateOne) RemoveChildren(v ...*Account) *AccountUpdateOne {
- ids := make([]int64, len(v))
- for i := range v {
- ids[i] = v[i].ID
- }
- return _u.RemoveChildIDs(ids...)
- }
- // ClearUsageLogs clears all "usage_logs" edges to the UsageLog entity.
- func (_u *AccountUpdateOne) ClearUsageLogs() *AccountUpdateOne {
- _u.mutation.ClearUsageLogs()
- return _u
- }
- // RemoveUsageLogIDs removes the "usage_logs" edge to UsageLog entities by IDs.
- func (_u *AccountUpdateOne) RemoveUsageLogIDs(ids ...int64) *AccountUpdateOne {
- _u.mutation.RemoveUsageLogIDs(ids...)
- return _u
- }
- // RemoveUsageLogs removes "usage_logs" edges to UsageLog entities.
- func (_u *AccountUpdateOne) RemoveUsageLogs(v ...*UsageLog) *AccountUpdateOne {
- ids := make([]int64, len(v))
- for i := range v {
- ids[i] = v[i].ID
- }
- return _u.RemoveUsageLogIDs(ids...)
- }
- // Where appends a list predicates to the AccountUpdate builder.
- func (_u *AccountUpdateOne) Where(ps ...predicate.Account) *AccountUpdateOne {
- _u.mutation.Where(ps...)
- return _u
- }
- // Select allows selecting one or more fields (columns) of the returned entity.
- // The default is selecting all fields defined in the entity schema.
- func (_u *AccountUpdateOne) Select(field string, fields ...string) *AccountUpdateOne {
- _u.fields = append([]string{field}, fields...)
- return _u
- }
- // Save executes the query and returns the updated Account entity.
- func (_u *AccountUpdateOne) Save(ctx context.Context) (*Account, error) {
- if err := _u.defaults(); err != nil {
- return nil, err
- }
- return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
- }
- // SaveX is like Save, but panics if an error occurs.
- func (_u *AccountUpdateOne) SaveX(ctx context.Context) *Account {
- node, err := _u.Save(ctx)
- if err != nil {
- panic(err)
- }
- return node
- }
- // Exec executes the query on the entity.
- func (_u *AccountUpdateOne) Exec(ctx context.Context) error {
- _, err := _u.Save(ctx)
- return err
- }
- // ExecX is like Exec, but panics if an error occurs.
- func (_u *AccountUpdateOne) ExecX(ctx context.Context) {
- if err := _u.Exec(ctx); err != nil {
- panic(err)
- }
- }
- // defaults sets the default values of the builder before save.
- func (_u *AccountUpdateOne) defaults() error {
- if _, ok := _u.mutation.UpdatedAt(); !ok {
- if account.UpdateDefaultUpdatedAt == nil {
- return fmt.Errorf("ent: uninitialized account.UpdateDefaultUpdatedAt (forgotten import ent/runtime?)")
- }
- v := account.UpdateDefaultUpdatedAt()
- _u.mutation.SetUpdatedAt(v)
- }
- return nil
- }
- // check runs all checks and user-defined validators on the builder.
- func (_u *AccountUpdateOne) check() error {
- if v, ok := _u.mutation.Name(); ok {
- if err := account.NameValidator(v); err != nil {
- return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "Account.name": %w`, err)}
- }
- }
- if v, ok := _u.mutation.Platform(); ok {
- if err := account.PlatformValidator(v); err != nil {
- return &ValidationError{Name: "platform", err: fmt.Errorf(`ent: validator failed for field "Account.platform": %w`, err)}
- }
- }
- if v, ok := _u.mutation.GetType(); ok {
- if err := account.TypeValidator(v); err != nil {
- return &ValidationError{Name: "type", err: fmt.Errorf(`ent: validator failed for field "Account.type": %w`, err)}
- }
- }
- if v, ok := _u.mutation.Status(); ok {
- if err := account.StatusValidator(v); err != nil {
- return &ValidationError{Name: "status", err: fmt.Errorf(`ent: validator failed for field "Account.status": %w`, err)}
- }
- }
- if v, ok := _u.mutation.SessionWindowStatus(); ok {
- if err := account.SessionWindowStatusValidator(v); err != nil {
- return &ValidationError{Name: "session_window_status", err: fmt.Errorf(`ent: validator failed for field "Account.session_window_status": %w`, err)}
- }
- }
- if v, ok := _u.mutation.QuotaDimension(); ok {
- if err := account.QuotaDimensionValidator(v); err != nil {
- return &ValidationError{Name: "quota_dimension", err: fmt.Errorf(`ent: validator failed for field "Account.quota_dimension": %w`, err)}
- }
- }
- return nil
- }
- func (_u *AccountUpdateOne) sqlSave(ctx context.Context) (_node *Account, err error) {
- if err := _u.check(); err != nil {
- return _node, err
- }
- _spec := sqlgraph.NewUpdateSpec(account.Table, account.Columns, sqlgraph.NewFieldSpec(account.FieldID, field.TypeInt64))
- id, ok := _u.mutation.ID()
- if !ok {
- return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Account.id" for update`)}
- }
- _spec.Node.ID.Value = id
- if fields := _u.fields; len(fields) > 0 {
- _spec.Node.Columns = make([]string, 0, len(fields))
- _spec.Node.Columns = append(_spec.Node.Columns, account.FieldID)
- for _, f := range fields {
- if !account.ValidColumn(f) {
- return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
- }
- if f != account.FieldID {
- _spec.Node.Columns = append(_spec.Node.Columns, f)
- }
- }
- }
- if ps := _u.mutation.predicates; len(ps) > 0 {
- _spec.Predicate = func(selector *sql.Selector) {
- for i := range ps {
- ps[i](selector)
- }
- }
- }
- if value, ok := _u.mutation.UpdatedAt(); ok {
- _spec.SetField(account.FieldUpdatedAt, field.TypeTime, value)
- }
- if value, ok := _u.mutation.DeletedAt(); ok {
- _spec.SetField(account.FieldDeletedAt, field.TypeTime, value)
- }
- if _u.mutation.DeletedAtCleared() {
- _spec.ClearField(account.FieldDeletedAt, field.TypeTime)
- }
- if value, ok := _u.mutation.Name(); ok {
- _spec.SetField(account.FieldName, field.TypeString, value)
- }
- if value, ok := _u.mutation.Notes(); ok {
- _spec.SetField(account.FieldNotes, field.TypeString, value)
- }
- if _u.mutation.NotesCleared() {
- _spec.ClearField(account.FieldNotes, field.TypeString)
- }
- if value, ok := _u.mutation.Platform(); ok {
- _spec.SetField(account.FieldPlatform, field.TypeString, value)
- }
- if value, ok := _u.mutation.GetType(); ok {
- _spec.SetField(account.FieldType, field.TypeString, value)
- }
- if value, ok := _u.mutation.Credentials(); ok {
- _spec.SetField(account.FieldCredentials, field.TypeJSON, value)
- }
- if value, ok := _u.mutation.Extra(); ok {
- _spec.SetField(account.FieldExtra, field.TypeJSON, value)
- }
- if value, ok := _u.mutation.ProxyFallbackOriginID(); ok {
- _spec.SetField(account.FieldProxyFallbackOriginID, field.TypeInt64, value)
- }
- if value, ok := _u.mutation.AddedProxyFallbackOriginID(); ok {
- _spec.AddField(account.FieldProxyFallbackOriginID, field.TypeInt64, value)
- }
- if _u.mutation.ProxyFallbackOriginIDCleared() {
- _spec.ClearField(account.FieldProxyFallbackOriginID, field.TypeInt64)
- }
- if value, ok := _u.mutation.Concurrency(); ok {
- _spec.SetField(account.FieldConcurrency, field.TypeInt, value)
- }
- if value, ok := _u.mutation.AddedConcurrency(); ok {
- _spec.AddField(account.FieldConcurrency, field.TypeInt, value)
- }
- if value, ok := _u.mutation.LoadFactor(); ok {
- _spec.SetField(account.FieldLoadFactor, field.TypeInt, value)
- }
- if value, ok := _u.mutation.AddedLoadFactor(); ok {
- _spec.AddField(account.FieldLoadFactor, field.TypeInt, value)
- }
- if _u.mutation.LoadFactorCleared() {
- _spec.ClearField(account.FieldLoadFactor, field.TypeInt)
- }
- if value, ok := _u.mutation.Priority(); ok {
- _spec.SetField(account.FieldPriority, field.TypeInt, value)
- }
- if value, ok := _u.mutation.AddedPriority(); ok {
- _spec.AddField(account.FieldPriority, field.TypeInt, value)
- }
- if value, ok := _u.mutation.RateMultiplier(); ok {
- _spec.SetField(account.FieldRateMultiplier, field.TypeFloat64, value)
- }
- if value, ok := _u.mutation.AddedRateMultiplier(); ok {
- _spec.AddField(account.FieldRateMultiplier, field.TypeFloat64, value)
- }
- if value, ok := _u.mutation.Status(); ok {
- _spec.SetField(account.FieldStatus, field.TypeString, value)
- }
- if value, ok := _u.mutation.ErrorMessage(); ok {
- _spec.SetField(account.FieldErrorMessage, field.TypeString, value)
- }
- if _u.mutation.ErrorMessageCleared() {
- _spec.ClearField(account.FieldErrorMessage, field.TypeString)
- }
- if value, ok := _u.mutation.LastUsedAt(); ok {
- _spec.SetField(account.FieldLastUsedAt, field.TypeTime, value)
- }
- if _u.mutation.LastUsedAtCleared() {
- _spec.ClearField(account.FieldLastUsedAt, field.TypeTime)
- }
- if value, ok := _u.mutation.ExpiresAt(); ok {
- _spec.SetField(account.FieldExpiresAt, field.TypeTime, value)
- }
- if _u.mutation.ExpiresAtCleared() {
- _spec.ClearField(account.FieldExpiresAt, field.TypeTime)
- }
- if value, ok := _u.mutation.AutoPauseOnExpired(); ok {
- _spec.SetField(account.FieldAutoPauseOnExpired, field.TypeBool, value)
- }
- if value, ok := _u.mutation.Schedulable(); ok {
- _spec.SetField(account.FieldSchedulable, field.TypeBool, value)
- }
- if value, ok := _u.mutation.RateLimitedAt(); ok {
- _spec.SetField(account.FieldRateLimitedAt, field.TypeTime, value)
- }
- if _u.mutation.RateLimitedAtCleared() {
- _spec.ClearField(account.FieldRateLimitedAt, field.TypeTime)
- }
- if value, ok := _u.mutation.RateLimitResetAt(); ok {
- _spec.SetField(account.FieldRateLimitResetAt, field.TypeTime, value)
- }
- if _u.mutation.RateLimitResetAtCleared() {
- _spec.ClearField(account.FieldRateLimitResetAt, field.TypeTime)
- }
- if value, ok := _u.mutation.OverloadUntil(); ok {
- _spec.SetField(account.FieldOverloadUntil, field.TypeTime, value)
- }
- if _u.mutation.OverloadUntilCleared() {
- _spec.ClearField(account.FieldOverloadUntil, field.TypeTime)
- }
- if value, ok := _u.mutation.TempUnschedulableUntil(); ok {
- _spec.SetField(account.FieldTempUnschedulableUntil, field.TypeTime, value)
- }
- if _u.mutation.TempUnschedulableUntilCleared() {
- _spec.ClearField(account.FieldTempUnschedulableUntil, field.TypeTime)
- }
- if value, ok := _u.mutation.TempUnschedulableReason(); ok {
- _spec.SetField(account.FieldTempUnschedulableReason, field.TypeString, value)
- }
- if _u.mutation.TempUnschedulableReasonCleared() {
- _spec.ClearField(account.FieldTempUnschedulableReason, field.TypeString)
- }
- if value, ok := _u.mutation.SessionWindowStart(); ok {
- _spec.SetField(account.FieldSessionWindowStart, field.TypeTime, value)
- }
- if _u.mutation.SessionWindowStartCleared() {
- _spec.ClearField(account.FieldSessionWindowStart, field.TypeTime)
- }
- if value, ok := _u.mutation.SessionWindowEnd(); ok {
- _spec.SetField(account.FieldSessionWindowEnd, field.TypeTime, value)
- }
- if _u.mutation.SessionWindowEndCleared() {
- _spec.ClearField(account.FieldSessionWindowEnd, field.TypeTime)
- }
- if value, ok := _u.mutation.SessionWindowStatus(); ok {
- _spec.SetField(account.FieldSessionWindowStatus, field.TypeString, value)
- }
- if _u.mutation.SessionWindowStatusCleared() {
- _spec.ClearField(account.FieldSessionWindowStatus, field.TypeString)
- }
- if value, ok := _u.mutation.QuotaDimension(); ok {
- _spec.SetField(account.FieldQuotaDimension, field.TypeEnum, value)
- }
- if _u.mutation.GroupsCleared() {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.M2M,
- Inverse: false,
- Table: account.GroupsTable,
- Columns: account.GroupsPrimaryKey,
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(group.FieldID, field.TypeInt64),
- },
- }
- createE := &AccountGroupCreate{config: _u.config, mutation: newAccountGroupMutation(_u.config, OpCreate)}
- createE.defaults()
- _, specE := createE.createSpec()
- edge.Target.Fields = specE.Fields
- _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
- }
- if nodes := _u.mutation.RemovedGroupsIDs(); len(nodes) > 0 && !_u.mutation.GroupsCleared() {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.M2M,
- Inverse: false,
- Table: account.GroupsTable,
- Columns: account.GroupsPrimaryKey,
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(group.FieldID, field.TypeInt64),
- },
- }
- for _, k := range nodes {
- edge.Target.Nodes = append(edge.Target.Nodes, k)
- }
- createE := &AccountGroupCreate{config: _u.config, mutation: newAccountGroupMutation(_u.config, OpCreate)}
- createE.defaults()
- _, specE := createE.createSpec()
- edge.Target.Fields = specE.Fields
- _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
- }
- if nodes := _u.mutation.GroupsIDs(); len(nodes) > 0 {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.M2M,
- Inverse: false,
- Table: account.GroupsTable,
- Columns: account.GroupsPrimaryKey,
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(group.FieldID, field.TypeInt64),
- },
- }
- for _, k := range nodes {
- edge.Target.Nodes = append(edge.Target.Nodes, k)
- }
- createE := &AccountGroupCreate{config: _u.config, mutation: newAccountGroupMutation(_u.config, OpCreate)}
- createE.defaults()
- _, specE := createE.createSpec()
- edge.Target.Fields = specE.Fields
- _spec.Edges.Add = append(_spec.Edges.Add, edge)
- }
- if _u.mutation.ProxyCleared() {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.M2O,
- Inverse: false,
- Table: account.ProxyTable,
- Columns: []string{account.ProxyColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(proxy.FieldID, field.TypeInt64),
- },
- }
- _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
- }
- if nodes := _u.mutation.ProxyIDs(); len(nodes) > 0 {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.M2O,
- Inverse: false,
- Table: account.ProxyTable,
- Columns: []string{account.ProxyColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(proxy.FieldID, field.TypeInt64),
- },
- }
- for _, k := range nodes {
- edge.Target.Nodes = append(edge.Target.Nodes, k)
- }
- _spec.Edges.Add = append(_spec.Edges.Add, edge)
- }
- if _u.mutation.ParentCleared() {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.M2O,
- Inverse: true,
- Table: account.ParentTable,
- Columns: []string{account.ParentColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(account.FieldID, field.TypeInt64),
- },
- }
- _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
- }
- if nodes := _u.mutation.ParentIDs(); len(nodes) > 0 {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.M2O,
- Inverse: true,
- Table: account.ParentTable,
- Columns: []string{account.ParentColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(account.FieldID, field.TypeInt64),
- },
- }
- for _, k := range nodes {
- edge.Target.Nodes = append(edge.Target.Nodes, k)
- }
- _spec.Edges.Add = append(_spec.Edges.Add, edge)
- }
- if _u.mutation.ChildrenCleared() {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.O2M,
- Inverse: false,
- Table: account.ChildrenTable,
- Columns: []string{account.ChildrenColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(account.FieldID, field.TypeInt64),
- },
- }
- _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
- }
- if nodes := _u.mutation.RemovedChildrenIDs(); len(nodes) > 0 && !_u.mutation.ChildrenCleared() {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.O2M,
- Inverse: false,
- Table: account.ChildrenTable,
- Columns: []string{account.ChildrenColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(account.FieldID, field.TypeInt64),
- },
- }
- for _, k := range nodes {
- edge.Target.Nodes = append(edge.Target.Nodes, k)
- }
- _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
- }
- if nodes := _u.mutation.ChildrenIDs(); len(nodes) > 0 {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.O2M,
- Inverse: false,
- Table: account.ChildrenTable,
- Columns: []string{account.ChildrenColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(account.FieldID, field.TypeInt64),
- },
- }
- for _, k := range nodes {
- edge.Target.Nodes = append(edge.Target.Nodes, k)
- }
- _spec.Edges.Add = append(_spec.Edges.Add, edge)
- }
- if _u.mutation.UsageLogsCleared() {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.O2M,
- Inverse: false,
- Table: account.UsageLogsTable,
- Columns: []string{account.UsageLogsColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(usagelog.FieldID, field.TypeInt64),
- },
- }
- _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
- }
- if nodes := _u.mutation.RemovedUsageLogsIDs(); len(nodes) > 0 && !_u.mutation.UsageLogsCleared() {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.O2M,
- Inverse: false,
- Table: account.UsageLogsTable,
- Columns: []string{account.UsageLogsColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(usagelog.FieldID, field.TypeInt64),
- },
- }
- for _, k := range nodes {
- edge.Target.Nodes = append(edge.Target.Nodes, k)
- }
- _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
- }
- if nodes := _u.mutation.UsageLogsIDs(); len(nodes) > 0 {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.O2M,
- Inverse: false,
- Table: account.UsageLogsTable,
- Columns: []string{account.UsageLogsColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(usagelog.FieldID, field.TypeInt64),
- },
- }
- for _, k := range nodes {
- edge.Target.Nodes = append(edge.Target.Nodes, k)
- }
- _spec.Edges.Add = append(_spec.Edges.Add, edge)
- }
- _node = &Account{config: _u.config}
- _spec.Assign = _node.assignValues
- _spec.ScanValues = _node.scanValues
- if err = sqlgraph.UpdateNode(ctx, _u.driver, _spec); err != nil {
- if _, ok := err.(*sqlgraph.NotFoundError); ok {
- err = &NotFoundError{account.Label}
- } else if sqlgraph.IsConstraintError(err) {
- err = &ConstraintError{msg: err.Error(), wrap: err}
- }
- return nil, err
- }
- _u.mutation.done = true
- return _node, nil
- }
|