mirror of
https://github.com/netbirdio/dex.git
synced 2026-05-22 18:43:53 -07:00
707 lines
23 KiB
Go
707 lines
23 KiB
Go
// Code generated by ent, DO NOT EDIT.
|
|
|
|
package db
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
"fmt"
|
|
|
|
"entgo.io/ent/dialect/sql"
|
|
"entgo.io/ent/dialect/sql/sqlgraph"
|
|
"entgo.io/ent/dialect/sql/sqljson"
|
|
"entgo.io/ent/schema/field"
|
|
"github.com/dexidp/dex/storage/ent/db/oauth2client"
|
|
"github.com/dexidp/dex/storage/ent/db/predicate"
|
|
)
|
|
|
|
// OAuth2ClientUpdate is the builder for updating OAuth2Client entities.
|
|
type OAuth2ClientUpdate struct {
|
|
config
|
|
hooks []Hook
|
|
mutation *OAuth2ClientMutation
|
|
}
|
|
|
|
// Where appends a list predicates to the OAuth2ClientUpdate builder.
|
|
func (_u *OAuth2ClientUpdate) Where(ps ...predicate.OAuth2Client) *OAuth2ClientUpdate {
|
|
_u.mutation.Where(ps...)
|
|
return _u
|
|
}
|
|
|
|
// SetSecret sets the "secret" field.
|
|
func (_u *OAuth2ClientUpdate) SetSecret(v string) *OAuth2ClientUpdate {
|
|
_u.mutation.SetSecret(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableSecret sets the "secret" field if the given value is not nil.
|
|
func (_u *OAuth2ClientUpdate) SetNillableSecret(v *string) *OAuth2ClientUpdate {
|
|
if v != nil {
|
|
_u.SetSecret(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetRedirectUris sets the "redirect_uris" field.
|
|
func (_u *OAuth2ClientUpdate) SetRedirectUris(v []string) *OAuth2ClientUpdate {
|
|
_u.mutation.SetRedirectUris(v)
|
|
return _u
|
|
}
|
|
|
|
// AppendRedirectUris appends value to the "redirect_uris" field.
|
|
func (_u *OAuth2ClientUpdate) AppendRedirectUris(v []string) *OAuth2ClientUpdate {
|
|
_u.mutation.AppendRedirectUris(v)
|
|
return _u
|
|
}
|
|
|
|
// ClearRedirectUris clears the value of the "redirect_uris" field.
|
|
func (_u *OAuth2ClientUpdate) ClearRedirectUris() *OAuth2ClientUpdate {
|
|
_u.mutation.ClearRedirectUris()
|
|
return _u
|
|
}
|
|
|
|
// SetTrustedPeers sets the "trusted_peers" field.
|
|
func (_u *OAuth2ClientUpdate) SetTrustedPeers(v []string) *OAuth2ClientUpdate {
|
|
_u.mutation.SetTrustedPeers(v)
|
|
return _u
|
|
}
|
|
|
|
// AppendTrustedPeers appends value to the "trusted_peers" field.
|
|
func (_u *OAuth2ClientUpdate) AppendTrustedPeers(v []string) *OAuth2ClientUpdate {
|
|
_u.mutation.AppendTrustedPeers(v)
|
|
return _u
|
|
}
|
|
|
|
// ClearTrustedPeers clears the value of the "trusted_peers" field.
|
|
func (_u *OAuth2ClientUpdate) ClearTrustedPeers() *OAuth2ClientUpdate {
|
|
_u.mutation.ClearTrustedPeers()
|
|
return _u
|
|
}
|
|
|
|
// SetPublic sets the "public" field.
|
|
func (_u *OAuth2ClientUpdate) SetPublic(v bool) *OAuth2ClientUpdate {
|
|
_u.mutation.SetPublic(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillablePublic sets the "public" field if the given value is not nil.
|
|
func (_u *OAuth2ClientUpdate) SetNillablePublic(v *bool) *OAuth2ClientUpdate {
|
|
if v != nil {
|
|
_u.SetPublic(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetName sets the "name" field.
|
|
func (_u *OAuth2ClientUpdate) SetName(v string) *OAuth2ClientUpdate {
|
|
_u.mutation.SetName(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableName sets the "name" field if the given value is not nil.
|
|
func (_u *OAuth2ClientUpdate) SetNillableName(v *string) *OAuth2ClientUpdate {
|
|
if v != nil {
|
|
_u.SetName(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetLogoURL sets the "logo_url" field.
|
|
func (_u *OAuth2ClientUpdate) SetLogoURL(v string) *OAuth2ClientUpdate {
|
|
_u.mutation.SetLogoURL(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableLogoURL sets the "logo_url" field if the given value is not nil.
|
|
func (_u *OAuth2ClientUpdate) SetNillableLogoURL(v *string) *OAuth2ClientUpdate {
|
|
if v != nil {
|
|
_u.SetLogoURL(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetAllowedConnectors sets the "allowed_connectors" field.
|
|
func (_u *OAuth2ClientUpdate) SetAllowedConnectors(v []string) *OAuth2ClientUpdate {
|
|
_u.mutation.SetAllowedConnectors(v)
|
|
return _u
|
|
}
|
|
|
|
// AppendAllowedConnectors appends value to the "allowed_connectors" field.
|
|
func (_u *OAuth2ClientUpdate) AppendAllowedConnectors(v []string) *OAuth2ClientUpdate {
|
|
_u.mutation.AppendAllowedConnectors(v)
|
|
return _u
|
|
}
|
|
|
|
// ClearAllowedConnectors clears the value of the "allowed_connectors" field.
|
|
func (_u *OAuth2ClientUpdate) ClearAllowedConnectors() *OAuth2ClientUpdate {
|
|
_u.mutation.ClearAllowedConnectors()
|
|
return _u
|
|
}
|
|
|
|
// SetMfaChain sets the "mfa_chain" field.
|
|
func (_u *OAuth2ClientUpdate) SetMfaChain(v []string) *OAuth2ClientUpdate {
|
|
_u.mutation.SetMfaChain(v)
|
|
return _u
|
|
}
|
|
|
|
// AppendMfaChain appends value to the "mfa_chain" field.
|
|
func (_u *OAuth2ClientUpdate) AppendMfaChain(v []string) *OAuth2ClientUpdate {
|
|
_u.mutation.AppendMfaChain(v)
|
|
return _u
|
|
}
|
|
|
|
// ClearMfaChain clears the value of the "mfa_chain" field.
|
|
func (_u *OAuth2ClientUpdate) ClearMfaChain() *OAuth2ClientUpdate {
|
|
_u.mutation.ClearMfaChain()
|
|
return _u
|
|
}
|
|
|
|
// SetPostLogoutRedirectUris sets the "post_logout_redirect_uris" field.
|
|
func (_u *OAuth2ClientUpdate) SetPostLogoutRedirectUris(v []string) *OAuth2ClientUpdate {
|
|
_u.mutation.SetPostLogoutRedirectUris(v)
|
|
return _u
|
|
}
|
|
|
|
// AppendPostLogoutRedirectUris appends value to the "post_logout_redirect_uris" field.
|
|
func (_u *OAuth2ClientUpdate) AppendPostLogoutRedirectUris(v []string) *OAuth2ClientUpdate {
|
|
_u.mutation.AppendPostLogoutRedirectUris(v)
|
|
return _u
|
|
}
|
|
|
|
// ClearPostLogoutRedirectUris clears the value of the "post_logout_redirect_uris" field.
|
|
func (_u *OAuth2ClientUpdate) ClearPostLogoutRedirectUris() *OAuth2ClientUpdate {
|
|
_u.mutation.ClearPostLogoutRedirectUris()
|
|
return _u
|
|
}
|
|
|
|
// SetSSOSharedWith sets the "sso_shared_with" field.
|
|
func (_u *OAuth2ClientUpdate) SetSSOSharedWith(v []string) *OAuth2ClientUpdate {
|
|
_u.mutation.SetSSOSharedWith(v)
|
|
return _u
|
|
}
|
|
|
|
// AppendSSOSharedWith appends value to the "sso_shared_with" field.
|
|
func (_u *OAuth2ClientUpdate) AppendSSOSharedWith(v []string) *OAuth2ClientUpdate {
|
|
_u.mutation.AppendSSOSharedWith(v)
|
|
return _u
|
|
}
|
|
|
|
// ClearSSOSharedWith clears the value of the "sso_shared_with" field.
|
|
func (_u *OAuth2ClientUpdate) ClearSSOSharedWith() *OAuth2ClientUpdate {
|
|
_u.mutation.ClearSSOSharedWith()
|
|
return _u
|
|
}
|
|
|
|
// Mutation returns the OAuth2ClientMutation object of the builder.
|
|
func (_u *OAuth2ClientUpdate) Mutation() *OAuth2ClientMutation {
|
|
return _u.mutation
|
|
}
|
|
|
|
// Save executes the query and returns the number of nodes affected by the update operation.
|
|
func (_u *OAuth2ClientUpdate) Save(ctx context.Context) (int, error) {
|
|
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
|
|
}
|
|
|
|
// SaveX is like Save, but panics if an error occurs.
|
|
func (_u *OAuth2ClientUpdate) SaveX(ctx context.Context) int {
|
|
affected, err := _u.Save(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return affected
|
|
}
|
|
|
|
// Exec executes the query.
|
|
func (_u *OAuth2ClientUpdate) Exec(ctx context.Context) error {
|
|
_, err := _u.Save(ctx)
|
|
return err
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (_u *OAuth2ClientUpdate) ExecX(ctx context.Context) {
|
|
if err := _u.Exec(ctx); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
|
|
// check runs all checks and user-defined validators on the builder.
|
|
func (_u *OAuth2ClientUpdate) check() error {
|
|
if v, ok := _u.mutation.Secret(); ok {
|
|
if err := oauth2client.SecretValidator(v); err != nil {
|
|
return &ValidationError{Name: "secret", err: fmt.Errorf(`db: validator failed for field "OAuth2Client.secret": %w`, err)}
|
|
}
|
|
}
|
|
if v, ok := _u.mutation.Name(); ok {
|
|
if err := oauth2client.NameValidator(v); err != nil {
|
|
return &ValidationError{Name: "name", err: fmt.Errorf(`db: validator failed for field "OAuth2Client.name": %w`, err)}
|
|
}
|
|
}
|
|
if v, ok := _u.mutation.LogoURL(); ok {
|
|
if err := oauth2client.LogoURLValidator(v); err != nil {
|
|
return &ValidationError{Name: "logo_url", err: fmt.Errorf(`db: validator failed for field "OAuth2Client.logo_url": %w`, err)}
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (_u *OAuth2ClientUpdate) sqlSave(ctx context.Context) (_node int, err error) {
|
|
if err := _u.check(); err != nil {
|
|
return _node, err
|
|
}
|
|
_spec := sqlgraph.NewUpdateSpec(oauth2client.Table, oauth2client.Columns, sqlgraph.NewFieldSpec(oauth2client.FieldID, field.TypeString))
|
|
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.Secret(); ok {
|
|
_spec.SetField(oauth2client.FieldSecret, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.RedirectUris(); ok {
|
|
_spec.SetField(oauth2client.FieldRedirectUris, field.TypeJSON, value)
|
|
}
|
|
if value, ok := _u.mutation.AppendedRedirectUris(); ok {
|
|
_spec.AddModifier(func(u *sql.UpdateBuilder) {
|
|
sqljson.Append(u, oauth2client.FieldRedirectUris, value)
|
|
})
|
|
}
|
|
if _u.mutation.RedirectUrisCleared() {
|
|
_spec.ClearField(oauth2client.FieldRedirectUris, field.TypeJSON)
|
|
}
|
|
if value, ok := _u.mutation.TrustedPeers(); ok {
|
|
_spec.SetField(oauth2client.FieldTrustedPeers, field.TypeJSON, value)
|
|
}
|
|
if value, ok := _u.mutation.AppendedTrustedPeers(); ok {
|
|
_spec.AddModifier(func(u *sql.UpdateBuilder) {
|
|
sqljson.Append(u, oauth2client.FieldTrustedPeers, value)
|
|
})
|
|
}
|
|
if _u.mutation.TrustedPeersCleared() {
|
|
_spec.ClearField(oauth2client.FieldTrustedPeers, field.TypeJSON)
|
|
}
|
|
if value, ok := _u.mutation.Public(); ok {
|
|
_spec.SetField(oauth2client.FieldPublic, field.TypeBool, value)
|
|
}
|
|
if value, ok := _u.mutation.Name(); ok {
|
|
_spec.SetField(oauth2client.FieldName, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.LogoURL(); ok {
|
|
_spec.SetField(oauth2client.FieldLogoURL, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.AllowedConnectors(); ok {
|
|
_spec.SetField(oauth2client.FieldAllowedConnectors, field.TypeJSON, value)
|
|
}
|
|
if value, ok := _u.mutation.AppendedAllowedConnectors(); ok {
|
|
_spec.AddModifier(func(u *sql.UpdateBuilder) {
|
|
sqljson.Append(u, oauth2client.FieldAllowedConnectors, value)
|
|
})
|
|
}
|
|
if _u.mutation.AllowedConnectorsCleared() {
|
|
_spec.ClearField(oauth2client.FieldAllowedConnectors, field.TypeJSON)
|
|
}
|
|
if value, ok := _u.mutation.MfaChain(); ok {
|
|
_spec.SetField(oauth2client.FieldMfaChain, field.TypeJSON, value)
|
|
}
|
|
if value, ok := _u.mutation.AppendedMfaChain(); ok {
|
|
_spec.AddModifier(func(u *sql.UpdateBuilder) {
|
|
sqljson.Append(u, oauth2client.FieldMfaChain, value)
|
|
})
|
|
}
|
|
if _u.mutation.MfaChainCleared() {
|
|
_spec.ClearField(oauth2client.FieldMfaChain, field.TypeJSON)
|
|
}
|
|
if value, ok := _u.mutation.PostLogoutRedirectUris(); ok {
|
|
_spec.SetField(oauth2client.FieldPostLogoutRedirectUris, field.TypeJSON, value)
|
|
}
|
|
if value, ok := _u.mutation.AppendedPostLogoutRedirectUris(); ok {
|
|
_spec.AddModifier(func(u *sql.UpdateBuilder) {
|
|
sqljson.Append(u, oauth2client.FieldPostLogoutRedirectUris, value)
|
|
})
|
|
}
|
|
if _u.mutation.PostLogoutRedirectUrisCleared() {
|
|
_spec.ClearField(oauth2client.FieldPostLogoutRedirectUris, field.TypeJSON)
|
|
}
|
|
if value, ok := _u.mutation.SSOSharedWith(); ok {
|
|
_spec.SetField(oauth2client.FieldSSOSharedWith, field.TypeJSON, value)
|
|
}
|
|
if value, ok := _u.mutation.AppendedSSOSharedWith(); ok {
|
|
_spec.AddModifier(func(u *sql.UpdateBuilder) {
|
|
sqljson.Append(u, oauth2client.FieldSSOSharedWith, value)
|
|
})
|
|
}
|
|
if _u.mutation.SSOSharedWithCleared() {
|
|
_spec.ClearField(oauth2client.FieldSSOSharedWith, field.TypeJSON)
|
|
}
|
|
if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil {
|
|
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
|
err = &NotFoundError{oauth2client.Label}
|
|
} else if sqlgraph.IsConstraintError(err) {
|
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
|
}
|
|
return 0, err
|
|
}
|
|
_u.mutation.done = true
|
|
return _node, nil
|
|
}
|
|
|
|
// OAuth2ClientUpdateOne is the builder for updating a single OAuth2Client entity.
|
|
type OAuth2ClientUpdateOne struct {
|
|
config
|
|
fields []string
|
|
hooks []Hook
|
|
mutation *OAuth2ClientMutation
|
|
}
|
|
|
|
// SetSecret sets the "secret" field.
|
|
func (_u *OAuth2ClientUpdateOne) SetSecret(v string) *OAuth2ClientUpdateOne {
|
|
_u.mutation.SetSecret(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableSecret sets the "secret" field if the given value is not nil.
|
|
func (_u *OAuth2ClientUpdateOne) SetNillableSecret(v *string) *OAuth2ClientUpdateOne {
|
|
if v != nil {
|
|
_u.SetSecret(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetRedirectUris sets the "redirect_uris" field.
|
|
func (_u *OAuth2ClientUpdateOne) SetRedirectUris(v []string) *OAuth2ClientUpdateOne {
|
|
_u.mutation.SetRedirectUris(v)
|
|
return _u
|
|
}
|
|
|
|
// AppendRedirectUris appends value to the "redirect_uris" field.
|
|
func (_u *OAuth2ClientUpdateOne) AppendRedirectUris(v []string) *OAuth2ClientUpdateOne {
|
|
_u.mutation.AppendRedirectUris(v)
|
|
return _u
|
|
}
|
|
|
|
// ClearRedirectUris clears the value of the "redirect_uris" field.
|
|
func (_u *OAuth2ClientUpdateOne) ClearRedirectUris() *OAuth2ClientUpdateOne {
|
|
_u.mutation.ClearRedirectUris()
|
|
return _u
|
|
}
|
|
|
|
// SetTrustedPeers sets the "trusted_peers" field.
|
|
func (_u *OAuth2ClientUpdateOne) SetTrustedPeers(v []string) *OAuth2ClientUpdateOne {
|
|
_u.mutation.SetTrustedPeers(v)
|
|
return _u
|
|
}
|
|
|
|
// AppendTrustedPeers appends value to the "trusted_peers" field.
|
|
func (_u *OAuth2ClientUpdateOne) AppendTrustedPeers(v []string) *OAuth2ClientUpdateOne {
|
|
_u.mutation.AppendTrustedPeers(v)
|
|
return _u
|
|
}
|
|
|
|
// ClearTrustedPeers clears the value of the "trusted_peers" field.
|
|
func (_u *OAuth2ClientUpdateOne) ClearTrustedPeers() *OAuth2ClientUpdateOne {
|
|
_u.mutation.ClearTrustedPeers()
|
|
return _u
|
|
}
|
|
|
|
// SetPublic sets the "public" field.
|
|
func (_u *OAuth2ClientUpdateOne) SetPublic(v bool) *OAuth2ClientUpdateOne {
|
|
_u.mutation.SetPublic(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillablePublic sets the "public" field if the given value is not nil.
|
|
func (_u *OAuth2ClientUpdateOne) SetNillablePublic(v *bool) *OAuth2ClientUpdateOne {
|
|
if v != nil {
|
|
_u.SetPublic(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetName sets the "name" field.
|
|
func (_u *OAuth2ClientUpdateOne) SetName(v string) *OAuth2ClientUpdateOne {
|
|
_u.mutation.SetName(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableName sets the "name" field if the given value is not nil.
|
|
func (_u *OAuth2ClientUpdateOne) SetNillableName(v *string) *OAuth2ClientUpdateOne {
|
|
if v != nil {
|
|
_u.SetName(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetLogoURL sets the "logo_url" field.
|
|
func (_u *OAuth2ClientUpdateOne) SetLogoURL(v string) *OAuth2ClientUpdateOne {
|
|
_u.mutation.SetLogoURL(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableLogoURL sets the "logo_url" field if the given value is not nil.
|
|
func (_u *OAuth2ClientUpdateOne) SetNillableLogoURL(v *string) *OAuth2ClientUpdateOne {
|
|
if v != nil {
|
|
_u.SetLogoURL(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetAllowedConnectors sets the "allowed_connectors" field.
|
|
func (_u *OAuth2ClientUpdateOne) SetAllowedConnectors(v []string) *OAuth2ClientUpdateOne {
|
|
_u.mutation.SetAllowedConnectors(v)
|
|
return _u
|
|
}
|
|
|
|
// AppendAllowedConnectors appends value to the "allowed_connectors" field.
|
|
func (_u *OAuth2ClientUpdateOne) AppendAllowedConnectors(v []string) *OAuth2ClientUpdateOne {
|
|
_u.mutation.AppendAllowedConnectors(v)
|
|
return _u
|
|
}
|
|
|
|
// ClearAllowedConnectors clears the value of the "allowed_connectors" field.
|
|
func (_u *OAuth2ClientUpdateOne) ClearAllowedConnectors() *OAuth2ClientUpdateOne {
|
|
_u.mutation.ClearAllowedConnectors()
|
|
return _u
|
|
}
|
|
|
|
// SetMfaChain sets the "mfa_chain" field.
|
|
func (_u *OAuth2ClientUpdateOne) SetMfaChain(v []string) *OAuth2ClientUpdateOne {
|
|
_u.mutation.SetMfaChain(v)
|
|
return _u
|
|
}
|
|
|
|
// AppendMfaChain appends value to the "mfa_chain" field.
|
|
func (_u *OAuth2ClientUpdateOne) AppendMfaChain(v []string) *OAuth2ClientUpdateOne {
|
|
_u.mutation.AppendMfaChain(v)
|
|
return _u
|
|
}
|
|
|
|
// ClearMfaChain clears the value of the "mfa_chain" field.
|
|
func (_u *OAuth2ClientUpdateOne) ClearMfaChain() *OAuth2ClientUpdateOne {
|
|
_u.mutation.ClearMfaChain()
|
|
return _u
|
|
}
|
|
|
|
// SetPostLogoutRedirectUris sets the "post_logout_redirect_uris" field.
|
|
func (_u *OAuth2ClientUpdateOne) SetPostLogoutRedirectUris(v []string) *OAuth2ClientUpdateOne {
|
|
_u.mutation.SetPostLogoutRedirectUris(v)
|
|
return _u
|
|
}
|
|
|
|
// AppendPostLogoutRedirectUris appends value to the "post_logout_redirect_uris" field.
|
|
func (_u *OAuth2ClientUpdateOne) AppendPostLogoutRedirectUris(v []string) *OAuth2ClientUpdateOne {
|
|
_u.mutation.AppendPostLogoutRedirectUris(v)
|
|
return _u
|
|
}
|
|
|
|
// ClearPostLogoutRedirectUris clears the value of the "post_logout_redirect_uris" field.
|
|
func (_u *OAuth2ClientUpdateOne) ClearPostLogoutRedirectUris() *OAuth2ClientUpdateOne {
|
|
_u.mutation.ClearPostLogoutRedirectUris()
|
|
return _u
|
|
}
|
|
|
|
// SetSSOSharedWith sets the "sso_shared_with" field.
|
|
func (_u *OAuth2ClientUpdateOne) SetSSOSharedWith(v []string) *OAuth2ClientUpdateOne {
|
|
_u.mutation.SetSSOSharedWith(v)
|
|
return _u
|
|
}
|
|
|
|
// AppendSSOSharedWith appends value to the "sso_shared_with" field.
|
|
func (_u *OAuth2ClientUpdateOne) AppendSSOSharedWith(v []string) *OAuth2ClientUpdateOne {
|
|
_u.mutation.AppendSSOSharedWith(v)
|
|
return _u
|
|
}
|
|
|
|
// ClearSSOSharedWith clears the value of the "sso_shared_with" field.
|
|
func (_u *OAuth2ClientUpdateOne) ClearSSOSharedWith() *OAuth2ClientUpdateOne {
|
|
_u.mutation.ClearSSOSharedWith()
|
|
return _u
|
|
}
|
|
|
|
// Mutation returns the OAuth2ClientMutation object of the builder.
|
|
func (_u *OAuth2ClientUpdateOne) Mutation() *OAuth2ClientMutation {
|
|
return _u.mutation
|
|
}
|
|
|
|
// Where appends a list predicates to the OAuth2ClientUpdate builder.
|
|
func (_u *OAuth2ClientUpdateOne) Where(ps ...predicate.OAuth2Client) *OAuth2ClientUpdateOne {
|
|
_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 *OAuth2ClientUpdateOne) Select(field string, fields ...string) *OAuth2ClientUpdateOne {
|
|
_u.fields = append([]string{field}, fields...)
|
|
return _u
|
|
}
|
|
|
|
// Save executes the query and returns the updated OAuth2Client entity.
|
|
func (_u *OAuth2ClientUpdateOne) Save(ctx context.Context) (*OAuth2Client, error) {
|
|
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
|
|
}
|
|
|
|
// SaveX is like Save, but panics if an error occurs.
|
|
func (_u *OAuth2ClientUpdateOne) SaveX(ctx context.Context) *OAuth2Client {
|
|
node, err := _u.Save(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return node
|
|
}
|
|
|
|
// Exec executes the query on the entity.
|
|
func (_u *OAuth2ClientUpdateOne) Exec(ctx context.Context) error {
|
|
_, err := _u.Save(ctx)
|
|
return err
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (_u *OAuth2ClientUpdateOne) ExecX(ctx context.Context) {
|
|
if err := _u.Exec(ctx); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
|
|
// check runs all checks and user-defined validators on the builder.
|
|
func (_u *OAuth2ClientUpdateOne) check() error {
|
|
if v, ok := _u.mutation.Secret(); ok {
|
|
if err := oauth2client.SecretValidator(v); err != nil {
|
|
return &ValidationError{Name: "secret", err: fmt.Errorf(`db: validator failed for field "OAuth2Client.secret": %w`, err)}
|
|
}
|
|
}
|
|
if v, ok := _u.mutation.Name(); ok {
|
|
if err := oauth2client.NameValidator(v); err != nil {
|
|
return &ValidationError{Name: "name", err: fmt.Errorf(`db: validator failed for field "OAuth2Client.name": %w`, err)}
|
|
}
|
|
}
|
|
if v, ok := _u.mutation.LogoURL(); ok {
|
|
if err := oauth2client.LogoURLValidator(v); err != nil {
|
|
return &ValidationError{Name: "logo_url", err: fmt.Errorf(`db: validator failed for field "OAuth2Client.logo_url": %w`, err)}
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (_u *OAuth2ClientUpdateOne) sqlSave(ctx context.Context) (_node *OAuth2Client, err error) {
|
|
if err := _u.check(); err != nil {
|
|
return _node, err
|
|
}
|
|
_spec := sqlgraph.NewUpdateSpec(oauth2client.Table, oauth2client.Columns, sqlgraph.NewFieldSpec(oauth2client.FieldID, field.TypeString))
|
|
id, ok := _u.mutation.ID()
|
|
if !ok {
|
|
return nil, &ValidationError{Name: "id", err: errors.New(`db: missing "OAuth2Client.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, oauth2client.FieldID)
|
|
for _, f := range fields {
|
|
if !oauth2client.ValidColumn(f) {
|
|
return nil, &ValidationError{Name: f, err: fmt.Errorf("db: invalid field %q for query", f)}
|
|
}
|
|
if f != oauth2client.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.Secret(); ok {
|
|
_spec.SetField(oauth2client.FieldSecret, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.RedirectUris(); ok {
|
|
_spec.SetField(oauth2client.FieldRedirectUris, field.TypeJSON, value)
|
|
}
|
|
if value, ok := _u.mutation.AppendedRedirectUris(); ok {
|
|
_spec.AddModifier(func(u *sql.UpdateBuilder) {
|
|
sqljson.Append(u, oauth2client.FieldRedirectUris, value)
|
|
})
|
|
}
|
|
if _u.mutation.RedirectUrisCleared() {
|
|
_spec.ClearField(oauth2client.FieldRedirectUris, field.TypeJSON)
|
|
}
|
|
if value, ok := _u.mutation.TrustedPeers(); ok {
|
|
_spec.SetField(oauth2client.FieldTrustedPeers, field.TypeJSON, value)
|
|
}
|
|
if value, ok := _u.mutation.AppendedTrustedPeers(); ok {
|
|
_spec.AddModifier(func(u *sql.UpdateBuilder) {
|
|
sqljson.Append(u, oauth2client.FieldTrustedPeers, value)
|
|
})
|
|
}
|
|
if _u.mutation.TrustedPeersCleared() {
|
|
_spec.ClearField(oauth2client.FieldTrustedPeers, field.TypeJSON)
|
|
}
|
|
if value, ok := _u.mutation.Public(); ok {
|
|
_spec.SetField(oauth2client.FieldPublic, field.TypeBool, value)
|
|
}
|
|
if value, ok := _u.mutation.Name(); ok {
|
|
_spec.SetField(oauth2client.FieldName, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.LogoURL(); ok {
|
|
_spec.SetField(oauth2client.FieldLogoURL, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.AllowedConnectors(); ok {
|
|
_spec.SetField(oauth2client.FieldAllowedConnectors, field.TypeJSON, value)
|
|
}
|
|
if value, ok := _u.mutation.AppendedAllowedConnectors(); ok {
|
|
_spec.AddModifier(func(u *sql.UpdateBuilder) {
|
|
sqljson.Append(u, oauth2client.FieldAllowedConnectors, value)
|
|
})
|
|
}
|
|
if _u.mutation.AllowedConnectorsCleared() {
|
|
_spec.ClearField(oauth2client.FieldAllowedConnectors, field.TypeJSON)
|
|
}
|
|
if value, ok := _u.mutation.MfaChain(); ok {
|
|
_spec.SetField(oauth2client.FieldMfaChain, field.TypeJSON, value)
|
|
}
|
|
if value, ok := _u.mutation.AppendedMfaChain(); ok {
|
|
_spec.AddModifier(func(u *sql.UpdateBuilder) {
|
|
sqljson.Append(u, oauth2client.FieldMfaChain, value)
|
|
})
|
|
}
|
|
if _u.mutation.MfaChainCleared() {
|
|
_spec.ClearField(oauth2client.FieldMfaChain, field.TypeJSON)
|
|
}
|
|
if value, ok := _u.mutation.PostLogoutRedirectUris(); ok {
|
|
_spec.SetField(oauth2client.FieldPostLogoutRedirectUris, field.TypeJSON, value)
|
|
}
|
|
if value, ok := _u.mutation.AppendedPostLogoutRedirectUris(); ok {
|
|
_spec.AddModifier(func(u *sql.UpdateBuilder) {
|
|
sqljson.Append(u, oauth2client.FieldPostLogoutRedirectUris, value)
|
|
})
|
|
}
|
|
if _u.mutation.PostLogoutRedirectUrisCleared() {
|
|
_spec.ClearField(oauth2client.FieldPostLogoutRedirectUris, field.TypeJSON)
|
|
}
|
|
if value, ok := _u.mutation.SSOSharedWith(); ok {
|
|
_spec.SetField(oauth2client.FieldSSOSharedWith, field.TypeJSON, value)
|
|
}
|
|
if value, ok := _u.mutation.AppendedSSOSharedWith(); ok {
|
|
_spec.AddModifier(func(u *sql.UpdateBuilder) {
|
|
sqljson.Append(u, oauth2client.FieldSSOSharedWith, value)
|
|
})
|
|
}
|
|
if _u.mutation.SSOSharedWithCleared() {
|
|
_spec.ClearField(oauth2client.FieldSSOSharedWith, field.TypeJSON)
|
|
}
|
|
_node = &OAuth2Client{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{oauth2client.Label}
|
|
} else if sqlgraph.IsConstraintError(err) {
|
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
|
}
|
|
return nil, err
|
|
}
|
|
_u.mutation.done = true
|
|
return _node, nil
|
|
}
|