| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938 |
- // 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/channelmonitor"
- "github.com/Wei-Shaw/sub2api/ent/channelmonitordailyrollup"
- "github.com/Wei-Shaw/sub2api/ent/channelmonitorhistory"
- "github.com/Wei-Shaw/sub2api/ent/channelmonitorrequesttemplate"
- )
- // ChannelMonitorCreate is the builder for creating a ChannelMonitor entity.
- type ChannelMonitorCreate struct {
- config
- mutation *ChannelMonitorMutation
- hooks []Hook
- conflict []sql.ConflictOption
- }
- // SetCreatedAt sets the "created_at" field.
- func (_c *ChannelMonitorCreate) SetCreatedAt(v time.Time) *ChannelMonitorCreate {
- _c.mutation.SetCreatedAt(v)
- return _c
- }
- // SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
- func (_c *ChannelMonitorCreate) SetNillableCreatedAt(v *time.Time) *ChannelMonitorCreate {
- if v != nil {
- _c.SetCreatedAt(*v)
- }
- return _c
- }
- // SetUpdatedAt sets the "updated_at" field.
- func (_c *ChannelMonitorCreate) SetUpdatedAt(v time.Time) *ChannelMonitorCreate {
- _c.mutation.SetUpdatedAt(v)
- return _c
- }
- // SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
- func (_c *ChannelMonitorCreate) SetNillableUpdatedAt(v *time.Time) *ChannelMonitorCreate {
- if v != nil {
- _c.SetUpdatedAt(*v)
- }
- return _c
- }
- // SetName sets the "name" field.
- func (_c *ChannelMonitorCreate) SetName(v string) *ChannelMonitorCreate {
- _c.mutation.SetName(v)
- return _c
- }
- // SetProvider sets the "provider" field.
- func (_c *ChannelMonitorCreate) SetProvider(v channelmonitor.Provider) *ChannelMonitorCreate {
- _c.mutation.SetProvider(v)
- return _c
- }
- // SetCheckMode sets the "check_mode" field.
- func (_c *ChannelMonitorCreate) SetCheckMode(v string) *ChannelMonitorCreate {
- _c.mutation.SetCheckMode(v)
- return _c
- }
- // SetNillableCheckMode sets the "check_mode" field if the given value is not nil.
- func (_c *ChannelMonitorCreate) SetNillableCheckMode(v *string) *ChannelMonitorCreate {
- if v != nil {
- _c.SetCheckMode(*v)
- }
- return _c
- }
- // SetAccountID sets the "account_id" field.
- func (_c *ChannelMonitorCreate) SetAccountID(v int64) *ChannelMonitorCreate {
- _c.mutation.SetAccountID(v)
- return _c
- }
- // SetNillableAccountID sets the "account_id" field if the given value is not nil.
- func (_c *ChannelMonitorCreate) SetNillableAccountID(v *int64) *ChannelMonitorCreate {
- if v != nil {
- _c.SetAccountID(*v)
- }
- return _c
- }
- // SetAPIMode sets the "api_mode" field.
- func (_c *ChannelMonitorCreate) SetAPIMode(v string) *ChannelMonitorCreate {
- _c.mutation.SetAPIMode(v)
- return _c
- }
- // SetNillableAPIMode sets the "api_mode" field if the given value is not nil.
- func (_c *ChannelMonitorCreate) SetNillableAPIMode(v *string) *ChannelMonitorCreate {
- if v != nil {
- _c.SetAPIMode(*v)
- }
- return _c
- }
- // SetEndpoint sets the "endpoint" field.
- func (_c *ChannelMonitorCreate) SetEndpoint(v string) *ChannelMonitorCreate {
- _c.mutation.SetEndpoint(v)
- return _c
- }
- // SetAPIKeyEncrypted sets the "api_key_encrypted" field.
- func (_c *ChannelMonitorCreate) SetAPIKeyEncrypted(v string) *ChannelMonitorCreate {
- _c.mutation.SetAPIKeyEncrypted(v)
- return _c
- }
- // SetPrimaryModel sets the "primary_model" field.
- func (_c *ChannelMonitorCreate) SetPrimaryModel(v string) *ChannelMonitorCreate {
- _c.mutation.SetPrimaryModel(v)
- return _c
- }
- // SetExtraModels sets the "extra_models" field.
- func (_c *ChannelMonitorCreate) SetExtraModels(v []string) *ChannelMonitorCreate {
- _c.mutation.SetExtraModels(v)
- return _c
- }
- // SetGroupName sets the "group_name" field.
- func (_c *ChannelMonitorCreate) SetGroupName(v string) *ChannelMonitorCreate {
- _c.mutation.SetGroupName(v)
- return _c
- }
- // SetNillableGroupName sets the "group_name" field if the given value is not nil.
- func (_c *ChannelMonitorCreate) SetNillableGroupName(v *string) *ChannelMonitorCreate {
- if v != nil {
- _c.SetGroupName(*v)
- }
- return _c
- }
- // SetEnabled sets the "enabled" field.
- func (_c *ChannelMonitorCreate) SetEnabled(v bool) *ChannelMonitorCreate {
- _c.mutation.SetEnabled(v)
- return _c
- }
- // SetNillableEnabled sets the "enabled" field if the given value is not nil.
- func (_c *ChannelMonitorCreate) SetNillableEnabled(v *bool) *ChannelMonitorCreate {
- if v != nil {
- _c.SetEnabled(*v)
- }
- return _c
- }
- // SetIntervalSeconds sets the "interval_seconds" field.
- func (_c *ChannelMonitorCreate) SetIntervalSeconds(v int) *ChannelMonitorCreate {
- _c.mutation.SetIntervalSeconds(v)
- return _c
- }
- // SetJitterSeconds sets the "jitter_seconds" field.
- func (_c *ChannelMonitorCreate) SetJitterSeconds(v int) *ChannelMonitorCreate {
- _c.mutation.SetJitterSeconds(v)
- return _c
- }
- // SetNillableJitterSeconds sets the "jitter_seconds" field if the given value is not nil.
- func (_c *ChannelMonitorCreate) SetNillableJitterSeconds(v *int) *ChannelMonitorCreate {
- if v != nil {
- _c.SetJitterSeconds(*v)
- }
- return _c
- }
- // SetLastCheckedAt sets the "last_checked_at" field.
- func (_c *ChannelMonitorCreate) SetLastCheckedAt(v time.Time) *ChannelMonitorCreate {
- _c.mutation.SetLastCheckedAt(v)
- return _c
- }
- // SetNillableLastCheckedAt sets the "last_checked_at" field if the given value is not nil.
- func (_c *ChannelMonitorCreate) SetNillableLastCheckedAt(v *time.Time) *ChannelMonitorCreate {
- if v != nil {
- _c.SetLastCheckedAt(*v)
- }
- return _c
- }
- // SetCreatedBy sets the "created_by" field.
- func (_c *ChannelMonitorCreate) SetCreatedBy(v int64) *ChannelMonitorCreate {
- _c.mutation.SetCreatedBy(v)
- return _c
- }
- // SetTemplateID sets the "template_id" field.
- func (_c *ChannelMonitorCreate) SetTemplateID(v int64) *ChannelMonitorCreate {
- _c.mutation.SetTemplateID(v)
- return _c
- }
- // SetNillableTemplateID sets the "template_id" field if the given value is not nil.
- func (_c *ChannelMonitorCreate) SetNillableTemplateID(v *int64) *ChannelMonitorCreate {
- if v != nil {
- _c.SetTemplateID(*v)
- }
- return _c
- }
- // SetExtraHeaders sets the "extra_headers" field.
- func (_c *ChannelMonitorCreate) SetExtraHeaders(v map[string]string) *ChannelMonitorCreate {
- _c.mutation.SetExtraHeaders(v)
- return _c
- }
- // SetBodyOverrideMode sets the "body_override_mode" field.
- func (_c *ChannelMonitorCreate) SetBodyOverrideMode(v string) *ChannelMonitorCreate {
- _c.mutation.SetBodyOverrideMode(v)
- return _c
- }
- // SetNillableBodyOverrideMode sets the "body_override_mode" field if the given value is not nil.
- func (_c *ChannelMonitorCreate) SetNillableBodyOverrideMode(v *string) *ChannelMonitorCreate {
- if v != nil {
- _c.SetBodyOverrideMode(*v)
- }
- return _c
- }
- // SetBodyOverride sets the "body_override" field.
- func (_c *ChannelMonitorCreate) SetBodyOverride(v map[string]interface{}) *ChannelMonitorCreate {
- _c.mutation.SetBodyOverride(v)
- return _c
- }
- // AddHistoryIDs adds the "history" edge to the ChannelMonitorHistory entity by IDs.
- func (_c *ChannelMonitorCreate) AddHistoryIDs(ids ...int64) *ChannelMonitorCreate {
- _c.mutation.AddHistoryIDs(ids...)
- return _c
- }
- // AddHistory adds the "history" edges to the ChannelMonitorHistory entity.
- func (_c *ChannelMonitorCreate) AddHistory(v ...*ChannelMonitorHistory) *ChannelMonitorCreate {
- ids := make([]int64, len(v))
- for i := range v {
- ids[i] = v[i].ID
- }
- return _c.AddHistoryIDs(ids...)
- }
- // AddDailyRollupIDs adds the "daily_rollups" edge to the ChannelMonitorDailyRollup entity by IDs.
- func (_c *ChannelMonitorCreate) AddDailyRollupIDs(ids ...int64) *ChannelMonitorCreate {
- _c.mutation.AddDailyRollupIDs(ids...)
- return _c
- }
- // AddDailyRollups adds the "daily_rollups" edges to the ChannelMonitorDailyRollup entity.
- func (_c *ChannelMonitorCreate) AddDailyRollups(v ...*ChannelMonitorDailyRollup) *ChannelMonitorCreate {
- ids := make([]int64, len(v))
- for i := range v {
- ids[i] = v[i].ID
- }
- return _c.AddDailyRollupIDs(ids...)
- }
- // SetRequestTemplateID sets the "request_template" edge to the ChannelMonitorRequestTemplate entity by ID.
- func (_c *ChannelMonitorCreate) SetRequestTemplateID(id int64) *ChannelMonitorCreate {
- _c.mutation.SetRequestTemplateID(id)
- return _c
- }
- // SetNillableRequestTemplateID sets the "request_template" edge to the ChannelMonitorRequestTemplate entity by ID if the given value is not nil.
- func (_c *ChannelMonitorCreate) SetNillableRequestTemplateID(id *int64) *ChannelMonitorCreate {
- if id != nil {
- _c = _c.SetRequestTemplateID(*id)
- }
- return _c
- }
- // SetRequestTemplate sets the "request_template" edge to the ChannelMonitorRequestTemplate entity.
- func (_c *ChannelMonitorCreate) SetRequestTemplate(v *ChannelMonitorRequestTemplate) *ChannelMonitorCreate {
- return _c.SetRequestTemplateID(v.ID)
- }
- // Mutation returns the ChannelMonitorMutation object of the builder.
- func (_c *ChannelMonitorCreate) Mutation() *ChannelMonitorMutation {
- return _c.mutation
- }
- // Save creates the ChannelMonitor in the database.
- func (_c *ChannelMonitorCreate) Save(ctx context.Context) (*ChannelMonitor, error) {
- _c.defaults()
- return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks)
- }
- // SaveX calls Save and panics if Save returns an error.
- func (_c *ChannelMonitorCreate) SaveX(ctx context.Context) *ChannelMonitor {
- v, err := _c.Save(ctx)
- if err != nil {
- panic(err)
- }
- return v
- }
- // Exec executes the query.
- func (_c *ChannelMonitorCreate) Exec(ctx context.Context) error {
- _, err := _c.Save(ctx)
- return err
- }
- // ExecX is like Exec, but panics if an error occurs.
- func (_c *ChannelMonitorCreate) ExecX(ctx context.Context) {
- if err := _c.Exec(ctx); err != nil {
- panic(err)
- }
- }
- // defaults sets the default values of the builder before save.
- func (_c *ChannelMonitorCreate) defaults() {
- if _, ok := _c.mutation.CreatedAt(); !ok {
- v := channelmonitor.DefaultCreatedAt()
- _c.mutation.SetCreatedAt(v)
- }
- if _, ok := _c.mutation.UpdatedAt(); !ok {
- v := channelmonitor.DefaultUpdatedAt()
- _c.mutation.SetUpdatedAt(v)
- }
- if _, ok := _c.mutation.CheckMode(); !ok {
- v := channelmonitor.DefaultCheckMode
- _c.mutation.SetCheckMode(v)
- }
- if _, ok := _c.mutation.APIMode(); !ok {
- v := channelmonitor.DefaultAPIMode
- _c.mutation.SetAPIMode(v)
- }
- if _, ok := _c.mutation.ExtraModels(); !ok {
- v := channelmonitor.DefaultExtraModels
- _c.mutation.SetExtraModels(v)
- }
- if _, ok := _c.mutation.GroupName(); !ok {
- v := channelmonitor.DefaultGroupName
- _c.mutation.SetGroupName(v)
- }
- if _, ok := _c.mutation.Enabled(); !ok {
- v := channelmonitor.DefaultEnabled
- _c.mutation.SetEnabled(v)
- }
- if _, ok := _c.mutation.JitterSeconds(); !ok {
- v := channelmonitor.DefaultJitterSeconds
- _c.mutation.SetJitterSeconds(v)
- }
- if _, ok := _c.mutation.ExtraHeaders(); !ok {
- v := channelmonitor.DefaultExtraHeaders
- _c.mutation.SetExtraHeaders(v)
- }
- if _, ok := _c.mutation.BodyOverrideMode(); !ok {
- v := channelmonitor.DefaultBodyOverrideMode
- _c.mutation.SetBodyOverrideMode(v)
- }
- }
- // check runs all checks and user-defined validators on the builder.
- func (_c *ChannelMonitorCreate) check() error {
- if _, ok := _c.mutation.CreatedAt(); !ok {
- return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "ChannelMonitor.created_at"`)}
- }
- if _, ok := _c.mutation.UpdatedAt(); !ok {
- return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "ChannelMonitor.updated_at"`)}
- }
- if _, ok := _c.mutation.Name(); !ok {
- return &ValidationError{Name: "name", err: errors.New(`ent: missing required field "ChannelMonitor.name"`)}
- }
- if v, ok := _c.mutation.Name(); ok {
- if err := channelmonitor.NameValidator(v); err != nil {
- return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "ChannelMonitor.name": %w`, err)}
- }
- }
- if _, ok := _c.mutation.Provider(); !ok {
- return &ValidationError{Name: "provider", err: errors.New(`ent: missing required field "ChannelMonitor.provider"`)}
- }
- if v, ok := _c.mutation.Provider(); ok {
- if err := channelmonitor.ProviderValidator(v); err != nil {
- return &ValidationError{Name: "provider", err: fmt.Errorf(`ent: validator failed for field "ChannelMonitor.provider": %w`, err)}
- }
- }
- if _, ok := _c.mutation.CheckMode(); !ok {
- return &ValidationError{Name: "check_mode", err: errors.New(`ent: missing required field "ChannelMonitor.check_mode"`)}
- }
- if v, ok := _c.mutation.CheckMode(); ok {
- if err := channelmonitor.CheckModeValidator(v); err != nil {
- return &ValidationError{Name: "check_mode", err: fmt.Errorf(`ent: validator failed for field "ChannelMonitor.check_mode": %w`, err)}
- }
- }
- if _, ok := _c.mutation.APIMode(); !ok {
- return &ValidationError{Name: "api_mode", err: errors.New(`ent: missing required field "ChannelMonitor.api_mode"`)}
- }
- if v, ok := _c.mutation.APIMode(); ok {
- if err := channelmonitor.APIModeValidator(v); err != nil {
- return &ValidationError{Name: "api_mode", err: fmt.Errorf(`ent: validator failed for field "ChannelMonitor.api_mode": %w`, err)}
- }
- }
- if _, ok := _c.mutation.Endpoint(); !ok {
- return &ValidationError{Name: "endpoint", err: errors.New(`ent: missing required field "ChannelMonitor.endpoint"`)}
- }
- if v, ok := _c.mutation.Endpoint(); ok {
- if err := channelmonitor.EndpointValidator(v); err != nil {
- return &ValidationError{Name: "endpoint", err: fmt.Errorf(`ent: validator failed for field "ChannelMonitor.endpoint": %w`, err)}
- }
- }
- if _, ok := _c.mutation.APIKeyEncrypted(); !ok {
- return &ValidationError{Name: "api_key_encrypted", err: errors.New(`ent: missing required field "ChannelMonitor.api_key_encrypted"`)}
- }
- if v, ok := _c.mutation.APIKeyEncrypted(); ok {
- if err := channelmonitor.APIKeyEncryptedValidator(v); err != nil {
- return &ValidationError{Name: "api_key_encrypted", err: fmt.Errorf(`ent: validator failed for field "ChannelMonitor.api_key_encrypted": %w`, err)}
- }
- }
- if _, ok := _c.mutation.PrimaryModel(); !ok {
- return &ValidationError{Name: "primary_model", err: errors.New(`ent: missing required field "ChannelMonitor.primary_model"`)}
- }
- if v, ok := _c.mutation.PrimaryModel(); ok {
- if err := channelmonitor.PrimaryModelValidator(v); err != nil {
- return &ValidationError{Name: "primary_model", err: fmt.Errorf(`ent: validator failed for field "ChannelMonitor.primary_model": %w`, err)}
- }
- }
- if _, ok := _c.mutation.ExtraModels(); !ok {
- return &ValidationError{Name: "extra_models", err: errors.New(`ent: missing required field "ChannelMonitor.extra_models"`)}
- }
- if v, ok := _c.mutation.GroupName(); ok {
- if err := channelmonitor.GroupNameValidator(v); err != nil {
- return &ValidationError{Name: "group_name", err: fmt.Errorf(`ent: validator failed for field "ChannelMonitor.group_name": %w`, err)}
- }
- }
- if _, ok := _c.mutation.Enabled(); !ok {
- return &ValidationError{Name: "enabled", err: errors.New(`ent: missing required field "ChannelMonitor.enabled"`)}
- }
- if _, ok := _c.mutation.IntervalSeconds(); !ok {
- return &ValidationError{Name: "interval_seconds", err: errors.New(`ent: missing required field "ChannelMonitor.interval_seconds"`)}
- }
- if v, ok := _c.mutation.IntervalSeconds(); ok {
- if err := channelmonitor.IntervalSecondsValidator(v); err != nil {
- return &ValidationError{Name: "interval_seconds", err: fmt.Errorf(`ent: validator failed for field "ChannelMonitor.interval_seconds": %w`, err)}
- }
- }
- if _, ok := _c.mutation.JitterSeconds(); !ok {
- return &ValidationError{Name: "jitter_seconds", err: errors.New(`ent: missing required field "ChannelMonitor.jitter_seconds"`)}
- }
- if v, ok := _c.mutation.JitterSeconds(); ok {
- if err := channelmonitor.JitterSecondsValidator(v); err != nil {
- return &ValidationError{Name: "jitter_seconds", err: fmt.Errorf(`ent: validator failed for field "ChannelMonitor.jitter_seconds": %w`, err)}
- }
- }
- if _, ok := _c.mutation.CreatedBy(); !ok {
- return &ValidationError{Name: "created_by", err: errors.New(`ent: missing required field "ChannelMonitor.created_by"`)}
- }
- if _, ok := _c.mutation.ExtraHeaders(); !ok {
- return &ValidationError{Name: "extra_headers", err: errors.New(`ent: missing required field "ChannelMonitor.extra_headers"`)}
- }
- if _, ok := _c.mutation.BodyOverrideMode(); !ok {
- return &ValidationError{Name: "body_override_mode", err: errors.New(`ent: missing required field "ChannelMonitor.body_override_mode"`)}
- }
- if v, ok := _c.mutation.BodyOverrideMode(); ok {
- if err := channelmonitor.BodyOverrideModeValidator(v); err != nil {
- return &ValidationError{Name: "body_override_mode", err: fmt.Errorf(`ent: validator failed for field "ChannelMonitor.body_override_mode": %w`, err)}
- }
- }
- return nil
- }
- func (_c *ChannelMonitorCreate) sqlSave(ctx context.Context) (*ChannelMonitor, error) {
- if err := _c.check(); err != nil {
- return nil, err
- }
- _node, _spec := _c.createSpec()
- if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil {
- if sqlgraph.IsConstraintError(err) {
- err = &ConstraintError{msg: err.Error(), wrap: err}
- }
- return nil, err
- }
- id := _spec.ID.Value.(int64)
- _node.ID = int64(id)
- _c.mutation.id = &_node.ID
- _c.mutation.done = true
- return _node, nil
- }
- func (_c *ChannelMonitorCreate) createSpec() (*ChannelMonitor, *sqlgraph.CreateSpec) {
- var (
- _node = &ChannelMonitor{config: _c.config}
- _spec = sqlgraph.NewCreateSpec(channelmonitor.Table, sqlgraph.NewFieldSpec(channelmonitor.FieldID, field.TypeInt64))
- )
- _spec.OnConflict = _c.conflict
- if value, ok := _c.mutation.CreatedAt(); ok {
- _spec.SetField(channelmonitor.FieldCreatedAt, field.TypeTime, value)
- _node.CreatedAt = value
- }
- if value, ok := _c.mutation.UpdatedAt(); ok {
- _spec.SetField(channelmonitor.FieldUpdatedAt, field.TypeTime, value)
- _node.UpdatedAt = value
- }
- if value, ok := _c.mutation.Name(); ok {
- _spec.SetField(channelmonitor.FieldName, field.TypeString, value)
- _node.Name = value
- }
- if value, ok := _c.mutation.Provider(); ok {
- _spec.SetField(channelmonitor.FieldProvider, field.TypeEnum, value)
- _node.Provider = value
- }
- if value, ok := _c.mutation.CheckMode(); ok {
- _spec.SetField(channelmonitor.FieldCheckMode, field.TypeString, value)
- _node.CheckMode = value
- }
- if value, ok := _c.mutation.AccountID(); ok {
- _spec.SetField(channelmonitor.FieldAccountID, field.TypeInt64, value)
- _node.AccountID = &value
- }
- if value, ok := _c.mutation.APIMode(); ok {
- _spec.SetField(channelmonitor.FieldAPIMode, field.TypeString, value)
- _node.APIMode = value
- }
- if value, ok := _c.mutation.Endpoint(); ok {
- _spec.SetField(channelmonitor.FieldEndpoint, field.TypeString, value)
- _node.Endpoint = value
- }
- if value, ok := _c.mutation.APIKeyEncrypted(); ok {
- _spec.SetField(channelmonitor.FieldAPIKeyEncrypted, field.TypeString, value)
- _node.APIKeyEncrypted = value
- }
- if value, ok := _c.mutation.PrimaryModel(); ok {
- _spec.SetField(channelmonitor.FieldPrimaryModel, field.TypeString, value)
- _node.PrimaryModel = value
- }
- if value, ok := _c.mutation.ExtraModels(); ok {
- _spec.SetField(channelmonitor.FieldExtraModels, field.TypeJSON, value)
- _node.ExtraModels = value
- }
- if value, ok := _c.mutation.GroupName(); ok {
- _spec.SetField(channelmonitor.FieldGroupName, field.TypeString, value)
- _node.GroupName = value
- }
- if value, ok := _c.mutation.Enabled(); ok {
- _spec.SetField(channelmonitor.FieldEnabled, field.TypeBool, value)
- _node.Enabled = value
- }
- if value, ok := _c.mutation.IntervalSeconds(); ok {
- _spec.SetField(channelmonitor.FieldIntervalSeconds, field.TypeInt, value)
- _node.IntervalSeconds = value
- }
- if value, ok := _c.mutation.JitterSeconds(); ok {
- _spec.SetField(channelmonitor.FieldJitterSeconds, field.TypeInt, value)
- _node.JitterSeconds = value
- }
- if value, ok := _c.mutation.LastCheckedAt(); ok {
- _spec.SetField(channelmonitor.FieldLastCheckedAt, field.TypeTime, value)
- _node.LastCheckedAt = &value
- }
- if value, ok := _c.mutation.CreatedBy(); ok {
- _spec.SetField(channelmonitor.FieldCreatedBy, field.TypeInt64, value)
- _node.CreatedBy = value
- }
- if value, ok := _c.mutation.ExtraHeaders(); ok {
- _spec.SetField(channelmonitor.FieldExtraHeaders, field.TypeJSON, value)
- _node.ExtraHeaders = value
- }
- if value, ok := _c.mutation.BodyOverrideMode(); ok {
- _spec.SetField(channelmonitor.FieldBodyOverrideMode, field.TypeString, value)
- _node.BodyOverrideMode = value
- }
- if value, ok := _c.mutation.BodyOverride(); ok {
- _spec.SetField(channelmonitor.FieldBodyOverride, field.TypeJSON, value)
- _node.BodyOverride = value
- }
- if nodes := _c.mutation.HistoryIDs(); len(nodes) > 0 {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.O2M,
- Inverse: false,
- Table: channelmonitor.HistoryTable,
- Columns: []string{channelmonitor.HistoryColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(channelmonitorhistory.FieldID, field.TypeInt64),
- },
- }
- for _, k := range nodes {
- edge.Target.Nodes = append(edge.Target.Nodes, k)
- }
- _spec.Edges = append(_spec.Edges, edge)
- }
- if nodes := _c.mutation.DailyRollupsIDs(); len(nodes) > 0 {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.O2M,
- Inverse: false,
- Table: channelmonitor.DailyRollupsTable,
- Columns: []string{channelmonitor.DailyRollupsColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(channelmonitordailyrollup.FieldID, field.TypeInt64),
- },
- }
- for _, k := range nodes {
- edge.Target.Nodes = append(edge.Target.Nodes, k)
- }
- _spec.Edges = append(_spec.Edges, edge)
- }
- if nodes := _c.mutation.RequestTemplateIDs(); len(nodes) > 0 {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.M2O,
- Inverse: false,
- Table: channelmonitor.RequestTemplateTable,
- Columns: []string{channelmonitor.RequestTemplateColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(channelmonitorrequesttemplate.FieldID, field.TypeInt64),
- },
- }
- for _, k := range nodes {
- edge.Target.Nodes = append(edge.Target.Nodes, k)
- }
- _node.TemplateID = &nodes[0]
- _spec.Edges = append(_spec.Edges, edge)
- }
- return _node, _spec
- }
- // OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
- // of the `INSERT` statement. For example:
- //
- // client.ChannelMonitor.Create().
- // SetCreatedAt(v).
- // OnConflict(
- // // Update the row with the new values
- // // the was proposed for insertion.
- // sql.ResolveWithNewValues(),
- // ).
- // // Override some of the fields with custom
- // // update values.
- // Update(func(u *ent.ChannelMonitorUpsert) {
- // SetCreatedAt(v+v).
- // }).
- // Exec(ctx)
- func (_c *ChannelMonitorCreate) OnConflict(opts ...sql.ConflictOption) *ChannelMonitorUpsertOne {
- _c.conflict = opts
- return &ChannelMonitorUpsertOne{
- create: _c,
- }
- }
- // OnConflictColumns calls `OnConflict` and configures the columns
- // as conflict target. Using this option is equivalent to using:
- //
- // client.ChannelMonitor.Create().
- // OnConflict(sql.ConflictColumns(columns...)).
- // Exec(ctx)
- func (_c *ChannelMonitorCreate) OnConflictColumns(columns ...string) *ChannelMonitorUpsertOne {
- _c.conflict = append(_c.conflict, sql.ConflictColumns(columns...))
- return &ChannelMonitorUpsertOne{
- create: _c,
- }
- }
- type (
- // ChannelMonitorUpsertOne is the builder for "upsert"-ing
- // one ChannelMonitor node.
- ChannelMonitorUpsertOne struct {
- create *ChannelMonitorCreate
- }
- // ChannelMonitorUpsert is the "OnConflict" setter.
- ChannelMonitorUpsert struct {
- *sql.UpdateSet
- }
- )
- // SetUpdatedAt sets the "updated_at" field.
- func (u *ChannelMonitorUpsert) SetUpdatedAt(v time.Time) *ChannelMonitorUpsert {
- u.Set(channelmonitor.FieldUpdatedAt, v)
- return u
- }
- // UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
- func (u *ChannelMonitorUpsert) UpdateUpdatedAt() *ChannelMonitorUpsert {
- u.SetExcluded(channelmonitor.FieldUpdatedAt)
- return u
- }
- // SetName sets the "name" field.
- func (u *ChannelMonitorUpsert) SetName(v string) *ChannelMonitorUpsert {
- u.Set(channelmonitor.FieldName, v)
- return u
- }
- // UpdateName sets the "name" field to the value that was provided on create.
- func (u *ChannelMonitorUpsert) UpdateName() *ChannelMonitorUpsert {
- u.SetExcluded(channelmonitor.FieldName)
- return u
- }
- // SetProvider sets the "provider" field.
- func (u *ChannelMonitorUpsert) SetProvider(v channelmonitor.Provider) *ChannelMonitorUpsert {
- u.Set(channelmonitor.FieldProvider, v)
- return u
- }
- // UpdateProvider sets the "provider" field to the value that was provided on create.
- func (u *ChannelMonitorUpsert) UpdateProvider() *ChannelMonitorUpsert {
- u.SetExcluded(channelmonitor.FieldProvider)
- return u
- }
- // SetCheckMode sets the "check_mode" field.
- func (u *ChannelMonitorUpsert) SetCheckMode(v string) *ChannelMonitorUpsert {
- u.Set(channelmonitor.FieldCheckMode, v)
- return u
- }
- // UpdateCheckMode sets the "check_mode" field to the value that was provided on create.
- func (u *ChannelMonitorUpsert) UpdateCheckMode() *ChannelMonitorUpsert {
- u.SetExcluded(channelmonitor.FieldCheckMode)
- return u
- }
- // SetAccountID sets the "account_id" field.
- func (u *ChannelMonitorUpsert) SetAccountID(v int64) *ChannelMonitorUpsert {
- u.Set(channelmonitor.FieldAccountID, v)
- return u
- }
- // UpdateAccountID sets the "account_id" field to the value that was provided on create.
- func (u *ChannelMonitorUpsert) UpdateAccountID() *ChannelMonitorUpsert {
- u.SetExcluded(channelmonitor.FieldAccountID)
- return u
- }
- // AddAccountID adds v to the "account_id" field.
- func (u *ChannelMonitorUpsert) AddAccountID(v int64) *ChannelMonitorUpsert {
- u.Add(channelmonitor.FieldAccountID, v)
- return u
- }
- // ClearAccountID clears the value of the "account_id" field.
- func (u *ChannelMonitorUpsert) ClearAccountID() *ChannelMonitorUpsert {
- u.SetNull(channelmonitor.FieldAccountID)
- return u
- }
- // SetAPIMode sets the "api_mode" field.
- func (u *ChannelMonitorUpsert) SetAPIMode(v string) *ChannelMonitorUpsert {
- u.Set(channelmonitor.FieldAPIMode, v)
- return u
- }
- // UpdateAPIMode sets the "api_mode" field to the value that was provided on create.
- func (u *ChannelMonitorUpsert) UpdateAPIMode() *ChannelMonitorUpsert {
- u.SetExcluded(channelmonitor.FieldAPIMode)
- return u
- }
- // SetEndpoint sets the "endpoint" field.
- func (u *ChannelMonitorUpsert) SetEndpoint(v string) *ChannelMonitorUpsert {
- u.Set(channelmonitor.FieldEndpoint, v)
- return u
- }
- // UpdateEndpoint sets the "endpoint" field to the value that was provided on create.
- func (u *ChannelMonitorUpsert) UpdateEndpoint() *ChannelMonitorUpsert {
- u.SetExcluded(channelmonitor.FieldEndpoint)
- return u
- }
- // SetAPIKeyEncrypted sets the "api_key_encrypted" field.
- func (u *ChannelMonitorUpsert) SetAPIKeyEncrypted(v string) *ChannelMonitorUpsert {
- u.Set(channelmonitor.FieldAPIKeyEncrypted, v)
- return u
- }
- // UpdateAPIKeyEncrypted sets the "api_key_encrypted" field to the value that was provided on create.
- func (u *ChannelMonitorUpsert) UpdateAPIKeyEncrypted() *ChannelMonitorUpsert {
- u.SetExcluded(channelmonitor.FieldAPIKeyEncrypted)
- return u
- }
- // SetPrimaryModel sets the "primary_model" field.
- func (u *ChannelMonitorUpsert) SetPrimaryModel(v string) *ChannelMonitorUpsert {
- u.Set(channelmonitor.FieldPrimaryModel, v)
- return u
- }
- // UpdatePrimaryModel sets the "primary_model" field to the value that was provided on create.
- func (u *ChannelMonitorUpsert) UpdatePrimaryModel() *ChannelMonitorUpsert {
- u.SetExcluded(channelmonitor.FieldPrimaryModel)
- return u
- }
- // SetExtraModels sets the "extra_models" field.
- func (u *ChannelMonitorUpsert) SetExtraModels(v []string) *ChannelMonitorUpsert {
- u.Set(channelmonitor.FieldExtraModels, v)
- return u
- }
- // UpdateExtraModels sets the "extra_models" field to the value that was provided on create.
- func (u *ChannelMonitorUpsert) UpdateExtraModels() *ChannelMonitorUpsert {
- u.SetExcluded(channelmonitor.FieldExtraModels)
- return u
- }
- // SetGroupName sets the "group_name" field.
- func (u *ChannelMonitorUpsert) SetGroupName(v string) *ChannelMonitorUpsert {
- u.Set(channelmonitor.FieldGroupName, v)
- return u
- }
- // UpdateGroupName sets the "group_name" field to the value that was provided on create.
- func (u *ChannelMonitorUpsert) UpdateGroupName() *ChannelMonitorUpsert {
- u.SetExcluded(channelmonitor.FieldGroupName)
- return u
- }
- // ClearGroupName clears the value of the "group_name" field.
- func (u *ChannelMonitorUpsert) ClearGroupName() *ChannelMonitorUpsert {
- u.SetNull(channelmonitor.FieldGroupName)
- return u
- }
- // SetEnabled sets the "enabled" field.
- func (u *ChannelMonitorUpsert) SetEnabled(v bool) *ChannelMonitorUpsert {
- u.Set(channelmonitor.FieldEnabled, v)
- return u
- }
- // UpdateEnabled sets the "enabled" field to the value that was provided on create.
- func (u *ChannelMonitorUpsert) UpdateEnabled() *ChannelMonitorUpsert {
- u.SetExcluded(channelmonitor.FieldEnabled)
- return u
- }
- // SetIntervalSeconds sets the "interval_seconds" field.
- func (u *ChannelMonitorUpsert) SetIntervalSeconds(v int) *ChannelMonitorUpsert {
- u.Set(channelmonitor.FieldIntervalSeconds, v)
- return u
- }
- // UpdateIntervalSeconds sets the "interval_seconds" field to the value that was provided on create.
- func (u *ChannelMonitorUpsert) UpdateIntervalSeconds() *ChannelMonitorUpsert {
- u.SetExcluded(channelmonitor.FieldIntervalSeconds)
- return u
- }
- // AddIntervalSeconds adds v to the "interval_seconds" field.
- func (u *ChannelMonitorUpsert) AddIntervalSeconds(v int) *ChannelMonitorUpsert {
- u.Add(channelmonitor.FieldIntervalSeconds, v)
- return u
- }
- // SetJitterSeconds sets the "jitter_seconds" field.
- func (u *ChannelMonitorUpsert) SetJitterSeconds(v int) *ChannelMonitorUpsert {
- u.Set(channelmonitor.FieldJitterSeconds, v)
- return u
- }
- // UpdateJitterSeconds sets the "jitter_seconds" field to the value that was provided on create.
- func (u *ChannelMonitorUpsert) UpdateJitterSeconds() *ChannelMonitorUpsert {
- u.SetExcluded(channelmonitor.FieldJitterSeconds)
- return u
- }
- // AddJitterSeconds adds v to the "jitter_seconds" field.
- func (u *ChannelMonitorUpsert) AddJitterSeconds(v int) *ChannelMonitorUpsert {
- u.Add(channelmonitor.FieldJitterSeconds, v)
- return u
- }
- // SetLastCheckedAt sets the "last_checked_at" field.
- func (u *ChannelMonitorUpsert) SetLastCheckedAt(v time.Time) *ChannelMonitorUpsert {
- u.Set(channelmonitor.FieldLastCheckedAt, v)
- return u
- }
- // UpdateLastCheckedAt sets the "last_checked_at" field to the value that was provided on create.
- func (u *ChannelMonitorUpsert) UpdateLastCheckedAt() *ChannelMonitorUpsert {
- u.SetExcluded(channelmonitor.FieldLastCheckedAt)
- return u
- }
- // ClearLastCheckedAt clears the value of the "last_checked_at" field.
- func (u *ChannelMonitorUpsert) ClearLastCheckedAt() *ChannelMonitorUpsert {
- u.SetNull(channelmonitor.FieldLastCheckedAt)
- return u
- }
- // SetCreatedBy sets the "created_by" field.
- func (u *ChannelMonitorUpsert) SetCreatedBy(v int64) *ChannelMonitorUpsert {
- u.Set(channelmonitor.FieldCreatedBy, v)
- return u
- }
- // UpdateCreatedBy sets the "created_by" field to the value that was provided on create.
- func (u *ChannelMonitorUpsert) UpdateCreatedBy() *ChannelMonitorUpsert {
- u.SetExcluded(channelmonitor.FieldCreatedBy)
- return u
- }
- // AddCreatedBy adds v to the "created_by" field.
- func (u *ChannelMonitorUpsert) AddCreatedBy(v int64) *ChannelMonitorUpsert {
- u.Add(channelmonitor.FieldCreatedBy, v)
- return u
- }
- // SetTemplateID sets the "template_id" field.
- func (u *ChannelMonitorUpsert) SetTemplateID(v int64) *ChannelMonitorUpsert {
- u.Set(channelmonitor.FieldTemplateID, v)
- return u
- }
- // UpdateTemplateID sets the "template_id" field to the value that was provided on create.
- func (u *ChannelMonitorUpsert) UpdateTemplateID() *ChannelMonitorUpsert {
- u.SetExcluded(channelmonitor.FieldTemplateID)
- return u
- }
- // ClearTemplateID clears the value of the "template_id" field.
- func (u *ChannelMonitorUpsert) ClearTemplateID() *ChannelMonitorUpsert {
- u.SetNull(channelmonitor.FieldTemplateID)
- return u
- }
- // SetExtraHeaders sets the "extra_headers" field.
- func (u *ChannelMonitorUpsert) SetExtraHeaders(v map[string]string) *ChannelMonitorUpsert {
- u.Set(channelmonitor.FieldExtraHeaders, v)
- return u
- }
- // UpdateExtraHeaders sets the "extra_headers" field to the value that was provided on create.
- func (u *ChannelMonitorUpsert) UpdateExtraHeaders() *ChannelMonitorUpsert {
- u.SetExcluded(channelmonitor.FieldExtraHeaders)
- return u
- }
- // SetBodyOverrideMode sets the "body_override_mode" field.
- func (u *ChannelMonitorUpsert) SetBodyOverrideMode(v string) *ChannelMonitorUpsert {
- u.Set(channelmonitor.FieldBodyOverrideMode, v)
- return u
- }
- // UpdateBodyOverrideMode sets the "body_override_mode" field to the value that was provided on create.
- func (u *ChannelMonitorUpsert) UpdateBodyOverrideMode() *ChannelMonitorUpsert {
- u.SetExcluded(channelmonitor.FieldBodyOverrideMode)
- return u
- }
- // SetBodyOverride sets the "body_override" field.
- func (u *ChannelMonitorUpsert) SetBodyOverride(v map[string]interface{}) *ChannelMonitorUpsert {
- u.Set(channelmonitor.FieldBodyOverride, v)
- return u
- }
- // UpdateBodyOverride sets the "body_override" field to the value that was provided on create.
- func (u *ChannelMonitorUpsert) UpdateBodyOverride() *ChannelMonitorUpsert {
- u.SetExcluded(channelmonitor.FieldBodyOverride)
- return u
- }
- // ClearBodyOverride clears the value of the "body_override" field.
- func (u *ChannelMonitorUpsert) ClearBodyOverride() *ChannelMonitorUpsert {
- u.SetNull(channelmonitor.FieldBodyOverride)
- return u
- }
- // UpdateNewValues updates the mutable fields using the new values that were set on create.
- // Using this option is equivalent to using:
- //
- // client.ChannelMonitor.Create().
- // OnConflict(
- // sql.ResolveWithNewValues(),
- // ).
- // Exec(ctx)
- func (u *ChannelMonitorUpsertOne) UpdateNewValues() *ChannelMonitorUpsertOne {
- u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues())
- u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) {
- if _, exists := u.create.mutation.CreatedAt(); exists {
- s.SetIgnore(channelmonitor.FieldCreatedAt)
- }
- }))
- return u
- }
- // Ignore sets each column to itself in case of conflict.
- // Using this option is equivalent to using:
- //
- // client.ChannelMonitor.Create().
- // OnConflict(sql.ResolveWithIgnore()).
- // Exec(ctx)
- func (u *ChannelMonitorUpsertOne) Ignore() *ChannelMonitorUpsertOne {
- u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore())
- return u
- }
- // DoNothing configures the conflict_action to `DO NOTHING`.
- // Supported only by SQLite and PostgreSQL.
- func (u *ChannelMonitorUpsertOne) DoNothing() *ChannelMonitorUpsertOne {
- u.create.conflict = append(u.create.conflict, sql.DoNothing())
- return u
- }
- // Update allows overriding fields `UPDATE` values. See the ChannelMonitorCreate.OnConflict
- // documentation for more info.
- func (u *ChannelMonitorUpsertOne) Update(set func(*ChannelMonitorUpsert)) *ChannelMonitorUpsertOne {
- u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
- set(&ChannelMonitorUpsert{UpdateSet: update})
- }))
- return u
- }
- // SetUpdatedAt sets the "updated_at" field.
- func (u *ChannelMonitorUpsertOne) SetUpdatedAt(v time.Time) *ChannelMonitorUpsertOne {
- return u.Update(func(s *ChannelMonitorUpsert) {
- s.SetUpdatedAt(v)
- })
- }
- // UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
- func (u *ChannelMonitorUpsertOne) UpdateUpdatedAt() *ChannelMonitorUpsertOne {
- return u.Update(func(s *ChannelMonitorUpsert) {
- s.UpdateUpdatedAt()
- })
- }
- // SetName sets the "name" field.
- func (u *ChannelMonitorUpsertOne) SetName(v string) *ChannelMonitorUpsertOne {
- return u.Update(func(s *ChannelMonitorUpsert) {
- s.SetName(v)
- })
- }
- // UpdateName sets the "name" field to the value that was provided on create.
- func (u *ChannelMonitorUpsertOne) UpdateName() *ChannelMonitorUpsertOne {
- return u.Update(func(s *ChannelMonitorUpsert) {
- s.UpdateName()
- })
- }
- // SetProvider sets the "provider" field.
- func (u *ChannelMonitorUpsertOne) SetProvider(v channelmonitor.Provider) *ChannelMonitorUpsertOne {
- return u.Update(func(s *ChannelMonitorUpsert) {
- s.SetProvider(v)
- })
- }
- // UpdateProvider sets the "provider" field to the value that was provided on create.
- func (u *ChannelMonitorUpsertOne) UpdateProvider() *ChannelMonitorUpsertOne {
- return u.Update(func(s *ChannelMonitorUpsert) {
- s.UpdateProvider()
- })
- }
- // SetCheckMode sets the "check_mode" field.
- func (u *ChannelMonitorUpsertOne) SetCheckMode(v string) *ChannelMonitorUpsertOne {
- return u.Update(func(s *ChannelMonitorUpsert) {
- s.SetCheckMode(v)
- })
- }
- // UpdateCheckMode sets the "check_mode" field to the value that was provided on create.
- func (u *ChannelMonitorUpsertOne) UpdateCheckMode() *ChannelMonitorUpsertOne {
- return u.Update(func(s *ChannelMonitorUpsert) {
- s.UpdateCheckMode()
- })
- }
- // SetAccountID sets the "account_id" field.
- func (u *ChannelMonitorUpsertOne) SetAccountID(v int64) *ChannelMonitorUpsertOne {
- return u.Update(func(s *ChannelMonitorUpsert) {
- s.SetAccountID(v)
- })
- }
- // AddAccountID adds v to the "account_id" field.
- func (u *ChannelMonitorUpsertOne) AddAccountID(v int64) *ChannelMonitorUpsertOne {
- return u.Update(func(s *ChannelMonitorUpsert) {
- s.AddAccountID(v)
- })
- }
- // UpdateAccountID sets the "account_id" field to the value that was provided on create.
- func (u *ChannelMonitorUpsertOne) UpdateAccountID() *ChannelMonitorUpsertOne {
- return u.Update(func(s *ChannelMonitorUpsert) {
- s.UpdateAccountID()
- })
- }
- // ClearAccountID clears the value of the "account_id" field.
- func (u *ChannelMonitorUpsertOne) ClearAccountID() *ChannelMonitorUpsertOne {
- return u.Update(func(s *ChannelMonitorUpsert) {
- s.ClearAccountID()
- })
- }
- // SetAPIMode sets the "api_mode" field.
- func (u *ChannelMonitorUpsertOne) SetAPIMode(v string) *ChannelMonitorUpsertOne {
- return u.Update(func(s *ChannelMonitorUpsert) {
- s.SetAPIMode(v)
- })
- }
- // UpdateAPIMode sets the "api_mode" field to the value that was provided on create.
- func (u *ChannelMonitorUpsertOne) UpdateAPIMode() *ChannelMonitorUpsertOne {
- return u.Update(func(s *ChannelMonitorUpsert) {
- s.UpdateAPIMode()
- })
- }
- // SetEndpoint sets the "endpoint" field.
- func (u *ChannelMonitorUpsertOne) SetEndpoint(v string) *ChannelMonitorUpsertOne {
- return u.Update(func(s *ChannelMonitorUpsert) {
- s.SetEndpoint(v)
- })
- }
- // UpdateEndpoint sets the "endpoint" field to the value that was provided on create.
- func (u *ChannelMonitorUpsertOne) UpdateEndpoint() *ChannelMonitorUpsertOne {
- return u.Update(func(s *ChannelMonitorUpsert) {
- s.UpdateEndpoint()
- })
- }
- // SetAPIKeyEncrypted sets the "api_key_encrypted" field.
- func (u *ChannelMonitorUpsertOne) SetAPIKeyEncrypted(v string) *ChannelMonitorUpsertOne {
- return u.Update(func(s *ChannelMonitorUpsert) {
- s.SetAPIKeyEncrypted(v)
- })
- }
- // UpdateAPIKeyEncrypted sets the "api_key_encrypted" field to the value that was provided on create.
- func (u *ChannelMonitorUpsertOne) UpdateAPIKeyEncrypted() *ChannelMonitorUpsertOne {
- return u.Update(func(s *ChannelMonitorUpsert) {
- s.UpdateAPIKeyEncrypted()
- })
- }
- // SetPrimaryModel sets the "primary_model" field.
- func (u *ChannelMonitorUpsertOne) SetPrimaryModel(v string) *ChannelMonitorUpsertOne {
- return u.Update(func(s *ChannelMonitorUpsert) {
- s.SetPrimaryModel(v)
- })
- }
- // UpdatePrimaryModel sets the "primary_model" field to the value that was provided on create.
- func (u *ChannelMonitorUpsertOne) UpdatePrimaryModel() *ChannelMonitorUpsertOne {
- return u.Update(func(s *ChannelMonitorUpsert) {
- s.UpdatePrimaryModel()
- })
- }
- // SetExtraModels sets the "extra_models" field.
- func (u *ChannelMonitorUpsertOne) SetExtraModels(v []string) *ChannelMonitorUpsertOne {
- return u.Update(func(s *ChannelMonitorUpsert) {
- s.SetExtraModels(v)
- })
- }
- // UpdateExtraModels sets the "extra_models" field to the value that was provided on create.
- func (u *ChannelMonitorUpsertOne) UpdateExtraModels() *ChannelMonitorUpsertOne {
- return u.Update(func(s *ChannelMonitorUpsert) {
- s.UpdateExtraModels()
- })
- }
- // SetGroupName sets the "group_name" field.
- func (u *ChannelMonitorUpsertOne) SetGroupName(v string) *ChannelMonitorUpsertOne {
- return u.Update(func(s *ChannelMonitorUpsert) {
- s.SetGroupName(v)
- })
- }
- // UpdateGroupName sets the "group_name" field to the value that was provided on create.
- func (u *ChannelMonitorUpsertOne) UpdateGroupName() *ChannelMonitorUpsertOne {
- return u.Update(func(s *ChannelMonitorUpsert) {
- s.UpdateGroupName()
- })
- }
- // ClearGroupName clears the value of the "group_name" field.
- func (u *ChannelMonitorUpsertOne) ClearGroupName() *ChannelMonitorUpsertOne {
- return u.Update(func(s *ChannelMonitorUpsert) {
- s.ClearGroupName()
- })
- }
- // SetEnabled sets the "enabled" field.
- func (u *ChannelMonitorUpsertOne) SetEnabled(v bool) *ChannelMonitorUpsertOne {
- return u.Update(func(s *ChannelMonitorUpsert) {
- s.SetEnabled(v)
- })
- }
- // UpdateEnabled sets the "enabled" field to the value that was provided on create.
- func (u *ChannelMonitorUpsertOne) UpdateEnabled() *ChannelMonitorUpsertOne {
- return u.Update(func(s *ChannelMonitorUpsert) {
- s.UpdateEnabled()
- })
- }
- // SetIntervalSeconds sets the "interval_seconds" field.
- func (u *ChannelMonitorUpsertOne) SetIntervalSeconds(v int) *ChannelMonitorUpsertOne {
- return u.Update(func(s *ChannelMonitorUpsert) {
- s.SetIntervalSeconds(v)
- })
- }
- // AddIntervalSeconds adds v to the "interval_seconds" field.
- func (u *ChannelMonitorUpsertOne) AddIntervalSeconds(v int) *ChannelMonitorUpsertOne {
- return u.Update(func(s *ChannelMonitorUpsert) {
- s.AddIntervalSeconds(v)
- })
- }
- // UpdateIntervalSeconds sets the "interval_seconds" field to the value that was provided on create.
- func (u *ChannelMonitorUpsertOne) UpdateIntervalSeconds() *ChannelMonitorUpsertOne {
- return u.Update(func(s *ChannelMonitorUpsert) {
- s.UpdateIntervalSeconds()
- })
- }
- // SetJitterSeconds sets the "jitter_seconds" field.
- func (u *ChannelMonitorUpsertOne) SetJitterSeconds(v int) *ChannelMonitorUpsertOne {
- return u.Update(func(s *ChannelMonitorUpsert) {
- s.SetJitterSeconds(v)
- })
- }
- // AddJitterSeconds adds v to the "jitter_seconds" field.
- func (u *ChannelMonitorUpsertOne) AddJitterSeconds(v int) *ChannelMonitorUpsertOne {
- return u.Update(func(s *ChannelMonitorUpsert) {
- s.AddJitterSeconds(v)
- })
- }
- // UpdateJitterSeconds sets the "jitter_seconds" field to the value that was provided on create.
- func (u *ChannelMonitorUpsertOne) UpdateJitterSeconds() *ChannelMonitorUpsertOne {
- return u.Update(func(s *ChannelMonitorUpsert) {
- s.UpdateJitterSeconds()
- })
- }
- // SetLastCheckedAt sets the "last_checked_at" field.
- func (u *ChannelMonitorUpsertOne) SetLastCheckedAt(v time.Time) *ChannelMonitorUpsertOne {
- return u.Update(func(s *ChannelMonitorUpsert) {
- s.SetLastCheckedAt(v)
- })
- }
- // UpdateLastCheckedAt sets the "last_checked_at" field to the value that was provided on create.
- func (u *ChannelMonitorUpsertOne) UpdateLastCheckedAt() *ChannelMonitorUpsertOne {
- return u.Update(func(s *ChannelMonitorUpsert) {
- s.UpdateLastCheckedAt()
- })
- }
- // ClearLastCheckedAt clears the value of the "last_checked_at" field.
- func (u *ChannelMonitorUpsertOne) ClearLastCheckedAt() *ChannelMonitorUpsertOne {
- return u.Update(func(s *ChannelMonitorUpsert) {
- s.ClearLastCheckedAt()
- })
- }
- // SetCreatedBy sets the "created_by" field.
- func (u *ChannelMonitorUpsertOne) SetCreatedBy(v int64) *ChannelMonitorUpsertOne {
- return u.Update(func(s *ChannelMonitorUpsert) {
- s.SetCreatedBy(v)
- })
- }
- // AddCreatedBy adds v to the "created_by" field.
- func (u *ChannelMonitorUpsertOne) AddCreatedBy(v int64) *ChannelMonitorUpsertOne {
- return u.Update(func(s *ChannelMonitorUpsert) {
- s.AddCreatedBy(v)
- })
- }
- // UpdateCreatedBy sets the "created_by" field to the value that was provided on create.
- func (u *ChannelMonitorUpsertOne) UpdateCreatedBy() *ChannelMonitorUpsertOne {
- return u.Update(func(s *ChannelMonitorUpsert) {
- s.UpdateCreatedBy()
- })
- }
- // SetTemplateID sets the "template_id" field.
- func (u *ChannelMonitorUpsertOne) SetTemplateID(v int64) *ChannelMonitorUpsertOne {
- return u.Update(func(s *ChannelMonitorUpsert) {
- s.SetTemplateID(v)
- })
- }
- // UpdateTemplateID sets the "template_id" field to the value that was provided on create.
- func (u *ChannelMonitorUpsertOne) UpdateTemplateID() *ChannelMonitorUpsertOne {
- return u.Update(func(s *ChannelMonitorUpsert) {
- s.UpdateTemplateID()
- })
- }
- // ClearTemplateID clears the value of the "template_id" field.
- func (u *ChannelMonitorUpsertOne) ClearTemplateID() *ChannelMonitorUpsertOne {
- return u.Update(func(s *ChannelMonitorUpsert) {
- s.ClearTemplateID()
- })
- }
- // SetExtraHeaders sets the "extra_headers" field.
- func (u *ChannelMonitorUpsertOne) SetExtraHeaders(v map[string]string) *ChannelMonitorUpsertOne {
- return u.Update(func(s *ChannelMonitorUpsert) {
- s.SetExtraHeaders(v)
- })
- }
- // UpdateExtraHeaders sets the "extra_headers" field to the value that was provided on create.
- func (u *ChannelMonitorUpsertOne) UpdateExtraHeaders() *ChannelMonitorUpsertOne {
- return u.Update(func(s *ChannelMonitorUpsert) {
- s.UpdateExtraHeaders()
- })
- }
- // SetBodyOverrideMode sets the "body_override_mode" field.
- func (u *ChannelMonitorUpsertOne) SetBodyOverrideMode(v string) *ChannelMonitorUpsertOne {
- return u.Update(func(s *ChannelMonitorUpsert) {
- s.SetBodyOverrideMode(v)
- })
- }
- // UpdateBodyOverrideMode sets the "body_override_mode" field to the value that was provided on create.
- func (u *ChannelMonitorUpsertOne) UpdateBodyOverrideMode() *ChannelMonitorUpsertOne {
- return u.Update(func(s *ChannelMonitorUpsert) {
- s.UpdateBodyOverrideMode()
- })
- }
- // SetBodyOverride sets the "body_override" field.
- func (u *ChannelMonitorUpsertOne) SetBodyOverride(v map[string]interface{}) *ChannelMonitorUpsertOne {
- return u.Update(func(s *ChannelMonitorUpsert) {
- s.SetBodyOverride(v)
- })
- }
- // UpdateBodyOverride sets the "body_override" field to the value that was provided on create.
- func (u *ChannelMonitorUpsertOne) UpdateBodyOverride() *ChannelMonitorUpsertOne {
- return u.Update(func(s *ChannelMonitorUpsert) {
- s.UpdateBodyOverride()
- })
- }
- // ClearBodyOverride clears the value of the "body_override" field.
- func (u *ChannelMonitorUpsertOne) ClearBodyOverride() *ChannelMonitorUpsertOne {
- return u.Update(func(s *ChannelMonitorUpsert) {
- s.ClearBodyOverride()
- })
- }
- // Exec executes the query.
- func (u *ChannelMonitorUpsertOne) Exec(ctx context.Context) error {
- if len(u.create.conflict) == 0 {
- return errors.New("ent: missing options for ChannelMonitorCreate.OnConflict")
- }
- return u.create.Exec(ctx)
- }
- // ExecX is like Exec, but panics if an error occurs.
- func (u *ChannelMonitorUpsertOne) ExecX(ctx context.Context) {
- if err := u.create.Exec(ctx); err != nil {
- panic(err)
- }
- }
- // Exec executes the UPSERT query and returns the inserted/updated ID.
- func (u *ChannelMonitorUpsertOne) ID(ctx context.Context) (id int64, err error) {
- node, err := u.create.Save(ctx)
- if err != nil {
- return id, err
- }
- return node.ID, nil
- }
- // IDX is like ID, but panics if an error occurs.
- func (u *ChannelMonitorUpsertOne) IDX(ctx context.Context) int64 {
- id, err := u.ID(ctx)
- if err != nil {
- panic(err)
- }
- return id
- }
- // ChannelMonitorCreateBulk is the builder for creating many ChannelMonitor entities in bulk.
- type ChannelMonitorCreateBulk struct {
- config
- err error
- builders []*ChannelMonitorCreate
- conflict []sql.ConflictOption
- }
- // Save creates the ChannelMonitor entities in the database.
- func (_c *ChannelMonitorCreateBulk) Save(ctx context.Context) ([]*ChannelMonitor, error) {
- if _c.err != nil {
- return nil, _c.err
- }
- specs := make([]*sqlgraph.CreateSpec, len(_c.builders))
- nodes := make([]*ChannelMonitor, len(_c.builders))
- mutators := make([]Mutator, len(_c.builders))
- for i := range _c.builders {
- func(i int, root context.Context) {
- builder := _c.builders[i]
- builder.defaults()
- var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
- mutation, ok := m.(*ChannelMonitorMutation)
- if !ok {
- return nil, fmt.Errorf("unexpected mutation type %T", m)
- }
- if err := builder.check(); err != nil {
- return nil, err
- }
- builder.mutation = mutation
- var err error
- nodes[i], specs[i] = builder.createSpec()
- if i < len(mutators)-1 {
- _, err = mutators[i+1].Mutate(root, _c.builders[i+1].mutation)
- } else {
- spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
- spec.OnConflict = _c.conflict
- // Invoke the actual operation on the latest mutation in the chain.
- if err = sqlgraph.BatchCreate(ctx, _c.driver, spec); err != nil {
- if sqlgraph.IsConstraintError(err) {
- err = &ConstraintError{msg: err.Error(), wrap: err}
- }
- }
- }
- if err != nil {
- return nil, err
- }
- mutation.id = &nodes[i].ID
- if specs[i].ID.Value != nil {
- id := specs[i].ID.Value.(int64)
- nodes[i].ID = int64(id)
- }
- mutation.done = true
- return nodes[i], nil
- })
- for i := len(builder.hooks) - 1; i >= 0; i-- {
- mut = builder.hooks[i](mut)
- }
- mutators[i] = mut
- }(i, ctx)
- }
- if len(mutators) > 0 {
- if _, err := mutators[0].Mutate(ctx, _c.builders[0].mutation); err != nil {
- return nil, err
- }
- }
- return nodes, nil
- }
- // SaveX is like Save, but panics if an error occurs.
- func (_c *ChannelMonitorCreateBulk) SaveX(ctx context.Context) []*ChannelMonitor {
- v, err := _c.Save(ctx)
- if err != nil {
- panic(err)
- }
- return v
- }
- // Exec executes the query.
- func (_c *ChannelMonitorCreateBulk) Exec(ctx context.Context) error {
- _, err := _c.Save(ctx)
- return err
- }
- // ExecX is like Exec, but panics if an error occurs.
- func (_c *ChannelMonitorCreateBulk) ExecX(ctx context.Context) {
- if err := _c.Exec(ctx); err != nil {
- panic(err)
- }
- }
- // OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
- // of the `INSERT` statement. For example:
- //
- // client.ChannelMonitor.CreateBulk(builders...).
- // OnConflict(
- // // Update the row with the new values
- // // the was proposed for insertion.
- // sql.ResolveWithNewValues(),
- // ).
- // // Override some of the fields with custom
- // // update values.
- // Update(func(u *ent.ChannelMonitorUpsert) {
- // SetCreatedAt(v+v).
- // }).
- // Exec(ctx)
- func (_c *ChannelMonitorCreateBulk) OnConflict(opts ...sql.ConflictOption) *ChannelMonitorUpsertBulk {
- _c.conflict = opts
- return &ChannelMonitorUpsertBulk{
- create: _c,
- }
- }
- // OnConflictColumns calls `OnConflict` and configures the columns
- // as conflict target. Using this option is equivalent to using:
- //
- // client.ChannelMonitor.Create().
- // OnConflict(sql.ConflictColumns(columns...)).
- // Exec(ctx)
- func (_c *ChannelMonitorCreateBulk) OnConflictColumns(columns ...string) *ChannelMonitorUpsertBulk {
- _c.conflict = append(_c.conflict, sql.ConflictColumns(columns...))
- return &ChannelMonitorUpsertBulk{
- create: _c,
- }
- }
- // ChannelMonitorUpsertBulk is the builder for "upsert"-ing
- // a bulk of ChannelMonitor nodes.
- type ChannelMonitorUpsertBulk struct {
- create *ChannelMonitorCreateBulk
- }
- // UpdateNewValues updates the mutable fields using the new values that
- // were set on create. Using this option is equivalent to using:
- //
- // client.ChannelMonitor.Create().
- // OnConflict(
- // sql.ResolveWithNewValues(),
- // ).
- // Exec(ctx)
- func (u *ChannelMonitorUpsertBulk) UpdateNewValues() *ChannelMonitorUpsertBulk {
- u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues())
- u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) {
- for _, b := range u.create.builders {
- if _, exists := b.mutation.CreatedAt(); exists {
- s.SetIgnore(channelmonitor.FieldCreatedAt)
- }
- }
- }))
- return u
- }
- // Ignore sets each column to itself in case of conflict.
- // Using this option is equivalent to using:
- //
- // client.ChannelMonitor.Create().
- // OnConflict(sql.ResolveWithIgnore()).
- // Exec(ctx)
- func (u *ChannelMonitorUpsertBulk) Ignore() *ChannelMonitorUpsertBulk {
- u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore())
- return u
- }
- // DoNothing configures the conflict_action to `DO NOTHING`.
- // Supported only by SQLite and PostgreSQL.
- func (u *ChannelMonitorUpsertBulk) DoNothing() *ChannelMonitorUpsertBulk {
- u.create.conflict = append(u.create.conflict, sql.DoNothing())
- return u
- }
- // Update allows overriding fields `UPDATE` values. See the ChannelMonitorCreateBulk.OnConflict
- // documentation for more info.
- func (u *ChannelMonitorUpsertBulk) Update(set func(*ChannelMonitorUpsert)) *ChannelMonitorUpsertBulk {
- u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
- set(&ChannelMonitorUpsert{UpdateSet: update})
- }))
- return u
- }
- // SetUpdatedAt sets the "updated_at" field.
- func (u *ChannelMonitorUpsertBulk) SetUpdatedAt(v time.Time) *ChannelMonitorUpsertBulk {
- return u.Update(func(s *ChannelMonitorUpsert) {
- s.SetUpdatedAt(v)
- })
- }
- // UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
- func (u *ChannelMonitorUpsertBulk) UpdateUpdatedAt() *ChannelMonitorUpsertBulk {
- return u.Update(func(s *ChannelMonitorUpsert) {
- s.UpdateUpdatedAt()
- })
- }
- // SetName sets the "name" field.
- func (u *ChannelMonitorUpsertBulk) SetName(v string) *ChannelMonitorUpsertBulk {
- return u.Update(func(s *ChannelMonitorUpsert) {
- s.SetName(v)
- })
- }
- // UpdateName sets the "name" field to the value that was provided on create.
- func (u *ChannelMonitorUpsertBulk) UpdateName() *ChannelMonitorUpsertBulk {
- return u.Update(func(s *ChannelMonitorUpsert) {
- s.UpdateName()
- })
- }
- // SetProvider sets the "provider" field.
- func (u *ChannelMonitorUpsertBulk) SetProvider(v channelmonitor.Provider) *ChannelMonitorUpsertBulk {
- return u.Update(func(s *ChannelMonitorUpsert) {
- s.SetProvider(v)
- })
- }
- // UpdateProvider sets the "provider" field to the value that was provided on create.
- func (u *ChannelMonitorUpsertBulk) UpdateProvider() *ChannelMonitorUpsertBulk {
- return u.Update(func(s *ChannelMonitorUpsert) {
- s.UpdateProvider()
- })
- }
- // SetCheckMode sets the "check_mode" field.
- func (u *ChannelMonitorUpsertBulk) SetCheckMode(v string) *ChannelMonitorUpsertBulk {
- return u.Update(func(s *ChannelMonitorUpsert) {
- s.SetCheckMode(v)
- })
- }
- // UpdateCheckMode sets the "check_mode" field to the value that was provided on create.
- func (u *ChannelMonitorUpsertBulk) UpdateCheckMode() *ChannelMonitorUpsertBulk {
- return u.Update(func(s *ChannelMonitorUpsert) {
- s.UpdateCheckMode()
- })
- }
- // SetAccountID sets the "account_id" field.
- func (u *ChannelMonitorUpsertBulk) SetAccountID(v int64) *ChannelMonitorUpsertBulk {
- return u.Update(func(s *ChannelMonitorUpsert) {
- s.SetAccountID(v)
- })
- }
- // AddAccountID adds v to the "account_id" field.
- func (u *ChannelMonitorUpsertBulk) AddAccountID(v int64) *ChannelMonitorUpsertBulk {
- return u.Update(func(s *ChannelMonitorUpsert) {
- s.AddAccountID(v)
- })
- }
- // UpdateAccountID sets the "account_id" field to the value that was provided on create.
- func (u *ChannelMonitorUpsertBulk) UpdateAccountID() *ChannelMonitorUpsertBulk {
- return u.Update(func(s *ChannelMonitorUpsert) {
- s.UpdateAccountID()
- })
- }
- // ClearAccountID clears the value of the "account_id" field.
- func (u *ChannelMonitorUpsertBulk) ClearAccountID() *ChannelMonitorUpsertBulk {
- return u.Update(func(s *ChannelMonitorUpsert) {
- s.ClearAccountID()
- })
- }
- // SetAPIMode sets the "api_mode" field.
- func (u *ChannelMonitorUpsertBulk) SetAPIMode(v string) *ChannelMonitorUpsertBulk {
- return u.Update(func(s *ChannelMonitorUpsert) {
- s.SetAPIMode(v)
- })
- }
- // UpdateAPIMode sets the "api_mode" field to the value that was provided on create.
- func (u *ChannelMonitorUpsertBulk) UpdateAPIMode() *ChannelMonitorUpsertBulk {
- return u.Update(func(s *ChannelMonitorUpsert) {
- s.UpdateAPIMode()
- })
- }
- // SetEndpoint sets the "endpoint" field.
- func (u *ChannelMonitorUpsertBulk) SetEndpoint(v string) *ChannelMonitorUpsertBulk {
- return u.Update(func(s *ChannelMonitorUpsert) {
- s.SetEndpoint(v)
- })
- }
- // UpdateEndpoint sets the "endpoint" field to the value that was provided on create.
- func (u *ChannelMonitorUpsertBulk) UpdateEndpoint() *ChannelMonitorUpsertBulk {
- return u.Update(func(s *ChannelMonitorUpsert) {
- s.UpdateEndpoint()
- })
- }
- // SetAPIKeyEncrypted sets the "api_key_encrypted" field.
- func (u *ChannelMonitorUpsertBulk) SetAPIKeyEncrypted(v string) *ChannelMonitorUpsertBulk {
- return u.Update(func(s *ChannelMonitorUpsert) {
- s.SetAPIKeyEncrypted(v)
- })
- }
- // UpdateAPIKeyEncrypted sets the "api_key_encrypted" field to the value that was provided on create.
- func (u *ChannelMonitorUpsertBulk) UpdateAPIKeyEncrypted() *ChannelMonitorUpsertBulk {
- return u.Update(func(s *ChannelMonitorUpsert) {
- s.UpdateAPIKeyEncrypted()
- })
- }
- // SetPrimaryModel sets the "primary_model" field.
- func (u *ChannelMonitorUpsertBulk) SetPrimaryModel(v string) *ChannelMonitorUpsertBulk {
- return u.Update(func(s *ChannelMonitorUpsert) {
- s.SetPrimaryModel(v)
- })
- }
- // UpdatePrimaryModel sets the "primary_model" field to the value that was provided on create.
- func (u *ChannelMonitorUpsertBulk) UpdatePrimaryModel() *ChannelMonitorUpsertBulk {
- return u.Update(func(s *ChannelMonitorUpsert) {
- s.UpdatePrimaryModel()
- })
- }
- // SetExtraModels sets the "extra_models" field.
- func (u *ChannelMonitorUpsertBulk) SetExtraModels(v []string) *ChannelMonitorUpsertBulk {
- return u.Update(func(s *ChannelMonitorUpsert) {
- s.SetExtraModels(v)
- })
- }
- // UpdateExtraModels sets the "extra_models" field to the value that was provided on create.
- func (u *ChannelMonitorUpsertBulk) UpdateExtraModels() *ChannelMonitorUpsertBulk {
- return u.Update(func(s *ChannelMonitorUpsert) {
- s.UpdateExtraModels()
- })
- }
- // SetGroupName sets the "group_name" field.
- func (u *ChannelMonitorUpsertBulk) SetGroupName(v string) *ChannelMonitorUpsertBulk {
- return u.Update(func(s *ChannelMonitorUpsert) {
- s.SetGroupName(v)
- })
- }
- // UpdateGroupName sets the "group_name" field to the value that was provided on create.
- func (u *ChannelMonitorUpsertBulk) UpdateGroupName() *ChannelMonitorUpsertBulk {
- return u.Update(func(s *ChannelMonitorUpsert) {
- s.UpdateGroupName()
- })
- }
- // ClearGroupName clears the value of the "group_name" field.
- func (u *ChannelMonitorUpsertBulk) ClearGroupName() *ChannelMonitorUpsertBulk {
- return u.Update(func(s *ChannelMonitorUpsert) {
- s.ClearGroupName()
- })
- }
- // SetEnabled sets the "enabled" field.
- func (u *ChannelMonitorUpsertBulk) SetEnabled(v bool) *ChannelMonitorUpsertBulk {
- return u.Update(func(s *ChannelMonitorUpsert) {
- s.SetEnabled(v)
- })
- }
- // UpdateEnabled sets the "enabled" field to the value that was provided on create.
- func (u *ChannelMonitorUpsertBulk) UpdateEnabled() *ChannelMonitorUpsertBulk {
- return u.Update(func(s *ChannelMonitorUpsert) {
- s.UpdateEnabled()
- })
- }
- // SetIntervalSeconds sets the "interval_seconds" field.
- func (u *ChannelMonitorUpsertBulk) SetIntervalSeconds(v int) *ChannelMonitorUpsertBulk {
- return u.Update(func(s *ChannelMonitorUpsert) {
- s.SetIntervalSeconds(v)
- })
- }
- // AddIntervalSeconds adds v to the "interval_seconds" field.
- func (u *ChannelMonitorUpsertBulk) AddIntervalSeconds(v int) *ChannelMonitorUpsertBulk {
- return u.Update(func(s *ChannelMonitorUpsert) {
- s.AddIntervalSeconds(v)
- })
- }
- // UpdateIntervalSeconds sets the "interval_seconds" field to the value that was provided on create.
- func (u *ChannelMonitorUpsertBulk) UpdateIntervalSeconds() *ChannelMonitorUpsertBulk {
- return u.Update(func(s *ChannelMonitorUpsert) {
- s.UpdateIntervalSeconds()
- })
- }
- // SetJitterSeconds sets the "jitter_seconds" field.
- func (u *ChannelMonitorUpsertBulk) SetJitterSeconds(v int) *ChannelMonitorUpsertBulk {
- return u.Update(func(s *ChannelMonitorUpsert) {
- s.SetJitterSeconds(v)
- })
- }
- // AddJitterSeconds adds v to the "jitter_seconds" field.
- func (u *ChannelMonitorUpsertBulk) AddJitterSeconds(v int) *ChannelMonitorUpsertBulk {
- return u.Update(func(s *ChannelMonitorUpsert) {
- s.AddJitterSeconds(v)
- })
- }
- // UpdateJitterSeconds sets the "jitter_seconds" field to the value that was provided on create.
- func (u *ChannelMonitorUpsertBulk) UpdateJitterSeconds() *ChannelMonitorUpsertBulk {
- return u.Update(func(s *ChannelMonitorUpsert) {
- s.UpdateJitterSeconds()
- })
- }
- // SetLastCheckedAt sets the "last_checked_at" field.
- func (u *ChannelMonitorUpsertBulk) SetLastCheckedAt(v time.Time) *ChannelMonitorUpsertBulk {
- return u.Update(func(s *ChannelMonitorUpsert) {
- s.SetLastCheckedAt(v)
- })
- }
- // UpdateLastCheckedAt sets the "last_checked_at" field to the value that was provided on create.
- func (u *ChannelMonitorUpsertBulk) UpdateLastCheckedAt() *ChannelMonitorUpsertBulk {
- return u.Update(func(s *ChannelMonitorUpsert) {
- s.UpdateLastCheckedAt()
- })
- }
- // ClearLastCheckedAt clears the value of the "last_checked_at" field.
- func (u *ChannelMonitorUpsertBulk) ClearLastCheckedAt() *ChannelMonitorUpsertBulk {
- return u.Update(func(s *ChannelMonitorUpsert) {
- s.ClearLastCheckedAt()
- })
- }
- // SetCreatedBy sets the "created_by" field.
- func (u *ChannelMonitorUpsertBulk) SetCreatedBy(v int64) *ChannelMonitorUpsertBulk {
- return u.Update(func(s *ChannelMonitorUpsert) {
- s.SetCreatedBy(v)
- })
- }
- // AddCreatedBy adds v to the "created_by" field.
- func (u *ChannelMonitorUpsertBulk) AddCreatedBy(v int64) *ChannelMonitorUpsertBulk {
- return u.Update(func(s *ChannelMonitorUpsert) {
- s.AddCreatedBy(v)
- })
- }
- // UpdateCreatedBy sets the "created_by" field to the value that was provided on create.
- func (u *ChannelMonitorUpsertBulk) UpdateCreatedBy() *ChannelMonitorUpsertBulk {
- return u.Update(func(s *ChannelMonitorUpsert) {
- s.UpdateCreatedBy()
- })
- }
- // SetTemplateID sets the "template_id" field.
- func (u *ChannelMonitorUpsertBulk) SetTemplateID(v int64) *ChannelMonitorUpsertBulk {
- return u.Update(func(s *ChannelMonitorUpsert) {
- s.SetTemplateID(v)
- })
- }
- // UpdateTemplateID sets the "template_id" field to the value that was provided on create.
- func (u *ChannelMonitorUpsertBulk) UpdateTemplateID() *ChannelMonitorUpsertBulk {
- return u.Update(func(s *ChannelMonitorUpsert) {
- s.UpdateTemplateID()
- })
- }
- // ClearTemplateID clears the value of the "template_id" field.
- func (u *ChannelMonitorUpsertBulk) ClearTemplateID() *ChannelMonitorUpsertBulk {
- return u.Update(func(s *ChannelMonitorUpsert) {
- s.ClearTemplateID()
- })
- }
- // SetExtraHeaders sets the "extra_headers" field.
- func (u *ChannelMonitorUpsertBulk) SetExtraHeaders(v map[string]string) *ChannelMonitorUpsertBulk {
- return u.Update(func(s *ChannelMonitorUpsert) {
- s.SetExtraHeaders(v)
- })
- }
- // UpdateExtraHeaders sets the "extra_headers" field to the value that was provided on create.
- func (u *ChannelMonitorUpsertBulk) UpdateExtraHeaders() *ChannelMonitorUpsertBulk {
- return u.Update(func(s *ChannelMonitorUpsert) {
- s.UpdateExtraHeaders()
- })
- }
- // SetBodyOverrideMode sets the "body_override_mode" field.
- func (u *ChannelMonitorUpsertBulk) SetBodyOverrideMode(v string) *ChannelMonitorUpsertBulk {
- return u.Update(func(s *ChannelMonitorUpsert) {
- s.SetBodyOverrideMode(v)
- })
- }
- // UpdateBodyOverrideMode sets the "body_override_mode" field to the value that was provided on create.
- func (u *ChannelMonitorUpsertBulk) UpdateBodyOverrideMode() *ChannelMonitorUpsertBulk {
- return u.Update(func(s *ChannelMonitorUpsert) {
- s.UpdateBodyOverrideMode()
- })
- }
- // SetBodyOverride sets the "body_override" field.
- func (u *ChannelMonitorUpsertBulk) SetBodyOverride(v map[string]interface{}) *ChannelMonitorUpsertBulk {
- return u.Update(func(s *ChannelMonitorUpsert) {
- s.SetBodyOverride(v)
- })
- }
- // UpdateBodyOverride sets the "body_override" field to the value that was provided on create.
- func (u *ChannelMonitorUpsertBulk) UpdateBodyOverride() *ChannelMonitorUpsertBulk {
- return u.Update(func(s *ChannelMonitorUpsert) {
- s.UpdateBodyOverride()
- })
- }
- // ClearBodyOverride clears the value of the "body_override" field.
- func (u *ChannelMonitorUpsertBulk) ClearBodyOverride() *ChannelMonitorUpsertBulk {
- return u.Update(func(s *ChannelMonitorUpsert) {
- s.ClearBodyOverride()
- })
- }
- // Exec executes the query.
- func (u *ChannelMonitorUpsertBulk) Exec(ctx context.Context) error {
- if u.create.err != nil {
- return u.create.err
- }
- for i, b := range u.create.builders {
- if len(b.conflict) != 0 {
- return fmt.Errorf("ent: OnConflict was set for builder %d. Set it on the ChannelMonitorCreateBulk instead", i)
- }
- }
- if len(u.create.conflict) == 0 {
- return errors.New("ent: missing options for ChannelMonitorCreateBulk.OnConflict")
- }
- return u.create.Exec(ctx)
- }
- // ExecX is like Exec, but panics if an error occurs.
- func (u *ChannelMonitorUpsertBulk) ExecX(ctx context.Context) {
- if err := u.create.Exec(ctx); err != nil {
- panic(err)
- }
- }
|