OpenID Connect (OIDC) identity and OAuth 2.0 provider with pluggable connectors
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

915 lines
28 KiB

// Code generated by ent, DO NOT EDIT.
package db
import (
"context"
"errors"
"fmt"
"time"
"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/authrequest"
"github.com/dexidp/dex/storage/ent/db/predicate"
)
// AuthRequestUpdate is the builder for updating AuthRequest entities.
type AuthRequestUpdate struct {
config
hooks []Hook
mutation *AuthRequestMutation
}
// Where appends a list predicates to the AuthRequestUpdate builder.
func (_u *AuthRequestUpdate) Where(ps ...predicate.AuthRequest) *AuthRequestUpdate {
_u.mutation.Where(ps...)
return _u
}
// SetClientID sets the "client_id" field.
func (_u *AuthRequestUpdate) SetClientID(v string) *AuthRequestUpdate {
_u.mutation.SetClientID(v)
return _u
}
// SetNillableClientID sets the "client_id" field if the given value is not nil.
func (_u *AuthRequestUpdate) SetNillableClientID(v *string) *AuthRequestUpdate {
if v != nil {
_u.SetClientID(*v)
}
return _u
}
// SetScopes sets the "scopes" field.
func (_u *AuthRequestUpdate) SetScopes(v []string) *AuthRequestUpdate {
_u.mutation.SetScopes(v)
return _u
}
// AppendScopes appends value to the "scopes" field.
func (_u *AuthRequestUpdate) AppendScopes(v []string) *AuthRequestUpdate {
_u.mutation.AppendScopes(v)
return _u
}
// ClearScopes clears the value of the "scopes" field.
func (_u *AuthRequestUpdate) ClearScopes() *AuthRequestUpdate {
_u.mutation.ClearScopes()
return _u
}
// SetResponseTypes sets the "response_types" field.
func (_u *AuthRequestUpdate) SetResponseTypes(v []string) *AuthRequestUpdate {
_u.mutation.SetResponseTypes(v)
return _u
}
// AppendResponseTypes appends value to the "response_types" field.
func (_u *AuthRequestUpdate) AppendResponseTypes(v []string) *AuthRequestUpdate {
_u.mutation.AppendResponseTypes(v)
return _u
}
// ClearResponseTypes clears the value of the "response_types" field.
func (_u *AuthRequestUpdate) ClearResponseTypes() *AuthRequestUpdate {
_u.mutation.ClearResponseTypes()
return _u
}
// SetRedirectURI sets the "redirect_uri" field.
func (_u *AuthRequestUpdate) SetRedirectURI(v string) *AuthRequestUpdate {
_u.mutation.SetRedirectURI(v)
return _u
}
// SetNillableRedirectURI sets the "redirect_uri" field if the given value is not nil.
func (_u *AuthRequestUpdate) SetNillableRedirectURI(v *string) *AuthRequestUpdate {
if v != nil {
_u.SetRedirectURI(*v)
}
return _u
}
// SetNonce sets the "nonce" field.
func (_u *AuthRequestUpdate) SetNonce(v string) *AuthRequestUpdate {
_u.mutation.SetNonce(v)
return _u
}
// SetNillableNonce sets the "nonce" field if the given value is not nil.
func (_u *AuthRequestUpdate) SetNillableNonce(v *string) *AuthRequestUpdate {
if v != nil {
_u.SetNonce(*v)
}
return _u
}
// SetState sets the "state" field.
func (_u *AuthRequestUpdate) SetState(v string) *AuthRequestUpdate {
_u.mutation.SetState(v)
return _u
}
// SetNillableState sets the "state" field if the given value is not nil.
func (_u *AuthRequestUpdate) SetNillableState(v *string) *AuthRequestUpdate {
if v != nil {
_u.SetState(*v)
}
return _u
}
// SetForceApprovalPrompt sets the "force_approval_prompt" field.
func (_u *AuthRequestUpdate) SetForceApprovalPrompt(v bool) *AuthRequestUpdate {
_u.mutation.SetForceApprovalPrompt(v)
return _u
}
// SetNillableForceApprovalPrompt sets the "force_approval_prompt" field if the given value is not nil.
func (_u *AuthRequestUpdate) SetNillableForceApprovalPrompt(v *bool) *AuthRequestUpdate {
if v != nil {
_u.SetForceApprovalPrompt(*v)
}
return _u
}
// SetLoggedIn sets the "logged_in" field.
func (_u *AuthRequestUpdate) SetLoggedIn(v bool) *AuthRequestUpdate {
_u.mutation.SetLoggedIn(v)
return _u
}
// SetNillableLoggedIn sets the "logged_in" field if the given value is not nil.
func (_u *AuthRequestUpdate) SetNillableLoggedIn(v *bool) *AuthRequestUpdate {
if v != nil {
_u.SetLoggedIn(*v)
}
return _u
}
// SetClaimsUserID sets the "claims_user_id" field.
func (_u *AuthRequestUpdate) SetClaimsUserID(v string) *AuthRequestUpdate {
_u.mutation.SetClaimsUserID(v)
return _u
}
// SetNillableClaimsUserID sets the "claims_user_id" field if the given value is not nil.
func (_u *AuthRequestUpdate) SetNillableClaimsUserID(v *string) *AuthRequestUpdate {
if v != nil {
_u.SetClaimsUserID(*v)
}
return _u
}
// SetClaimsUsername sets the "claims_username" field.
func (_u *AuthRequestUpdate) SetClaimsUsername(v string) *AuthRequestUpdate {
_u.mutation.SetClaimsUsername(v)
return _u
}
// SetNillableClaimsUsername sets the "claims_username" field if the given value is not nil.
func (_u *AuthRequestUpdate) SetNillableClaimsUsername(v *string) *AuthRequestUpdate {
if v != nil {
_u.SetClaimsUsername(*v)
}
return _u
}
// SetClaimsEmail sets the "claims_email" field.
func (_u *AuthRequestUpdate) SetClaimsEmail(v string) *AuthRequestUpdate {
_u.mutation.SetClaimsEmail(v)
return _u
}
// SetNillableClaimsEmail sets the "claims_email" field if the given value is not nil.
func (_u *AuthRequestUpdate) SetNillableClaimsEmail(v *string) *AuthRequestUpdate {
if v != nil {
_u.SetClaimsEmail(*v)
}
return _u
}
// SetClaimsEmailVerified sets the "claims_email_verified" field.
func (_u *AuthRequestUpdate) SetClaimsEmailVerified(v bool) *AuthRequestUpdate {
_u.mutation.SetClaimsEmailVerified(v)
return _u
}
// SetNillableClaimsEmailVerified sets the "claims_email_verified" field if the given value is not nil.
func (_u *AuthRequestUpdate) SetNillableClaimsEmailVerified(v *bool) *AuthRequestUpdate {
if v != nil {
_u.SetClaimsEmailVerified(*v)
}
return _u
}
// SetClaimsGroups sets the "claims_groups" field.
func (_u *AuthRequestUpdate) SetClaimsGroups(v []string) *AuthRequestUpdate {
_u.mutation.SetClaimsGroups(v)
return _u
}
// AppendClaimsGroups appends value to the "claims_groups" field.
func (_u *AuthRequestUpdate) AppendClaimsGroups(v []string) *AuthRequestUpdate {
_u.mutation.AppendClaimsGroups(v)
return _u
}
// ClearClaimsGroups clears the value of the "claims_groups" field.
func (_u *AuthRequestUpdate) ClearClaimsGroups() *AuthRequestUpdate {
_u.mutation.ClearClaimsGroups()
return _u
}
// SetClaimsPreferredUsername sets the "claims_preferred_username" field.
func (_u *AuthRequestUpdate) SetClaimsPreferredUsername(v string) *AuthRequestUpdate {
_u.mutation.SetClaimsPreferredUsername(v)
return _u
}
// SetNillableClaimsPreferredUsername sets the "claims_preferred_username" field if the given value is not nil.
func (_u *AuthRequestUpdate) SetNillableClaimsPreferredUsername(v *string) *AuthRequestUpdate {
if v != nil {
_u.SetClaimsPreferredUsername(*v)
}
return _u
}
// SetConnectorID sets the "connector_id" field.
func (_u *AuthRequestUpdate) SetConnectorID(v string) *AuthRequestUpdate {
_u.mutation.SetConnectorID(v)
return _u
}
// SetNillableConnectorID sets the "connector_id" field if the given value is not nil.
func (_u *AuthRequestUpdate) SetNillableConnectorID(v *string) *AuthRequestUpdate {
if v != nil {
_u.SetConnectorID(*v)
}
return _u
}
// SetConnectorData sets the "connector_data" field.
func (_u *AuthRequestUpdate) SetConnectorData(v []byte) *AuthRequestUpdate {
_u.mutation.SetConnectorData(v)
return _u
}
// ClearConnectorData clears the value of the "connector_data" field.
func (_u *AuthRequestUpdate) ClearConnectorData() *AuthRequestUpdate {
_u.mutation.ClearConnectorData()
return _u
}
// SetExpiry sets the "expiry" field.
func (_u *AuthRequestUpdate) SetExpiry(v time.Time) *AuthRequestUpdate {
_u.mutation.SetExpiry(v)
return _u
}
// SetNillableExpiry sets the "expiry" field if the given value is not nil.
func (_u *AuthRequestUpdate) SetNillableExpiry(v *time.Time) *AuthRequestUpdate {
if v != nil {
_u.SetExpiry(*v)
}
return _u
}
// SetCodeChallenge sets the "code_challenge" field.
func (_u *AuthRequestUpdate) SetCodeChallenge(v string) *AuthRequestUpdate {
_u.mutation.SetCodeChallenge(v)
return _u
}
// SetNillableCodeChallenge sets the "code_challenge" field if the given value is not nil.
func (_u *AuthRequestUpdate) SetNillableCodeChallenge(v *string) *AuthRequestUpdate {
if v != nil {
_u.SetCodeChallenge(*v)
}
return _u
}
// SetCodeChallengeMethod sets the "code_challenge_method" field.
func (_u *AuthRequestUpdate) SetCodeChallengeMethod(v string) *AuthRequestUpdate {
_u.mutation.SetCodeChallengeMethod(v)
return _u
}
// SetNillableCodeChallengeMethod sets the "code_challenge_method" field if the given value is not nil.
func (_u *AuthRequestUpdate) SetNillableCodeChallengeMethod(v *string) *AuthRequestUpdate {
if v != nil {
_u.SetCodeChallengeMethod(*v)
}
return _u
}
// SetHmacKey sets the "hmac_key" field.
func (_u *AuthRequestUpdate) SetHmacKey(v []byte) *AuthRequestUpdate {
_u.mutation.SetHmacKey(v)
return _u
}
// Mutation returns the AuthRequestMutation object of the builder.
func (_u *AuthRequestUpdate) Mutation() *AuthRequestMutation {
return _u.mutation
}
// Save executes the query and returns the number of nodes affected by the update operation.
func (_u *AuthRequestUpdate) 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 *AuthRequestUpdate) SaveX(ctx context.Context) int {
affected, err := _u.Save(ctx)
if err != nil {
panic(err)
}
return affected
}
// Exec executes the query.
func (_u *AuthRequestUpdate) Exec(ctx context.Context) error {
_, err := _u.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (_u *AuthRequestUpdate) ExecX(ctx context.Context) {
if err := _u.Exec(ctx); err != nil {
panic(err)
}
}
func (_u *AuthRequestUpdate) sqlSave(ctx context.Context) (_node int, err error) {
_spec := sqlgraph.NewUpdateSpec(authrequest.Table, authrequest.Columns, sqlgraph.NewFieldSpec(authrequest.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.ClientID(); ok {
_spec.SetField(authrequest.FieldClientID, field.TypeString, value)
}
if value, ok := _u.mutation.Scopes(); ok {
_spec.SetField(authrequest.FieldScopes, field.TypeJSON, value)
}
if value, ok := _u.mutation.AppendedScopes(); ok {
_spec.AddModifier(func(u *sql.UpdateBuilder) {
sqljson.Append(u, authrequest.FieldScopes, value)
})
}
if _u.mutation.ScopesCleared() {
_spec.ClearField(authrequest.FieldScopes, field.TypeJSON)
}
if value, ok := _u.mutation.ResponseTypes(); ok {
_spec.SetField(authrequest.FieldResponseTypes, field.TypeJSON, value)
}
if value, ok := _u.mutation.AppendedResponseTypes(); ok {
_spec.AddModifier(func(u *sql.UpdateBuilder) {
sqljson.Append(u, authrequest.FieldResponseTypes, value)
})
}
if _u.mutation.ResponseTypesCleared() {
_spec.ClearField(authrequest.FieldResponseTypes, field.TypeJSON)
}
if value, ok := _u.mutation.RedirectURI(); ok {
_spec.SetField(authrequest.FieldRedirectURI, field.TypeString, value)
}
if value, ok := _u.mutation.Nonce(); ok {
_spec.SetField(authrequest.FieldNonce, field.TypeString, value)
}
if value, ok := _u.mutation.State(); ok {
_spec.SetField(authrequest.FieldState, field.TypeString, value)
}
if value, ok := _u.mutation.ForceApprovalPrompt(); ok {
_spec.SetField(authrequest.FieldForceApprovalPrompt, field.TypeBool, value)
}
if value, ok := _u.mutation.LoggedIn(); ok {
_spec.SetField(authrequest.FieldLoggedIn, field.TypeBool, value)
}
if value, ok := _u.mutation.ClaimsUserID(); ok {
_spec.SetField(authrequest.FieldClaimsUserID, field.TypeString, value)
}
if value, ok := _u.mutation.ClaimsUsername(); ok {
_spec.SetField(authrequest.FieldClaimsUsername, field.TypeString, value)
}
if value, ok := _u.mutation.ClaimsEmail(); ok {
_spec.SetField(authrequest.FieldClaimsEmail, field.TypeString, value)
}
if value, ok := _u.mutation.ClaimsEmailVerified(); ok {
_spec.SetField(authrequest.FieldClaimsEmailVerified, field.TypeBool, value)
}
if value, ok := _u.mutation.ClaimsGroups(); ok {
_spec.SetField(authrequest.FieldClaimsGroups, field.TypeJSON, value)
}
if value, ok := _u.mutation.AppendedClaimsGroups(); ok {
_spec.AddModifier(func(u *sql.UpdateBuilder) {
sqljson.Append(u, authrequest.FieldClaimsGroups, value)
})
}
if _u.mutation.ClaimsGroupsCleared() {
_spec.ClearField(authrequest.FieldClaimsGroups, field.TypeJSON)
}
if value, ok := _u.mutation.ClaimsPreferredUsername(); ok {
_spec.SetField(authrequest.FieldClaimsPreferredUsername, field.TypeString, value)
}
if value, ok := _u.mutation.ConnectorID(); ok {
_spec.SetField(authrequest.FieldConnectorID, field.TypeString, value)
}
if value, ok := _u.mutation.ConnectorData(); ok {
_spec.SetField(authrequest.FieldConnectorData, field.TypeBytes, value)
}
if _u.mutation.ConnectorDataCleared() {
_spec.ClearField(authrequest.FieldConnectorData, field.TypeBytes)
}
if value, ok := _u.mutation.Expiry(); ok {
_spec.SetField(authrequest.FieldExpiry, field.TypeTime, value)
}
if value, ok := _u.mutation.CodeChallenge(); ok {
_spec.SetField(authrequest.FieldCodeChallenge, field.TypeString, value)
}
if value, ok := _u.mutation.CodeChallengeMethod(); ok {
_spec.SetField(authrequest.FieldCodeChallengeMethod, field.TypeString, value)
}
if value, ok := _u.mutation.HmacKey(); ok {
_spec.SetField(authrequest.FieldHmacKey, field.TypeBytes, value)
}
if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{authrequest.Label}
} else if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return 0, err
}
_u.mutation.done = true
return _node, nil
}
// AuthRequestUpdateOne is the builder for updating a single AuthRequest entity.
type AuthRequestUpdateOne struct {
config
fields []string
hooks []Hook
mutation *AuthRequestMutation
}
// SetClientID sets the "client_id" field.
func (_u *AuthRequestUpdateOne) SetClientID(v string) *AuthRequestUpdateOne {
_u.mutation.SetClientID(v)
return _u
}
// SetNillableClientID sets the "client_id" field if the given value is not nil.
func (_u *AuthRequestUpdateOne) SetNillableClientID(v *string) *AuthRequestUpdateOne {
if v != nil {
_u.SetClientID(*v)
}
return _u
}
// SetScopes sets the "scopes" field.
func (_u *AuthRequestUpdateOne) SetScopes(v []string) *AuthRequestUpdateOne {
_u.mutation.SetScopes(v)
return _u
}
// AppendScopes appends value to the "scopes" field.
func (_u *AuthRequestUpdateOne) AppendScopes(v []string) *AuthRequestUpdateOne {
_u.mutation.AppendScopes(v)
return _u
}
// ClearScopes clears the value of the "scopes" field.
func (_u *AuthRequestUpdateOne) ClearScopes() *AuthRequestUpdateOne {
_u.mutation.ClearScopes()
return _u
}
// SetResponseTypes sets the "response_types" field.
func (_u *AuthRequestUpdateOne) SetResponseTypes(v []string) *AuthRequestUpdateOne {
_u.mutation.SetResponseTypes(v)
return _u
}
// AppendResponseTypes appends value to the "response_types" field.
func (_u *AuthRequestUpdateOne) AppendResponseTypes(v []string) *AuthRequestUpdateOne {
_u.mutation.AppendResponseTypes(v)
return _u
}
// ClearResponseTypes clears the value of the "response_types" field.
func (_u *AuthRequestUpdateOne) ClearResponseTypes() *AuthRequestUpdateOne {
_u.mutation.ClearResponseTypes()
return _u
}
// SetRedirectURI sets the "redirect_uri" field.
func (_u *AuthRequestUpdateOne) SetRedirectURI(v string) *AuthRequestUpdateOne {
_u.mutation.SetRedirectURI(v)
return _u
}
// SetNillableRedirectURI sets the "redirect_uri" field if the given value is not nil.
func (_u *AuthRequestUpdateOne) SetNillableRedirectURI(v *string) *AuthRequestUpdateOne {
if v != nil {
_u.SetRedirectURI(*v)
}
return _u
}
// SetNonce sets the "nonce" field.
func (_u *AuthRequestUpdateOne) SetNonce(v string) *AuthRequestUpdateOne {
_u.mutation.SetNonce(v)
return _u
}
// SetNillableNonce sets the "nonce" field if the given value is not nil.
func (_u *AuthRequestUpdateOne) SetNillableNonce(v *string) *AuthRequestUpdateOne {
if v != nil {
_u.SetNonce(*v)
}
return _u
}
// SetState sets the "state" field.
func (_u *AuthRequestUpdateOne) SetState(v string) *AuthRequestUpdateOne {
_u.mutation.SetState(v)
return _u
}
// SetNillableState sets the "state" field if the given value is not nil.
func (_u *AuthRequestUpdateOne) SetNillableState(v *string) *AuthRequestUpdateOne {
if v != nil {
_u.SetState(*v)
}
return _u
}
// SetForceApprovalPrompt sets the "force_approval_prompt" field.
func (_u *AuthRequestUpdateOne) SetForceApprovalPrompt(v bool) *AuthRequestUpdateOne {
_u.mutation.SetForceApprovalPrompt(v)
return _u
}
// SetNillableForceApprovalPrompt sets the "force_approval_prompt" field if the given value is not nil.
func (_u *AuthRequestUpdateOne) SetNillableForceApprovalPrompt(v *bool) *AuthRequestUpdateOne {
if v != nil {
_u.SetForceApprovalPrompt(*v)
}
return _u
}
// SetLoggedIn sets the "logged_in" field.
func (_u *AuthRequestUpdateOne) SetLoggedIn(v bool) *AuthRequestUpdateOne {
_u.mutation.SetLoggedIn(v)
return _u
}
// SetNillableLoggedIn sets the "logged_in" field if the given value is not nil.
func (_u *AuthRequestUpdateOne) SetNillableLoggedIn(v *bool) *AuthRequestUpdateOne {
if v != nil {
_u.SetLoggedIn(*v)
}
return _u
}
// SetClaimsUserID sets the "claims_user_id" field.
func (_u *AuthRequestUpdateOne) SetClaimsUserID(v string) *AuthRequestUpdateOne {
_u.mutation.SetClaimsUserID(v)
return _u
}
// SetNillableClaimsUserID sets the "claims_user_id" field if the given value is not nil.
func (_u *AuthRequestUpdateOne) SetNillableClaimsUserID(v *string) *AuthRequestUpdateOne {
if v != nil {
_u.SetClaimsUserID(*v)
}
return _u
}
// SetClaimsUsername sets the "claims_username" field.
func (_u *AuthRequestUpdateOne) SetClaimsUsername(v string) *AuthRequestUpdateOne {
_u.mutation.SetClaimsUsername(v)
return _u
}
// SetNillableClaimsUsername sets the "claims_username" field if the given value is not nil.
func (_u *AuthRequestUpdateOne) SetNillableClaimsUsername(v *string) *AuthRequestUpdateOne {
if v != nil {
_u.SetClaimsUsername(*v)
}
return _u
}
// SetClaimsEmail sets the "claims_email" field.
func (_u *AuthRequestUpdateOne) SetClaimsEmail(v string) *AuthRequestUpdateOne {
_u.mutation.SetClaimsEmail(v)
return _u
}
// SetNillableClaimsEmail sets the "claims_email" field if the given value is not nil.
func (_u *AuthRequestUpdateOne) SetNillableClaimsEmail(v *string) *AuthRequestUpdateOne {
if v != nil {
_u.SetClaimsEmail(*v)
}
return _u
}
// SetClaimsEmailVerified sets the "claims_email_verified" field.
func (_u *AuthRequestUpdateOne) SetClaimsEmailVerified(v bool) *AuthRequestUpdateOne {
_u.mutation.SetClaimsEmailVerified(v)
return _u
}
// SetNillableClaimsEmailVerified sets the "claims_email_verified" field if the given value is not nil.
func (_u *AuthRequestUpdateOne) SetNillableClaimsEmailVerified(v *bool) *AuthRequestUpdateOne {
if v != nil {
_u.SetClaimsEmailVerified(*v)
}
return _u
}
// SetClaimsGroups sets the "claims_groups" field.
func (_u *AuthRequestUpdateOne) SetClaimsGroups(v []string) *AuthRequestUpdateOne {
_u.mutation.SetClaimsGroups(v)
return _u
}
// AppendClaimsGroups appends value to the "claims_groups" field.
func (_u *AuthRequestUpdateOne) AppendClaimsGroups(v []string) *AuthRequestUpdateOne {
_u.mutation.AppendClaimsGroups(v)
return _u
}
// ClearClaimsGroups clears the value of the "claims_groups" field.
func (_u *AuthRequestUpdateOne) ClearClaimsGroups() *AuthRequestUpdateOne {
_u.mutation.ClearClaimsGroups()
return _u
}
// SetClaimsPreferredUsername sets the "claims_preferred_username" field.
func (_u *AuthRequestUpdateOne) SetClaimsPreferredUsername(v string) *AuthRequestUpdateOne {
_u.mutation.SetClaimsPreferredUsername(v)
return _u
}
// SetNillableClaimsPreferredUsername sets the "claims_preferred_username" field if the given value is not nil.
func (_u *AuthRequestUpdateOne) SetNillableClaimsPreferredUsername(v *string) *AuthRequestUpdateOne {
if v != nil {
_u.SetClaimsPreferredUsername(*v)
}
return _u
}
// SetConnectorID sets the "connector_id" field.
func (_u *AuthRequestUpdateOne) SetConnectorID(v string) *AuthRequestUpdateOne {
_u.mutation.SetConnectorID(v)
return _u
}
// SetNillableConnectorID sets the "connector_id" field if the given value is not nil.
func (_u *AuthRequestUpdateOne) SetNillableConnectorID(v *string) *AuthRequestUpdateOne {
if v != nil {
_u.SetConnectorID(*v)
}
return _u
}
// SetConnectorData sets the "connector_data" field.
func (_u *AuthRequestUpdateOne) SetConnectorData(v []byte) *AuthRequestUpdateOne {
_u.mutation.SetConnectorData(v)
return _u
}
// ClearConnectorData clears the value of the "connector_data" field.
func (_u *AuthRequestUpdateOne) ClearConnectorData() *AuthRequestUpdateOne {
_u.mutation.ClearConnectorData()
return _u
}
// SetExpiry sets the "expiry" field.
func (_u *AuthRequestUpdateOne) SetExpiry(v time.Time) *AuthRequestUpdateOne {
_u.mutation.SetExpiry(v)
return _u
}
// SetNillableExpiry sets the "expiry" field if the given value is not nil.
func (_u *AuthRequestUpdateOne) SetNillableExpiry(v *time.Time) *AuthRequestUpdateOne {
if v != nil {
_u.SetExpiry(*v)
}
return _u
}
// SetCodeChallenge sets the "code_challenge" field.
func (_u *AuthRequestUpdateOne) SetCodeChallenge(v string) *AuthRequestUpdateOne {
_u.mutation.SetCodeChallenge(v)
return _u
}
// SetNillableCodeChallenge sets the "code_challenge" field if the given value is not nil.
func (_u *AuthRequestUpdateOne) SetNillableCodeChallenge(v *string) *AuthRequestUpdateOne {
if v != nil {
_u.SetCodeChallenge(*v)
}
return _u
}
// SetCodeChallengeMethod sets the "code_challenge_method" field.
func (_u *AuthRequestUpdateOne) SetCodeChallengeMethod(v string) *AuthRequestUpdateOne {
_u.mutation.SetCodeChallengeMethod(v)
return _u
}
// SetNillableCodeChallengeMethod sets the "code_challenge_method" field if the given value is not nil.
func (_u *AuthRequestUpdateOne) SetNillableCodeChallengeMethod(v *string) *AuthRequestUpdateOne {
if v != nil {
_u.SetCodeChallengeMethod(*v)
}
return _u
}
// SetHmacKey sets the "hmac_key" field.
func (_u *AuthRequestUpdateOne) SetHmacKey(v []byte) *AuthRequestUpdateOne {
_u.mutation.SetHmacKey(v)
return _u
}
// Mutation returns the AuthRequestMutation object of the builder.
func (_u *AuthRequestUpdateOne) Mutation() *AuthRequestMutation {
return _u.mutation
}
// Where appends a list predicates to the AuthRequestUpdate builder.
func (_u *AuthRequestUpdateOne) Where(ps ...predicate.AuthRequest) *AuthRequestUpdateOne {
_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 *AuthRequestUpdateOne) Select(field string, fields ...string) *AuthRequestUpdateOne {
_u.fields = append([]string{field}, fields...)
return _u
}
// Save executes the query and returns the updated AuthRequest entity.
func (_u *AuthRequestUpdateOne) Save(ctx context.Context) (*AuthRequest, error) {
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
}
// SaveX is like Save, but panics if an error occurs.
func (_u *AuthRequestUpdateOne) SaveX(ctx context.Context) *AuthRequest {
node, err := _u.Save(ctx)
if err != nil {
panic(err)
}
return node
}
// Exec executes the query on the entity.
func (_u *AuthRequestUpdateOne) Exec(ctx context.Context) error {
_, err := _u.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (_u *AuthRequestUpdateOne) ExecX(ctx context.Context) {
if err := _u.Exec(ctx); err != nil {
panic(err)
}
}
func (_u *AuthRequestUpdateOne) sqlSave(ctx context.Context) (_node *AuthRequest, err error) {
_spec := sqlgraph.NewUpdateSpec(authrequest.Table, authrequest.Columns, sqlgraph.NewFieldSpec(authrequest.FieldID, field.TypeString))
id, ok := _u.mutation.ID()
if !ok {
return nil, &ValidationError{Name: "id", err: errors.New(`db: missing "AuthRequest.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, authrequest.FieldID)
for _, f := range fields {
if !authrequest.ValidColumn(f) {
return nil, &ValidationError{Name: f, err: fmt.Errorf("db: invalid field %q for query", f)}
}
if f != authrequest.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.ClientID(); ok {
_spec.SetField(authrequest.FieldClientID, field.TypeString, value)
}
if value, ok := _u.mutation.Scopes(); ok {
_spec.SetField(authrequest.FieldScopes, field.TypeJSON, value)
}
if value, ok := _u.mutation.AppendedScopes(); ok {
_spec.AddModifier(func(u *sql.UpdateBuilder) {
sqljson.Append(u, authrequest.FieldScopes, value)
})
}
if _u.mutation.ScopesCleared() {
_spec.ClearField(authrequest.FieldScopes, field.TypeJSON)
}
if value, ok := _u.mutation.ResponseTypes(); ok {
_spec.SetField(authrequest.FieldResponseTypes, field.TypeJSON, value)
}
if value, ok := _u.mutation.AppendedResponseTypes(); ok {
_spec.AddModifier(func(u *sql.UpdateBuilder) {
sqljson.Append(u, authrequest.FieldResponseTypes, value)
})
}
if _u.mutation.ResponseTypesCleared() {
_spec.ClearField(authrequest.FieldResponseTypes, field.TypeJSON)
}
if value, ok := _u.mutation.RedirectURI(); ok {
_spec.SetField(authrequest.FieldRedirectURI, field.TypeString, value)
}
if value, ok := _u.mutation.Nonce(); ok {
_spec.SetField(authrequest.FieldNonce, field.TypeString, value)
}
if value, ok := _u.mutation.State(); ok {
_spec.SetField(authrequest.FieldState, field.TypeString, value)
}
if value, ok := _u.mutation.ForceApprovalPrompt(); ok {
_spec.SetField(authrequest.FieldForceApprovalPrompt, field.TypeBool, value)
}
if value, ok := _u.mutation.LoggedIn(); ok {
_spec.SetField(authrequest.FieldLoggedIn, field.TypeBool, value)
}
if value, ok := _u.mutation.ClaimsUserID(); ok {
_spec.SetField(authrequest.FieldClaimsUserID, field.TypeString, value)
}
if value, ok := _u.mutation.ClaimsUsername(); ok {
_spec.SetField(authrequest.FieldClaimsUsername, field.TypeString, value)
}
if value, ok := _u.mutation.ClaimsEmail(); ok {
_spec.SetField(authrequest.FieldClaimsEmail, field.TypeString, value)
}
if value, ok := _u.mutation.ClaimsEmailVerified(); ok {
_spec.SetField(authrequest.FieldClaimsEmailVerified, field.TypeBool, value)
}
if value, ok := _u.mutation.ClaimsGroups(); ok {
_spec.SetField(authrequest.FieldClaimsGroups, field.TypeJSON, value)
}
if value, ok := _u.mutation.AppendedClaimsGroups(); ok {
_spec.AddModifier(func(u *sql.UpdateBuilder) {
sqljson.Append(u, authrequest.FieldClaimsGroups, value)
})
}
if _u.mutation.ClaimsGroupsCleared() {
_spec.ClearField(authrequest.FieldClaimsGroups, field.TypeJSON)
}
if value, ok := _u.mutation.ClaimsPreferredUsername(); ok {
_spec.SetField(authrequest.FieldClaimsPreferredUsername, field.TypeString, value)
}
if value, ok := _u.mutation.ConnectorID(); ok {
_spec.SetField(authrequest.FieldConnectorID, field.TypeString, value)
}
if value, ok := _u.mutation.ConnectorData(); ok {
_spec.SetField(authrequest.FieldConnectorData, field.TypeBytes, value)
}
if _u.mutation.ConnectorDataCleared() {
_spec.ClearField(authrequest.FieldConnectorData, field.TypeBytes)
}
if value, ok := _u.mutation.Expiry(); ok {
_spec.SetField(authrequest.FieldExpiry, field.TypeTime, value)
}
if value, ok := _u.mutation.CodeChallenge(); ok {
_spec.SetField(authrequest.FieldCodeChallenge, field.TypeString, value)
}
if value, ok := _u.mutation.CodeChallengeMethod(); ok {
_spec.SetField(authrequest.FieldCodeChallengeMethod, field.TypeString, value)
}
if value, ok := _u.mutation.HmacKey(); ok {
_spec.SetField(authrequest.FieldHmacKey, field.TypeBytes, value)
}
_node = &AuthRequest{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{authrequest.Label}
} else if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return nil, err
}
_u.mutation.done = true
return _node, nil
}